@@ -1232,11 +1232,12 @@ static int test_bdev_super_fc(struct super_block *s, struct fs_context *fc)
* @fill_super: Helper to initialise a new superblock
*/
int vfs_get_block_super(struct fs_context *fc,
- int (*fill_super)(struct super_block *,
- struct fs_context *))
+ int (*fill_super)(struct super_block *, struct fs_context *),
+ struct dentry* (*select_root)(struct fs_context *, struct super_block *))
{
struct block_device *bdev;
struct super_block *s;
+ struct dentry *root;
int error = 0;
fc->bdev_mode = FMODE_READ | FMODE_EXCL;
@@ -1302,7 +1303,11 @@ int vfs_get_block_super(struct fs_context *fc,
}
BUG_ON(fc->root);
- fc->root = dget(s->s_root);
+ if (select_root)
+ root = select_root(fc, s);
+ else
+ root = s->s_root;
+ fc->root = dget(root);
return 0;
error_sb:
@@ -145,8 +145,8 @@ extern int vfs_get_super(struct fs_context *fc,
struct fs_context *fc));
extern int vfs_get_block_super(struct fs_context *fc,
- int (*fill_super)(struct super_block *sb,
- struct fs_context *fc));
+ int (*fill_super)(struct super_block *, struct fs_context *),
+ struct dentry* (*select_root)(struct fs_context *, struct super_block *));
extern const struct file_operations fscontext_fops;
Take a function pointer 'select_root' in vfs_get_block_super() to allow callers to select the root dentry based on the context. This is intended for gfs2 to select between the normal root and the 'meta' root, which must be done whether a root already exists for a superblock or not, i.e. it cannot be decided in fill_super(). This will allow gfs2 to avoid duplicating a function from the vfs just to special-case the root dentry selection. Signed-off-by: Andrew Price <anprice@redhat.com> --- Depends on "vfs: Create fs_context-aware mount_bdev() replacement" fs/super.c | 11 ++++++++--- include/linux/fs_context.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-)