Skip to content

Commit

Permalink
chore: helper to get crypto vbdev's base bdev
Browse files Browse the repository at this point in the history
Signed-off-by: Diwakar Sharma <[email protected]>
  • Loading branch information
dsharma-dc committed Feb 25, 2025
1 parent 0e48462 commit 5be07f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn main() {
.allowlist_function(".*.aio.*")
.allowlist_function("^accel.*")
.allowlist_function(".*.crypto_disk.*")
.allowlist_function(".*.crypto_opts")
.allowlist_function(".*.crypto_opts.*")
.allowlist_function(".*.iscsi.*")
.allowlist_function(".*.lock_lba_range")
.allowlist_function(".*.lvol.*")
Expand Down
16 changes: 15 additions & 1 deletion src/bdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
spdk_bdev_get_aliases, spdk_bdev_get_buf_align, spdk_bdev_get_by_name,
spdk_bdev_has_write_cache, spdk_bdev_io_type_supported, spdk_bdev_module,
spdk_bdev_module_release_bdev, spdk_bdev_register, spdk_bdev_unregister,
SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
vbdev_crypto_disk_get_base_bdev, SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
},
BdevIo, BdevModule, BdevOps, IoChannel, IoDevice, IoType, Thread, Uuid,
};
Expand Down Expand Up @@ -71,6 +71,20 @@ where
unsafe { (*self.as_inner_ref().module).name.as_str() }
}

/// Returns the bdev handle which is the base of `self` bdev here.
/// e.g self could be a crypto vbdev and base an aio bdev.
/// XXX: This must be called only by crypto vbdev today.
pub fn crypto_base_bdev(&self) -> Option<Self> {
let p = unsafe {
vbdev_crypto_disk_get_base_bdev(self.name().as_ptr() as *mut std::os::raw::c_char)
};
if p.is_null() {
None
} else {
Some(Self::from_inner_ptr(p))
}
}

/// TODO
/// ... lookup a bdev by its name
pub fn lookup_by_name(name: &str) -> Option<Self> {
Expand Down

0 comments on commit 5be07f1

Please sign in to comment.