Skip to content

Commit a27c061

Browse files
author
Miklos Szeredi
committed
fuse: get rid of fuse_put_super()
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 <[email protected]>
1 parent d534d31 commit a27c061

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

fs/fuse/fuse_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,9 @@ int fuse_init_fs_context_submount(struct fs_context *fsc);
11211121
*/
11221122
void fuse_conn_destroy(struct fuse_mount *fm);
11231123

1124+
/* Drop the connection and free the fuse mount */
1125+
void fuse_mount_destroy(struct fuse_mount *fm);
1126+
11241127
/**
11251128
* Add connection to control filesystem
11261129
*/

fs/fuse/inode.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,6 @@ static void fuse_send_destroy(struct fuse_mount *fm)
457457
}
458458
}
459459

460-
static void fuse_put_super(struct super_block *sb)
461-
{
462-
struct fuse_mount *fm = get_fuse_mount_super(sb);
463-
464-
fuse_conn_put(fm->fc);
465-
kfree(fm);
466-
}
467-
468460
static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr)
469461
{
470462
stbuf->f_type = FUSE_SUPER_MAGIC;
@@ -1003,7 +995,6 @@ static const struct super_operations fuse_super_operations = {
1003995
.evict_inode = fuse_evict_inode,
1004996
.write_inode = fuse_write_inode,
1005997
.drop_inode = generic_delete_inode,
1006-
.put_super = fuse_put_super,
1007998
.umount_begin = fuse_umount_begin,
1008999
.statfs = fuse_statfs,
10091000
.sync_fs = fuse_sync_fs,
@@ -1754,10 +1745,20 @@ static void fuse_sb_destroy(struct super_block *sb)
17541745
}
17551746
}
17561747

1748+
void fuse_mount_destroy(struct fuse_mount *fm)
1749+
{
1750+
if (fm) {
1751+
fuse_conn_put(fm->fc);
1752+
kfree(fm);
1753+
}
1754+
}
1755+
EXPORT_SYMBOL(fuse_mount_destroy);
1756+
17571757
static void fuse_kill_sb_anon(struct super_block *sb)
17581758
{
17591759
fuse_sb_destroy(sb);
17601760
kill_anon_super(sb);
1761+
fuse_mount_destroy(get_fuse_mount_super(sb));
17611762
}
17621763

17631764
static struct file_system_type fuse_fs_type = {
@@ -1775,6 +1776,7 @@ static void fuse_kill_sb_blk(struct super_block *sb)
17751776
{
17761777
fuse_sb_destroy(sb);
17771778
kill_block_super(sb);
1779+
fuse_mount_destroy(get_fuse_mount_super(sb));
17781780
}
17791781

17801782
static struct file_system_type fuseblk_fs_type = {

fs/fuse/virtio_fs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ static void virtio_kill_sb(struct super_block *sb)
14001400
virtio_fs_conn_destroy(fm);
14011401
}
14021402
kill_anon_super(sb);
1403+
fuse_mount_destroy(fm);
14031404
}
14041405

14051406
static int virtio_fs_test_super(struct super_block *sb,

0 commit comments

Comments
 (0)