Skip to content

Commit

Permalink
fuse: get rid of fuse_put_super()
Browse files Browse the repository at this point in the history
The ->put_super callback is called from generic_shutdown_super() in case of
a fully initialized sb.  This is called from kill_***_super(), which is
called from ->kill_sb instances.

Fuse uses ->put_super to destroy the fs specific fuse_mount and drop the
reference to the fuse_conn, while it does the same on each error case
during sb setup.

This patch moves the destruction from fuse_put_super() to
fuse_mount_destroy(), called at the end of all ->kill_sb instances.  A
follup patch will clean up the error paths.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Oct 21, 2021
1 parent d534d31 commit a27c061
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,9 @@ int fuse_init_fs_context_submount(struct fs_context *fsc);
*/
void fuse_conn_destroy(struct fuse_mount *fm);

/* Drop the connection and free the fuse mount */
void fuse_mount_destroy(struct fuse_mount *fm);

/**
* Add connection to control filesystem
*/
Expand Down
20 changes: 11 additions & 9 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,6 @@ static void fuse_send_destroy(struct fuse_mount *fm)
}
}

static void fuse_put_super(struct super_block *sb)
{
struct fuse_mount *fm = get_fuse_mount_super(sb);

fuse_conn_put(fm->fc);
kfree(fm);
}

static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr)
{
stbuf->f_type = FUSE_SUPER_MAGIC;
Expand Down Expand Up @@ -1003,7 +995,6 @@ static const struct super_operations fuse_super_operations = {
.evict_inode = fuse_evict_inode,
.write_inode = fuse_write_inode,
.drop_inode = generic_delete_inode,
.put_super = fuse_put_super,
.umount_begin = fuse_umount_begin,
.statfs = fuse_statfs,
.sync_fs = fuse_sync_fs,
Expand Down Expand Up @@ -1754,10 +1745,20 @@ static void fuse_sb_destroy(struct super_block *sb)
}
}

void fuse_mount_destroy(struct fuse_mount *fm)
{
if (fm) {
fuse_conn_put(fm->fc);
kfree(fm);
}
}
EXPORT_SYMBOL(fuse_mount_destroy);

static void fuse_kill_sb_anon(struct super_block *sb)
{
fuse_sb_destroy(sb);
kill_anon_super(sb);
fuse_mount_destroy(get_fuse_mount_super(sb));
}

static struct file_system_type fuse_fs_type = {
Expand All @@ -1775,6 +1776,7 @@ static void fuse_kill_sb_blk(struct super_block *sb)
{
fuse_sb_destroy(sb);
kill_block_super(sb);
fuse_mount_destroy(get_fuse_mount_super(sb));
}

static struct file_system_type fuseblk_fs_type = {
Expand Down
1 change: 1 addition & 0 deletions fs/fuse/virtio_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,7 @@ static void virtio_kill_sb(struct super_block *sb)
virtio_fs_conn_destroy(fm);
}
kill_anon_super(sb);
fuse_mount_destroy(fm);
}

static int virtio_fs_test_super(struct super_block *sb,
Expand Down

0 comments on commit a27c061

Please sign in to comment.