Skip to content

Commit

Permalink
fuse: clean up fuse_mount destruction
Browse files Browse the repository at this point in the history
1. call fuse_mount_destroy() for open coded variants

2. before deactivate_locked_super() don't need fuse_mount destruction since
that will now be done (if ->s_fs_info is not cleared)

3. rearrange fuse_mount setup in fuse_get_tree_submount() so that the
regular pattern can be used

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Oct 21, 2021
1 parent a27c061 commit c191cd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
17 changes: 5 additions & 12 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,20 +1415,17 @@ static int fuse_get_tree_submount(struct fs_context *fsc)
if (!fm)
return -ENOMEM;

fm->fc = fuse_conn_get(fc);
fsc->s_fs_info = fm;
sb = sget_fc(fsc, NULL, set_anon_super_fc);
if (IS_ERR(sb)) {
kfree(fm);
if (fsc->s_fs_info)
fuse_mount_destroy(fm);
if (IS_ERR(sb))
return PTR_ERR(sb);
}
fm->fc = fuse_conn_get(fc);

/* Initialize superblock, making @mp_fi its root */
err = fuse_fill_super_submount(sb, mp_fi);
if (err) {
fuse_conn_put(fc);
kfree(fm);
sb->s_fs_info = NULL;
deactivate_locked_super(sb);
return err;
}
Expand Down Expand Up @@ -1595,16 +1592,12 @@ static int fuse_fill_super(struct super_block *sb, struct fs_context *fsc)

err = fuse_fill_super_common(sb, ctx);
if (err)
goto err_put_conn;
goto err;
/* file->private_data shall be visible on all CPUs after this */
smp_mb();
fuse_send_init(get_fuse_mount_super(sb));
return 0;

err_put_conn:
fuse_conn_put(fc);
kfree(fm);
sb->s_fs_info = NULL;
err:
return err;
}
Expand Down
9 changes: 2 additions & 7 deletions fs/fuse/virtio_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,19 +1456,14 @@ static int virtio_fs_get_tree(struct fs_context *fsc)

fsc->s_fs_info = fm;
sb = sget_fc(fsc, virtio_fs_test_super, set_anon_super_fc);
if (fsc->s_fs_info) {
fuse_conn_put(fc);
kfree(fm);
}
if (fsc->s_fs_info)
fuse_mount_destroy(fm);
if (IS_ERR(sb))
return PTR_ERR(sb);

if (!sb->s_root) {
err = virtio_fs_fill_super(sb, fsc);
if (err) {
fuse_conn_put(fc);
kfree(fm);
sb->s_fs_info = NULL;
deactivate_locked_super(sb);
return err;
}
Expand Down

0 comments on commit c191cd0

Please sign in to comment.