Skip to content

Commit

Permalink
Btrfs: fix spinlock assertions on UP systems
Browse files Browse the repository at this point in the history
btrfs_tree_locked was being used to make sure a given extent_buffer was
properly locked in a few places.  But, it wasn't correct for UP compiled
kernels.

This switches it to using assert_spin_locked instead, and renames it to
btrfs_assert_tree_locked to better reflect how it was really being used.

Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
chrismason-xx committed Mar 9, 2009
1 parent 4e06bdd commit b9447ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
if (*cow_ret == buf)
unlock_orig = 1;

WARN_ON(!btrfs_tree_locked(buf));
btrfs_assert_tree_locked(buf);

if (parent)
parent_start = parent->start;
Expand Down Expand Up @@ -2365,7 +2365,7 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
if (slot >= btrfs_header_nritems(upper) - 1)
return 1;

WARN_ON(!btrfs_tree_locked(path->nodes[1]));
btrfs_assert_tree_locked(path->nodes[1]);

right = read_node_slot(root, upper, slot + 1);
btrfs_tree_lock(right);
Expand Down Expand Up @@ -2562,7 +2562,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
if (right_nritems == 0)
return 1;

WARN_ON(!btrfs_tree_locked(path->nodes[1]));
btrfs_assert_tree_locked(path->nodes[1]);

left = read_node_slot(root, path->nodes[1], slot - 1);
btrfs_tree_lock(left);
Expand Down Expand Up @@ -4101,7 +4101,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)

next = read_node_slot(root, c, slot);
if (!path->skip_locking) {
WARN_ON(!btrfs_tree_locked(c));
btrfs_assert_tree_locked(c);
btrfs_tree_lock(next);
btrfs_set_lock_blocking(next);
}
Expand All @@ -4126,7 +4126,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
reada_for_search(root, path, level, slot, 0);
next = read_node_slot(root, next, 0);
if (!path->skip_locking) {
WARN_ON(!btrfs_tree_locked(path->nodes[level]));
btrfs_assert_tree_locked(path->nodes[level]);
btrfs_tree_lock(next);
btrfs_set_lock_blocking(next);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct inode *btree_inode = root->fs_info->btree_inode;
if (btrfs_header_generation(buf) ==
root->fs_info->running_transaction->transid) {
WARN_ON(!btrfs_tree_locked(buf));
btrfs_assert_tree_locked(buf);

/* ugh, clear_extent_buffer_dirty can be expensive */
btrfs_set_lock_blocking(buf);
Expand Down Expand Up @@ -2361,7 +2361,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)

btrfs_set_lock_blocking(buf);

WARN_ON(!btrfs_tree_locked(buf));
btrfs_assert_tree_locked(buf);
if (transid != root->fs_info->generation) {
printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
"found %llu running %llu\n",
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4418,13 +4418,13 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path();
BUG_ON(!path);

BUG_ON(!btrfs_tree_locked(parent));
btrfs_assert_tree_locked(parent);
parent_level = btrfs_header_level(parent);
extent_buffer_get(parent);
path->nodes[parent_level] = parent;
path->slots[parent_level] = btrfs_header_nritems(parent);

BUG_ON(!btrfs_tree_locked(node));
btrfs_assert_tree_locked(node);
level = btrfs_header_level(node);
extent_buffer_get(node);
path->nodes[level] = node;
Expand Down
6 changes: 3 additions & 3 deletions fs/btrfs/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ int btrfs_tree_unlock(struct extent_buffer *eb)
return 0;
}

int btrfs_tree_locked(struct extent_buffer *eb)
void btrfs_assert_tree_locked(struct extent_buffer *eb)
{
return test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags) ||
spin_is_locked(&eb->lock);
if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
assert_spin_locked(&eb->lock);
}
2 changes: 1 addition & 1 deletion fs/btrfs/locking.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

int btrfs_tree_lock(struct extent_buffer *eb);
int btrfs_tree_unlock(struct extent_buffer *eb);
int btrfs_tree_locked(struct extent_buffer *eb);

int btrfs_try_tree_lock(struct extent_buffer *eb);
int btrfs_try_spin_lock(struct extent_buffer *eb);

void btrfs_set_lock_blocking(struct extent_buffer *eb);
void btrfs_clear_lock_blocking(struct extent_buffer *eb);
void btrfs_assert_tree_locked(struct extent_buffer *eb);
#endif

0 comments on commit b9447ef

Please sign in to comment.