Skip to content

Commit

Permalink
Merge #1476
Browse files Browse the repository at this point in the history
1476: fix(lvs/bdev): don't show nil uuids r=tiagolobocastro a=tiagolobocastro

Recent spdk change made all bdev have nil uuid by default. This makes list-pools a bit confusing as shows device with nil uuid, and at the same time pool also has its own uuid.
So let's not add nil uuid to the URI.
todo: Should we set the bdev uuid to the lvs pool uuid?

Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Jul 27, 2023
2 parents e5d8339 + 7d538b1 commit 0110b16
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions io-engine/src/bdev/nexus/nexus_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ impl<'n> Share for Nexus<'n> {
}

/// TODO
fn bdev_uri(&self) -> Option<String> {
fn bdev_uri(&self) -> Option<url::Url> {
unsafe { self.bdev().bdev_uri() }
}

/// TODO
fn bdev_uri_original(&self) -> Option<String> {
fn bdev_uri_original(&self) -> Option<url::Url> {
unsafe { self.bdev().bdev_uri_original() }
}
}
Expand Down
19 changes: 5 additions & 14 deletions io-engine/src/bdev_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use snafu::Snafu;
use std::{convert::TryFrom, num::ParseIntError, str::ParseBoolError};
use url::ParseError;

use crate::{bdev::uri, core::Bdev};
use crate::{
bdev::uri,
core::{Bdev, Share},
};

// parse URI and bdev create/destroy errors common for all types of bdevs
#[derive(Debug, Snafu, Clone)]
Expand Down Expand Up @@ -152,19 +155,7 @@ where
type Error = BdevError;

fn try_from(bdev: Bdev<T>) -> Result<Self, Self::Error> {
for alias in bdev.aliases().iter() {
if let Ok(mut uri) = url::Url::parse(alias) {
if bdev_uri_eq(&bdev, &uri) {
if !uri.query_pairs().any(|e| e.0 == "uuid") {
uri.query_pairs_mut()
.append_pair("uuid", &bdev.uuid_as_string());
}
return Ok(uri);
}
}
}

Err(BdevError::BdevNoMatchingUri {
bdev.bdev_uri().ok_or(BdevError::BdevNoMatchingUri {
name: bdev.name().to_string(),
aliases: bdev.aliases(),
})
Expand Down
25 changes: 11 additions & 14 deletions io-engine/src/core/bdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,27 +279,24 @@ where
}

/// return the URI that was used to construct the bdev
fn bdev_uri(&self) -> Option<String> {
for alias in self.aliases().iter() {
if let Ok(mut uri) = url::Url::parse(alias) {
if bdev_uri_eq(self, &uri) {
if !uri.query_pairs().any(|e| e.0 == "uuid") {
uri.query_pairs_mut()
.append_pair("uuid", &self.uuid_as_string());
}
return Some(uri.to_string());
}
fn bdev_uri(&self) -> Option<url::Url> {
self.bdev_uri_original().map(|mut uri| {
if !uri.query_pairs().any(|e| e.0 == "uuid")
&& !self.uuid().is_nil()
{
uri.query_pairs_mut()
.append_pair("uuid", &self.uuid_as_string());
}
}
None
uri
})
}

/// return the URI that was used to construct the bdev, without uuid
fn bdev_uri_original(&self) -> Option<String> {
fn bdev_uri_original(&self) -> Option<url::Url> {
for alias in self.aliases().iter() {
if let Ok(uri) = url::Url::parse(alias) {
if bdev_uri_eq(self, &uri) {
return Some(uri.to_string());
return Some(uri);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions io-engine/src/core/share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,14 @@ pub trait Share: std::fmt::Debug {
fn allowed_hosts(&self) -> Vec<String>;

/// TODO
fn bdev_uri(&self) -> Option<String>;
fn bdev_uri(&self) -> Option<url::Url>;
fn bdev_uri_str(&self) -> Option<String> {
self.bdev_uri().map(|uri| uri.to_string())
}

/// TODO
fn bdev_uri_original(&self) -> Option<String>;
fn bdev_uri_original(&self) -> Option<url::Url>;
fn bdev_uri_original_str(&self) -> Option<String> {
self.bdev_uri_original().map(|uri| uri.to_string())
}
}
5 changes: 4 additions & 1 deletion io-engine/src/grpc/v0/mayastor_grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ impl From<Lvs> for Pool {
fn from(l: Lvs) -> Self {
Self {
name: l.name().into(),
disks: vec![l.base_bdev().bdev_uri().unwrap_or_else(|| "".into())],
disks: vec![l
.base_bdev()
.bdev_uri_str()
.unwrap_or_else(|| "".into())],
state: PoolState::PoolOnline.into(),
capacity: l.capacity(),
used: l.used(),
Expand Down
5 changes: 4 additions & 1 deletion io-engine/src/grpc/v1/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ impl From<Lvs> for Pool {
Self {
uuid: l.uuid(),
name: l.name().into(),
disks: vec![l.base_bdev().bdev_uri().unwrap_or_else(|| "".into())],
disks: vec![l
.base_bdev()
.bdev_uri_str()
.unwrap_or_else(|| "".into())],
state: PoolState::PoolOnline.into(),
capacity: l.capacity(),
used: l.used(),
Expand Down
4 changes: 2 additions & 2 deletions io-engine/src/lvs/lvs_lvol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ impl Share for Lvol {
/// returns the URI that is used to construct the bdev. This is always None
/// as lvols can not be created by URIs directly, but only through the
/// ['Lvs'] interface.
fn bdev_uri(&self) -> Option<String> {
fn bdev_uri(&self) -> Option<url::Url> {
None
}

fn bdev_uri_original(&self) -> Option<String> {
fn bdev_uri_original(&self) -> Option<url::Url> {
None
}
}
Expand Down
4 changes: 2 additions & 2 deletions io-engine/src/lvs/lvs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl Lvs {

info!("{}: lvs exported successfully", self_str);

bdev_destroy(&base_bdev.bdev_uri_original().unwrap())
bdev_destroy(&base_bdev.bdev_uri_original_str().unwrap())
.await
.map_err(|e| Error::Destroy {
source: e,
Expand Down Expand Up @@ -633,7 +633,7 @@ impl Lvs {

info!("{}: lvs destroyed successfully", self_str);

bdev_destroy(&base_bdev.bdev_uri_original().unwrap())
bdev_destroy(&base_bdev.bdev_uri_original_str().unwrap())
.await
.map_err(|e| Error::Destroy {
source: e,
Expand Down
2 changes: 1 addition & 1 deletion io-engine/src/subsys/config/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl From<LvsBdev> for Pool {
Self {
name: lvs_bdev.name(),
disks: vec![base
.bdev_uri()
.bdev_uri_str()
.unwrap_or_else(|| base.name().to_string())],
replicas: None,
}
Expand Down

0 comments on commit 0110b16

Please sign in to comment.