lkml.org 
[lkml]   [2018]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 45/52] virtio: Free fuse devices on umount
Date
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

When unmounting the fs close all the fuse devices.
This includes making sure the daemon gets a FUSE_DESTROY to
tell it.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
fs/fuse/fuse_i.h | 1 +
fs/fuse/inode.c | 3 ++-
fs/fuse/virtio_fs.c | 13 ++++++++++++-
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 7b2db87c6ead..30c7b4b56200 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -85,6 +85,7 @@ struct fuse_mount_data {
unsigned default_permissions:1;
unsigned allow_other:1;
unsigned dax:1;
+ unsigned destroy:1;
unsigned max_read;
unsigned blksize;

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 178ac3171564..4d2d623e607f 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1263,7 +1263,7 @@ int fuse_fill_super_common(struct super_block *sb,
goto err_put_root;
__set_bit(FR_BACKGROUND, &init_req->flags);

- if (is_bdev) {
+ if (mount_data->destroy) {
fc->destroy_req = fuse_request_alloc(0);
if (!fc->destroy_req)
goto err_free_init_req;
@@ -1339,6 +1339,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
d.fiq_ops = &fuse_dev_fiq_ops;
d.fiq_priv = NULL;
d.fudptr = &file->private_data;
+ d.destroy = is_bdev;
err = fuse_fill_super_common(sb, &d);

err_fput:
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index f436f5b3f85c..c71bc47395b4 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1128,6 +1128,7 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data,
d.fiq_ops = &virtio_fs_fiq_ops;
d.fiq_priv = fs;
d.fudptr = (void **)&fs->vqs[2].fud;
+ d.destroy = true; /* Send destroy request on unmount */
err = fuse_fill_super_common(sb, &d);

if (err < 0)
@@ -1160,6 +1161,16 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data,
return err;
}

+static void virtio_kill_sb(struct super_block *sb)
+{
+ struct fuse_conn *fc = get_fuse_conn_super(sb);
+ fuse_kill_sb_anon(sb);
+ if (fc) {
+ struct virtio_fs *vfs = fc->iq.priv;
+ virtio_fs_free_devs(vfs);
+ }
+}
+
static struct dentry *virtio_fs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name,
void *raw_data)
@@ -1171,7 +1182,7 @@ static struct file_system_type virtio_fs_type = {
.owner = THIS_MODULE,
.name = KBUILD_MODNAME,
.mount = virtio_fs_mount,
- .kill_sb = fuse_kill_sb_anon,
+ .kill_sb = virtio_kill_sb,
};

static int __init virtio_fs_init(void)
--
2.13.6
\
 
 \ /
  Last update: 2018-12-10 18:17    [W:0.380 / U:1.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site