aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--example/passthrough_hp.cc4
-rw-r--r--include/fuse_common.h9
-rw-r--r--lib/fuse_lowlevel.c4
3 files changed, 17 insertions, 0 deletions
diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc
index 96201d6..66fe6f8 100644
--- a/example/passthrough_hp.cc
+++ b/example/passthrough_hp.cc
@@ -212,6 +212,10 @@ static void sfs_init(void *userdata, fuse_conn_info *conn) {
if (conn->capable & FUSE_CAP_SPLICE_READ)
conn->want |= FUSE_CAP_SPLICE_READ;
}
+
+ /* This is a local file system - no network coherency needed */
+ if (conn->capable & FUSE_CAP_DIRECT_IO_ALLOW_MMAP)
+ conn->want |= FUSE_CAP_DIRECT_IO_ALLOW_MMAP;
}
diff --git a/include/fuse_common.h b/include/fuse_common.h
index 3ff14ec..a804134 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -441,6 +441,15 @@ struct fuse_loop_config_v1 {
#define FUSE_CAP_SETXATTR_EXT (1 << 27)
/**
+ * Files opened with FUSE_DIRECT_IO do not support MAP_SHARED mmap. This restriction
+ * is relaxed through FUSE_CAP_DIRECT_IO_RELAX (kernel flag: FUSE_DIRECT_IO_RELAX).
+ * MAP_SHARED is disabled by default for FUSE_DIRECT_IO, as this flag can be used to
+ * ensure coherency between mount points (or network clients) and with kernel page
+ * cache as enforced by mmap that cannot be guaranteed anymore.
+ */
+#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1 << 27)
+
+/**
* Ioctl flags
*
* FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index ea98536..41e626b 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -2019,6 +2019,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
bufsize = max_bufsize;
}
}
+ if (inargflags & FUSE_DIRECT_IO_ALLOW_MMAP)
+ se->conn.capable |= FUSE_CAP_DIRECT_IO_ALLOW_MMAP;
if (arg->minor >= 38)
se->conn.capable |= FUSE_CAP_EXPIRE_ONLY;
} else {
@@ -2151,6 +2153,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
outargflags |= FUSE_EXPLICIT_INVAL_DATA;
if (se->conn.want & FUSE_CAP_SETXATTR_EXT)
outargflags |= FUSE_SETXATTR_EXT;
+ if (se->conn.want & FUSE_CAP_DIRECT_IO_ALLOW_MMAP)
+ outargflags |= FUSE_DIRECT_IO_ALLOW_MMAP;
if (inargflags & FUSE_INIT_EXT) {
outargflags |= FUSE_INIT_EXT;