diff options
author | Jeff Mahoney <jeffm@suse.com> | 2016-06-15 09:22:56 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-12-06 16:06:58 +0100 |
commit | da17066c40472c2d6a1aab7bb0090c3d285531c9 (patch) | |
tree | f51910799ffea3bfe5af34d009a2967b9e99e6ad /fs/btrfs/free-space-tree.c | |
parent | f15376df0dc2b632eb689793a73d4adba8404987 (diff) | |
download | linux-stable-da17066c40472c2d6a1aab7bb0090c3d285531c9.tar.gz linux-stable-da17066c40472c2d6a1aab7bb0090c3d285531c9.tar.bz2 linux-stable-da17066c40472c2d6a1aab7bb0090c3d285531c9.zip |
btrfs: pull node/sector/stripe sizes out of root and into fs_info
We track the node sizes per-root, but they never vary from the values
in the superblock. This patch messes with the 80-column style a bit,
but subsequent patches to factor out root->fs_info into a convenience
variable fix it up again.
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 | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 57401b474ec6..9dfb535d8378 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -39,7 +39,7 @@ void set_free_space_tree_thresholds(struct btrfs_block_group_cache *cache) * We convert to bitmaps when the disk space required for using extents * exceeds that required for using bitmaps. */ - bitmap_range = cache->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; + bitmap_range = cache->fs_info->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; num_bitmaps = div_u64(cache->key.offset + bitmap_range - 1, bitmap_range); bitmap_size = sizeof(struct btrfs_item) + BTRFS_FREE_SPACE_BITMAP_SIZE; @@ -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->sectorsize); + block_group->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->sectorsize); + block_group->fs_info->sectorsize); last = div_u64(found_key.objectid + found_key.offset - start, - block_group->sectorsize); + block_group->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->sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS; + bitmap_range = block_group->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->sectorsize); + block_group->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->sectorsize); + block_group->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->sectorsize * + block_group->fs_info->sectorsize * BITS_PER_BYTE); bitmap_cursor = bitmap + bitmap_pos; data_size = free_space_bitmap_size(found_key.offset, - block_group->sectorsize); + block_group->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->sectorsize; + offset += block_group->fs_info->sectorsize; bitnr++; } if (prev_bit == 1) { @@ -517,7 +517,8 @@ int free_space_test_bit(struct btrfs_block_group_cache *block_group, ASSERT(offset >= found_start && offset < found_end); ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); - i = div_u64(offset - found_start, block_group->sectorsize); + i = div_u64(offset - found_start, + block_group->fs_info->sectorsize); return !!extent_buffer_test_bit(leaf, ptr, i); } @@ -544,8 +545,10 @@ 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->sectorsize); - last = div_u64(end - found_start, block_group->sectorsize); + first = div_u64(*start - found_start, + block_group->fs_info->sectorsize); + last = div_u64(end - found_start, + block_group->fs_info->sectorsize); if (bit) extent_buffer_bitmap_set(leaf, ptr, first, last - first); else @@ -606,7 +609,7 @@ static int modify_free_space_bitmap(struct btrfs_trans_handle *trans, * that block is within the block group. */ if (start > block_group->key.objectid) { - u64 prev_block = start - block_group->sectorsize; + u64 prev_block = start - block_group->fs_info->sectorsize; key.objectid = prev_block; key.type = (u8)-1; @@ -1121,7 +1124,7 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans, } start = key.objectid; if (key.type == BTRFS_METADATA_ITEM_KEY) - start += fs_info->tree_root->nodesize; + start += fs_info->nodesize; else start += key.offset; } else if (key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) { @@ -1473,7 +1476,7 @@ static int load_free_space_bitmaps(struct btrfs_caching_control *caching_ctl, extent_count++; } prev_bit = bit; - offset += block_group->sectorsize; + offset += block_group->fs_info->sectorsize; } } if (prev_bit == 1) { |