提交 67439dad 编写于 作者: D David Sterba

btrfs: opencode extent_buffer_get

The helper is trivial and we can understand what the atomic_inc on
something named refs does.
Reviewed-by: NJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: NAnand Jain <anand.jain@oracle.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 f7bddf1e
...@@ -1100,7 +1100,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, ...@@ -1100,7 +1100,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV)
parent_start = buf->start; parent_start = buf->start;
extent_buffer_get(cow); atomic_inc(&cow->refs);
ret = tree_mod_log_insert_root(root->node, cow, 1); ret = tree_mod_log_insert_root(root->node, cow, 1);
BUG_ON(ret < 0); BUG_ON(ret < 0);
rcu_assign_pointer(root->node, cow); rcu_assign_pointer(root->node, cow);
...@@ -2011,7 +2011,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, ...@@ -2011,7 +2011,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
/* update the path */ /* update the path */
if (left) { if (left) {
if (btrfs_header_nritems(left) > orig_slot) { if (btrfs_header_nritems(left) > orig_slot) {
extent_buffer_get(left); atomic_inc(&left->refs);
/* left was locked after cow */ /* left was locked after cow */
path->nodes[level] = left; path->nodes[level] = left;
path->slots[level + 1] -= 1; path->slots[level + 1] -= 1;
...@@ -2601,7 +2601,7 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root, ...@@ -2601,7 +2601,7 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root,
} else { } else {
b = root->commit_root; b = root->commit_root;
extent_buffer_get(b); atomic_inc(&b->refs);
} }
level = btrfs_header_level(b); level = btrfs_header_level(b);
/* /*
...@@ -3375,7 +3375,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, ...@@ -3375,7 +3375,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,
free_extent_buffer(old); free_extent_buffer(old);
add_root_to_dirty_list(root); add_root_to_dirty_list(root);
extent_buffer_get(c); atomic_inc(&c->refs);
path->nodes[level] = c; path->nodes[level] = c;
path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING; path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
path->slots[level] = 0; path->slots[level] = 0;
...@@ -4908,7 +4908,7 @@ static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans, ...@@ -4908,7 +4908,7 @@ static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans,
root_sub_used(root, leaf->len); root_sub_used(root, leaf->len);
extent_buffer_get(leaf); atomic_inc(&leaf->refs);
btrfs_free_tree_block(trans, root, leaf, 0, 1); btrfs_free_tree_block(trans, root, leaf, 0, 1);
free_extent_buffer_stale(leaf); free_extent_buffer_stale(leaf);
} }
...@@ -4989,7 +4989,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, ...@@ -4989,7 +4989,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
* for possible call to del_ptr below * for possible call to del_ptr below
*/ */
slot = path->slots[1]; slot = path->slots[1];
extent_buffer_get(leaf); atomic_inc(&leaf->refs);
btrfs_set_path_blocking(path); btrfs_set_path_blocking(path);
wret = push_leaf_left(trans, root, path, 1, 1, wret = push_leaf_left(trans, root, path, 1, 1,
......
...@@ -610,7 +610,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -610,7 +610,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
/* the pending IO might have been the only thing that kept this buffer /* the pending IO might have been the only thing that kept this buffer
* in memory. Make sure we have a ref for all this other checks * in memory. Make sure we have a ref for all this other checks
*/ */
extent_buffer_get(eb); atomic_inc(&eb->refs);
reads_done = atomic_dec_and_test(&eb->io_pages); reads_done = atomic_dec_and_test(&eb->io_pages);
if (!reads_done) if (!reads_done)
......
...@@ -5436,7 +5436,7 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans, ...@@ -5436,7 +5436,7 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
btrfs_assert_tree_locked(parent); btrfs_assert_tree_locked(parent);
parent_level = btrfs_header_level(parent); parent_level = btrfs_header_level(parent);
extent_buffer_get(parent); atomic_inc(&parent->refs);
path->nodes[parent_level] = parent; path->nodes[parent_level] = parent;
path->slots[parent_level] = btrfs_header_nritems(parent); path->slots[parent_level] = btrfs_header_nritems(parent);
......
...@@ -230,11 +230,6 @@ static inline int num_extent_pages(const struct extent_buffer *eb) ...@@ -230,11 +230,6 @@ static inline int num_extent_pages(const struct extent_buffer *eb)
(eb->start >> PAGE_SHIFT); (eb->start >> PAGE_SHIFT);
} }
static inline void extent_buffer_get(struct extent_buffer *eb)
{
atomic_inc(&eb->refs);
}
static inline int extent_buffer_uptodate(struct extent_buffer *eb) static inline int extent_buffer_uptodate(struct extent_buffer *eb)
{ {
return test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); return test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
......
...@@ -1811,7 +1811,7 @@ static int qgroup_trace_extent_swap(struct btrfs_trans_handle* trans, ...@@ -1811,7 +1811,7 @@ static int qgroup_trace_extent_swap(struct btrfs_trans_handle* trans,
btrfs_item_key_to_cpu(dst_path->nodes[dst_level], &key, 0); btrfs_item_key_to_cpu(dst_path->nodes[dst_level], &key, 0);
/* For src_path */ /* For src_path */
extent_buffer_get(src_eb); atomic_inc(&src_eb->refs);
src_path->nodes[root_level] = src_eb; src_path->nodes[root_level] = src_eb;
src_path->slots[root_level] = dst_path->slots[root_level]; src_path->slots[root_level] = dst_path->slots[root_level];
src_path->locks[root_level] = 0; src_path->locks[root_level] = 0;
...@@ -2067,7 +2067,7 @@ static int qgroup_trace_subtree_swap(struct btrfs_trans_handle *trans, ...@@ -2067,7 +2067,7 @@ static int qgroup_trace_subtree_swap(struct btrfs_trans_handle *trans,
goto out; goto out;
} }
/* For dst_path */ /* For dst_path */
extent_buffer_get(dst_eb); atomic_inc(&dst_eb->refs);
dst_path->nodes[level] = dst_eb; dst_path->nodes[level] = dst_eb;
dst_path->slots[level] = 0; dst_path->slots[level] = 0;
dst_path->locks[level] = 0; dst_path->locks[level] = 0;
...@@ -2126,7 +2126,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans, ...@@ -2126,7 +2126,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
* walk back up the tree (adjusting slot pointers as we go) * walk back up the tree (adjusting slot pointers as we go)
* and restart the search process. * and restart the search process.
*/ */
extent_buffer_get(root_eb); /* For path */ atomic_inc(&root_eb->refs); /* For path */
path->nodes[root_level] = root_eb; path->nodes[root_level] = root_eb;
path->slots[root_level] = 0; path->slots[root_level] = 0;
path->locks[root_level] = 0; /* so release_path doesn't try to unlock */ path->locks[root_level] = 0; /* so release_path doesn't try to unlock */
......
...@@ -2246,7 +2246,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2246,7 +2246,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) { if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
level = btrfs_root_level(root_item); level = btrfs_root_level(root_item);
extent_buffer_get(reloc_root->node); atomic_inc(&reloc_root->node->refs);
path->nodes[level] = reloc_root->node; path->nodes[level] = reloc_root->node;
path->slots[level] = 0; path->slots[level] = 0;
} else { } else {
...@@ -4688,7 +4688,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, ...@@ -4688,7 +4688,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
node->new_bytenr != buf->start); node->new_bytenr != buf->start);
drop_node_buffer(node); drop_node_buffer(node);
extent_buffer_get(cow); atomic_inc(&cow->refs);
node->eb = cow; node->eb = cow;
node->new_bytenr = cow->start; node->new_bytenr = cow->start;
......
...@@ -2851,7 +2851,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, ...@@ -2851,7 +2851,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
level = btrfs_header_level(log->node); level = btrfs_header_level(log->node);
orig_level = level; orig_level = level;
path->nodes[level] = log->node; path->nodes[level] = log->node;
extent_buffer_get(log->node); atomic_inc(&log->node->refs);
path->slots[level] = 0; path->slots[level] = 0;
while (1) { while (1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册