Skip to content

Commit 05cd3d3

Browse files
mayastor-borsdsharma-dc
andcommitted
Merge #1846
1846: fix(lvs/export): destroy bdevs correctly considering crypto pool r=dsharma-dc a=dsharma-dc Copies the bdev destroy logic as we do in pool destroy path, to the pool export path. Co-authored-by: Diwakar Sharma <[email protected]>
2 parents 6cc2073 + a30697f commit 05cd3d3

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

io-engine/src/lvs/lvs_store.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl Lvs {
672672
info!("{}: exporting lvs...", self_str);
673673

674674
let pool = self.name().to_string();
675-
let base_bdev = self.base_bdev();
675+
let mut base_bdev = self.base_bdev();
676676
let (s, r) = pair::<i32>();
677677

678678
self.unshare_all().await;
@@ -688,12 +688,35 @@ impl Lvs {
688688

689689
info!("{}: lvs exported successfully", self_str);
690690

691-
bdev_destroy(&base_bdev.bdev_uri_original_str().unwrap_or_default())
692-
.await
693-
.map_err(|e| LvsError::Destroy {
691+
// If the base_bdev is a crypto vbdev then we need to destroy both - the crypto vbdev and it's base.
692+
if base_bdev.driver() == "crypto" {
693+
let cbdev = base_bdev.crypto_base_bdev();
694+
695+
if let Err(e) = destroy_crypto_vbdev(base_bdev.name().to_string()).await {
696+
error!(
697+
"failed to delete crypto vbdev {:?} during lvs export. {e}",
698+
base_bdev.name()
699+
);
700+
}
701+
702+
// A None cbdev here is highly unlikely as the vbdev can't exist in thin air.
703+
// If cbdev is somehow None anyway, then the following bdev_destroy will likely
704+
// fail, and we can let it.
705+
if let Some(c) = cbdev {
706+
base_bdev = Bdev::new(c);
707+
}
708+
}
709+
trace!(
710+
"Deleting bdev {}, uri {:?}",
711+
base_bdev.name(),
712+
base_bdev.bdev_uri_original_str()
713+
);
714+
if let Some(u) = base_bdev.bdev_uri_original_str() {
715+
bdev_destroy(&u).await.map_err(|e| LvsError::Destroy {
694716
source: e,
695717
name: base_bdev.name().to_string(),
696718
})?;
719+
}
697720

698721
Ok(())
699722
}

0 commit comments

Comments
 (0)