Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243162
b: refs/heads/master
c: 240f62c
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason authored and root committed Mar 28, 2011
1 parent 98a618f commit 855c2de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c0da7aa1a2d8fcafe271a7077599253c8ed94bb2
refs/heads/master: 240f62c8756df285da11469259b3900f32883168
27 changes: 8 additions & 19 deletions trunk/fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ noinline void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p)
struct extent_buffer *btrfs_root_node(struct btrfs_root *root)
{
struct extent_buffer *eb;
spin_lock(&root->node_lock);
eb = root->node;

rcu_read_lock();
eb = rcu_dereference(root->node);
extent_buffer_get(eb);
spin_unlock(&root->node_lock);
rcu_read_unlock();
return eb;
}

Expand All @@ -165,14 +166,8 @@ struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
while (1) {
eb = btrfs_root_node(root);
btrfs_tree_lock(eb);

spin_lock(&root->node_lock);
if (eb == root->node) {
spin_unlock(&root->node_lock);
if (eb == root->node)
break;
}
spin_unlock(&root->node_lock);

btrfs_tree_unlock(eb);
free_extent_buffer(eb);
}
Expand Down Expand Up @@ -458,10 +453,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
else
parent_start = 0;

spin_lock(&root->node_lock);
root->node = cow;
extent_buffer_get(cow);
spin_unlock(&root->node_lock);
rcu_assign_pointer(root->node, cow);

btrfs_free_tree_block(trans, root, buf, parent_start,
last_ref);
Expand Down Expand Up @@ -930,9 +923,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
goto enospc;
}

spin_lock(&root->node_lock);
root->node = child;
spin_unlock(&root->node_lock);
rcu_assign_pointer(root->node, child);

add_root_to_dirty_list(root);
btrfs_tree_unlock(child);
Expand Down Expand Up @@ -2007,10 +1998,8 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,

btrfs_mark_buffer_dirty(c);

spin_lock(&root->node_lock);
old = root->node;
root->node = c;
spin_unlock(&root->node_lock);
rcu_assign_pointer(root->node, c);

/* the super has an extra ref to root->node */
free_extent_buffer(old);
Expand Down

0 comments on commit 855c2de

Please sign in to comment.