Skip to content

Commit fe0a7bd

Browse files
gkurzMiklos Szeredi
authored andcommitted
fuse: add dedicated filesystem context ops for submounts
The creation of a submount is open-coded in fuse_dentry_automount(). This brings a lot of complexity and we recently had to fix bugs because we weren't setting SB_BORN or because we were unlocking sb->s_umount before sb was fully configured. Most of these could have been avoided by using the mount API instead of open-coding. Basically, this means coming up with a proper ->get_tree() implementation for submounts and call vfs_get_tree(), or better fc_mount(). The creation of the superblock for submounts is quite different from the root mount. Especially, it doesn't require to allocate a FUSE filesystem context, nor to parse parameters. Introduce a dedicated context ops for submounts to make this clear. This is just a placeholder for now, fuse_get_tree_submount() will be populated in a subsequent patch. Only visible change is that we stop allocating/freeing a useless FUSE filesystem context with submounts. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 2d82ab2 commit fe0a7bd

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

fs/fuse/fuse_i.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,11 @@ int fuse_fill_super_submount(struct super_block *sb,
11001100
*/
11011101
bool fuse_mount_remove(struct fuse_mount *fm);
11021102

1103+
/*
1104+
* Setup context ops for submounts
1105+
*/
1106+
int fuse_init_fs_context_submount(struct fs_context *fsc);
1107+
11031108
/*
11041109
* Shut down the connection (possibly sending DESTROY request).
11051110
*/

fs/fuse/inode.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,22 @@ int fuse_fill_super_submount(struct super_block *sb,
13531353
return 0;
13541354
}
13551355

1356+
static int fuse_get_tree_submount(struct fs_context *fsc)
1357+
{
1358+
return 0;
1359+
}
1360+
1361+
static const struct fs_context_operations fuse_context_submount_ops = {
1362+
.get_tree = fuse_get_tree_submount,
1363+
};
1364+
1365+
int fuse_init_fs_context_submount(struct fs_context *fsc)
1366+
{
1367+
fsc->ops = &fuse_context_submount_ops;
1368+
return 0;
1369+
}
1370+
EXPORT_SYMBOL_GPL(fuse_init_fs_context_submount);
1371+
13561372
int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
13571373
{
13581374
struct fuse_dev *fud = NULL;

fs/fuse/virtio_fs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,9 @@ static int virtio_fs_init_fs_context(struct fs_context *fsc)
14971497
{
14981498
struct fuse_fs_context *ctx;
14991499

1500+
if (fsc->purpose == FS_CONTEXT_FOR_SUBMOUNT)
1501+
return fuse_init_fs_context_submount(fsc);
1502+
15001503
ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
15011504
if (!ctx)
15021505
return -ENOMEM;

0 commit comments

Comments
 (0)