diff options
author | Jeff Mahoney <jeffm@suse.com> | 2016-06-22 18:54:23 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-12-06 16:06:59 +0100 |
commit | 0b246afa62b0cf5b09d078121f543135f28492ad (patch) | |
tree | 200ad296d09f1b2f5329658c8de81bc625007ace /fs/btrfs/free-space-tree.c | |
parent | 6202df6921494f29308307e0ae6f567c2ab2ba19 (diff) |
btrfs: root->fs_info cleanup, add fs_info convenience variables
In routines where someptr->fs_info is referenced multiple times, we
introduce a convenience variable. This makes the code considerably
more readable.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/free-space-tree.c')
-rw-r--r-- | fs/btrfs/free-space-tree.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 9dfb535d8378..2a08f518353b 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -189,7 +189,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, int ret; bitmap_size = free_space_bitmap_size(block_group->key.offset, - block_group->fs_info->sectorsize); + fs_info->sectorsize); bitmap = alloc_bitmap(bitmap_size); if (!bitmap) { ret = -ENOMEM; @@ -227,9 +227,9 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, ASSERT(found_key.objectid + found_key.offset <= end); first = div_u64(found_key.objectid - start, - block_group->fs_info->sectorsize); + fs_info->sectorsize); last = div_u64(found_key.objectid + found_key.offset - start, - block_group->fs_info->sectorsize); + fs_info->sectorsize); le_bitmap_set(bitmap, first, last - first); extent_count++; @@ -270,7 +270,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, } bitmap_cursor = bitmap; - bitmap_range = block_group->fs_info->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; + bitmap_range = fs_info->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; i = start; while (i < end) { unsigned long ptr; @@ -279,7 +279,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, extent_size = min(end - i, bitmap_range); data_size = free_space_bitmap_size(extent_size, - block_group->fs_info->sectorsize); + fs_info->sectorsize); key.objectid = i; key.type = BTRFS_FREE_SPACE_BITMAP_KEY; @@ -330,7 +330,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, int ret; bitmap_size = free_space_bitmap_size(block_group->key.offset, - block_group->fs_info->sectorsize); + fs_info->sectorsize); bitmap = alloc_bitmap(bitmap_size); if (!bitmap) { ret = -ENOMEM; @@ -370,11 +370,11 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, ASSERT(found_key.objectid + found_key.offset <= end); bitmap_pos = div_u64(found_key.objectid - start, - block_group->fs_info->sectorsize * + fs_info->sectorsize * BITS_PER_BYTE); bitmap_cursor = bitmap + bitmap_pos; data_size = free_space_bitmap_size(found_key.offset, - block_group->fs_info->sectorsize); + fs_info->sectorsize); ptr = btrfs_item_ptr_offset(leaf, path->slots[0] - 1); read_extent_buffer(leaf, bitmap_cursor, ptr, @@ -425,7 +425,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, extent_count++; } prev_bit = bit; - offset += block_group->fs_info->sectorsize; + offset += fs_info->sectorsize; bitnr++; } if (prev_bit == 1) { @@ -526,6 +526,7 @@ static void free_space_set_bits(struct btrfs_block_group_cache *block_group, struct btrfs_path *path, u64 *start, u64 *size, int bit) { + struct btrfs_fs_info *fs_info = block_group->fs_info; struct extent_buffer *leaf; struct btrfs_key key; u64 end = *start + *size; @@ -545,10 +546,8 @@ static void free_space_set_bits(struct btrfs_block_group_cache *block_group, end = found_end; ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); - first = div_u64(*start - found_start, - block_group->fs_info->sectorsize); - last = div_u64(end - found_start, - block_group->fs_info->sectorsize); + first = div_u64(*start - found_start, fs_info->sectorsize); + last = div_u64(end - found_start, fs_info->sectorsize); if (bit) extent_buffer_bitmap_set(leaf, ptr, first, last - first); else @@ -1270,7 +1269,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) list_del(&free_space_root->dirty_list); btrfs_tree_lock(free_space_root->node); - clean_tree_block(trans, tree_root->fs_info, free_space_root->node); + clean_tree_block(trans, fs_info, free_space_root->node); btrfs_tree_unlock(free_space_root->node); btrfs_free_tree_block(trans, free_space_root, free_space_root->node, 0, 1); @@ -1476,7 +1475,7 @@ static int load_free_space_bitmaps(struct btrfs_caching_control *caching_ctl, extent_count++; } prev_bit = bit; - offset += block_group->fs_info->sectorsize; + offset += fs_info->sectorsize; } } if (prev_bit == 1) { |