提交 681145d4 编写于 作者: N Nikolay Borisov 提交者: David Sterba

btrfs: pull up qgroup checks from delayed-ref core to init time

Instead of checking whether qgroup processing for a dealyed ref has to
happen in the core of delayed ref, simply pull the check at init time of
respective delayed ref structures. This eliminates the final use of
real_root in delayed-ref core paving the way to making this member
optional.
Signed-off-by: NNikolay Borisov <nborisov@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 f42c5da6
...@@ -921,8 +921,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -921,8 +921,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
} }
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
is_fstree(generic_ref->real_root) &&
is_fstree(generic_ref->tree_ref.owning_root) &&
!generic_ref->skip_qgroup) { !generic_ref->skip_qgroup) {
record = kzalloc(sizeof(*record), GFP_NOFS); record = kzalloc(sizeof(*record), GFP_NOFS);
if (!record) { if (!record) {
...@@ -1027,8 +1025,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, ...@@ -1027,8 +1025,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
} }
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
is_fstree(ref_root) &&
is_fstree(generic_ref->real_root) &&
!generic_ref->skip_qgroup) { !generic_ref->skip_qgroup) {
record = kzalloc(sizeof(*record), GFP_NOFS); record = kzalloc(sizeof(*record), GFP_NOFS);
if (!record) { if (!record) {
......
...@@ -279,6 +279,12 @@ static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, ...@@ -279,6 +279,12 @@ static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref,
generic_ref->tree_ref.level = level; generic_ref->tree_ref.level = level;
generic_ref->tree_ref.owning_root = root; generic_ref->tree_ref.owning_root = root;
generic_ref->type = BTRFS_REF_METADATA; generic_ref->type = BTRFS_REF_METADATA;
if (skip_qgroup || !(is_fstree(root) &&
(!mod_root || is_fstree(mod_root))))
generic_ref->skip_qgroup = true;
else
generic_ref->skip_qgroup = false;
} }
static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref, static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref,
...@@ -292,6 +298,11 @@ static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref, ...@@ -292,6 +298,11 @@ static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref,
generic_ref->data_ref.ino = ino; generic_ref->data_ref.ino = ino;
generic_ref->data_ref.offset = offset; generic_ref->data_ref.offset = offset;
generic_ref->type = BTRFS_REF_DATA; generic_ref->type = BTRFS_REF_DATA;
if (skip_qgroup || !(is_fstree(ref_root) &&
(!mod_root || is_fstree(mod_root))))
generic_ref->skip_qgroup = true;
else
generic_ref->skip_qgroup = false;
} }
static inline struct btrfs_delayed_extent_op * static inline struct btrfs_delayed_extent_op *
......
...@@ -2437,11 +2437,9 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2437,11 +2437,9 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
key.offset -= btrfs_file_extent_offset(buf, fi); key.offset -= btrfs_file_extent_offset(buf, fi);
btrfs_init_generic_ref(&generic_ref, action, bytenr, btrfs_init_generic_ref(&generic_ref, action, bytenr,
num_bytes, parent); num_bytes, parent);
generic_ref.real_root = root->root_key.objectid;
btrfs_init_data_ref(&generic_ref, ref_root, key.objectid, btrfs_init_data_ref(&generic_ref, ref_root, key.objectid,
key.offset, root->root_key.objectid, key.offset, root->root_key.objectid,
for_reloc); for_reloc);
generic_ref.skip_qgroup = for_reloc;
if (inc) if (inc)
ret = btrfs_inc_extent_ref(trans, &generic_ref); ret = btrfs_inc_extent_ref(trans, &generic_ref);
else else
...@@ -2453,10 +2451,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2453,10 +2451,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
num_bytes = fs_info->nodesize; num_bytes = fs_info->nodesize;
btrfs_init_generic_ref(&generic_ref, action, bytenr, btrfs_init_generic_ref(&generic_ref, action, bytenr,
num_bytes, parent); num_bytes, parent);
generic_ref.real_root = root->root_key.objectid;
btrfs_init_tree_ref(&generic_ref, level - 1, ref_root, btrfs_init_tree_ref(&generic_ref, level - 1, ref_root,
root->root_key.objectid, for_reloc); root->root_key.objectid, for_reloc);
generic_ref.skip_qgroup = for_reloc;
if (inc) if (inc)
ret = btrfs_inc_extent_ref(trans, &generic_ref); ret = btrfs_inc_extent_ref(trans, &generic_ref);
else else
...@@ -4936,7 +4932,6 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, ...@@ -4936,7 +4932,6 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT, btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
ins.objectid, ins.offset, parent); ins.objectid, ins.offset, parent);
generic_ref.real_root = root->root_key.objectid;
btrfs_init_tree_ref(&generic_ref, level, root_objectid, btrfs_init_tree_ref(&generic_ref, level, root_objectid,
root->root_key.objectid, false); root->root_key.objectid, false);
btrfs_ref_tree_mod(fs_info, &generic_ref); btrfs_ref_tree_mod(fs_info, &generic_ref);
......
...@@ -4919,7 +4919,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4919,7 +4919,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF,
extent_start, extent_num_bytes, 0); extent_start, extent_num_bytes, 0);
ref.real_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
ino, extent_offset, ino, extent_offset,
root->root_key.objectid, false); root->root_key.objectid, false);
......
...@@ -1146,7 +1146,6 @@ int replace_file_extents(struct btrfs_trans_handle *trans, ...@@ -1146,7 +1146,6 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
key.offset -= btrfs_file_extent_offset(leaf, fi); key.offset -= btrfs_file_extent_offset(leaf, fi);
btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
num_bytes, parent); num_bytes, parent);
ref.real_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
key.objectid, key.offset, key.objectid, key.offset,
root->root_key.objectid, false); root->root_key.objectid, false);
...@@ -1158,7 +1157,6 @@ int replace_file_extents(struct btrfs_trans_handle *trans, ...@@ -1158,7 +1157,6 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr, btrfs_init_generic_ref(&ref, BTRFS_DROP_DELAYED_REF, bytenr,
num_bytes, parent); num_bytes, parent);
ref.real_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), btrfs_init_data_ref(&ref, btrfs_header_owner(leaf),
key.objectid, key.offset, key.objectid, key.offset,
root->root_key.objectid, false); root->root_key.objectid, false);
...@@ -1370,7 +1368,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1370,7 +1368,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, old_bytenr, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, old_bytenr,
blocksize, path->nodes[level]->start); blocksize, path->nodes[level]->start);
ref.skip_qgroup = true;
btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid,
0, true); 0, true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
...@@ -1380,7 +1377,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1380,7 +1377,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
} }
btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, new_bytenr,
blocksize, 0); blocksize, 0);
ref.skip_qgroup = true;
btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, 0, btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, 0,
true); true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
...@@ -1393,7 +1389,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1393,7 +1389,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
blocksize, path->nodes[level]->start); blocksize, path->nodes[level]->start);
btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid,
0, true); 0, true);
ref.skip_qgroup = true;
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -1404,7 +1399,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1404,7 +1399,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
blocksize, 0); blocksize, 0);
btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid,
0, true); 0, true);
ref.skip_qgroup = true;
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -2480,7 +2474,6 @@ static int do_relocation(struct btrfs_trans_handle *trans, ...@@ -2480,7 +2474,6 @@ static int do_relocation(struct btrfs_trans_handle *trans,
btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF, btrfs_init_generic_ref(&ref, BTRFS_ADD_DELAYED_REF,
node->eb->start, blocksize, node->eb->start, blocksize,
upper->eb->start); upper->eb->start);
ref.real_root = root->root_key.objectid;
btrfs_init_tree_ref(&ref, node->level, btrfs_init_tree_ref(&ref, node->level,
btrfs_header_owner(upper->eb), btrfs_header_owner(upper->eb),
root->root_key.objectid, false); root->root_key.objectid, false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册