From 9b78bdad4d1d08c01dfa6029319845fee6b0c687 Mon Sep 17 00:00:00 2001 From: Diwakar Sharma Date: Tue, 18 Feb 2025 11:38:01 +0000 Subject: [PATCH] chore: helper to get crypto vbdev's base bdev Signed-off-by: Diwakar Sharma --- build.rs | 2 +- src/bdev.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index e1445fa..01dfc7c 100644 --- a/build.rs +++ b/build.rs @@ -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.*") diff --git a/src/bdev.rs b/src/bdev.rs index f58ee88..39cd360 100644 --- a/src/bdev.rs +++ b/src/bdev.rs @@ -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, }; @@ -71,6 +71,16 @@ 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) -> Self { + let p = unsafe { + vbdev_crypto_disk_get_base_bdev(self.name().as_ptr() as *mut std::os::raw::c_char) + }; + Self::from_inner_ptr(p) + } + /// TODO /// ... lookup a bdev by its name pub fn lookup_by_name(name: &str) -> Option {