-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Savitskiy <[email protected]>
- Loading branch information
1 parent
46fbe24
commit a8b4170
Showing
15 changed files
with
165 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef MAYASTOR_SPDK_COMMON_H | ||
#define MAYASTOR_SPDK_COMMON_H | ||
|
||
#include <spdk/assert.h> | ||
|
||
#ifndef assert | ||
#define assert(expression) ((void)0) | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use futures::channel::oneshot::{self, Canceled}; | ||
use nix::errno::Errno; | ||
|
||
use crate::{ | ||
ffihelper::{ | ||
cb_arg, | ||
copy_str_with_null, | ||
done_errno_cb, | ||
drop_cb_arg, | ||
ErrnoResult, | ||
IntoCString, | ||
}, | ||
libspdk::{bdev_nvme_delete, nvme_path_id, SPDK_NVME_TRANSPORT_PCIE}, | ||
}; | ||
|
||
/// Async wrapper for `bdev_nvme_delete`. | ||
/// `bdev_nvme_delete` differs from other bdev_*_delete function family, | ||
/// as it may return errno instead calling the callback (which is optional). | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `name`: Controller name. | ||
/// | ||
/// * `path_id`: Controller path ID. If not given, `name` is used for traddr, | ||
/// and SPDK_NVME_TRANSPORT_PCIE for trtype. | ||
pub async fn bdev_nvme_delete_async( | ||
name: &str, | ||
path_id: Option<nvme_path_id>, | ||
) -> Result<ErrnoResult<()>, Canceled> { | ||
let path_id = path_id.unwrap_or_else(|| { | ||
let mut path_id = nvme_path_id::default(); | ||
copy_str_with_null(name, &mut path_id.trid.traddr); | ||
path_id.trid.trtype = SPDK_NVME_TRANSPORT_PCIE; | ||
path_id | ||
}); | ||
|
||
let (s, r) = oneshot::channel::<ErrnoResult<()>>(); | ||
let arg = cb_arg(s); | ||
|
||
let errno = unsafe { | ||
bdev_nvme_delete( | ||
name.to_string().into_cstring().as_ptr(), | ||
&path_id, | ||
Some(done_errno_cb), | ||
arg, | ||
) | ||
}; | ||
|
||
// `bdev_nvme_delete` failed to run: callback won't be called. | ||
if errno < 0 { | ||
drop_cb_arg::<()>(arg); | ||
return Ok(Err(Errno::from_i32(-errno))); | ||
} | ||
|
||
r.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
///! Wrappers for individual Bdev types. | ||
pub mod bdev_nvme; | ||
|
||
pub use bdev_nvme::bdev_nvme_delete_async; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters