Skip to content

Commit dcb2137

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: move all btree inode initialization into btrfs_init_btree_inode
Move the remaining code that deals with initializing the btree inode into btrfs_init_btree_inode instead of splitting it between that helpers and its only caller. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 19337f8 commit dcb2137

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

fs/btrfs/disk-io.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,11 +2125,16 @@ static void btrfs_init_balance(struct btrfs_fs_info *fs_info)
21252125
atomic_set(&fs_info->reloc_cancel_req, 0);
21262126
}
21272127

2128-
static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
2128+
static int btrfs_init_btree_inode(struct super_block *sb)
21292129
{
2130-
struct inode *inode = fs_info->btree_inode;
2130+
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
21312131
unsigned long hash = btrfs_inode_hash(BTRFS_BTREE_INODE_OBJECTID,
21322132
fs_info->tree_root);
2133+
struct inode *inode;
2134+
2135+
inode = new_inode(sb);
2136+
if (!inode)
2137+
return -ENOMEM;
21332138

21342139
inode->i_ino = BTRFS_BTREE_INODE_OBJECTID;
21352140
set_nlink(inode, 1);
@@ -2140,6 +2145,7 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
21402145
*/
21412146
inode->i_size = OFFSET_MAX;
21422147
inode->i_mapping->a_ops = &btree_aops;
2148+
mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
21432149

21442150
RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
21452151
extent_io_tree_init(fs_info, &BTRFS_I(inode)->io_tree,
@@ -2152,6 +2158,9 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
21522158
BTRFS_I(inode)->location.offset = 0;
21532159
set_bit(BTRFS_INODE_DUMMY, &BTRFS_I(inode)->runtime_flags);
21542160
__insert_inode_hash(inode, hash);
2161+
fs_info->btree_inode = inode;
2162+
2163+
return 0;
21552164
}
21562165

21572166
static void btrfs_init_dev_replace_locks(struct btrfs_fs_info *fs_info)
@@ -3365,13 +3374,11 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
33653374
goto fail;
33663375
}
33673376

3368-
fs_info->btree_inode = new_inode(sb);
3369-
if (!fs_info->btree_inode) {
3370-
err = -ENOMEM;
3377+
ret = btrfs_init_btree_inode(sb);
3378+
if (ret) {
3379+
err = ret;
33713380
goto fail;
33723381
}
3373-
mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
3374-
btrfs_init_btree_inode(fs_info);
33753382

33763383
invalidate_bdev(fs_devices->latest_dev->bdev);
33773384

0 commit comments

Comments
 (0)