virtiofsd: add FUSE_INIT map_alignment field
cover virtiofsd: add FUSE_INIT map_alignment field
The client must know the server's alignment constraints for FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING. This is necessary because mmap(2)/munmap(2) have alignment constraints and the guest may have a different page size from the host. The new FUSE_INIT map_alignment field communicates this information to the client.
Stefan Hajnoczi (3):
virtiofsd: sync up fuse.h Linux 5.1 header
virtiofsd: add map_alignment to fuse_kernel.h
virtiofsd: implement FUSE_INIT map_alignment field
contrib/virtiofsd/fuse_kernel.h | 56 +++++++++++++++++++++---------- contrib/virtiofsd/fuse_lowlevel.c | 8 +++++ 2 files changed, 47 insertions(+), 17 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/3 virtiofsd: sync up fuse.h Linux 5.1 header
--- contrib/virtiofsd/fuse_kernel.h | 51 ++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 17 deletions(-)
contrib/virtiofsd/fuse_kernel.h +34 -17
@@ -119,6 +119,12 @@* * 7.28 * - add FUSE_COPY_FILE_RANGE +* - add FOPEN_CACHE_DIR +* - add FUSE_MAX_PAGES, add max_pages to init_out +* - add FUSE_CACHE_SYMLINKS +* +* 7.29 +* - add FUSE_NO_OPENDIR_SUPPORT flag */ #ifndef _LINUX_FUSE_H
@@ -154,7 +160,7 @@#define FUSE_KERNEL_VERSION 7/** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 27 +#define FUSE_KERNEL_MINOR_VERSION 29/** The node ID of the root inode */ #define FUSE_ROOT_ID 1
@@ -222,10 +228,12 @@ struct fuse_file_lock {* FOPEN_DIRECT_IO: bypass page cache for this open file * FOPEN_KEEP_CACHE: don't invalidate the data cache on open * FOPEN_NONSEEKABLE: the file is not seekable +* FOPEN_CACHE_DIR: allow caching this directory */ #define FOPEN_DIRECT_IO (1 << 0)#define FOPEN_KEEP_CACHE (1 << 1)#define FOPEN_NONSEEKABLE (1 << 2) +#define FOPEN_CACHE_DIR (1 << 3)/** * INIT request/reply flags
@@ -252,6 +260,9 @@ struct fuse_file_lock {* FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc * FUSE_POSIX_ACL: filesystem supports posix acls * FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED +* FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages +* FUSE_CACHE_SYMLINKS: cache READLINK responses +* FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -275,6 +286,9 @@ struct fuse_file_lock {#define FUSE_HANDLE_KILLPRIV (1 << 19)#define FUSE_POSIX_ACL (1 << 20)#define FUSE_ABORT_ERROR (1 << 21) +#define FUSE_MAX_PAGES (1 << 22) +#define FUSE_CACHE_SYMLINKS (1 << 23) +#define FUSE_NO_OPENDIR_SUPPORT (1 << 24)/** * CUSE INIT request/reply flags
@@ -385,8 +399,8 @@ enum fuse_opcode {FUSE_RENAME2 =45 ,FUSE_LSEEK =46 ,FUSE_COPY_FILE_RANGE =47 , -FUSE_SETUPMAPPING =48 , -FUSE_REMOVEMAPPING =49 , +FUSE_SETUPMAPPING =48 , +FUSE_REMOVEMAPPING =49 ,/* CUSE specific operations */ CUSE_INIT = 4096,
@@ -621,7 +635,9 @@ struct fuse_init_out {uint16_t congestion_threshold;uint32_t max_write;uint32_t time_gran; -uint32_t unused[9 ]; +uint16_t max_pages; +uint16_t padding; +uint32_t unused[8 ]; };#define CUSE_INIT_INFO_MAX 4096
@@ -814,31 +830,32 @@ struct fuse_copy_file_range_in { };#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) +#define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1)struct fuse_setupmapping_in { -/* An already open handle */ +/* An already open handle */ uint64_t fh; -/* Offset into the file to start the mapping */ -uint64_t foffset; -/* Length of mapping required */ -uint64_t len; -/* Flags, FUSE_SETUPMAPPING_FLAG_* */ -uint64_t flags; -/* memory offset in to dax window */ -uint64_t moffset; +/* Offset into the file to start the mapping */ +uint64_t foffset; +/* Length of mapping required */ +uint64_t len; +/* Flags, FUSE_SETUPMAPPING_FLAG_* */ +uint64_t flags; +/* Offset in Memory Window */ +uint64_t moffset; };struct fuse_removemapping_in {/* An already open handle */ -uint64_t fh; +uint64_t fh;/* number of fuse_removemapping_one follows */ uint32_t count; };struct fuse_removemapping_one { -/* Offset into the dax to start the unmapping */ +/* Offset into the dax window start the unmapping */ uint64_t moffset; -/* Length of mapping required */ -uint64_t len; +/* Length of mapping required */ +uint64_t len; };#endif /* _LINUX_FUSE_H */
Signature · 1 line
2.21.0
PATCH 2/3 virtiofsd: add map_alignment to fuse_kernel.h
In reply to Stefan HajnocziThis new FUSE_INIT field communicates the alignment constraint for FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING.
This feature will be implemented in the next commit.
--- contrib/virtiofsd/fuse_kernel.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
contrib/virtiofsd/fuse_kernel.h +6 -1
@@ -263,6 +263,9 @@ struct fuse_file_lock {* FUSE_MAX_PAGES: init_out.max_pages contains the max number of req pages * FUSE_CACHE_SYMLINKS: cache READLINK responses * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir +* FUSE_MAP_ALIGNMENT: init_out.map_alignment contains byte alignment for +* foffset and moffset fields in struct +* fuse_setupmapping_out and fuse_removemapping_one. */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -289,6 +292,7 @@ struct fuse_file_lock {#define FUSE_MAX_PAGES (1 << 22)#define FUSE_CACHE_SYMLINKS (1 << 23)#define FUSE_NO_OPENDIR_SUPPORT (1 << 24) +#define FUSE_MAP_ALIGNMENT (1 << 25)/** * CUSE INIT request/reply flags
@@ -637,7 +641,8 @@ struct fuse_init_out {uint32_t time_gran;uint16_t max_pages;uint16_t padding; -uint32_t unused[8 ]; +uint32_t map_alignment; +uint32_t unused[7 ]; };#define CUSE_INIT_INFO_MAX 4096
Signature · 1 line
2.21.0
PATCH 3/3 virtiofsd: implement FUSE_INIT map_alignment field
In reply to Stefan HajnocziCommunicate the host page size to the FUSE client so that FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING requests are aware of our alignment constraints.
--- contrib/virtiofsd/fuse_lowlevel.c | 8 ++++++++ 1 file changed, 8 insertions(+)
contrib/virtiofsd/fuse_lowlevel.c +8 -0
@@ -2131,6 +2131,12 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, }if (se->conn.proto_minor >=23 ) outarg.time_gran = se->conn.time_gran; +if (arg->flags &FUSE_MAP_ALIGNMENT ) { + outarg.flags |=FUSE_MAP_ALIGNMENT ; + +/* This constraint comes from mmap(2) and munmap(2) */ + outarg.map_alignment =sysconf (_SC_PAGE_SIZE); + }if (se->debug) {fuse_debug (" INIT: %u.%u\n" , outarg.major, outarg.minor);
@@ -2144,6 +2150,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, outarg.congestion_threshold);fuse_debug (" time_gran=%u\n" , outarg.time_gran); +fuse_debug (" map_alignment=%u\n" , + outarg.map_alignment); }if (arg->minor <5 ) outargsize =FUSE_COMPAT_INIT_OUT_SIZE ;
Signature · 1 line
2.21.0
Quoted 5 lines · * Stefan Hajnoczi ([email protected]) wrote:
The client must know the server's alignment constraints for
FUSE_SETUPMAPPINGandFUSE_REMOVEMAPPING. This is necessary because mmap(2)/munmap(2) have alignment constraints and the guest may have a different page size from the host. The newFUSE_INITmap_alignmentfield communicates this information to the client.
OK, merged into my local world.
DAve
Quoted 5 lines
Stefan Hajnoczi (3):
virtiofsd: sync upfuse.hLinux 5.1 header
virtiofsd: addmap_alignmenttofuse_kernel.h
virtiofsd: implementFUSE_INITmap_alignmentfield
Quoted 7 lines
contrib/virtiofsd/fuse_kernel.h | 56 +++++++++++++++++++++---------- contrib/virtiofsd/fuse_lowlevel.c | 8 +++++ 2 files changed, 47 insertions(+), 17 deletions(-)Signature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK