Skip to content

Commit

Permalink
chore(lvs/lvol): add trace message before zeroing super
Browse files Browse the repository at this point in the history
This is useful to trace how long zeroing takes.
Also use write_zeroes variant that is now available which is much simpler.

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jun 2, 2023
1 parent bf567ad commit 43bd669
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
31 changes: 6 additions & 25 deletions io-engine/src/lvs/lvs_lvol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use spdk_rs::libspdk::{
vbdev_lvol_destroy,
vbdev_lvol_get_from_bdev,
LVS_CLEAR_WITH_UNMAP,
SPDK_BDEV_LARGE_BUF_MAX_SIZE,
};

use super::{Error, Lvs};
Expand Down Expand Up @@ -294,34 +293,16 @@ impl Lvol {
}
})?;

// Set the buffer size to the maximum allowed by SPDK.
let buf_size = SPDK_BDEV_LARGE_BUF_MAX_SIZE as u64;
let buf = hdl.dma_malloc(buf_size).map_err(|e| {
error!(
?self,
?e,
"no memory available to allocate zero buffer"
);
// write zero to the first 8MB which wipes the metadata and the
// first 4MB of the data partition
hdl.write_zeroes_at(0, WIPE_SUPER_LEN).await.map_err(|e| {
error!(?self, ?e);
Error::RepDestroy {
source: Errno::ENOMEM,
source: Errno::EIO,
name: self.name(),
msg: "no memory available to allocate zero buffer".into(),
msg: "failed to write to lvol".into(),
}
})?;
// write zero to the first 8MB which wipes the metadata and the
// first 4MB of the data partition
let range =
std::cmp::min(self.as_bdev().size_in_bytes(), WIPE_SUPER_LEN);
for offset in 0 .. (range / buf_size) {
hdl.write_at(offset * buf.len(), &buf).await.map_err(|e| {
error!(?self, ?e);
Error::RepDestroy {
source: Errno::EIO,
name: self.name(),
msg: "failed to write to lvol".into(),
}
})?;
}
}
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions io-engine/src/lvs/lvs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ impl Lvs {
})
.map(Lvol::from_inner_ptr)?;

info!("{:?}: wipping super", lvol);

if let Err(error) = lvol.wipe_super().await {
// If we fail to destroy it hopefully the control-plane will clean
// it up, though it's possible it may attempt to use it...
Expand Down

0 comments on commit 43bd669

Please sign in to comment.