diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-10-23 13:55:37 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-08 20:35:18 +0000 |
commit | 2b109386e7676333a53b1511c12dce3a4ff329e3 (patch) | |
tree | aeca2fb84e1c452117ea79ee03ace897ebd81592 /sys_util | |
parent | f68a2940f4734687fba96380d1111bfae2c43ffa (diff) | |
download | crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar.gz crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar.bz2 crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar.lz crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar.xz crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.tar.zst crosvm-2b109386e7676333a53b1511c12dce3a4ff329e3.zip |
devices: virtio: block: advertise seg_max
The virtio-blk configuration space has a `seg_max` field that lets the device inform the driver of the maximum number of segments allowed within a single request. The Linux virtio block driver assumes that if the corresponding feature (VIRTIO_BLK_F_SEG_MAX) is not advertised, then only one segment can be used. Add a segment limit based on sysconf(_SC_IOV_MAX) to allow the Linux block stack to make use of multiple segments in a single request, which will get translated into a single readv/writev call in the crosvm block device. BUG=None TEST=strace crosvm virtio-blk process and note preadv with iov_cnt > 1 Change-Id: Ia14ebebb85daa21e2d43437bb74886f32e6e8187 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1876806 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys_util/src/lib.rs b/sys_util/src/lib.rs index 594c79a..331dbac 100644 --- a/sys_util/src/lib.rs +++ b/sys_util/src/lib.rs @@ -80,7 +80,7 @@ use std::ptr; use libc::{ c_long, gid_t, kill, pid_t, pipe2, syscall, sysconf, uid_t, waitpid, O_CLOEXEC, SIGKILL, - WNOHANG, _SC_PAGESIZE, + WNOHANG, _SC_IOV_MAX, _SC_PAGESIZE, }; use syscall_defines::linux::LinuxSyscall::SYS_getpid; @@ -92,6 +92,12 @@ pub fn pagesize() -> usize { unsafe { sysconf(_SC_PAGESIZE) as usize } } +/// Safe wrapper for `sysconf(_SC_IOV_MAX)`. +pub fn iov_max() -> usize { + // Trivially safe + unsafe { sysconf(_SC_IOV_MAX) as usize } +} + /// Uses the system's page size in bytes to round the given value up to the nearest page boundary. #[inline(always)] pub fn round_up_to_page_size(v: usize) -> usize { |