]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fuse: negotiate per inode DAX in FUSE_INIT
authorJeffle Xu <jefflexu@linux.alibaba.com>
Thu, 25 Nov 2021 07:05:28 +0000 (15:05 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 14 Dec 2021 10:09:37 +0000 (11:09 +0100)
Among the FUSE_INIT phase, client shall advertise per inode DAX if it's
mounted with "dax=inode". Then server is aware that client is in per
inode DAX mode, and will construct per-inode DAX attribute accordingly.

Server shall also advertise support for per inode DAX. If server doesn't
support it while client is mounted with "dax=inode", client will
silently fallback to "dax=never" since "dax=inode" is advisory only.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dax.c
fs/fuse/fuse_i.h
fs/fuse/inode.c

index ff17bc7a0b6e6abfb7f0ca64078c8c2458404866..663270dc6e2010d8732768c2e94410a2c00cab1a 100644 (file)
@@ -1349,7 +1349,7 @@ static bool fuse_should_enable_dax(struct inode *inode, unsigned int flags)
                return true;
 
        /* dax_mode is FUSE_DAX_INODE* */
-       return flags & FUSE_ATTR_DAX;
+       return fc->inode_dax && (flags & FUSE_ATTR_DAX);
 }
 
 void fuse_dax_inode_init(struct inode *inode, unsigned int flags)
index ccbc4de7870baeb3949772cb8cc5315dafb43120..6d63bd403a43be3e916994c68e2f2747d29566a0 100644 (file)
@@ -780,6 +780,9 @@ struct fuse_conn {
        /* Initialize security xattrs when creating a new inode */
        unsigned int init_security:1;
 
+       /* Does the filesystem support per inode DAX? */
+       unsigned int inode_dax:1;
+
        /** The number of requests waiting for completion */
        atomic_t num_waiting;
 
index dc6714350f2138329902950d5ae198bc286fd273..c256fd82af3c65f29ff7a30b9badb9e9e1a16efb 100644 (file)
@@ -1171,10 +1171,13 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
                                        min_t(unsigned int, fc->max_pages_limit,
                                        max_t(unsigned int, arg->max_pages, 1));
                        }
-                       if (IS_ENABLED(CONFIG_FUSE_DAX) &&
-                           flags & FUSE_MAP_ALIGNMENT &&
-                           !fuse_dax_check_alignment(fc, arg->map_alignment)) {
-                               ok = false;
+                       if (IS_ENABLED(CONFIG_FUSE_DAX)) {
+                               if (flags & FUSE_MAP_ALIGNMENT &&
+                                   !fuse_dax_check_alignment(fc, arg->map_alignment)) {
+                                       ok = false;
+                               }
+                               if (flags & FUSE_HAS_INODE_DAX)
+                                       fc->inode_dax = 1;
                        }
                        if (flags & FUSE_HANDLE_KILLPRIV_V2) {
                                fc->handle_killpriv_v2 = 1;
@@ -1233,6 +1236,8 @@ void fuse_send_init(struct fuse_mount *fm)
 #ifdef CONFIG_FUSE_DAX
        if (fm->fc->dax)
                flags |= FUSE_MAP_ALIGNMENT;
+       if (fuse_is_inode_dax_mode(fm->fc->dax_mode))
+               flags |= FUSE_HAS_INODE_DAX;
 #endif
        if (fm->fc->auto_submounts)
                flags |= FUSE_SUBMOUNTS;