Skip to content

Commit dc932b1

Browse files
committed
chore: helper to get crypto vbdev's base bdev
Signed-off-by: Diwakar Sharma <diwakar.sharma@datacore.com>
1 parent 0e48462 commit dc932b1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn main() {
298298
.allowlist_function(".*.aio.*")
299299
.allowlist_function("^accel.*")
300300
.allowlist_function(".*.crypto_disk.*")
301-
.allowlist_function(".*.crypto_opts")
301+
.allowlist_function(".*.crypto_opts.*")
302302
.allowlist_function(".*.iscsi.*")
303303
.allowlist_function(".*.lock_lba_range")
304304
.allowlist_function(".*.lvol.*")

src/bdev.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
spdk_bdev_get_aliases, spdk_bdev_get_buf_align, spdk_bdev_get_by_name,
1818
spdk_bdev_has_write_cache, spdk_bdev_io_type_supported, spdk_bdev_module,
1919
spdk_bdev_module_release_bdev, spdk_bdev_register, spdk_bdev_unregister,
20-
SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
20+
vbdev_crypto_disk_get_base_bdev, SPDK_BDEV_CLAIM_EXCL_WRITE, SPDK_BDEV_CLAIM_NONE,
2121
},
2222
BdevIo, BdevModule, BdevOps, IoChannel, IoDevice, IoType, Thread, Uuid,
2323
};
@@ -71,6 +71,16 @@ where
7171
unsafe { (*self.as_inner_ref().module).name.as_str() }
7272
}
7373

74+
/// Returns the bdev handle which is the base of `self` bdev here.
75+
/// e.g self could be a crypto vbdev and base an aio bdev.
76+
/// XXX: This must be called only by crypto vbdev today.
77+
pub fn crypto_base_bdev(&self) -> Self {
78+
let p = unsafe {
79+
vbdev_crypto_disk_get_base_bdev(self.name().as_ptr() as *mut std::os::raw::c_char)
80+
};
81+
Self::from_inner_ptr(p)
82+
}
83+
7484
/// TODO
7585
/// ... lookup a bdev by its name
7686
pub fn lookup_by_name(name: &str) -> Option<Self> {

0 commit comments

Comments
 (0)