Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-20 14:37:43 +0800
committerQu Wenruo <wqu@suse.com>2019-05-20 14:37:43 +0800
commitedd4a157ee97923b30a10a200966f2446def5680 (patch)
treebf6c3cd9b4a9bf2de56fbdb4cca1f1570065eb5c
parent96fdbcf6324153ab0abb3dd3579863c41f030d3e (diff)
btrfs: delayed-ref: Use btrfs_ref to refactor
btrfs_add_delayed_data_ref() (bsc#1063638 bsc#1128052 bsc#1108838). suse-commit: 5346636714b609f3f9604c3d9e0338fea62d270c
-rw-r--r--fs/btrfs/delayed-ref.c16
-rw-r--r--fs/btrfs/delayed-ref.h4
-rw-r--r--fs/btrfs/extent-tree.c25
3 files changed, 25 insertions, 20 deletions
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 2338efc4b5bb..a3ffd845868b 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -807,9 +807,7 @@ free_ref:
*/
int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
struct btrfs_trans_handle *trans,
- u64 bytenr, u64 num_bytes,
- u64 parent, u64 ref_root,
- u64 owner, u64 offset, u64 reserved, int action,
+ struct btrfs_ref *generic_ref, u64 reserved,
struct btrfs_delayed_extent_op *extent_op,
int *old_ref_mod, int *new_ref_mod)
{
@@ -817,9 +815,17 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
+ int action = generic_ref->action;
int ret;
+ u64 bytenr = generic_ref->bytenr;
+ u64 num_bytes = generic_ref->len;
+ u64 parent = generic_ref->parent;
+ u64 ref_root = generic_ref->data_ref.ref_root;
+ u64 owner = generic_ref->data_ref.ino;
+ u64 offset = generic_ref->data_ref.offset;
u8 ref_type;
+ ASSERT(generic_ref->type == BTRFS_REF_DATA && action);
BUG_ON(extent_op && !extent_op->is_data);
ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS);
if (!ref)
@@ -843,7 +849,9 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
}
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
- is_fstree(ref_root)) {
+ is_fstree(ref_root) &&
+ is_fstree(generic_ref->real_root) &&
+ !generic_ref->skip_qgroup) {
record = kzalloc(sizeof(*record), GFP_NOFS);
if (!record) {
kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index c977633e983f..a9f1cf949ccb 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -355,9 +355,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
int *old_ref_mod, int *new_ref_mod);
int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
struct btrfs_trans_handle *trans,
- u64 bytenr, u64 num_bytes,
- u64 parent, u64 ref_root,
- u64 owner, u64 offset, u64 reserved, int action,
+ struct btrfs_ref *generic_ref, u64 reserved,
struct btrfs_delayed_extent_op *extent_op,
int *old_ref_mod, int *new_ref_mod);
int btrfs_add_delayed_qgroup_reserve(struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1ab18cbdb954..fb2fac7e4975 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2114,10 +2114,9 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
&generic_ref, NULL,
&old_ref_mod, &new_ref_mod);
} else {
- ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
- num_bytes, parent, root_objectid,
- owner, offset, 0,
- BTRFS_ADD_DELAYED_REF, NULL,
+ btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
+ ret = btrfs_add_delayed_data_ref(fs_info, trans,
+ &generic_ref, 0, NULL,
&old_ref_mod, &new_ref_mod);
}
if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
@@ -7270,11 +7269,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
&generic_ref, NULL,
&old_ref_mod, &new_ref_mod);
} else {
- ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
- num_bytes,
- parent, root_objectid, owner,
- offset, 0,
- BTRFS_DROP_DELAYED_REF, NULL,
+ btrfs_init_data_ref(&generic_ref, root_objectid, owner, offset);
+ ret = btrfs_add_delayed_data_ref(fs_info, trans,
+ &generic_ref, 0, NULL,
&old_ref_mod, &new_ref_mod);
}
@@ -8217,14 +8214,16 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
u64 offset, u64 ram_bytes,
struct btrfs_key *ins)
{
+ struct btrfs_ref generic_ref = { 0 };
int ret;
BUG_ON(root_objectid == BTRFS_TREE_LOG_OBJECTID);
- ret = btrfs_add_delayed_data_ref(root->fs_info, trans, ins->objectid,
- ins->offset, 0,
- root_objectid, owner, offset,
- ram_bytes, BTRFS_ADD_DELAYED_EXTENT,
+ btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
+ ins->objectid, ins->offset, 0);
+ btrfs_init_data_ref(&generic_ref, root->root_key.objectid, owner, offset);
+ ret = btrfs_add_delayed_data_ref(root->fs_info, trans,
+ &generic_ref, ram_bytes,
NULL, NULL, NULL);
return ret;
}