Skip to content

Commit 2ff7e61

Browse files
jeffmahoneykdave
authored andcommitted
btrfs: take an fs_info directly when the root is not used otherwise
There are loads of functions in btrfs that accept a root parameter but only use it to obtain an fs_info pointer. Let's convert those to just accept an fs_info pointer directly. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent afdb571 commit 2ff7e61

44 files changed

Lines changed: 1119 additions & 1243 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎fs/btrfs/backref.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
788788
if (ref->key_for_search.type)
789789
continue;
790790
BUG_ON(!ref->wanted_disk_byte);
791-
eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
792-
0);
791+
eb = read_tree_block(fs_info, ref->wanted_disk_byte, 0);
793792
if (IS_ERR(eb)) {
794793
return PTR_ERR(eb);
795794
} else if (!extent_buffer_uptodate(eb)) {
@@ -1405,8 +1404,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
14051404
ref->level == 0) {
14061405
struct extent_buffer *eb;
14071406

1408-
eb = read_tree_block(fs_info->extent_root,
1409-
ref->parent, 0);
1407+
eb = read_tree_block(fs_info, ref->parent, 0);
14101408
if (IS_ERR(eb)) {
14111409
ret = PTR_ERR(eb);
14121410
goto out;

‎fs/btrfs/check-integrity.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,14 +2904,13 @@ int btrfsic_submit_bio_wait(struct bio *bio)
29042904
return submit_bio_wait(bio);
29052905
}
29062906

2907-
int btrfsic_mount(struct btrfs_root *root,
2907+
int btrfsic_mount(struct btrfs_fs_info *fs_info,
29082908
struct btrfs_fs_devices *fs_devices,
29092909
int including_extent_data, u32 print_mask)
29102910
{
29112911
int ret;
29122912
struct btrfsic_state *state;
29132913
struct list_head *dev_head = &fs_devices->devices;
2914-
struct btrfs_fs_info *fs_info = root->fs_info;
29152914
struct btrfs_device *device;
29162915

29172916
if (fs_info->nodesize & ((u64)PAGE_SIZE - 1)) {
@@ -2939,7 +2938,7 @@ int btrfsic_mount(struct btrfs_root *root,
29392938
btrfsic_is_initialized = 1;
29402939
}
29412940
mutex_lock(&btrfsic_mutex);
2942-
state->fs_info = root->fs_info;
2941+
state->fs_info = fs_info;
29432942
state->print_mask = print_mask;
29442943
state->include_extent_data = including_extent_data;
29452944
state->csum_size = 0;
@@ -2977,7 +2976,7 @@ int btrfsic_mount(struct btrfs_root *root,
29772976
ret = btrfsic_process_superblock(state, fs_devices);
29782977
if (0 != ret) {
29792978
mutex_unlock(&btrfsic_mutex);
2980-
btrfsic_unmount(root, fs_devices);
2979+
btrfsic_unmount(fs_devices);
29812980
return ret;
29822981
}
29832982

@@ -2990,8 +2989,7 @@ int btrfsic_mount(struct btrfs_root *root,
29902989
return 0;
29912990
}
29922991

2993-
void btrfsic_unmount(struct btrfs_root *root,
2994-
struct btrfs_fs_devices *fs_devices)
2992+
void btrfsic_unmount(struct btrfs_fs_devices *fs_devices)
29952993
{
29962994
struct btrfsic_block *b_all, *tmp_all;
29972995
struct btrfsic_state *state;

‎fs/btrfs/check-integrity.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ int btrfsic_submit_bio_wait(struct bio *bio);
2929
#define btrfsic_submit_bio_wait submit_bio_wait
3030
#endif
3131

32-
int btrfsic_mount(struct btrfs_root *root,
32+
int btrfsic_mount(struct btrfs_fs_info *fs_info,
3333
struct btrfs_fs_devices *fs_devices,
3434
int including_extent_data, u32 print_mask);
35-
void btrfsic_unmount(struct btrfs_root *root,
36-
struct btrfs_fs_devices *fs_devices);
35+
void btrfsic_unmount(struct btrfs_fs_devices *fs_devices);
3736

3837
#endif

‎fs/btrfs/compression.c‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ static int btrfs_decompress_bio(int type, struct page **pages_in,
8585
u64 disk_start, struct bio *orig_bio,
8686
size_t srclen);
8787

88-
static inline int compressed_bio_size(struct btrfs_root *root,
88+
static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
8989
unsigned long disk_size)
9090
{
91-
struct btrfs_fs_info *fs_info = root->fs_info;
9291
u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
9392

9493
return sizeof(struct compressed_bio) +
@@ -331,7 +330,6 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
331330
{
332331
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
333332
struct bio *bio = NULL;
334-
struct btrfs_root *root = BTRFS_I(inode)->root;
335333
struct compressed_bio *cb;
336334
unsigned long bytes_left;
337335
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
@@ -343,7 +341,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
343341
int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
344342

345343
WARN_ON(start & ((u64)PAGE_SIZE - 1));
346-
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
344+
cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
347345
if (!cb)
348346
return -ENOMEM;
349347
atomic_set(&cb->pending_bios, 0);
@@ -398,12 +396,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
398396
BUG_ON(ret); /* -ENOMEM */
399397

400398
if (!skip_sum) {
401-
ret = btrfs_csum_one_bio(root, inode, bio,
402-
start, 1);
399+
ret = btrfs_csum_one_bio(inode, bio, start, 1);
403400
BUG_ON(ret); /* -ENOMEM */
404401
}
405402

406-
ret = btrfs_map_bio(root, bio, 0, 1);
403+
ret = btrfs_map_bio(fs_info, bio, 0, 1);
407404
if (ret) {
408405
bio->bi_error = ret;
409406
bio_endio(bio);
@@ -433,11 +430,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
433430
BUG_ON(ret); /* -ENOMEM */
434431

435432
if (!skip_sum) {
436-
ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
433+
ret = btrfs_csum_one_bio(inode, bio, start, 1);
437434
BUG_ON(ret); /* -ENOMEM */
438435
}
439436

440-
ret = btrfs_map_bio(root, bio, 0, 1);
437+
ret = btrfs_map_bio(fs_info, bio, 0, 1);
441438
if (ret) {
442439
bio->bi_error = ret;
443440
bio_endio(bio);
@@ -581,7 +578,6 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
581578
struct extent_io_tree *tree;
582579
struct extent_map_tree *em_tree;
583580
struct compressed_bio *cb;
584-
struct btrfs_root *root = BTRFS_I(inode)->root;
585581
unsigned long compressed_len;
586582
unsigned long nr_pages;
587583
unsigned long pg_index;
@@ -609,7 +605,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
609605
return -EIO;
610606

611607
compressed_len = em->block_len;
612-
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
608+
cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
613609
if (!cb)
614610
goto out;
615611

@@ -694,14 +690,14 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
694690
atomic_inc(&cb->pending_bios);
695691

696692
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
697-
ret = btrfs_lookup_bio_sums(root, inode,
698-
comp_bio, sums);
693+
ret = btrfs_lookup_bio_sums(inode, comp_bio,
694+
sums);
699695
BUG_ON(ret); /* -ENOMEM */
700696
}
701697
sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
702698
fs_info->sectorsize);
703699

704-
ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
700+
ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
705701
if (ret) {
706702
comp_bio->bi_error = ret;
707703
bio_endio(comp_bio);
@@ -726,11 +722,11 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
726722
BUG_ON(ret); /* -ENOMEM */
727723

728724
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
729-
ret = btrfs_lookup_bio_sums(root, inode, comp_bio, sums);
725+
ret = btrfs_lookup_bio_sums(inode, comp_bio, sums);
730726
BUG_ON(ret); /* -ENOMEM */
731727
}
732728

733-
ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
729+
ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
734730
if (ret) {
735731
comp_bio->bi_error = ret;
736732
bio_endio(comp_bio);

0 commit comments

Comments
 (0)