qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field
@ 2019-07-26  8:33 Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 1/3] virtiofsd: sync up fuse.h Linux 5.1 header Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2019-07-26  8:33 UTC (permalink / raw)
  To: qemu-devel, virtio-fs; +Cc: Dr. David Alan Gilbert, Stefan Hajnoczi

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(-)

-- 
2.21.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/3] virtiofsd: sync up fuse.h Linux 5.1 header
  2019-07-26  8:33 [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field Stefan Hajnoczi
@ 2019-07-26  8:33 ` Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 2/3] virtiofsd: add map_alignment to fuse_kernel.h Stefan Hajnoczi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2019-07-26  8:33 UTC (permalink / raw)
  To: qemu-devel, virtio-fs; +Cc: Dr. David Alan Gilbert, Stefan Hajnoczi

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 contrib/virtiofsd/fuse_kernel.h | 51 ++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/contrib/virtiofsd/fuse_kernel.h b/contrib/virtiofsd/fuse_kernel.h
index 3186efbed6..7722e0ac23 100644
--- a/contrib/virtiofsd/fuse_kernel.h
+++ b/contrib/virtiofsd/fuse_kernel.h
@@ -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 */
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/3] virtiofsd: add map_alignment to fuse_kernel.h
  2019-07-26  8:33 [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 1/3] virtiofsd: sync up fuse.h Linux 5.1 header Stefan Hajnoczi
@ 2019-07-26  8:33 ` Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 3/3] virtiofsd: implement FUSE_INIT map_alignment field Stefan Hajnoczi
  2019-07-29  9:25 ` [Qemu-devel] [PATCH 0/3] virtiofsd: add " Dr. David Alan Gilbert
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2019-07-26  8:33 UTC (permalink / raw)
  To: qemu-devel, virtio-fs; +Cc: Dr. David Alan Gilbert, Stefan Hajnoczi

This new FUSE_INIT field communicates the alignment constraint for
FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING.

This feature will be implemented in the next commit.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 contrib/virtiofsd/fuse_kernel.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/contrib/virtiofsd/fuse_kernel.h b/contrib/virtiofsd/fuse_kernel.h
index 7722e0ac23..550fc3cb64 100644
--- a/contrib/virtiofsd/fuse_kernel.h
+++ b/contrib/virtiofsd/fuse_kernel.h
@@ -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
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 3/3] virtiofsd: implement FUSE_INIT map_alignment field
  2019-07-26  8:33 [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 1/3] virtiofsd: sync up fuse.h Linux 5.1 header Stefan Hajnoczi
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 2/3] virtiofsd: add map_alignment to fuse_kernel.h Stefan Hajnoczi
@ 2019-07-26  8:33 ` Stefan Hajnoczi
  2019-07-29  9:25 ` [Qemu-devel] [PATCH 0/3] virtiofsd: add " Dr. David Alan Gilbert
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2019-07-26  8:33 UTC (permalink / raw)
  To: qemu-devel, virtio-fs; +Cc: Dr. David Alan Gilbert, Stefan Hajnoczi

Communicate the host page size to the FUSE client so that
FUSE_SETUPMAPPING/FUSE_REMOVEMAPPING requests are aware of our alignment
constraints.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 contrib/virtiofsd/fuse_lowlevel.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/contrib/virtiofsd/fuse_lowlevel.c b/contrib/virtiofsd/fuse_lowlevel.c
index dbbfda78bf..452dd6b2b0 100644
--- a/contrib/virtiofsd/fuse_lowlevel.c
+++ b/contrib/virtiofsd/fuse_lowlevel.c
@@ -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;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field
  2019-07-26  8:33 [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2019-07-26  8:33 ` [Qemu-devel] [PATCH 3/3] virtiofsd: implement FUSE_INIT map_alignment field Stefan Hajnoczi
@ 2019-07-29  9:25 ` Dr. David Alan Gilbert
  3 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2019-07-29  9:25 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: virtio-fs, qemu-devel

* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> 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.

OK, merged into my local world.

DAve

> 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(-)
> 
> -- 
> 2.21.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-29  9:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-26  8:33 [Qemu-devel] [PATCH 0/3] virtiofsd: add FUSE_INIT map_alignment field Stefan Hajnoczi
2019-07-26  8:33 ` [Qemu-devel] [PATCH 1/3] virtiofsd: sync up fuse.h Linux 5.1 header Stefan Hajnoczi
2019-07-26  8:33 ` [Qemu-devel] [PATCH 2/3] virtiofsd: add map_alignment to fuse_kernel.h Stefan Hajnoczi
2019-07-26  8:33 ` [Qemu-devel] [PATCH 3/3] virtiofsd: implement FUSE_INIT map_alignment field Stefan Hajnoczi
2019-07-29  9:25 ` [Qemu-devel] [PATCH 0/3] virtiofsd: add " Dr. David Alan Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).