Home Home > GIT Browse > SLE12-SP3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-20 14:45:17 +0800
committerQu Wenruo <wqu@suse.com>2019-05-20 14:45:17 +0800
commitf4a11bd6a73fd53b844f2838aa3d273ca595ccda (patch)
treedd4f47bd1d032f51fb2cf0afdba39679fd0bf449
parentedd4a157ee97923b30a10a200966f2446def5680 (diff)
btrfs: extent-tree: Use btrfs_ref to refactor
add_pinned_bytes() (bsc#1063638 bsc#1128052 bsc#1108838). suse-commit: b7d3c80811faf02a95c0b65a8d7a0fca287f4e80
-rw-r--r--fs/btrfs/extent-tree.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fb2fac7e4975..885a8694e1fd 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -755,14 +755,15 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
return NULL;
}
-static void add_pinned_bytes(struct btrfs_fs_info *fs_info, s64 num_bytes,
- u64 owner, u64 root_objectid)
+static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
+ struct btrfs_ref *ref)
{
struct btrfs_space_info *space_info;
+ s64 num_bytes = -ref->len;
u64 flags;
- if (owner < BTRFS_FIRST_FREE_OBJECTID) {
- if (root_objectid == BTRFS_CHUNK_TREE_OBJECTID)
+ if (ref->type == BTRFS_REF_METADATA) {
+ if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
flags = BTRFS_BLOCK_GROUP_SYSTEM;
else
flags = BTRFS_BLOCK_GROUP_METADATA;
@@ -2120,7 +2121,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
&old_ref_mod, &new_ref_mod);
}
if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
- add_pinned_bytes(fs_info, -num_bytes, owner, root_objectid);
+ add_pinned_bytes(fs_info, &generic_ref);
return ret;
}
@@ -7224,9 +7225,8 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
}
out:
if (pin)
- add_pinned_bytes(root->fs_info, buf->len,
- btrfs_header_level(buf),
- root->root_key.objectid);
+ add_pinned_bytes(root->fs_info, &generic_ref);
+
if (last_ref) {
/*
@@ -7276,7 +7276,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
}
if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
- add_pinned_bytes(fs_info, num_bytes, owner, root_objectid);
+ add_pinned_bytes(fs_info, &generic_ref);
return ret;
}