From 89e28539be7b097fd10ede946d2759e73cd9b18c Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Mon, 4 Oct 2021 09:13:48 -0700 Subject: [PATCH] util package (#480) Move all of our utility code to a new package, which can be used by both zettacache and zettaobject. The utility package has code that is not directly related to the ZFS logic, e.g. extensions on the standard library or other external crates. --- cmd/zfs_object_agent/Cargo.lock | 23 ++++++++++++++---- cmd/zfs_object_agent/Cargo.toml | 3 ++- cmd/zfs_object_agent/Makefile.am | 2 +- cmd/zfs_object_agent/server/Cargo.toml | 1 + cmd/zfs_object_agent/server/src/main.rs | 2 +- cmd/zfs_object_agent/util/Cargo.toml | 18 ++++++++++++++ .../src/bitmap_range_iterator.rs | 0 .../{zettacache => util}/src/die.rs | 0 cmd/zfs_object_agent/util/src/from64.rs | 12 ++++++++++ cmd/zfs_object_agent/util/src/lib.rs | 24 +++++++++++++++++++ .../{zettacache => util}/src/lock_set.rs | 0 .../{zettacache => util}/src/mutex_ext.rs | 0 .../{zettacache => util}/src/range_tree.rs | 0 .../{zettacache => util}/src/tunable.rs | 0 cmd/zfs_object_agent/util/src/vec_ext.rs | 14 +++++++++++ cmd/zfs_object_agent/zettacache/Cargo.toml | 6 +---- .../zettacache/src/base_types.rs | 13 +--------- .../zettacache/src/block_access.rs | 4 ++-- .../zettacache/src/block_allocator.rs | 8 +++---- .../zettacache/src/block_based_log.rs | 2 +- .../zettacache/src/extent_allocator.rs | 2 +- cmd/zfs_object_agent/zettacache/src/lib.rs | 9 ------- .../zettacache/src/zettacache.rs | 11 +++++---- cmd/zfs_object_agent/zettaobject/Cargo.toml | 1 + .../zettaobject/src/heartbeat.rs | 3 ++- .../zettaobject/src/object_access.rs | 8 +++++-- .../zettaobject/src/object_based_log.rs | 2 +- cmd/zfs_object_agent/zettaobject/src/pool.rs | 14 +++-------- .../zettaobject/src/pool_destroy.rs | 2 +- .../zettaobject/src/public_connection.rs | 7 +++--- .../zettaobject/src/root_connection.rs | 4 ++-- .../zettaobject/src/server.rs | 2 +- 32 files changed, 128 insertions(+), 69 deletions(-) create mode 100644 cmd/zfs_object_agent/util/Cargo.toml rename cmd/zfs_object_agent/{zettacache => util}/src/bitmap_range_iterator.rs (100%) rename cmd/zfs_object_agent/{zettacache => util}/src/die.rs (100%) create mode 100644 cmd/zfs_object_agent/util/src/from64.rs create mode 100644 cmd/zfs_object_agent/util/src/lib.rs rename cmd/zfs_object_agent/{zettacache => util}/src/lock_set.rs (100%) rename cmd/zfs_object_agent/{zettacache => util}/src/mutex_ext.rs (100%) rename cmd/zfs_object_agent/{zettacache => util}/src/range_tree.rs (100%) rename cmd/zfs_object_agent/{zettacache => util}/src/tunable.rs (100%) create mode 100644 cmd/zfs_object_agent/util/src/vec_ext.rs diff --git a/cmd/zfs_object_agent/Cargo.lock b/cmd/zfs_object_agent/Cargo.lock index e08460bc924a..29f824a6df71 100644 --- a/cmd/zfs_object_agent/Cargo.lock +++ b/cmd/zfs_object_agent/Cargo.lock @@ -2378,6 +2378,22 @@ dependencies = [ "traitobject", ] +[[package]] +name = "util" +version = "0.1.0" +dependencies = [ + "async-trait", + "backtrace", + "config", + "lazy_static", + "log", + "more-asserts", + "rand", + "roaring", + "serde 1.0.130", + "tokio", +] + [[package]] name = "uuid" version = "0.8.2" @@ -2589,11 +2605,8 @@ version = "0.1.0" dependencies = [ "anyhow", "async-stream", - "async-trait", - "backtrace", "bincode", "chrono", - "config", "conv", "futures", "futures-core", @@ -2605,12 +2618,12 @@ dependencies = [ "more-asserts", "nix", "num", - "rand", "roaring", "seahash", "serde 1.0.130", "serde_json", "tokio", + "util", ] [[package]] @@ -2648,6 +2661,7 @@ dependencies = [ "stream-reduce", "tokio", "tokio-stream", + "util", "uuid", "zettacache", ] @@ -2659,6 +2673,7 @@ dependencies = [ "chrono", "clap", "log", + "util", "zettacache", "zettaobject", ] diff --git a/cmd/zfs_object_agent/Cargo.toml b/cmd/zfs_object_agent/Cargo.toml index 56a033cb93bd..7f86f4f60b5d 100644 --- a/cmd/zfs_object_agent/Cargo.toml +++ b/cmd/zfs_object_agent/Cargo.toml @@ -10,10 +10,11 @@ incremental = true [workspace] members = [ "client", + "object_perf", "server", + "util", "zcdb", "zettacache", "zettaobject", - "object_perf", "zoa", ] diff --git a/cmd/zfs_object_agent/Makefile.am b/cmd/zfs_object_agent/Makefile.am index ad37ebd0b4d0..b7da2195c4db 100644 --- a/cmd/zfs_object_agent/Makefile.am +++ b/cmd/zfs_object_agent/Makefile.am @@ -2,7 +2,7 @@ lib_LTLIBRARIES = libzoa.la sbin_PROGRAMS = zcachedb zfs_object_agent zfs_object_perf zoa_test -common_sources = $(wildcard zettacache/src/*.rs zettacache/Cargo.toml zettaobject/src/*.rs zettaobject/Cargo.toml Cargo.lock Cargo.toml) +common_sources = $(wildcard util/src/*.rs util/Cargo.toml zettacache/src/*.rs zettacache/Cargo.toml zettaobject/src/*.rs zettaobject/Cargo.toml Cargo.lock Cargo.toml) zcachedb_SOURCES = $(wildcard zcdb/src/*.rs zcdb/Cargo.toml) $(common_sources) diff --git a/cmd/zfs_object_agent/server/Cargo.toml b/cmd/zfs_object_agent/server/Cargo.toml index 4f080cbbec6c..92dcd604cde7 100644 --- a/cmd/zfs_object_agent/server/Cargo.toml +++ b/cmd/zfs_object_agent/server/Cargo.toml @@ -10,5 +10,6 @@ edition = "2018" chrono = "0.4" clap = "2" log = "0.4" +util = { path = "../util" } zettacache = { path = "../zettacache" } zettaobject = { path = "../zettaobject" } diff --git a/cmd/zfs_object_agent/server/src/main.rs b/cmd/zfs_object_agent/server/src/main.rs index 2883be9ea0e2..abeafb5eab8d 100644 --- a/cmd/zfs_object_agent/server/src/main.rs +++ b/cmd/zfs_object_agent/server/src/main.rs @@ -65,7 +65,7 @@ fn main() { ); if let Some(file_name) = matches.value_of("config-file") { - zettacache::read_tunable_config(file_name); + util::read_tunable_config(file_name); } error!( diff --git a/cmd/zfs_object_agent/util/Cargo.toml b/cmd/zfs_object_agent/util/Cargo.toml new file mode 100644 index 000000000000..70d5a20ffae2 --- /dev/null +++ b/cmd/zfs_object_agent/util/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "util" +version = "0.1.0" +authors = ["Delphix"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +async-trait = "0.1.51" +backtrace = "0.3" +config = "0.11" +lazy_static = "1.4.0" +log = "0.4" +more-asserts = "0.2.1" +rand = "0.8.3" +roaring = "0.7.0" +serde = { version = "1.0.125", features = ["derive"] } +tokio = { version = "1.4", features = ["full"] } diff --git a/cmd/zfs_object_agent/zettacache/src/bitmap_range_iterator.rs b/cmd/zfs_object_agent/util/src/bitmap_range_iterator.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/bitmap_range_iterator.rs rename to cmd/zfs_object_agent/util/src/bitmap_range_iterator.rs diff --git a/cmd/zfs_object_agent/zettacache/src/die.rs b/cmd/zfs_object_agent/util/src/die.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/die.rs rename to cmd/zfs_object_agent/util/src/die.rs diff --git a/cmd/zfs_object_agent/util/src/from64.rs b/cmd/zfs_object_agent/util/src/from64.rs new file mode 100644 index 000000000000..2dca4a7ed4e2 --- /dev/null +++ b/cmd/zfs_object_agent/util/src/from64.rs @@ -0,0 +1,12 @@ +use std::convert::TryInto; + +/// Conversions that are safe assuming that we are on LP64 (usize == u64) +pub trait From64 { + fn from64(a: A) -> Self; +} + +impl From64 for usize { + fn from64(a: u64) -> usize { + a.try_into().unwrap() + } +} diff --git a/cmd/zfs_object_agent/util/src/lib.rs b/cmd/zfs_object_agent/util/src/lib.rs new file mode 100644 index 000000000000..41c9f134d0ea --- /dev/null +++ b/cmd/zfs_object_agent/util/src/lib.rs @@ -0,0 +1,24 @@ +#![warn(clippy::cast_lossless)] +#![warn(clippy::cast_possible_truncation)] +#![warn(clippy::cast_possible_wrap)] +#![warn(clippy::cast_sign_loss)] + +mod bitmap_range_iterator; +mod die; +mod from64; +mod lock_set; +mod mutex_ext; +mod range_tree; +mod tunable; +mod vec_ext; + +pub use bitmap_range_iterator::BitmapRangeIterator; +pub use die::maybe_die_with; +pub use from64::From64; +pub use lock_set::LockSet; +pub use lock_set::LockedItem; +pub use mutex_ext::MutexExt; +pub use range_tree::RangeTree; +pub use tunable::get_tunable; +pub use tunable::read_tunable_config; +pub use vec_ext::TerseVec; diff --git a/cmd/zfs_object_agent/zettacache/src/lock_set.rs b/cmd/zfs_object_agent/util/src/lock_set.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/lock_set.rs rename to cmd/zfs_object_agent/util/src/lock_set.rs diff --git a/cmd/zfs_object_agent/zettacache/src/mutex_ext.rs b/cmd/zfs_object_agent/util/src/mutex_ext.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/mutex_ext.rs rename to cmd/zfs_object_agent/util/src/mutex_ext.rs diff --git a/cmd/zfs_object_agent/zettacache/src/range_tree.rs b/cmd/zfs_object_agent/util/src/range_tree.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/range_tree.rs rename to cmd/zfs_object_agent/util/src/range_tree.rs diff --git a/cmd/zfs_object_agent/zettacache/src/tunable.rs b/cmd/zfs_object_agent/util/src/tunable.rs similarity index 100% rename from cmd/zfs_object_agent/zettacache/src/tunable.rs rename to cmd/zfs_object_agent/util/src/tunable.rs diff --git a/cmd/zfs_object_agent/util/src/vec_ext.rs b/cmd/zfs_object_agent/util/src/vec_ext.rs new file mode 100644 index 000000000000..1ec6d8489214 --- /dev/null +++ b/cmd/zfs_object_agent/util/src/vec_ext.rs @@ -0,0 +1,14 @@ +use serde::Deserialize; +use serde::Serialize; +use std::fmt::Debug; +use std::fmt::Formatter; +use std::fmt::Result; + +/// exists just to reduce Debug output on fields we don't really care about +#[derive(Serialize, Deserialize)] +pub struct TerseVec(pub Vec); +impl Debug for TerseVec { + fn fmt(&self, fmt: &mut Formatter) -> Result { + fmt.write_fmt(format_args!("[...{} elements...]", self.0.len())) + } +} diff --git a/cmd/zfs_object_agent/zettacache/Cargo.toml b/cmd/zfs_object_agent/zettacache/Cargo.toml index 4d9edebbb8d4..c85a3236e2f1 100644 --- a/cmd/zfs_object_agent/zettacache/Cargo.toml +++ b/cmd/zfs_object_agent/zettacache/Cargo.toml @@ -9,11 +9,8 @@ edition = "2018" [dependencies] anyhow = "1.0" async-stream = "0.3.0" -async-trait = "0.1.51" -backtrace = "0.3" bincode = "1.3.2" chrono = "0.4" -config = "0.11" conv = "0.3.3" futures = "0.3.13" futures-core = "0.3.13" @@ -25,10 +22,9 @@ metered = "0.8" more-asserts = "0.2.1" nix = "0.22.0" num = "0.4.0" -rand = "0.8.3" roaring = "0.7.0" seahash = "4.1.0" serde = { version = "1.0.125", features = ["derive"] } serde_json = "1.0.64" tokio = { version = "1.4", features = ["full"] } - +util = { path = "../util" } diff --git a/cmd/zfs_object_agent/zettacache/src/base_types.rs b/cmd/zfs_object_agent/zettacache/src/base_types.rs index 989d9b291c6b..24aee48ef416 100644 --- a/cmd/zfs_object_agent/zettacache/src/base_types.rs +++ b/cmd/zfs_object_agent/zettacache/src/base_types.rs @@ -1,10 +1,10 @@ use more_asserts::*; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; use std::fmt::*; use std::ops::Add; use std::ops::Sub; +use util::From64; /* * Things that are stored on disk. @@ -107,14 +107,3 @@ impl ReclaimLogId { usize::from(self.0) } } - -/// Conversions that are safe assuming that we are on LP64 (usize == u64) -pub trait From64 { - fn from64(a: A) -> Self; -} - -impl From64 for usize { - fn from64(a: u64) -> usize { - a.try_into().unwrap() - } -} diff --git a/cmd/zfs_object_agent/zettacache/src/block_access.rs b/cmd/zfs_object_agent/zettacache/src/block_access.rs index de48617e7e9d..e2a14357d97f 100644 --- a/cmd/zfs_object_agent/zettacache/src/block_access.rs +++ b/cmd/zfs_object_agent/zettacache/src/block_access.rs @@ -1,7 +1,5 @@ use crate::base_types::DiskLocation; use crate::base_types::Extent; -use crate::base_types::From64; -use crate::get_tunable; use anyhow::{anyhow, Result}; use bincode::Options; use lazy_static::lazy_static; @@ -24,6 +22,8 @@ use std::time::Instant; use tokio::fs::File; use tokio::fs::OpenOptions; use tokio::sync::Semaphore; +use util::get_tunable; +use util::From64; lazy_static! { static ref MIN_SECTOR_SIZE: usize = get_tunable("min_sector_size", 512); diff --git a/cmd/zfs_object_agent/zettacache/src/block_allocator.rs b/cmd/zfs_object_agent/zettacache/src/block_allocator.rs index f8b52365400f..9e8e9b5688b6 100644 --- a/cmd/zfs_object_agent/zettacache/src/block_allocator.rs +++ b/cmd/zfs_object_agent/zettacache/src/block_allocator.rs @@ -1,10 +1,6 @@ use crate::base_types::*; -use crate::base_types::{Extent, OnDisk}; -use crate::bitmap_range_iterator::BitmapRangeIterator; use crate::block_access::BlockAccess; use crate::extent_allocator::ExtentAllocator; -use crate::get_tunable; -use crate::range_tree::RangeTree; use crate::space_map::{SpaceMap, SpaceMapEntry, SpaceMapPhys}; use crate::zettacache::DEFAULT_SLAB_SIZE; use lazy_static::lazy_static; @@ -19,6 +15,10 @@ use std::convert::TryFrom; use std::ops::Bound::*; use std::sync::Arc; use std::{iter, mem}; +use util::get_tunable; +use util::BitmapRangeIterator; +use util::From64; +use util::RangeTree; lazy_static! { static ref DEFAULT_SLAB_BUCKETS: SlabAllocationBucketsPhys = diff --git a/cmd/zfs_object_agent/zettacache/src/block_based_log.rs b/cmd/zfs_object_agent/zettacache/src/block_based_log.rs index 6a394799a918..5f962ac40b03 100644 --- a/cmd/zfs_object_agent/zettacache/src/block_based_log.rs +++ b/cmd/zfs_object_agent/zettacache/src/block_based_log.rs @@ -2,7 +2,6 @@ use crate::base_types::*; use crate::block_access::BlockAccess; use crate::block_access::EncodeType; use crate::extent_allocator::ExtentAllocator; -use crate::get_tunable; use anyhow::Context; use async_stream::stream; use futures::stream::FuturesUnordered; @@ -23,6 +22,7 @@ use std::ops::Bound::*; use std::ops::Sub; use std::sync::Arc; use std::time::Instant; +use util::get_tunable; lazy_static! { // XXX maybe this is wasteful for the smaller logs? diff --git a/cmd/zfs_object_agent/zettacache/src/extent_allocator.rs b/cmd/zfs_object_agent/zettacache/src/extent_allocator.rs index 24e7c123ea89..673963861da0 100644 --- a/cmd/zfs_object_agent/zettacache/src/extent_allocator.rs +++ b/cmd/zfs_object_agent/zettacache/src/extent_allocator.rs @@ -1,10 +1,10 @@ use crate::base_types::DiskLocation; use crate::base_types::Extent; -use crate::range_tree::RangeTree; use log::*; use more_asserts::*; use serde::{Deserialize, Serialize}; use std::mem; +use util::RangeTree; #[derive(Serialize, Deserialize, Debug, Copy, Clone)] pub struct ExtentAllocatorPhys { diff --git a/cmd/zfs_object_agent/zettacache/src/lib.rs b/cmd/zfs_object_agent/zettacache/src/lib.rs index 4ae64d3ecb7a..fd7320a24931 100644 --- a/cmd/zfs_object_agent/zettacache/src/lib.rs +++ b/cmd/zfs_object_agent/zettacache/src/lib.rs @@ -4,25 +4,16 @@ #![warn(clippy::cast_sign_loss)] pub mod base_types; -mod bitmap_range_iterator; mod block_access; mod block_allocator; mod block_based_log; -mod die; mod extent_allocator; mod index; -mod lock_set; -mod mutex_ext; -mod range_tree; mod space_map; -mod tunable; mod zcachedb; mod zettacache; pub use crate::zettacache::LookupResponse; pub use crate::zettacache::ZettaCache; -pub use die::maybe_die_with; -pub use tunable::get_tunable; -pub use tunable::read_tunable_config; pub use zcachedb::DumpStructuresOptions; pub use zcachedb::ZettaCacheDBCommand; diff --git a/cmd/zfs_object_agent/zettacache/src/zettacache.rs b/cmd/zfs_object_agent/zettacache/src/zettacache.rs index 034980c3c630..b92c1e38ebe6 100644 --- a/cmd/zfs_object_agent/zettacache/src/zettacache.rs +++ b/cmd/zfs_object_agent/zettacache/src/zettacache.rs @@ -6,12 +6,7 @@ use crate::block_allocator::BlockAllocatorPhys; use crate::block_based_log::*; use crate::extent_allocator::ExtentAllocator; use crate::extent_allocator::ExtentAllocatorPhys; -use crate::get_tunable; use crate::index::*; -use crate::lock_set::LockSet; -use crate::lock_set::LockedItem; -use crate::maybe_die_with; -use crate::mutex_ext::MutexExt; use crate::DumpStructuresOptions; use anyhow::Result; use conv::ConvUtil; @@ -37,6 +32,12 @@ use std::time::Instant; use tokio::sync::OwnedSemaphorePermit; use tokio::sync::Semaphore; use tokio::time::{sleep_until, timeout_at}; +use util::get_tunable; +use util::maybe_die_with; +use util::From64; +use util::LockSet; +use util::LockedItem; +use util::MutexExt; lazy_static! { static ref SUPERBLOCK_SIZE: u64 = get_tunable("superblock_size", 4 * 1024); diff --git a/cmd/zfs_object_agent/zettaobject/Cargo.toml b/cmd/zfs_object_agent/zettaobject/Cargo.toml index 5e34218258c9..6e9b9debd5bb 100644 --- a/cmd/zfs_object_agent/zettaobject/Cargo.toml +++ b/cmd/zfs_object_agent/zettaobject/Cargo.toml @@ -38,5 +38,6 @@ serde_json = "1.0.64" stream-reduce = "0.1.0" tokio = { version = "1.4", features = ["full"] } tokio-stream = "0.1.5" +util = { path = "../util" } uuid = {version = "0.8.2", features = ["v4", "serde"]} zettacache = { path = "../zettacache" } diff --git a/cmd/zfs_object_agent/zettaobject/src/heartbeat.rs b/cmd/zfs_object_agent/zettaobject/src/heartbeat.rs index 2b6f7a8fd3e5..5c8ffc1b615e 100644 --- a/cmd/zfs_object_agent/zettaobject/src/heartbeat.rs +++ b/cmd/zfs_object_agent/zettaobject/src/heartbeat.rs @@ -9,8 +9,9 @@ use std::{ time::{Duration, Instant, SystemTime}, }; use tokio::sync::watch::{self, Receiver}; +use util::get_tunable; +use util::maybe_die_with; use uuid::Uuid; -use zettacache::{get_tunable, maybe_die_with}; lazy_static! { pub static ref LEASE_DURATION: Duration = diff --git a/cmd/zfs_object_agent/zettaobject/src/object_access.rs b/cmd/zfs_object_agent/zettaobject/src/object_access.rs index 1b8a0f689ac0..4161b9cc8075 100644 --- a/cmd/zfs_object_agent/zettaobject/src/object_access.rs +++ b/cmd/zfs_object_agent/zettaobject/src/object_access.rs @@ -13,7 +13,11 @@ use lru::LruCache; use rand::prelude::*; use rusoto_core::{ByteStream, RusotoError}; use rusoto_credential::{AutoRefreshingProvider, ChainProvider, ProfileProvider}; -use rusoto_s3::*; +use rusoto_s3::{ + Delete, DeleteObjectsRequest, GetObjectRequest, HeadObjectOutput, HeadObjectRequest, + ListObjectsV2Request, ObjectIdentifier, PutObjectError, PutObjectOutput, PutObjectRequest, + S3Client, S3, +}; use std::convert::TryFrom; use std::error::Error; use std::iter; @@ -21,7 +25,7 @@ use std::sync::Arc; use std::time::Instant; use std::{collections::HashMap, fmt::Display}; use tokio::{sync::watch, time::error::Elapsed}; -use zettacache::get_tunable; +use util::get_tunable; struct ObjectCache { // XXX cache key should include Bucket diff --git a/cmd/zfs_object_agent/zettaobject/src/object_based_log.rs b/cmd/zfs_object_agent/zettaobject/src/object_based_log.rs index 8f1fb8e8689b..bce10fc0e236 100644 --- a/cmd/zfs_object_agent/zettaobject/src/object_based_log.rs +++ b/cmd/zfs_object_agent/zettaobject/src/object_based_log.rs @@ -15,8 +15,8 @@ use std::marker::PhantomData; use std::sync::Arc; use std::time::Instant; use tokio::task::JoinHandle; +use util::get_tunable; use zettacache::base_types::*; -use zettacache::get_tunable; lazy_static! { pub static ref ENTRIES_PER_OBJECT: usize = get_tunable("entries_per_object", 100_000); diff --git a/cmd/zfs_object_agent/zettaobject/src/pool.rs b/cmd/zfs_object_agent/zettaobject/src/pool.rs index 608b073e202b..d6b6c83b2462 100644 --- a/cmd/zfs_object_agent/zettaobject/src/pool.rs +++ b/cmd/zfs_object_agent/zettaobject/src/pool.rs @@ -49,10 +49,11 @@ use stream_reduce::Reduce; use tokio::sync::oneshot; use tokio::task::JoinHandle; use tokio::time::sleep; +use util::get_tunable; +use util::maybe_die_with; +use util::TerseVec; use uuid::Uuid; use zettacache::base_types::*; -use zettacache::get_tunable; -use zettacache::maybe_die_with; use zettacache::LookupResponse; use zettacache::ZettaCache; @@ -206,15 +207,6 @@ pub struct UberblockPhys { } impl OnDisk for UberblockPhys {} -/// exists just to reduce Debug output on fields we don't really care about -#[derive(Serialize, Deserialize)] -pub struct TerseVec(Vec); -impl fmt::Debug for TerseVec { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.write_fmt(format_args!("[...{} elements...]", self.0.len())) - } -} - #[derive(Serialize, Deserialize, Debug, Default, Clone, Copy)] pub struct PoolStatsPhys { pub blocks_count: u64, // Note: does not include the pending_object diff --git a/cmd/zfs_object_agent/zettaobject/src/pool_destroy.rs b/cmd/zfs_object_agent/zettaobject/src/pool_destroy.rs index 03e8a66311aa..d62f91fe21a1 100644 --- a/cmd/zfs_object_agent/zettaobject/src/pool_destroy.rs +++ b/cmd/zfs_object_agent/zettaobject/src/pool_destroy.rs @@ -17,8 +17,8 @@ use tokio::fs::OpenOptions; use tokio::io::AsyncReadExt; use tokio::sync::mpsc; use tokio::sync::Mutex; +use util::get_tunable; use zettacache::base_types::*; -use zettacache::get_tunable; lazy_static! { static ref POOL_DESTROYER: Mutex> = Default::default(); diff --git a/cmd/zfs_object_agent/zettaobject/src/public_connection.rs b/cmd/zfs_object_agent/zettaobject/src/public_connection.rs index 8ec682137d22..08f787557599 100644 --- a/cmd/zfs_object_agent/zettaobject/src/public_connection.rs +++ b/cmd/zfs_object_agent/zettaobject/src/public_connection.rs @@ -1,6 +1,3 @@ -use std::fs; -use std::os::unix::prelude::PermissionsExt; - use crate::object_access::ObjectAccess; use crate::pool::*; use crate::pool_destroy; @@ -11,9 +8,11 @@ use lazy_static::lazy_static; use log::*; use nvpair::NvList; use rusoto_s3::S3; +use std::fs; +use std::os::unix::prelude::PermissionsExt; use std::sync::{Arc, Mutex}; +use util::get_tunable; use zettacache::base_types::*; -use zettacache::get_tunable; lazy_static! { pub static ref GET_POOLS_QUEUE_DEPTH: usize = get_tunable("get_pools_queue_depth", 100); diff --git a/cmd/zfs_object_agent/zettaobject/src/root_connection.rs b/cmd/zfs_object_agent/zettaobject/src/root_connection.rs index 6601e3eb73b3..bcf922075f1b 100644 --- a/cmd/zfs_object_agent/zettaobject/src/root_connection.rs +++ b/cmd/zfs_object_agent/zettaobject/src/root_connection.rs @@ -15,10 +15,10 @@ use log::*; use nvpair::{NvData, NvList, NvListRef}; use std::convert::TryFrom; use std::sync::Arc; +use util::get_tunable; +use util::maybe_die_with; use uuid::Uuid; use zettacache::base_types::*; -use zettacache::get_tunable; -use zettacache::maybe_die_with; use zettacache::ZettaCache; lazy_static! { diff --git a/cmd/zfs_object_agent/zettaobject/src/server.rs b/cmd/zfs_object_agent/zettaobject/src/server.rs index 92dfb39f3fee..bf0d4e2389a9 100644 --- a/cmd/zfs_object_agent/zettaobject/src/server.rs +++ b/cmd/zfs_object_agent/zettaobject/src/server.rs @@ -19,7 +19,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf}; use tokio::net::{UnixListener, UnixStream}; use tokio::sync::{mpsc, Mutex}; -use zettacache::base_types::From64; +use util::From64; // Ss: ServerState (consumer's state associated with the server) // Cs: ConnectionState (consumer's state associated with the connection)