Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-20 14:49:51 +0800
committerQu Wenruo <wqu@suse.com>2019-05-20 14:49:51 +0800
commit37fc1d83b8693547fdb87afcf2fbb6a8f654edd0 (patch)
treecd66ecf951681d2bc827c8c3a9001ca00389ce96
parentf4a11bd6a73fd53b844f2838aa3d273ca595ccda (diff)
btrfs: extent-tree: Fix a bug that btrfs is unable to add
pinned bytes (bsc#1063638 bsc#1128052 bsc#1108838). suse-commit: 7c0883e35e2b948b9435981bfce1ec509d3fab33
-rw-r--r--fs/btrfs/extent-tree.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 885a8694e1fd..1bd96de9ab2b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -756,12 +756,14 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
}
static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
- struct btrfs_ref *ref)
+ struct btrfs_ref *ref, int sign)
{
struct btrfs_space_info *space_info;
- s64 num_bytes = -ref->len;
+ s64 num_bytes;
u64 flags;
+ ASSERT(sign == 1 || sign == -1);
+ num_bytes = sign * ref->len;
if (ref->type == BTRFS_REF_METADATA) {
if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
flags = BTRFS_BLOCK_GROUP_SYSTEM;
@@ -2121,7 +2123,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, &generic_ref);
+ add_pinned_bytes(fs_info, &generic_ref, -1);
return ret;
}
@@ -7225,7 +7227,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
}
out:
if (pin)
- add_pinned_bytes(root->fs_info, &generic_ref);
+ add_pinned_bytes(root->fs_info, &generic_ref, 1);
if (last_ref) {
@@ -7276,7 +7278,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, &generic_ref);
+ add_pinned_bytes(fs_info, &generic_ref, 1);
return ret;
}