From 74cd3d0dc2e299f1078f6035b61cf7d049f240c9 Mon Sep 17 00:00:00 2001 From: Hao Xu Date: Fri, 24 Feb 2023 19:05:55 +0800 Subject: [PATCH] virtio-devices: Reset offset properly upon unmap for virtio-fs. We should reset the offset to 0, when asked to remove the whole dax mapping. Signed-off-by: Hao Xu --- virtio-devices/src/vhost_user/fs.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 74a1e37ee..58ef70dc9 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -119,7 +119,6 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { debug!("fs_slave_unmap"); for i in 0..VHOST_USER_FS_SLAVE_ENTRIES { - let offset = fs.cache_offset[i]; let mut len = fs.len[i]; // Ignore if the length is 0. @@ -129,9 +128,12 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { // Need to handle a special case where the slave ask for the unmapping // of the entire mapping. - if len == 0xffff_ffff_ffff_ffff { + let offset = if len == 0xffff_ffff_ffff_ffff { len = self.cache_size; - } + 0 + } else { + fs.cache_offset[i] + }; if !self.is_req_valid(offset, len) { return Err(io::Error::from_raw_os_error(libc::EINVAL));