@@ -3096,13 +3096,12 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
INIT_WORK(&fs_info->reclaim_bgs_work, btrfs_reclaim_bgs_work);
}
-static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block *sb)
+static int init_mount_fs_info(struct btrfs_fs_info *fs_info)
{
int ret;
- fs_info->sb = sb;
- sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE;
- sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE);
+ fs_info->sb->s_blocksize = BTRFS_BDEV_BLOCKSIZE;
+ fs_info->sb->s_blocksize_bits = blksize_bits(BTRFS_BDEV_BLOCKSIZE);
ret = percpu_counter_init(&fs_info->ordered_bytes, 0, GFP_KERNEL);
if (ret)
@@ -3130,7 +3129,7 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block
return -ENOMEM;
btrfs_init_delayed_root(fs_info->delayed_root);
- if (sb_rdonly(sb))
+ if (sb_rdonly(fs_info->sb))
set_bit(BTRFS_FS_STATE_RO, &fs_info->fs_state);
return btrfs_alloc_stripe_hash_table(fs_info);
@@ -3308,7 +3307,9 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
int err = -EINVAL;
int level;
- ret = init_mount_fs_info(fs_info, sb);
+ fs_info->sb = sb;
+
+ ret = init_mount_fs_info(fs_info);
if (ret) {
err = ret;
goto fail;
@@ -3326,7 +3327,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
goto fail;
}
- fs_info->btree_inode = new_inode(sb);
+ fs_info->btree_inode = new_inode(fs_info->sb);
if (!fs_info->btree_inode) {
err = -ENOMEM;
goto fail;
@@ -3434,7 +3435,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size;
fs_info->stripesize = stripesize;
- ret = btrfs_parse_options(fs_info, options, sb->s_flags);
+ ret = btrfs_parse_options(fs_info, options, fs_info->sb->s_flags);
if (ret) {
err = ret;
goto fail_alloc;
@@ -3484,7 +3485,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
features = btrfs_super_compat_ro_flags(disk_super) &
~BTRFS_FEATURE_COMPAT_RO_SUPP;
- if (!sb_rdonly(sb) && features) {
+ if (!sb_rdonly(fs_info->sb) && features) {
btrfs_err(fs_info,
"cannot mount read-write because of unsupported optional features (0x%llx)",
features);
@@ -3536,12 +3537,12 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
goto fail_sb_buffer;
}
- sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
- sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
+ fs_info->sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
+ fs_info->sb->s_bdi->ra_pages = max(fs_info->sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
- sb->s_blocksize = sectorsize;
- sb->s_blocksize_bits = blksize_bits(sectorsize);
- memcpy(&sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE);
+ fs_info->sb->s_blocksize = sectorsize;
+ fs_info->sb->s_blocksize_bits = blksize_bits(sectorsize);
+ memcpy(&fs_info->sb->s_uuid, fs_info->fs_devices->fsid, BTRFS_FSID_SIZE);
mutex_lock(&fs_info->chunk_mutex);
ret = btrfs_read_sys_array(fs_info);
@@ -3738,7 +3739,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
goto fail_qgroup;
}
- if (sb_rdonly(sb))
+ if (sb_rdonly(fs_info->sb))
goto clear_oneshot;
ret = btrfs_start_pre_rw_mount(fs_info);
Currently at open_ctree(), sb->s_fs_info is already initialized to the fs_info we want. On the other hand, fs_info->sb is not initialized until init_mount_fs_info(). This patch will initialize fs_info->sb at the very beginning of open_ctree(), so later code can use fs_info->sb to grab the super block. This does not only remove the @sb parameter for init_mount_fs_info(), but also provides the basis for later open_ctree() refactor which requires everything to be accessible from a single @fs_info pointer. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/disk-io.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)