diff --git a/Cargo.lock b/Cargo.lock index 3d2be0417e..91fbd6fd98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,10 +186,10 @@ dependencies = [ [[package]] name = "devicemapper" version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/jbaublitz/devicemapper-rs?branch=u128-bytes#ae4b09a7595c7075c748a60a1dc5d4dfe46094e6" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", @@ -241,11 +241,11 @@ dependencies = [ [[package]] name = "error-chain" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -388,10 +388,10 @@ dependencies = [ "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "dbus 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "devicemapper 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)", + "devicemapper 0.28.0 (git+https://github.com/jbaublitz/devicemapper-rs?branch=u128-bytes)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", @@ -907,6 +907,11 @@ name = "version_check" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "void" version = "1.0.2" @@ -995,13 +1000,13 @@ dependencies = [ "checksum crc 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc1914fae6f18ae347320f0ba5e4fc270e17c037ea621fe41ec7e8adf67d11b0" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum dbus 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd043051adb767dd40f869e6034c8ea4d3a0a719e78d4058f705a8038649059" -"checksum devicemapper 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a417275b3c8275cf39af619cd5d52d719f511a87b0262b7b40c4480ba5bccc" +"checksum devicemapper 0.28.0 (git+https://github.com/jbaublitz/devicemapper-rs?branch=u128-bytes)" = "" "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" -"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" +"checksum error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" @@ -1082,6 +1087,7 @@ dependencies = [ "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" "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" "checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8" diff --git a/Cargo.toml b/Cargo.toml index 5ba33dc54a..9cbc20ebcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ build = "build.rs" dbus = {version = "0.8", optional = true} clap = "2" nix = "0.14" -devicemapper = "0.28.0" +devicemapper = { git = "https://github.com/jbaublitz/devicemapper-rs", branch = "u128-bytes" } crc = "1" byteorder = "1" chrono = "0.4" diff --git a/src/dbus_api/blockdev/fetch_properties_2_0/methods.rs b/src/dbus_api/blockdev/fetch_properties_2_0/methods.rs index 9e0438c0c7..eadc35abf4 100644 --- a/src/dbus_api/blockdev/fetch_properties_2_0/methods.rs +++ b/src/dbus_api/blockdev/fetch_properties_2_0/methods.rs @@ -26,24 +26,20 @@ fn get_properties_shared( let return_message = message.method_return(); - let return_value: HashMap>)> = - properties - .unique() - .filter_map(|prop| match prop.as_str() { - consts::BLOCKDEV_TOTAL_SIZE_PROP => Some(( - prop, - result_to_tuple(blockdev_operation( - m.tree, - object_path.get_name(), - |_, bd| { - Ok((u128::from(*bd.size()) * devicemapper::SECTOR_SIZE as u128) - .to_string()) - }, - )), + let return_value: HashMap>)> = properties + .unique() + .filter_map(|prop| match prop.as_str() { + consts::BLOCKDEV_TOTAL_SIZE_PROP => Some(( + prop, + result_to_tuple(blockdev_operation( + m.tree, + object_path.get_name(), + |_, bd| Ok((*bd.size()).to_string()), )), - _ => None, - }) - .collect(); + )), + _ => None, + }) + .collect(); Ok(vec![return_message.append1(return_value)]) } diff --git a/src/dbus_api/pool/shared.rs b/src/dbus_api/pool/shared.rs index 76771a908d..637b68e718 100644 --- a/src/dbus_api/pool/shared.rs +++ b/src/dbus_api/pool/shared.rs @@ -75,10 +75,7 @@ pub fn get_pool_has_cache(m: &MethodInfo, TData>) -> Result, TData>) -> Result { pool_operation(m.tree, m.path.get_name(), |(_, _, pool)| { - Ok( - (u128::from(*pool.total_physical_size()) * devicemapper::SECTOR_SIZE as u128) - .to_string(), - ) + Ok((*pool.total_physical_size().bytes()).to_string()) }) } @@ -86,7 +83,7 @@ pub fn get_pool_total_used(m: &MethodInfo, TData>) -> Result Sectors { - Bytes(IEC::Gi).sectors() + Bytes(u128::from(IEC::Gi)).sectors() } fn set_dbus_path(&mut self, path: MaybeDbusPath) { diff --git a/src/engine/sim_engine/keys.rs b/src/engine/sim_engine/keys.rs index 95945e9fe0..5b056f0225 100644 --- a/src/engine/sim_engine/keys.rs +++ b/src/engine/sim_engine/keys.rs @@ -78,7 +78,7 @@ impl KeyActions for SimKeyActions { ErrorEnum::Invalid, format!( "Provided key exceeded maximum allow length of {}", - Bytes(MAX_STRATIS_PASS_SIZE as u64) + Bytes(MAX_STRATIS_PASS_SIZE as u128) ), )); } diff --git a/src/engine/strat_engine/backstore/blockdevmgr.rs b/src/engine/strat_engine/backstore/blockdevmgr.rs index c6acf885fe..38b10b17c5 100644 --- a/src/engine/strat_engine/backstore/blockdevmgr.rs +++ b/src/engine/strat_engine/backstore/blockdevmgr.rs @@ -307,7 +307,7 @@ impl BlockDevMgr { current_time }; - let data_size = Bytes(metadata.len() as u64); + let data_size = Bytes(metadata.len() as u128); let candidates = self .block_devs .iter_mut() diff --git a/src/engine/strat_engine/backstore/devices.rs b/src/engine/strat_engine/backstore/devices.rs index 666d0de43a..6fa107327d 100644 --- a/src/engine/strat_engine/backstore/devices.rs +++ b/src/engine/strat_engine/backstore/devices.rs @@ -36,7 +36,7 @@ use crate::{ stratis::{ErrorEnum, StratisError, StratisResult}, }; -const MIN_DEV_SIZE: Bytes = Bytes(IEC::Gi); +const MIN_DEV_SIZE: Bytes = Bytes(IEC::Gi as u128); // Get information that can be obtained from udev for the block device // identified by devnode. Return an error if there was an error finding the diff --git a/src/engine/strat_engine/backstore/metadata/mda.rs b/src/engine/strat_engine/backstore/metadata/mda.rs index c651bbc8e7..1a85bd543f 100644 --- a/src/engine/strat_engine/backstore/metadata/mda.rs +++ b/src/engine/strat_engine/backstore/metadata/mda.rs @@ -4,7 +4,9 @@ use std::{ cmp::Ordering, + convert::TryInto, io::{Read, Seek, SeekFrom}, + num::TryFromIntError, }; use byteorder::{ByteOrder, LittleEndian}; @@ -43,7 +45,7 @@ pub struct MDARegions { impl MDARegions { /// Calculate the offset from start of device for an MDARegion. - fn mda_offset(header_size: Bytes, index: usize, per_region_size: Bytes) -> u64 { + fn mda_offset(header_size: Bytes, index: usize, per_region_size: Bytes) -> u128 { *(header_size + per_region_size * index) } @@ -71,11 +73,11 @@ impl MDARegions { let region_size = mda_size.region_size(); let region_size_bytes = region_size.sectors().bytes(); for region in 0..mda_size::NUM_MDA_REGIONS { - f.seek(SeekFrom::Start(MDARegions::mda_offset( - header_size, - region, - region_size_bytes, - )))?; + f.seek(SeekFrom::Start( + MDARegions::mda_offset(header_size, region, region_size_bytes) + .try_into() + .map_err(|e: TryFromIntError| StratisError::Error(e.to_string()))?, + ))?; f.write_all(&hdr_buf)?; } @@ -111,11 +113,11 @@ impl MDARegions { // been corrupted, return an error. let mut load_a_region = |index: usize| -> StratisResult> { let mut hdr_buf = [0u8; mda_size::_MDA_REGION_HDR_SIZE]; - f.seek(SeekFrom::Start(MDARegions::mda_offset( - header_size, - index, - region_size_bytes, - )))?; + f.seek(SeekFrom::Start( + MDARegions::mda_offset(header_size, index, region_size_bytes) + .try_into() + .map_err(|e: TryFromIntError| StratisError::Error(e.to_string()))?, + ))?; f.read_exact(&mut hdr_buf)?; Ok(MDAHeader::from_buf(&hdr_buf)?) }; @@ -158,7 +160,7 @@ impl MDARegions { )); } - let used = Bytes(data.len() as u64); + let used = Bytes(data.len() as u128); let max_available = self.max_data_size().bytes(); if used > max_available { let err_msg = format!( @@ -178,11 +180,11 @@ impl MDARegions { // Write data to a region specified by index. let region_size = self.region_size.sectors().bytes(); let mut save_region = |index: usize| -> StratisResult<()> { - f.seek(SeekFrom::Start(MDARegions::mda_offset( - header_size, - index, - region_size, - )))?; + f.seek(SeekFrom::Start( + MDARegions::mda_offset(header_size, index, region_size) + .try_into() + .map_err(|e: TryFromIntError| StratisError::Error(e.to_string()))?, + ))?; f.write_all(&hdr_buf)?; f.write_all(data)?; f.sync_all()?; @@ -220,8 +222,10 @@ impl MDARegions { // It is an error if the metadata can not be found. let mut load_region = |index: usize| -> StratisResult> { let offset = MDARegions::mda_offset(header_size, index, region_size) - + mda_size::_MDA_REGION_HDR_SIZE as u64; - f.seek(SeekFrom::Start(offset))?; + + mda_size::_MDA_REGION_HDR_SIZE as u128; + f.seek(SeekFrom::Start(offset.try_into().map_err( + |e: TryFromIntError| StratisError::Error(e.to_string()), + )?))?; mda.load_region(f) }; @@ -334,7 +338,7 @@ impl MDAHeader { assert!(secs <= std::i64::MAX as u64); Some(MDAHeader { - used: MetaDataSize::new(Bytes(used)), + used: MetaDataSize::new(Bytes(u128::from(used))), last_updated: Utc.timestamp(secs as i64, LittleEndian::read_u32(&buf[24..28])), data_crc: LittleEndian::read_u32(&buf[4..8]), }) @@ -484,7 +488,7 @@ mod tests { let header = MDAHeader { last_updated: Utc.timestamp(sec, nsec), - used: MetaDataSize::new(Bytes(data.len() as u64)), + used: MetaDataSize::new(Bytes(data.len() as u128)), data_crc: crc32::checksum_castagnoli(data), }; let buf = header.to_buf(); @@ -506,7 +510,7 @@ mod tests { let header = MDAHeader { last_updated: Utc::now(), - used: MetaDataSize::new(Bytes(data.len() as u64)), + used: MetaDataSize::new(Bytes(data.len() as u128)), data_crc: crc32::checksum_castagnoli(&data), }; let mut buf = header.to_buf(); diff --git a/src/engine/strat_engine/backstore/metadata/sizes.rs b/src/engine/strat_engine/backstore/metadata/sizes.rs index 754f2db35b..24652cd450 100644 --- a/src/engine/strat_engine/backstore/metadata/sizes.rs +++ b/src/engine/strat_engine/backstore/metadata/sizes.rs @@ -48,7 +48,7 @@ pub mod mda_size { use devicemapper::{Bytes, Sectors}; pub const _MDA_REGION_HDR_SIZE: usize = 32; - const MDA_REGION_HDR_SIZE: Bytes = Bytes(_MDA_REGION_HDR_SIZE as u64); + const MDA_REGION_HDR_SIZE: Bytes = Bytes(_MDA_REGION_HDR_SIZE as u128); // The minimum size allocated for variable length metadata pub const MIN_MDA_DATA_REGION_SIZE: Bytes = Bytes(260_064); diff --git a/src/engine/strat_engine/backstore/metadata/static_header.rs b/src/engine/strat_engine/backstore/metadata/static_header.rs index b7fcbbd883..6c6ae82cf9 100644 --- a/src/engine/strat_engine/backstore/metadata/static_header.rs +++ b/src/engine/strat_engine/backstore/metadata/static_header.rs @@ -505,11 +505,11 @@ pub mod tests { let pool_uuid = Uuid::new_v4(); let dev_uuid = Uuid::new_v4(); let mda_size = MDADataSize::new( - MDADataSize::default().bytes() + Bytes(u64::from(mda_size_factor * 4)), + MDADataSize::default().bytes() + Bytes(u128::from(mda_size_factor * 4)), ) .region_size() .mda_size(); - let blkdev_size = (Bytes(IEC::Mi) + Sectors(blkdev_size).bytes()).sectors(); + let blkdev_size = (Bytes(IEC::Mi as u128) + Sectors(blkdev_size).bytes()).sectors(); StaticHeader::new( StratisIdentifiers::new(pool_uuid, dev_uuid), mda_size, diff --git a/src/engine/strat_engine/device.rs b/src/engine/strat_engine/device.rs index 0c61130c8f..91deed2a9b 100644 --- a/src/engine/strat_engine/device.rs +++ b/src/engine/strat_engine/device.rs @@ -5,8 +5,10 @@ // Functions for dealing with devices. use std::{ + convert::TryInto, fs::{File, OpenOptions}, io::{self, BufWriter, Cursor, Seek, SeekFrom, Write}, + num::TryFromIntError, os::unix::prelude::AsRawFd, path::Path, }; @@ -33,7 +35,7 @@ pub fn blkdev_size(file: &File) -> StratisResult { match unsafe { blkgetsize64(file.as_raw_fd(), &mut val) } { Err(x) => Err(StratisError::Nix(x)), - Ok(_) => Ok(Bytes(val)), + Ok(_) => Ok(Bytes(u128::from(val))), } } @@ -82,7 +84,9 @@ pub fn write_sectors>( let mut f = BufWriter::with_capacity(IEC::Mi as usize, OpenOptions::new().write(true).open(path)?); - f.seek(SeekFrom::Start(*offset.bytes()))?; + f.seek(SeekFrom::Start((*offset.bytes()).try_into().map_err( + |e: TryFromIntError| StratisError::Error(e.to_string()), + )?))?; for _ in 0..*length { f.write_all(buf)?; } diff --git a/src/engine/strat_engine/keys.rs b/src/engine/strat_engine/keys.rs index ded4304611..c3ae2e44f5 100644 --- a/src/engine/strat_engine/keys.rs +++ b/src/engine/strat_engine/keys.rs @@ -397,7 +397,7 @@ impl KeyActions for StratKeyActions { ErrorEnum::Invalid, format!( "Provided key exceeded maximum allow length of {}", - Bytes(MAX_STRATIS_PASS_SIZE as u64) + Bytes(MAX_STRATIS_PASS_SIZE as u128) ), )); } diff --git a/src/engine/strat_engine/pool.rs b/src/engine/strat_engine/pool.rs index 6c7d0e287b..95a28eaa96 100644 --- a/src/engine/strat_engine/pool.rs +++ b/src/engine/strat_engine/pool.rs @@ -932,7 +932,7 @@ mod tests { let buf = &[1u8; SECTOR_SIZE]; let mut amount_written = Sectors(0); - let buffer_length = Bytes(buffer_length).sectors(); + let buffer_length = Bytes(u128::from(buffer_length)).sectors(); while pool.thin_pool.extend_state() == PoolExtendState::Good && pool.thin_pool.state() == PoolState::Running { @@ -958,7 +958,11 @@ mod tests { #[test] fn loop_test_add_datadevs() { loopbacked::test_with_spec( - &loopbacked::DeviceLimits::Range(2, 3, Some((4u64 * Bytes(IEC::Gi)).sectors())), + &loopbacked::DeviceLimits::Range( + 2, + 3, + Some((4u64 * Bytes(u128::from(IEC::Gi))).sectors()), + ), test_add_datadevs, ); } @@ -968,8 +972,8 @@ mod tests { real::test_with_spec( &real::DeviceLimits::AtLeast( 2, - Some((2u64 * Bytes(IEC::Gi)).sectors()), - Some((4u64 * Bytes(IEC::Gi)).sectors()), + Some((2u64 * Bytes(u128::from(IEC::Gi))).sectors()), + Some((4u64 * Bytes(u128::from(IEC::Gi))).sectors()), ), test_add_datadevs, ); diff --git a/src/engine/strat_engine/tests/loopbacked.rs b/src/engine/strat_engine/tests/loopbacked.rs index 2cb318e81a..307d75c206 100644 --- a/src/engine/strat_engine/tests/loopbacked.rs +++ b/src/engine/strat_engine/tests/loopbacked.rs @@ -37,7 +37,7 @@ impl LoopTestDev { /// Create its backing store of specified size. The file is sparse but /// will appear to be zeroed. pub fn new(lc: &LoopControl, path: &Path, size: Option) -> LoopTestDev { - let size = size.unwrap_or_else(|| Bytes(IEC::Gi).sectors()); + let size = size.unwrap_or_else(|| Bytes(u128::from(IEC::Gi)).sectors()); let f = OpenOptions::new() .read(true) diff --git a/src/engine/strat_engine/tests/real.rs b/src/engine/strat_engine/tests/real.rs index 15e1f1f063..cb99af22da 100644 --- a/src/engine/strat_engine/tests/real.rs +++ b/src/engine/strat_engine/tests/real.rs @@ -33,7 +33,12 @@ impl RealTestDev { /// Wipe initial MiB to clear metadata. pub fn new(dev: Either) -> RealTestDev { let test_dev = RealTestDev { dev }; - wipe_sectors(test_dev.as_path(), Sectors(0), Bytes(IEC::Mi).sectors()).unwrap(); + wipe_sectors( + test_dev.as_path(), + Sectors(0), + Bytes(u128::from(IEC::Mi)).sectors(), + ) + .unwrap(); test_dev } @@ -44,7 +49,12 @@ impl RealTestDev { /// Teardown a real test dev fn teardown(self) { - wipe_sectors(&self.as_path(), Sectors(0), Bytes(IEC::Mi).sectors()).unwrap(); + wipe_sectors( + &self.as_path(), + Sectors(0), + Bytes(u128::from(IEC::Mi)).sectors(), + ) + .unwrap(); if let Some(mut ld) = self.dev.right() { ld.teardown(get_dm()).unwrap(); } @@ -88,7 +98,7 @@ fn get_device_runs<'a>( } }; - let min_size = min_size.unwrap_or_else(|| Bytes(IEC::Gi).sectors()); + let min_size = min_size.unwrap_or_else(|| Bytes(u128::from(IEC::Gi)).sectors()); assert!(max_size.is_none() || Some(min_size) <= max_size); diff --git a/src/engine/strat_engine/thinpool/filesystem.rs b/src/engine/strat_engine/thinpool/filesystem.rs index 31789e4287..34e849e232 100644 --- a/src/engine/strat_engine/thinpool/filesystem.rs +++ b/src/engine/strat_engine/thinpool/filesystem.rs @@ -354,7 +354,7 @@ pub fn fs_usage(mount_point: &Path) -> StratisResult<(Bytes, Bytes)> { stat.blocks_free() as u64, ); Ok(( - Bytes(block_size * blocks), - Bytes(block_size * (blocks - blocks_free)), + Bytes(u128::from(block_size * blocks)), + Bytes(u128::from(block_size * (blocks - blocks_free))), )) } diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 68c700a4fe..ae89374d4a 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1409,7 +1409,7 @@ mod tests { #[test] fn loop_test_full_pool() { loopbacked::test_with_spec( - &loopbacked::DeviceLimits::Exactly(2, Some(Bytes(IEC::Gi).sectors())), + &loopbacked::DeviceLimits::Exactly(2, Some(Bytes(u128::from(IEC::Gi)).sectors())), test_full_pool, ); } @@ -1419,8 +1419,8 @@ mod tests { real::test_with_spec( &real::DeviceLimits::Exactly( 2, - Some(Bytes(IEC::Gi).sectors()), - Some(Bytes(IEC::Gi * 4).sectors()), + Some(Bytes(u128::from(IEC::Gi)).sectors()), + Some(Bytes(u128::from(IEC::Gi) * 4).sectors()), ), test_full_pool, ); @@ -1726,7 +1726,7 @@ mod tests { // Create a filesystem as small as possible. Allocate 1 MiB bigger than // the low water mark. - let fs_size = FILESYSTEM_LOWATER + Bytes(IEC::Mi).sectors(); + let fs_size = FILESYSTEM_LOWATER + Bytes(u128::from(IEC::Mi)).sectors(); let pool_name = "stratis_test_pool"; devlinks::pool_added(pool_name); @@ -1755,7 +1755,7 @@ mod tests { } // Write 2 MiB of data. The filesystem's free space is now 1 MiB // below FILESYSTEM_LOWATER. - let write_size = Bytes(IEC::Mi * 2).sectors(); + let write_size = Bytes(u128::from(IEC::Mi) * 2).sectors(); let buf = &[1u8; SECTOR_SIZE]; for i in 0..*write_size { let file_path = tmp_dir.path().join(format!("stratis_test{}.txt", i));