summaryrefslogtreecommitdiff
path: root/extent-tree.c
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2018-05-02 14:52:54 +0300
committerDavid Sterba <dsterba@suse.com>2018-06-07 16:37:33 +0200
commit9f8316f1c870415383d8761e1455f1375e2e00b0 (patch)
treeaa4420bcc344182f24d1af5d884e1c686f93febe /extent-tree.c
parentf841497b6085748262f10a96585836cd69070ba7 (diff)
btrfs-progs: Use exclude_super_stripes instead of account_super_bytes
Originally commit 2681e00f00fe ("btrfs-progs: check for matchingi free space in cache") added the account_super_bytes function to prevent false negative when running btrfs check. Turns out this function is really copied exclude_super_stripes, excluding the calls to exclude_super_stripes. Later commit e4797df6a9fa ("btrfs-progs: check the free space tree in btrfsck") introduced proper version of exclude_super_stripes. Instead of duplicating the function, just remove account_super_bytes and use exclude_super_stripes instead of the former. This also has the benefit of bringing the userspace code a bit closer to the kernel counterpart. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'extent-tree.c')
-rw-r--r--extent-tree.c52
1 files changed, 2 insertions, 50 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 297d178..1b8a4f8 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -3164,54 +3164,6 @@ error:
return ret;
}
-static void account_super_bytes(struct btrfs_fs_info *fs_info,
- struct btrfs_block_group_cache *cache)
-{
- u64 bytenr;
- u64 *logical;
- int stripe_len;
- int i, nr, ret;
-
- if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) {
- stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid;
- cache->bytes_super += stripe_len;
- }
-
- for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
- bytenr = btrfs_sb_offset(i);
- ret = btrfs_rmap_block(fs_info,
- cache->key.objectid, bytenr,
- &logical, &nr, &stripe_len);
- if (ret)
- return;
-
- while (nr--) {
- u64 start, len;
-
- if (logical[nr] > cache->key.objectid +
- cache->key.offset)
- continue;
-
- if (logical[nr] + stripe_len <= cache->key.objectid)
- continue;
-
- start = logical[nr];
- if (start < cache->key.objectid) {
- start = cache->key.objectid;
- len = (logical[nr] + stripe_len) - start;
- } else {
- len = min_t(u64, stripe_len,
- cache->key.objectid +
- cache->key.offset - start);
- }
-
- cache->bytes_super += len;
- }
-
- kfree(logical);
- }
-}
-
int btrfs_read_block_groups(struct btrfs_root *root)
{
struct btrfs_path *path;
@@ -3287,7 +3239,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
if (btrfs_chunk_readonly(info, cache->key.objectid))
cache->ro = 1;
- account_super_bytes(info, cache);
+ exclude_super_stripes(root, cache);
ret = update_space_info(info, cache->flags, found_key.offset,
btrfs_block_group_used(&cache->item),
@@ -3331,7 +3283,7 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type,
cache->flags = type;
btrfs_set_block_group_flags(&cache->item, type);
- account_super_bytes(fs_info, cache);
+ exclude_super_stripes(fs_info->extent_root, cache);
ret = update_space_info(fs_info, cache->flags, size, bytes_used,
&cache->space_info);
BUG_ON(ret);