Fuse definitions for virtiofs
Subsystems (2)
cover Fuse definitions for virtiofs
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
Virtiofs is a fuse-over-virtio filesystem to allow
virtual machines to access a fileystem easily, it's currently in development, and we'd like to try and get some of our structures and commands stabilised. Since it runs over virtio, a spec is currently running through the virtio standardisation process, and they'd like to see the additional Fuse commands nailed down. Also we'd like to stop chasing bit/command number allocation.
The additions included here provide a performance feature that lets the daemon map files into the hypervisor and thus guests address space, allowing a DAX like mapping.
Note:
For you following these patches in virtiofs, I've
made three changes:
a) Remove the unused 'fh' field from removemapping
b) Change the 'map_alignment' field to be log2(size) and use up the current uint16_t padding rather than eating a fresh uint32_t
c) Moved FUSE_MAP_ALIGNMENT along one bit since FUSE_EXPLICIT_INVAL_DATA used up bit 25.
References:
virtiofs home page: https://virtio-fs.gitlab.io/
virtio-fs specification patches: https://lists.oasis-open.org/archives/virtio-dev/201907/msg00052.html
Dave
Dr. David Alan Gilbert (3):
fuse: Add 'setupmapping'
fuse: add 'removemapping'
fuse: Add map_alignment for setup/remove mapping
include/uapi/linux/fuse.h | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
PATCH 1/3 fuse: Add 'setupmapping'
From: "Dr. David Alan Gilbert" <[email protected]>
'setupmapping' is a command for use with 'virtiofsd', a fuse-over-virtio implementation; it may find use in other fuse impelementations as well in which the kernel does not have access to the address space of the daemon directly.
A 'setupmapping' operation causes a section of a file to be mapped into a memory window visible to the kernel.
The offsets in the file and the window are defined by the kernel performing the operation.
The daemon may reject the request, for reasons including permissions and limited resources.
When a request perfectly overlaps a previous mapping, the previous mapping is replaced. When a mapping partially overlaps a previous mapping, the previous mapping is split into one or two smaller mappings.
--- include/uapi/linux/fuse.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/uapi/linux/fuse.h +17 -0
@@ -133,6 +133,7 @@* * 7.31 * - add FUSE_WRITE_KILL_PRIV flag +* - add FUSE_SETUPMAPPING */ #ifndef _LINUX_FUSE_H
@@ -422,6 +423,7 @@ enum fuse_opcode {FUSE_RENAME2 =45 ,FUSE_LSEEK =46 ,FUSE_COPY_FILE_RANGE =47 , +FUSE_SETUPMAPPING =48 ,/* CUSE specific operations */ CUSE_INIT = 4096,
@@ -845,4 +847,19 @@ struct fuse_copy_file_range_in { uint64_t flags; }; +#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) +#define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) +struct fuse_setupmapping_in { +/* 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; +/* Offset in Memory Window */ +uint64_t moffset; +}; +#endif /* _LINUX_FUSE_H */
Signature · 1 line
2.21.0
PATCH 2/3 fuse: add 'removemapping'
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
'removemapping' is the complement to 'setupmapping', it unmaps a range of mapped files from the window visible to the kernel.
A 'removemapping' call consists of 'count' regions to unmap, each consisting of an offset and length.
--- include/uapi/linux/fuse.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
include/uapi/linux/fuse.h +14 -1
@@ -133,7 +133,7 @@* * 7.31 * - add FUSE_WRITE_KILL_PRIV flag -* - add FUSE_SETUPMAPPING +* - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING */ #ifndef _LINUX_FUSE_H
@@ -424,6 +424,7 @@ enum fuse_opcode {FUSE_LSEEK =46 ,FUSE_COPY_FILE_RANGE =47 ,FUSE_SETUPMAPPING =48 , +FUSE_REMOVEMAPPING =49 ,/* CUSE specific operations */ CUSE_INIT = 4096,
@@ -862,4 +863,16 @@ struct fuse_setupmapping_in { uint64_t moffset; }; +struct fuse_removemapping_in { +/* number of fuse_removemapping_one following */ +uint32_t count; +}; + +struct fuse_removemapping_one { +/* Offset into the dax window at start of unmapping */ +uint64_t moffset; +/* Length of unmapping required */ +uint64_t len; +}; +#endif /* _LINUX_FUSE_H */
Signature · 1 line
2.21.0
PATCH 3/3 fuse: Add map_alignment for setup/remove mapping
In reply to Dr. David Alan Gilbert (git)From: "Dr. David Alan Gilbert" <[email protected]>
This new FUSE_INIT field communicates the alignment constraint for FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING and allows the daemon to constrain the addresses and file offsets chosen by the kernel.
--- include/uapi/linux/fuse.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/uapi/linux/fuse.h +7 -1
@@ -134,6 +134,7 @@* 7.31 * - add FUSE_WRITE_KILL_PRIV flag * - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING +* - add map_alignment to fuse_init_out */ #ifndef _LINUX_FUSE_H
@@ -275,6 +276,9 @@ struct fuse_file_lock {* FUSE_CACHE_SYMLINKS: cache READLINK responses * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request +* FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for +* foffset and moffset fields in struct +* fuse_setupmapping_in and fuse_removemapping_one. */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -302,6 +306,8 @@ struct fuse_file_lock {#define FUSE_CACHE_SYMLINKS (1 << 23)#define FUSE_NO_OPENDIR_SUPPORT (1 << 24)#define FUSE_EXPLICIT_INVAL_DATA (1 << 25) +#define FUSE_MAP_ALIGNMENT (1 << 26) +/** * CUSE INIT request/reply flags
@@ -655,7 +661,7 @@ struct fuse_init_out {uint32_t max_write;uint32_t time_gran;uint16_t max_pages; -uint16_t padding; +uint16_t map_alignment;uint32_t unused[8 ]; };
Signature · 1 line
2.21.0