summary refs log tree commit diff
path: root/devices
diff options
context:
space:
mode:
authorChirantan Ekbote <chirantan@chromium.org>2020-03-17 18:46:52 +0900
committerCommit Bot <commit-bot@chromium.org>2020-03-19 08:13:32 +0000
commit5b2447ceaf8ec4fa12afa32936af075c61e900df (patch)
tree60515c1da19be7fa2aa18d3a1f6d01796ed0fd54 /devices
parent6dfa1e4ce5c260eabbda21c12d7bd9769f1cc995 (diff)
downloadcrosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar.gz
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar.bz2
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar.lz
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar.xz
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.tar.zst
crosvm-5b2447ceaf8ec4fa12afa32936af075c61e900df.zip
devices: fs: Bump fuse minor version to 31
Add new definitions and constants to support fuse minor version 31.
These include the FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING opcodes used
by the virtio-fs driver for implementing DAX support.

BUG=b:147341783
TEST=vm.Virtiofs

Change-Id: Ie59ec1a44e555910f2ee2c5ba7afccb8bd435db9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105823
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Diffstat (limited to 'devices')
-rw-r--r--devices/src/virtio/fs/fuse.rs52
-rw-r--r--devices/src/virtio/fs/server.rs2
2 files changed, 51 insertions, 3 deletions
diff --git a/devices/src/virtio/fs/fuse.rs b/devices/src/virtio/fs/fuse.rs
index 0533a5c..5c531cf 100644
--- a/devices/src/virtio/fs/fuse.rs
+++ b/devices/src/virtio/fs/fuse.rs
@@ -16,7 +16,7 @@ pub const KERNEL_VERSION: u32 = 7;
 pub const OLDEST_SUPPORTED_KERNEL_MINOR_VERSION: u32 = 27;
 
 /// Minor version number of this interface.
-pub const KERNEL_MINOR_VERSION: u32 = 28;
+pub const KERNEL_MINOR_VERSION: u32 = 31;
 
 /// The ID of the inode corresponding to the root directory of the file system.
 pub const ROOT_ID: u64 = 1;
@@ -151,6 +151,15 @@ const MAX_PAGES: u32 = 4194304;
 /// Cache `readlink` responses.
 const CACHE_SYMLINKS: u32 = 8388608;
 
+/// Kernel supports zero-message opens for directories.
+const NO_OPENDIR_SUPPORT: u32 = 16777216;
+
+/// Kernel supports explicit cache invalidation.
+const EXPLICIT_INVAL_DATA: u32 = 33554432;
+
+/// The `map_alignment` field of the `InitOut` struct is valid.
+const MAP_ALIGNMENT: u32 = 67108864;
+
 bitflags! {
     /// A bitfield passed in as a parameter to and returned from the `init` method of the
     /// `FileSystem` trait.
@@ -320,6 +329,34 @@ bitflags! {
 
         /// Indicates that the kernel may cache responses to `readlink` calls.
         const CACHE_SYMLINKS = CACHE_SYMLINKS;
+
+        /// Indicates support for zero-message opens for directories. If this flag is set in the
+        /// `capable` parameter of the `init` trait method, then the file system may return `ENOSYS`
+        /// from the opendir() handler to indicate success. Further attempts to open directories
+        /// will be handled in the kernel. (If this flag is not set, returning ENOSYS will be
+        /// treated as an error and signaled to the caller).
+        ///
+        /// Setting (or not setting) the field in the `FsOptions` returned from the `init` method
+        /// has no effect.
+        const ZERO_MESSAGE_OPENDIR = NO_OPENDIR_SUPPORT;
+
+        /// Indicates support for invalidating cached pages only on explicit request.
+        ///
+        /// If this flag is set in the `capable` parameter of the `init` trait method, then the FUSE
+        /// kernel module supports invalidating cached pages only on explicit request by the
+        /// filesystem.
+        ///
+        /// By setting this flag in the return value of the `init` trait method, the filesystem is
+        /// responsible for invalidating cached pages through explicit requests to the kernel.
+        ///
+        /// Note that setting this flag does not prevent the cached pages from being flushed by OS
+        /// itself and/or through user actions.
+        ///
+        /// Note that if both EXPLICIT_INVAL_DATA and AUTO_INVAL_DATA are set in the `capable`
+        /// parameter of the `init` trait method then AUTO_INVAL_DATA takes precedence.
+        ///
+        /// This feature is disabled by default.
+        const EXPLICIT_INVAL_DATA = EXPLICIT_INVAL_DATA;
     }
 }
 
@@ -341,6 +378,9 @@ pub const WRITE_CACHE: u32 = 1;
 /// `lock_owner` field is valid.
 pub const WRITE_LOCKOWNER: u32 = 2;
 
+/// Kill the suid and sgid bits.
+pub const WRITE_KILL_PRIV: u32 = 3;
+
 // Read flags.
 pub const READ_LOCKOWNER: u32 = 2;
 
@@ -361,6 +401,9 @@ const IOCTL_32BIT: u32 = 8;
 /// Is a directory
 const IOCTL_DIR: u32 = 16;
 
+/// 32-bit compat ioctl on 64-bit machine with 64-bit time_t.
+const IOCTL_COMPAT_X32: u32 = 32;
+
 /// Maximum of in_iovecs + out_iovecs
 pub const IOCTL_MAX_IOV: usize = 256;
 
@@ -380,6 +423,9 @@ bitflags! {
 
         /// Is a directory
         const DIR = IOCTL_DIR;
+
+        /// 32-bit compat ioctl on 64-bit machine with 64-bit time_t.
+        const COMPAT_X32 = IOCTL_COMPAT_X32;
     }
 }
 
@@ -535,6 +581,8 @@ pub enum Opcode {
     Rename2 = 45,
     Lseek = 46,
     CopyFileRange = 47,
+    SetUpMapping = 48,
+    RemoveMapping = 49,
 }
 
 #[repr(u32)]
@@ -855,7 +903,7 @@ pub struct InitOut {
     pub max_write: u32,
     pub time_gran: u32,
     pub max_pages: u16,
-    pub padding: u16,
+    pub map_alignment: u16,
     pub unused: [u32; 8],
 }
 unsafe impl DataInit for InitOut {}
diff --git a/devices/src/virtio/fs/server.rs b/devices/src/virtio/fs/server.rs
index 76f2830..c9025f2 100644
--- a/devices/src/virtio/fs/server.rs
+++ b/devices/src/virtio/fs/server.rs
@@ -119,7 +119,7 @@ impl<F: FileSystem + Sync> Server<F> {
             Some(Opcode::Rename2) => self.rename2(in_header, r, w),
             Some(Opcode::Lseek) => self.lseek(in_header, r, w),
             Some(Opcode::CopyFileRange) => self.copy_file_range(in_header, r, w),
-            None => reply_error(
+            Some(Opcode::SetUpMapping) | Some(Opcode::RemoveMapping) | None => reply_error(
                 io::Error::from_raw_os_error(libc::ENOSYS),
                 in_header.unique,
                 w,