summaryrefslogtreecommitdiffstats
path: root/fs/fuse/dax.c
diff options
context:
space:
mode:
authorJeffle Xu <jefflexu@linux.alibaba.com>2021-11-25 08:05:25 +0100
committerMiklos Szeredi <mszeredi@redhat.com>2021-12-14 11:09:36 +0100
commit780b1b959f9bd959e1aca450e9fee0e2c00b31ad (patch)
tree8e1704713c3fdbd5328a5c2b28e178e06e98bcbf /fs/fuse/dax.c
parentfuse: add fuse_should_enable_dax() helper (diff)
downloadlinux-780b1b959f9bd959e1aca450e9fee0e2c00b31ad.tar.xz
linux-780b1b959f9bd959e1aca450e9fee0e2c00b31ad.zip
fuse: make DAX mount option a tri-state
We add 'always', 'never', and 'inode' (default). '-o dax' continues to operate the same which is equivalent to 'always'. The following behavior is consistent with that on ext4/xfs: - The default behavior (when neither '-o dax' nor '-o dax=always|never|inode' option is specified) is equal to 'inode' mode, while 'dax=inode' won't be printed among the mount option list. - The 'inode' mode is only advisory. It will silently fallback to 'never' mode if fuse server doesn't support that. Also noted that by the time of this commit, 'inode' mode is actually equal to 'always' mode, before the per inode DAX flag is introduced in the following patch. Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com> Reviewed-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/dax.c')
-rw-r--r--fs/fuse/dax.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index 8057fbf5576c..d2bc5e7f5132 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -1279,11 +1279,14 @@ out_err:
return ret;
}
-int fuse_dax_conn_alloc(struct fuse_conn *fc, struct dax_device *dax_dev)
+int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode dax_mode,
+ struct dax_device *dax_dev)
{
struct fuse_conn_dax *fcd;
int err;
+ fc->dax_mode = dax_mode;
+
if (!dax_dev)
return 0;
@@ -1330,7 +1333,15 @@ static const struct address_space_operations fuse_dax_file_aops = {
static bool fuse_should_enable_dax(struct inode *inode)
{
struct fuse_conn *fc = get_fuse_conn(inode);
+ enum fuse_dax_mode dax_mode = fc->dax_mode;
+
+ if (dax_mode == FUSE_DAX_NEVER)
+ return false;
+ /*
+ * fc->dax may be NULL in 'inode' mode when filesystem device doesn't
+ * support DAX, in which case it will silently fallback to 'never' mode.
+ */
if (!fc->dax)
return false;