diff options
author | Eric Sandeen <sandeen@redhat.com> | 2014-08-01 19:12:40 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-02-16 12:48:45 -0500 |
commit | f37938e0e22f90740cfbfe74ecd9aad5e8369b9d (patch) | |
tree | f52716704588c7aeee8b9f5306d6272d4310da04 /fs/btrfs | |
parent | 779a65a495b76aee7fae500ac7ae360dc8fd81ff (diff) |
btrfs: factor btrfs_init_btree_inode() out of open_ctree()
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
[renamed to btrfs_init_btree_inode]
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/disk-io.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b95b033b2494..6a64e666de05 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2169,6 +2169,36 @@ static void btrfs_init_balance(struct btrfs_fs_info *fs_info) | |||
2169 | init_waitqueue_head(&fs_info->balance_wait_q); | 2169 | init_waitqueue_head(&fs_info->balance_wait_q); |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info, | ||
2173 | struct btrfs_root *tree_root) | ||
2174 | { | ||
2175 | fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID; | ||
2176 | set_nlink(fs_info->btree_inode, 1); | ||
2177 | /* | ||
2178 | * we set the i_size on the btree inode to the max possible int. | ||
2179 | * the real end of the address space is determined by all of | ||
2180 | * the devices in the system | ||
2181 | */ | ||
2182 | fs_info->btree_inode->i_size = OFFSET_MAX; | ||
2183 | fs_info->btree_inode->i_mapping->a_ops = &btree_aops; | ||
2184 | fs_info->btree_inode->i_mapping->backing_dev_info = &fs_info->bdi; | ||
2185 | |||
2186 | RB_CLEAR_NODE(&BTRFS_I(fs_info->btree_inode)->rb_node); | ||
2187 | extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree, | ||
2188 | fs_info->btree_inode->i_mapping); | ||
2189 | BTRFS_I(fs_info->btree_inode)->io_tree.track_uptodate = 0; | ||
2190 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree); | ||
2191 | |||
2192 | BTRFS_I(fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops; | ||
2193 | |||
2194 | BTRFS_I(fs_info->btree_inode)->root = tree_root; | ||
2195 | memset(&BTRFS_I(fs_info->btree_inode)->location, 0, | ||
2196 | sizeof(struct btrfs_key)); | ||
2197 | set_bit(BTRFS_INODE_DUMMY, | ||
2198 | &BTRFS_I(fs_info->btree_inode)->runtime_flags); | ||
2199 | btrfs_insert_inode_hash(fs_info->btree_inode); | ||
2200 | } | ||
2201 | |||
2172 | int open_ctree(struct super_block *sb, | 2202 | int open_ctree(struct super_block *sb, |
2173 | struct btrfs_fs_devices *fs_devices, | 2203 | struct btrfs_fs_devices *fs_devices, |
2174 | char *options) | 2204 | char *options) |
@@ -2329,31 +2359,7 @@ int open_ctree(struct super_block *sb, | |||
2329 | sb->s_blocksize_bits = blksize_bits(4096); | 2359 | sb->s_blocksize_bits = blksize_bits(4096); |
2330 | sb->s_bdi = &fs_info->bdi; | 2360 | sb->s_bdi = &fs_info->bdi; |
2331 | 2361 | ||
2332 | fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID; | 2362 | btrfs_init_btree_inode(fs_info, tree_root); |
2333 | set_nlink(fs_info->btree_inode, 1); | ||
2334 | /* | ||
2335 | * we set the i_size on the btree inode to the max possible int. | ||
2336 | * the real end of the address space is determined by all of | ||
2337 | * the devices in the system | ||
2338 | */ | ||
2339 | fs_info->btree_inode->i_size = OFFSET_MAX; | ||
2340 | fs_info->btree_inode->i_mapping->a_ops = &btree_aops; | ||
2341 | fs_info->btree_inode->i_mapping->backing_dev_info = &fs_info->bdi; | ||
2342 | |||
2343 | RB_CLEAR_NODE(&BTRFS_I(fs_info->btree_inode)->rb_node); | ||
2344 | extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree, | ||
2345 | fs_info->btree_inode->i_mapping); | ||
2346 | BTRFS_I(fs_info->btree_inode)->io_tree.track_uptodate = 0; | ||
2347 | extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree); | ||
2348 | |||
2349 | BTRFS_I(fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops; | ||
2350 | |||
2351 | BTRFS_I(fs_info->btree_inode)->root = tree_root; | ||
2352 | memset(&BTRFS_I(fs_info->btree_inode)->location, 0, | ||
2353 | sizeof(struct btrfs_key)); | ||
2354 | set_bit(BTRFS_INODE_DUMMY, | ||
2355 | &BTRFS_I(fs_info->btree_inode)->runtime_flags); | ||
2356 | btrfs_insert_inode_hash(fs_info->btree_inode); | ||
2357 | 2363 | ||
2358 | spin_lock_init(&fs_info->block_group_cache_lock); | 2364 | spin_lock_init(&fs_info->block_group_cache_lock); |
2359 | fs_info->block_group_cache_tree = RB_ROOT; | 2365 | fs_info->block_group_cache_tree = RB_ROOT; |