diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 49bfe0837..395d768a5 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use std::fs::File; -use std::io::{Seek, SeekFrom}; +use std::io::{Error, Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; use io_uring::{opcode, squeue, types, IoUring}; @@ -86,7 +86,7 @@ impl AsyncIo for RawFileAsync { // SAFETY: we know the file descriptor is valid and we // relied on vm-memory to provide the buffer address. - let _ = unsafe { + unsafe { sq.push( &opcode::Readv::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32) .offset(offset.try_into().unwrap()) @@ -94,6 +94,7 @@ impl AsyncIo for RawFileAsync { .flags(squeue::Flags::ASYNC) .user_data(user_data), ) + .map_err(|_| AsyncIoError::ReadVectored(Error::other("Submission queue is full")))? }; // Update the submission queue and submit new operations to the @@ -114,7 +115,7 @@ impl AsyncIo for RawFileAsync { // SAFETY: we know the file descriptor is valid and we // relied on vm-memory to provide the buffer address. - let _ = unsafe { + unsafe { sq.push( &opcode::Writev::new(types::Fd(self.fd), iovecs.as_ptr(), iovecs.len() as u32) .offset(offset.try_into().unwrap()) @@ -122,6 +123,7 @@ impl AsyncIo for RawFileAsync { .flags(squeue::Flags::ASYNC) .user_data(user_data), ) + .map_err(|_| AsyncIoError::WriteVectored(Error::other("Submission queue is full")))? }; // Update the submission queue and submit new operations to the @@ -137,13 +139,14 @@ impl AsyncIo for RawFileAsync { let (submitter, mut sq, _) = self.io_uring.split(); // SAFETY: we know the file descriptor is valid. - let _ = unsafe { + unsafe { sq.push( &opcode::Fsync::new(types::Fd(self.fd)) .build() .flags(squeue::Flags::ASYNC) .user_data(user_data), ) + .map_err(|_| AsyncIoError::Fsync(Error::other("Submission queue is full")))? }; // Update the submission queue and submit new operations to the