@@ -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;
@@ -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:
@@ -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)