Skip to content

Commit

Permalink
fix some nightly clippy nits (openzfs#494)
Browse files Browse the repository at this point in the history
Fix some nits that are only detected by `cargo +nightly clippy` but
which seem to be good recommendations.
  • Loading branch information
ahrens authored Jun 24, 2022
1 parent 2fb74da commit f347827
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
5 changes: 2 additions & 3 deletions cmd/zfs_object_agent/util/src/async_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,13 @@ mod test {
let (tx, rx) = watch_once::channel::<Value>();
let (started_tx, started_rx) = oneshot::channel::<()>();
let join_handle = tokio::spawn(async move {
let v = cache
cache
.get(key, move |_| {
started_tx.send(()).ok();
async move { Ok(rx.recv().await.unwrap()) }
})
.await
.unwrap();
v
.unwrap()
});

(started_rx, Sender { tx, join_handle })
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/util/src/zettacache_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::nice_p2size;
use crate::write_stdout;

/// The zettacache disk I/O types that are collected and displayed for each disk.
#[derive(Debug, Enum, Copy, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Enum, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum DiskIoType {
ReadDataForLookup,
ReadIndexForLookup,
Expand Down
8 changes: 5 additions & 3 deletions cmd/zfs_object_agent/zettacache/src/atime_histogram.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt::Display;
use std::fmt::Write;
use std::iter;
use std::mem;
use std::ops::AddAssign;
Expand Down Expand Up @@ -150,14 +151,15 @@ impl AtimeHistogramPhys {
let mut message = String::new();
for (index, (&value, &other_value)) in zip.enumerate() {
if value != other_value {
message.push_str(&format!(
"index {} ({:?}) does not match (self={} other={} delta={})\n",
let _ = writeln!(
message,
"index {} ({:?}) does not match (self={} other={} delta={})",
index,
self.first_ghost + index,
value,
other_value,
value - other_value
));
);
}
}
if !message.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ impl<T: SummarizedBlockBasedLogEntry> ReadOnlySummarizedBlockBasedLog<T> {
/// Returns (value, chunk_cache_hit), where the value is the value corresponding to the key
/// argument if found, and chunk_cache_hit that tells us whether we found the value on the
/// chunk cache (true) or had to reach out to disk (false).
pub async fn lookup_by_key(
&self,
pub async fn lookup_by_key<'a>(
&'a self,
key: &T::Key,
) -> (Option<BlockBasedLogValueGuard<'_, T>>, bool) {
) -> (Option<BlockBasedLogValueGuard<'a, T>>, bool) {
let (value, chunk_cache_hit) = self.lookup_by_key_impl(key).await;
(
value.map(|v| BlockBasedLogValueGuard {
value.map(|v| BlockBasedLogValueGuard::<'a, _> {
inner: v,
_marker: &PhantomData,
}),
Expand Down Expand Up @@ -470,10 +470,10 @@ impl<T: SummarizedBlockBasedLogEntry> SummarizedBlockBasedLog<T> {
}

/// See ReadOnlySummarizedBlockBasedLog::lookup_by_key()
pub async fn lookup_by_key(
&self,
pub async fn lookup_by_key<'a>(
&'a self,
key: &T::Key,
) -> (Option<BlockBasedLogValueGuard<'_, T>>, bool) {
) -> (Option<BlockBasedLogValueGuard<'a, T>>, bool) {
self.readonly.lookup_by_key(key).await
}
}
12 changes: 5 additions & 7 deletions cmd/zfs_object_agent/zettacache/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl IndexKey {
}
}

#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
#[repr(packed)]
pub struct IndexValue {
location: Option<DiskLocation>,
Expand Down Expand Up @@ -313,7 +313,7 @@ impl IndexRun {
slab_allocator: Arc<SlabAllocator>,
phys: IndexRunPhys,
) -> Self {
let index = Self {
Self {
trim_key: phys.trim_key,
last_key: phys.last_key,
atime_histogram_phys: phys.atime_histogram_phys,
Expand All @@ -325,8 +325,7 @@ impl IndexRun {
.await,
block_access,
slab_allocator,
};
index
}
}

/// Returns new Phys and a Vec which can be passed to ReadOnlyIndexRun::update()
Expand Down Expand Up @@ -489,13 +488,12 @@ impl ReadOnlyIndexRun {
slab_allocator: Arc<SlabAllocator>,
phys: IndexRunPhys,
) -> Self {
let index = Self {
Self {
trim_key: phys.trim_key,
last_key: phys.last_key,
log: ReadOnlySummarizedBlockBasedLog::open(block_access, slab_allocator, phys.log)
.await,
};
index
}
}

pub fn last_key(&self) -> Option<IndexKey> {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/zettaobject/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tunable! {
pub static ref HEARTBEAT_TIMEOUT: Duration = *LEASE_DURATION / 5;
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct HeartbeatPhys {
pub timestamp: SystemTime,
pub hostname: String,
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/zettaobject/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn start(
RootServerState::start(socket_dir, cache, id);

// keep the process from exiting
let () = futures::future::pending().await;
futures::future::pending::<()>().await;
Ok(())
})
}
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/zettaobject/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ impl Pool {
}
sleep(*CLAIM_DURATION * 3).await;

return handle_final_owner(object_access, guid, id).await;
handle_final_owner(object_access, guid, id).await
}

pub async fn claim(&mut self, id: Uuid) -> Result<(), PoolOpenError> {
Expand Down

0 comments on commit f347827

Please sign in to comment.