Fuse client can enable or disable per-file DAX inside kernel/guest by
chattr(1). Similarly the new state won't be updated until the file is
closed and reopened later.

Signed-off-by: Jeffle Xu <jeffl...@linux.alibaba.com>
---
 fs/fuse/ioctl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index 546ea3d58fb4..a9ed53c5dbd1 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -469,8 +469,6 @@ int fuse_fileattr_set(struct user_namespace *mnt_userns,
        if (fa->flags_valid) {
                err = fuse_priv_ioctl(inode, ff, FS_IOC_SETFLAGS,
                                      &flags, sizeof(flags));
-               if (err)
-                       goto cleanup;
        } else {
                memset(&xfa, 0, sizeof(xfa));
                xfa.fsx_xflags = fa->fsx_xflags;
@@ -483,6 +481,19 @@ int fuse_fileattr_set(struct user_namespace *mnt_userns,
                                      &xfa, sizeof(xfa));
        }
 
+       if (err)
+               goto cleanup;
+
+       if (IS_ENABLED(CONFIG_FUSE_DAX)) {
+               bool newdax;
+
+               if (fa->flags_valid)
+                       newdax = flags & FS_DAX_FL;
+               else
+                       newdax = fa->fsx_xflags & FS_XFLAG_DAX;
+               fuse_dax_dontcache(inode, newdax);
+       }
+
 cleanup:
        fuse_priv_ioctl_cleanup(inode, ff);
 
-- 
2.27.0

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to