Skip to contentSkip to conversation

virtiofs: Fail dax mount if device does not support it

PATCH In review Vivek Goyal 3 participants 4 messages Feb 9, 2021 – Mar 5, 2021

Subsystems (3)
lore
Share & tools
lore

Vivek Goyal

author maintainer
#0 lore raw

PATCH 1/1 virtiofs: Fail dax mount if device does not support it

Right now "mount -t virtiofs -o dax myfs /mnt/virtiofs" succeeds even if filesystem deivce does not have a cache window and hence DAX can't be supported.

This gives a false sense to user that they are using DAX with virtiofs but fact of the matter is that they are not.

Fix this by returning error if dax can't be supported and user has asked for it.

---
 fs/fuse/virtio_fs.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/fuse/virtio_fs.c +8 -1
Index: redhat-linux/fs/fuse/virtio_fs.c
===================================================================
@@ -1324,8 +1324,15 @@ static int virtio_fs_fill_super(struct s
 
 	/* virtiofs allocates and installs its own fuse devices */
 	ctx->fudptr = NULL;
-	if (ctx->dax)
+	if (ctx->dax) {
+		if (!fs->dax_dev) {
+			err = -EINVAL;
+			pr_err("virtio-fs: dax can't be enabled as filesystem"
+			       " device does not support it.\n");
+			goto err_free_fuse_devs;
+		}
 		ctx->dax_dev = fs->dax_dev;
+	}
 	err = fuse_fill_super_common(sb, ctx);
 	if (err < 0)
 		goto err_free_fuse_devs;
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Vivek Goyal

Right now "mount -t virtiofs -o dax myfs /mnt/virtiofs" succeeds even if filesystem deivce does not have a cache window and hence DAX can't be supported.

This gives a false sense to user that they are using DAX with virtiofs but fact of the matter is that they are not.

Fix this by returning error if dax can't be supported and user has asked for it.

---
 fs/fuse/virtio_fs.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: redhat-linux/fs/fuse/virtio_fs.c
===================================================================

fs/fuse/virtio_fs.c +2 -1
@@ -1324,8 +1324,15 @@ static int virtio_fs_fill_super(struct s
 
 	/* virtiofs allocates and installs its own fuse devices */
 	ctx->fudptr = NULL;
-	if (ctx->dax)
+	if (ctx->dax) {
+		if (!fs->dax_dev) {

fs/fuse/virtio_fs.c static int virtio_fs_fill_super(struct s · line 1338

Quoted 10 lines
fs/fuse/virtio_fs.c +6 -0
+			err = -EINVAL;
+			pr_err("virtio-fs: dax can't be enabled as filesystem"
+			       " device does not support it.\n");
+			goto err_free_fuse_devs;
+		}
 		ctx->dax_dev = fs->dax_dev;
+	}
 	err = fuse_fill_super_common(sb, ctx);
 	if (err < 0)
 		goto err_free_fuse_devs;
author maintainer
#2 lore raw
In reply to Vivek Goyal
Quoted 9 lines · Vivek Goyal

Right now "mount -t virtiofs -o dax myfs /mnt/virtiofs" succeeds even if filesystem deivce does not have a cache window and hence DAX can't be supported.

This gives a false sense to user that they are using DAX with virtiofs but fact of the matter is that they are not.

Fix this by returning error if dax can't be supported and user has asked for it.

Hi Miklos,

Did you get a chance to look at this patch.

Vivek

Quoted 27 lines
---
 fs/fuse/virtio_fs.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: redhat-linux/fs/fuse/virtio_fs.c
===================================================================

fs/fuse/virtio_fs.c +8 -1
@@ -1324,8 +1324,15 @@ static int virtio_fs_fill_super(struct s
 
 	/* virtiofs allocates and installs its own fuse devices */
 	ctx->fudptr = NULL;
-	if (ctx->dax)
+	if (ctx->dax) {
+		if (!fs->dax_dev) {
+			err = -EINVAL;
+			pr_err("virtio-fs: dax can't be enabled as filesystem"
+			       " device does not support it.\n");
+			goto err_free_fuse_devs;
+		}
 		ctx->dax_dev = fs->dax_dev;
+	}
 	err = fuse_fill_super_common(sb, ctx);
 	if (err < 0)
 		goto err_free_fuse_devs;
maintainer
#3 lore raw
Quoted 9 lines · Vivek Goyal
Quoted 7 lines · Vivek Goyal

Right now "mount -t virtiofs -o dax myfs /mnt/virtiofs" succeeds even if filesystem deivce does not have a cache window and hence DAX can't be supported.

This gives a false sense to user that they are using DAX with virtiofs but fact of the matter is that they are not.

Quoted 6 lines
Quoted 2 lines

Fix this by returning error if dax can't be supported and user has asked for it.

Hi Miklos,

Did you get a chance to look at this patch.

Thanks for the reminder. Pushed out now.

Miklos