From e7a51cde7831ecea506d987cfb90cdec76342d89 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 10 Jan 2023 12:44:00 +0000 Subject: [PATCH] block_util: Pass a reference to the slice of iovecs Rather than passing the vector of iovecs for the I/O to act on pass a reference to the slice of values inside them. This removes the explicit container type from the API allowing the use of e.g. SmallVec. Signed-off-by: Rob Bradford --- block_util/src/async_io.rs | 4 ++-- block_util/src/fixed_vhd_async.rs | 4 ++-- block_util/src/fixed_vhd_sync.rs | 4 ++-- block_util/src/lib.rs | 8 ++++---- block_util/src/qcow_sync.rs | 4 ++-- block_util/src/raw_async.rs | 4 ++-- block_util/src/raw_sync.rs | 4 ++-- block_util/src/vhdx_sync.rs | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/block_util/src/async_io.rs b/block_util/src/async_io.rs index 6f91e6209..cb27b080e 100644 --- a/block_util/src/async_io.rs +++ b/block_util/src/async_io.rs @@ -131,13 +131,13 @@ pub trait AsyncIo: Send { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()>; fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()>; fn fsync(&mut self, user_data: Option) -> AsyncIoResult<()>; diff --git a/block_util/src/fixed_vhd_async.rs b/block_util/src/fixed_vhd_async.rs index 16aba4fe6..583375a5c 100644 --- a/block_util/src/fixed_vhd_async.rs +++ b/block_util/src/fixed_vhd_async.rs @@ -64,7 +64,7 @@ impl AsyncIo for FixedVhdAsync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { if offset as u64 >= self.size { @@ -83,7 +83,7 @@ impl AsyncIo for FixedVhdAsync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { if offset as u64 >= self.size { diff --git a/block_util/src/fixed_vhd_sync.rs b/block_util/src/fixed_vhd_sync.rs index f4293ea88..e9944d18e 100644 --- a/block_util/src/fixed_vhd_sync.rs +++ b/block_util/src/fixed_vhd_sync.rs @@ -62,7 +62,7 @@ impl AsyncIo for FixedVhdSync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { if offset as u64 >= self.size { @@ -81,7 +81,7 @@ impl AsyncIo for FixedVhdSync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { if offset as u64 >= self.size { diff --git a/block_util/src/lib.rs b/block_util/src/lib.rs index 1ffbe5397..620dbba6f 100644 --- a/block_util/src/lib.rs +++ b/block_util/src/lib.rs @@ -431,12 +431,12 @@ impl Request { .mark_dirty(0, *data_len as usize); } disk_image - .read_vectored(offset, iovecs, user_data) + .read_vectored(offset, &iovecs, user_data) .map_err(ExecuteError::AsyncRead)?; } RequestType::Out => { disk_image - .write_vectored(offset, iovecs, user_data) + .write_vectored(offset, &iovecs, user_data) .map_err(ExecuteError::AsyncWrite)?; } RequestType::Flush => { @@ -590,7 +590,7 @@ where fn read_vectored_sync( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, eventfd: &EventFd, completion_list: &mut Vec<(u64, i32)>, @@ -623,7 +623,7 @@ where fn write_vectored_sync( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, eventfd: &EventFd, completion_list: &mut Vec<(u64, i32)>, diff --git a/block_util/src/qcow_sync.rs b/block_util/src/qcow_sync.rs index 990c4ec2d..097bcfea3 100644 --- a/block_util/src/qcow_sync.rs +++ b/block_util/src/qcow_sync.rs @@ -65,7 +65,7 @@ impl AsyncIo for QcowSync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { self.qcow_file.read_vectored_sync( @@ -80,7 +80,7 @@ impl AsyncIo for QcowSync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { self.qcow_file.write_vectored_sync( diff --git a/block_util/src/raw_async.rs b/block_util/src/raw_async.rs index 9c2e32260..8891eea28 100644 --- a/block_util/src/raw_async.rs +++ b/block_util/src/raw_async.rs @@ -76,7 +76,7 @@ impl AsyncIo for RawFileAsync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { let (submitter, mut sq, _) = self.io_uring.split(); @@ -104,7 +104,7 @@ impl AsyncIo for RawFileAsync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { let (submitter, mut sq, _) = self.io_uring.split(); diff --git a/block_util/src/raw_sync.rs b/block_util/src/raw_sync.rs index fe856a69e..80c44daeb 100644 --- a/block_util/src/raw_sync.rs +++ b/block_util/src/raw_sync.rs @@ -65,7 +65,7 @@ impl AsyncIo for RawFileSync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { // SAFETY: FFI call with valid arguments @@ -90,7 +90,7 @@ impl AsyncIo for RawFileSync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { // SAFETY: FFI call with valid arguments diff --git a/block_util/src/vhdx_sync.rs b/block_util/src/vhdx_sync.rs index 48b0e3ac5..769c3f713 100644 --- a/block_util/src/vhdx_sync.rs +++ b/block_util/src/vhdx_sync.rs @@ -64,7 +64,7 @@ impl AsyncIo for VhdxSync { fn read_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { self.vhdx_file.read_vectored_sync( @@ -79,7 +79,7 @@ impl AsyncIo for VhdxSync { fn write_vectored( &mut self, offset: libc::off_t, - iovecs: Vec, + iovecs: &[libc::iovec], user_data: u64, ) -> AsyncIoResult<()> { self.vhdx_file.write_vectored_sync(