stratisd/0002-Update-uuid-to-0.7.x.patch
Igor Gnatenko 8750bcf58d bump proptest to 0.8 and uuid to 0.7
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-04-08 16:46:59 +02:00

355 lines
17 KiB
Diff

From 90f6e358bcf266673aba10b781c728f1be68dd75 Mon Sep 17 00:00:00 2001
From: Andy Grover <agrover@redhat.com>
Date: Wed, 12 Dec 2018 10:50:57 -0800
Subject: [PATCH 2/2] Update uuid to 0.7.x
Some straightforward code changes were needed.
Signed-off-by: Andy Grover <agrover@redhat.com>
---
Cargo.lock | 21 +++++++++----------
Cargo.toml | 2 +-
src/dbus_api/pool.rs | 6 ++++--
src/dbus_api/util.rs | 2 +-
.../strat_engine/backstore/blockdevmgr.rs | 4 ++--
src/engine/strat_engine/backstore/metadata.rs | 8 +++----
src/engine/strat_engine/backstore/setup.rs | 6 +++---
src/engine/strat_engine/names.rs | 10 ++++-----
src/engine/strat_engine/thinpool/mdv.rs | 6 +++---
src/engine/strat_engine/thinpool/thinpool.rs | 2 +-
src/engine/structures.rs | 5 ++---
src/stratis/errors.rs | 6 +++---
12 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index d94de22..bb83a3d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -155,7 +155,7 @@ dependencies = [
"macro-attr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"newtype_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -309,12 +309,12 @@ dependencies = [
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"timerfd 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -577,7 +577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
-version = "1.0.44"
+version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -607,7 +607,7 @@ dependencies = [
"dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -729,12 +729,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "uuid"
-version = "0.6.3"
+version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -880,7 +879,7 @@ dependencies = [
"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
"checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c"
"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
-"checksum serde 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "ce67a48047802238bfc88687272de48fd6d7af256b0097f110e968b0017235a5"
+"checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6"
"checksum serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "10552fad5500771f3902d0c5ba187c5881942b811b7ba0d8fbbfbf84d80806d3"
"checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a"
"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b"
@@ -899,7 +898,7 @@ dependencies = [
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
-"checksum uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8630752f979f1b6b87c49830a5e3784082545de63920d59fbaac252474319447"
+"checksum uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dab5c5526c5caa3d106653401a267fed923e7046f35895ffcb5ca42db64942e6"
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9f3bf741a801531993db6478b95682117471f76916f5e690dd8d45395b09349"
diff --git a/Cargo.toml b/Cargo.toml
index aead8f3..d10be5c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@ timerfd = "1.0.0"
walkdir = "2.2.5"
[dependencies.uuid]
-version = "0.6"
+version = "0.7"
features = ["serde", "v4"]
[dev-dependencies]
diff --git a/src/dbus_api/pool.rs b/src/dbus_api/pool.rs
index 46395a3..d253861 100644
--- a/src/dbus_api/pool.rs
+++ b/src/dbus_api/pool.rs
@@ -131,8 +131,10 @@ fn destroy_filesystems(m: &MethodInfo<MTFn<TData>, TData>) -> MethodResult {
dbus_context.actions.borrow_mut().push_remove(op, m.tree);
}
- let return_value: Vec<String> =
- uuids.iter().map(|n| format!("{}", n.simple())).collect();
+ let return_value: Vec<String> = uuids
+ .iter()
+ .map(|n| n.to_simple_ref().to_string())
+ .collect();
return_message.append3(return_value, msg_code_ok(), msg_string_ok())
}
Err(err) => {
diff --git a/src/dbus_api/util.rs b/src/dbus_api/util.rs
index 87b6e08..170e892 100644
--- a/src/dbus_api/util.rs
+++ b/src/dbus_api/util.rs
@@ -87,7 +87,7 @@ pub fn get_uuid(i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>) -> Result<
.as_ref()
.ok_or_else(|| MethodErr::failed(&format!("no data for object path {}", object_path)))?;
- i.append(format!("{}", data.uuid.simple()));
+ i.append(data.uuid.to_simple_ref().to_string());
Ok(())
}
diff --git a/src/engine/strat_engine/backstore/blockdevmgr.rs b/src/engine/strat_engine/backstore/blockdevmgr.rs
index 8b8ffda..518128b 100644
--- a/src/engine/strat_engine/backstore/blockdevmgr.rs
+++ b/src/engine/strat_engine/backstore/blockdevmgr.rs
@@ -74,7 +74,7 @@ impl BlkDevSegment {
impl fmt::Debug for BlkDevSegment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("BlkDevSegment")
- .field("uuid", &self.uuid.simple().to_string())
+ .field("uuid", &self.uuid.to_simple_ref())
.field("segment", &self.segment)
.finish()
}
@@ -247,7 +247,7 @@ impl BlockDevMgr {
ErrorEnum::Error,
format!(
"Blockdev corresponding to UUID: {} not found.",
- uuid.simple().to_string()
+ uuid.to_simple_ref()
),
));
}
diff --git a/src/engine/strat_engine/backstore/metadata.rs b/src/engine/strat_engine/backstore/metadata.rs
index 1c36e3e..1c52dfc 100644
--- a/src/engine/strat_engine/backstore/metadata.rs
+++ b/src/engine/strat_engine/backstore/metadata.rs
@@ -358,8 +358,8 @@ impl StaticHeader {
buf[4..20].clone_from_slice(STRAT_MAGIC);
LittleEndian::write_u64(&mut buf[20..28], *self.blkdev_size);
buf[28] = STRAT_SIGBLOCK_VERSION;
- buf[32..64].clone_from_slice(self.pool_uuid.simple().to_string().as_bytes());
- buf[64..96].clone_from_slice(self.dev_uuid.simple().to_string().as_bytes());
+ buf[32..64].clone_from_slice(self.pool_uuid.to_simple_ref().to_string().as_bytes());
+ buf[64..96].clone_from_slice(self.dev_uuid.to_simple_ref().to_string().as_bytes());
LittleEndian::write_u64(&mut buf[96..104], *self.mda_size);
LittleEndian::write_u64(&mut buf[104..112], *self.reserved_size);
LittleEndian::write_u64(&mut buf[120..128], self.initialization_time);
@@ -419,8 +419,8 @@ impl fmt::Debug for StaticHeader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("StaticHeader")
.field("blkdev_size", &self.blkdev_size)
- .field("pool_uuid", &self.pool_uuid.simple().to_string())
- .field("dev_uuid", &self.dev_uuid.simple().to_string())
+ .field("pool_uuid", &self.pool_uuid.to_simple_ref())
+ .field("dev_uuid", &self.dev_uuid.to_simple_ref())
.field("mda_size", &self.mda_size)
.field("reserved_size", &self.reserved_size)
.field("flags", &self.flags)
diff --git a/src/engine/strat_engine/backstore/setup.rs b/src/engine/strat_engine/backstore/setup.rs
index 9bd388c..23b89bf 100644
--- a/src/engine/strat_engine/backstore/setup.rs
+++ b/src/engine/strat_engine/backstore/setup.rs
@@ -283,7 +283,7 @@ pub fn get_blockdevs(
if !duplicate_uuids.is_empty() {
let err_msg = format!(
"The following list of Stratis UUIDs were each claimed by more than one Stratis device: {}",
- duplicate_uuids.iter().map(|p| p.simple().to_string()).collect::<Vec<String>>().join(", ")
+ duplicate_uuids.iter().map(|u| u.to_simple_ref().to_string()).collect::<Vec<_>>().join(", ")
);
return Err(StratisError::Engine(ErrorEnum::Invalid, err_msg));
}
@@ -292,8 +292,8 @@ pub fn get_blockdevs(
if uuids != recorded_uuids {
let err_msg = format!(
"UUIDs of devices found ({}) did not correspond with UUIDs specified in the metadata for this group of devices ({})",
- uuids.iter().map(|p| p.simple().to_string()).collect::<Vec<String>>().join(", "),
- recorded_uuids.iter().map(|p| p.simple().to_string()).collect::<Vec<String>>().join(", "),
+ uuids.iter().map(|u| u.to_simple_ref().to_string()).collect::<Vec<_>>().join(", "),
+ recorded_uuids.iter().map(|u| u.to_simple_ref().to_string()).collect::<Vec<_>>().join(", "),
);
return Err(StratisError::Engine(ErrorEnum::Invalid, err_msg));
}
diff --git a/src/engine/strat_engine/names.rs b/src/engine/strat_engine/names.rs
index 39c882f..0d5a0f1 100644
--- a/src/engine/strat_engine/names.rs
+++ b/src/engine/strat_engine/names.rs
@@ -43,7 +43,7 @@ pub enum ThinRole {
impl Display for ThinRole {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
- ThinRole::Filesystem(uuid) => write!(f, "fs-{}", uuid.simple().to_string()),
+ ThinRole::Filesystem(uuid) => write!(f, "fs-{}", uuid.to_simple_ref()),
}
}
}
@@ -104,7 +104,7 @@ pub fn format_flex_ids(pool_uuid: PoolUuid, role: FlexRole) -> (DmNameBuf, DmUui
let value = format!(
"stratis-{}-private-{}-flex-{}",
FORMAT_VERSION,
- pool_uuid.simple().to_string(),
+ pool_uuid.to_simple_ref(),
role
);
(
@@ -128,7 +128,7 @@ pub fn format_thin_ids(pool_uuid: PoolUuid, role: ThinRole) -> (DmNameBuf, DmUui
let value = format!(
"stratis-{}-{}-thin-{}",
FORMAT_VERSION,
- pool_uuid.simple().to_string(),
+ pool_uuid.to_simple_ref(),
role
);
(
@@ -153,7 +153,7 @@ pub fn format_thinpool_ids(pool_uuid: PoolUuid, role: ThinPoolRole) -> (DmNameBu
let value = format!(
"stratis-{}-private-{}-thinpool-{}",
FORMAT_VERSION,
- pool_uuid.simple().to_string(),
+ pool_uuid.to_simple_ref(),
role
);
(
@@ -178,7 +178,7 @@ pub fn format_backstore_ids(pool_uuid: PoolUuid, role: CacheRole) -> (DmNameBuf,
let value = format!(
"stratis-{}-private-{}-physical-{}",
FORMAT_VERSION,
- pool_uuid.simple().to_string(),
+ pool_uuid.to_simple_ref(),
role
);
(
diff --git a/src/engine/strat_engine/thinpool/mdv.rs b/src/engine/strat_engine/thinpool/mdv.rs
index d80e7ab..86669a4 100644
--- a/src/engine/strat_engine/thinpool/mdv.rs
+++ b/src/engine/strat_engine/thinpool/mdv.rs
@@ -96,7 +96,7 @@ impl MetadataVol {
/// Set up an existing Metadata Volume.
pub fn setup(pool_uuid: PoolUuid, dev: LinearDev) -> StratisResult<MetadataVol> {
- let filename = format!(".mdv-{}", pool_uuid.simple());
+ let filename = format!(".mdv-{}", pool_uuid.to_simple_ref());
let mount_pt: PathBuf = vec![DEV_PATH, &filename].iter().collect();
let mdv = MetadataVol { dev, mount_pt };
@@ -131,7 +131,7 @@ impl MetadataVol {
let data = serde_json::to_string(&fs.record(name, uuid))?;
let path = self.mount_pt
.join(FILESYSTEM_DIR)
- .join(uuid.simple().to_string())
+ .join(uuid.to_simple_ref().to_string())
.with_extension("json");
let temp_path = path.clone().with_extension("temp");
@@ -159,7 +159,7 @@ impl MetadataVol {
pub fn rm_fs(&self, fs_uuid: FilesystemUuid) -> StratisResult<()> {
let fs_path = self.mount_pt
.join(FILESYSTEM_DIR)
- .join(fs_uuid.simple().to_string())
+ .join(fs_uuid.to_simple_ref().to_string())
.with_extension("json");
let _mount = MountedMDV::mount(self)?;
diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs
index e0495eb..4c6baa8 100644
--- a/src/engine/strat_engine/thinpool/thinpool.rs
+++ b/src/engine/strat_engine/thinpool/thinpool.rs
@@ -751,7 +751,7 @@ impl ThinPool {
) -> StratisResult<Sectors> {
assert!(modulus != Sectors(0));
let sub_device_str = if data { "data" } else { "metadata" };
- let pool_uuid_str = pool_uuid.simple().to_string();
+ let pool_uuid_str = pool_uuid.to_simple_ref();
info!(
"Attempting to extend thinpool {} sub-device belonging to pool {} by {}",
sub_device_str, pool_uuid_str, extend_size,
diff --git a/src/engine/structures.rs b/src/engine/structures.rs
index ed68e30..337b93d 100644
--- a/src/engine/structures.rs
+++ b/src/engine/structures.rs
@@ -20,9 +20,8 @@ impl<T: fmt::Debug> fmt::Debug for Table<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_map()
.entries(
- self.iter().map(|(name, uuid, item)| {
- ((name.to_string(), uuid.simple().to_string()), item)
- }),
+ self.iter()
+ .map(|(name, uuid, item)| ((name.to_string(), uuid.to_simple_ref()), item)),
)
.finish()
}
diff --git a/src/stratis/errors.rs b/src/stratis/errors.rs
index e4e9c2e..ed8f502 100644
--- a/src/stratis/errors.rs
+++ b/src/stratis/errors.rs
@@ -33,7 +33,7 @@ pub enum StratisError {
Engine(ErrorEnum, String),
Io(io::Error),
Nix(nix::Error),
- Uuid(uuid::ParseError),
+ Uuid(uuid::parser::ParseError),
Utf8(str::Utf8Error),
Serde(serde_json::error::Error),
DM(devicemapper::DmError),
@@ -111,8 +111,8 @@ impl From<nix::Error> for StratisError {
}
}
-impl From<uuid::ParseError> for StratisError {
- fn from(err: uuid::ParseError) -> StratisError {
+impl From<uuid::parser::ParseError> for StratisError {
+ fn from(err: uuid::parser::ParseError) -> StratisError {
StratisError::Uuid(err)
}
}
--
2.20.0