Skip to content

Commit ec0b50d

Browse files
build: update spdk to error stats change
Brings the spdk fix https://review.spdk.io/c/spdk/spdk/+/27491 Adds rust enum for the stats mode Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
1 parent 32147a2 commit ec0b50d

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

nix/pkgs/libspdk/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ let
9292
# Derivation attributes
9393
#
9494
spdk = rec {
95-
rev = "f61f929aac373ed8af3a27a4bafa4cee046e1922";
96-
sha256 = "sha256-k+jezN1lGteu9AN7qozVyaTmtuYC7dgNRPDpSSYt2l8=";
95+
rev = "1999ff22d5d32711755baa9ad190261b92a4e08b";
96+
sha256 = "sha256-CqbgQ/jlu2MUhVxvpwjWdiW29YdT3yU9cWS6lG8OWZ0=";
9797
pname = "libspdk${nameSuffix}";
9898
version = "25.05-${lib.substring 0 7 rev}";
9999
name = "${pname}-${version}";

src/bdev_async.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@ use crate::{
88
ffihelper::{cb_arg, done_errno_cb, errno_error, errno_result_from_i32, ErrnoResult},
99
libspdk::{
1010
bdev_reset_device_stat, spdk_bdev, spdk_bdev_get_device_stat, spdk_bdev_io_stat,
11-
spdk_bdev_unregister, SPDK_BDEV_RESET_STAT_ALL, SPDK_BDEV_RESET_STAT_NONE,
11+
spdk_bdev_unregister,
1212
},
1313
Bdev, BdevOps,
1414
};
1515

1616
/// TODO
1717
pub type BdevStats = spdk_bdev_io_stat;
1818

19+
/// Bdev Stat reset mode.
20+
pub enum BdevStatsResetMode {
21+
All,
22+
MaxMin,
23+
Errors,
24+
}
25+
impl From<BdevStatsResetMode> for crate::libspdk::spdk_bdev_reset_stat_mode {
26+
fn from(value: BdevStatsResetMode) -> Self {
27+
match value {
28+
BdevStatsResetMode::All => crate::libspdk::SPDK_BDEV_RESET_STAT_ALL,
29+
BdevStatsResetMode::MaxMin => crate::libspdk::SPDK_BDEV_RESET_STAT_MAXMIN,
30+
BdevStatsResetMode::Errors => crate::libspdk::SPDK_BDEV_RESET_STAT_ERROR,
31+
}
32+
}
33+
}
34+
1935
/// TODO
2036
pub struct BdevAsyncCallContext {
2137
/// TODO
@@ -86,7 +102,7 @@ where
86102
spdk_bdev_get_device_stat(
87103
self.as_inner_ptr(),
88104
&mut stat as *mut _,
89-
SPDK_BDEV_RESET_STAT_NONE,
105+
crate::libspdk::SPDK_BDEV_RESET_STAT_NONE,
90106
Some(inner_stats_callback),
91107
cb_arg(s),
92108
);
@@ -98,14 +114,14 @@ where
98114

99115
/// This function resets all stat counters for a given Bdev.
100116
/// Returns Errno in case of an error.
101-
pub async fn stats_reset_async(&self) -> ErrnoResult<()> {
117+
pub async fn stats_reset_async(&self, reset_mode: BdevStatsResetMode) -> ErrnoResult<()> {
102118
let (s, r) = oneshot::channel::<i32>();
103119
// This will iterate over I/O channels to reset IOStats and call async
104120
// callback when done.
105121
unsafe {
106122
bdev_reset_device_stat(
107123
self.as_inner_ptr(),
108-
SPDK_BDEV_RESET_STAT_ALL,
124+
reset_mode.into(),
109125
Some(inner_stats_reset_callback),
110126
cb_arg(s),
111127
);

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ mod uuid;
5252

5353
pub use crate::{
5454
bdev::Bdev,
55-
bdev_async::{BdevAsyncCallContext, BdevStats},
55+
bdev_async::{BdevAsyncCallContext, BdevStats, BdevStatsResetMode},
5656
bdev_builder::BdevBuilder,
5757
bdev_desc::{BdevDesc, BdevDescError, BdevEvent, LbaRange, LbaRangeLock},
5858
bdev_io::BdevIo,

0 commit comments

Comments
 (0)