Skip to content

Commit

Permalink
fix: clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Wünsche committed Jan 15, 2024
1 parent 98e3495 commit 6340cb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 8 additions & 2 deletions betree/src/storage_pool/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ pub enum Vdev {
#[serde(untagged, deny_unknown_fields, rename_all = "lowercase")]
pub enum LeafVdev {
#[cfg(feature = "nvm")]
PMemFile { path: PathBuf, len: usize },
/// Backed by NVM with `pmdk`.
PMemFile {
/// Path to the underlying file.
path: PathBuf,
/// Size of backing file in bytes.
len: usize,
},
/// Backed by a file or disk.
File(PathBuf),
/// Customisable file vdev.
Expand Down Expand Up @@ -416,7 +422,7 @@ impl LeafVdev {
writeln!(f, "{:indent$}memory({})", "", mem, indent = indent)
}
#[cfg(feature = "nvm")]
LeafVdev::PMemFile { path, len } => {
LeafVdev::PMemFile { path, len: _ } => {
writeln!(f, "{:indent$}{}", "", path.display(), indent = indent)
}
}
Expand Down
17 changes: 8 additions & 9 deletions betree/src/vdev/pmemfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ use super::{
errors::*, AtomicStatistics, Block, Result, ScrubResult, Statistics, Vdev, VdevLeafRead,
VdevLeafWrite, VdevRead,
};
use crate::{buffer::Buf, buffer::BufWrite, checksum::Checksum};
use crate::{buffer::Buf, checksum::Checksum};
use async_trait::async_trait;
use libc::{c_ulong, ioctl};
use pmdk;
use std::{
fs,
io::{self, Write},
os::unix::{
fs::{FileExt, FileTypeExt},
io,
os::unix::
io::AsRawFd,
},

sync::atomic::Ordering,
};

/// `LeafVdev` that is backed by a file.
/// `LeafVdev` which is backed by NVM and uses `pmdk`.
#[derive(Debug)]
pub struct PMemFile {
file: pmdk::PMem,
Expand Down Expand Up @@ -151,16 +150,16 @@ impl VdevLeafWrite for PMemFile {
&self,
data: W,
offset: Block<u64>,
is_repair: bool,
_is_repair: bool,
) -> Result<()> {
let block_cnt = Block::from_bytes(data.as_ref().len() as u64).as_u64();
self.stats.written.fetch_add(block_cnt, Ordering::Relaxed);

unsafe { Ok(self.file.write(offset.to_bytes() as usize, data.as_ref())) }
unsafe { self.file.write(offset.to_bytes() as usize, data.as_ref()) };
Ok(())
}

fn flush(&self) -> Result<()> {
//Ok(self.file.sync_data()?)
Ok(())
}
}

0 comments on commit 6340cb5

Please sign in to comment.