Skip to content

Commit 0f61718

Browse files
committed
fix(driver): unify buffer pool error to ResourceBusy across backends
1 parent aa6cc46 commit 0f61718

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

compio-driver/src/sys/buffer_pool/fallback.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ impl BufControl {
2222
}
2323

2424
pub fn pop(&mut self) -> io::Result<u16> {
25-
self.queue
26-
.pop_front()
27-
.ok_or_else(|| io::Error::other("buffer ring has no available buffer"))
25+
self.queue.pop_front().ok_or_else(|| {
26+
io::Error::new(
27+
io::ErrorKind::ResourceBusy,
28+
"buffer ring has no available buffer",
29+
)
30+
})
2831
}
2932

3033
pub unsafe fn reset(&mut self, buffer_id: u16, _: BufPtr, _: u32) {

compio-driver/src/sys/driver/iour/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,17 @@ fn create_entry(cq_entry: CEntry) -> Entry {
462462

463463
fn create_result(result: i32) -> io::Result<usize> {
464464
if result < 0 {
465-
Err(io::Error::from_raw_os_error(-result))
465+
let err = io::Error::from_raw_os_error(-result);
466+
// This is for ENOBUFS, which means io-uring report buffer pool has no available
467+
// buffer.
468+
if err.raw_os_error() == Some(libc::ENOBUFS) {
469+
Err(io::Error::new(
470+
io::ErrorKind::ResourceBusy,
471+
"buffer ring has no available buffer",
472+
))
473+
} else {
474+
Err(err)
475+
}
466476
} else {
467477
Ok(result as _)
468478
}

0 commit comments

Comments
 (0)