Btrfs: fix spinlock assertions on UP systems
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 <chris.mason@oracle.com>
This commit is contained in:
parent
4e06bdd6cb
commit
b9447ef80b
|
@ -277,7 +277,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
|
||||||
if (*cow_ret == buf)
|
if (*cow_ret == buf)
|
||||||
unlock_orig = 1;
|
unlock_orig = 1;
|
||||||
|
|
||||||
WARN_ON(!btrfs_tree_locked(buf));
|
btrfs_assert_tree_locked(buf);
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
parent_start = parent->start;
|
parent_start = parent->start;
|
||||||
|
@ -2365,7 +2365,7 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||||
if (slot >= btrfs_header_nritems(upper) - 1)
|
if (slot >= btrfs_header_nritems(upper) - 1)
|
||||||
return 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);
|
right = read_node_slot(root, upper, slot + 1);
|
||||||
btrfs_tree_lock(right);
|
btrfs_tree_lock(right);
|
||||||
|
@ -2562,7 +2562,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||||
if (right_nritems == 0)
|
if (right_nritems == 0)
|
||||||
return 1;
|
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);
|
left = read_node_slot(root, path->nodes[1], slot - 1);
|
||||||
btrfs_tree_lock(left);
|
btrfs_tree_lock(left);
|
||||||
|
@ -4101,7 +4101,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
|
|
||||||
next = read_node_slot(root, c, slot);
|
next = read_node_slot(root, c, slot);
|
||||||
if (!path->skip_locking) {
|
if (!path->skip_locking) {
|
||||||
WARN_ON(!btrfs_tree_locked(c));
|
btrfs_assert_tree_locked(c);
|
||||||
btrfs_tree_lock(next);
|
btrfs_tree_lock(next);
|
||||||
btrfs_set_lock_blocking(next);
|
btrfs_set_lock_blocking(next);
|
||||||
}
|
}
|
||||||
|
@ -4126,7 +4126,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
|
||||||
reada_for_search(root, path, level, slot, 0);
|
reada_for_search(root, path, level, slot, 0);
|
||||||
next = read_node_slot(root, next, 0);
|
next = read_node_slot(root, next, 0);
|
||||||
if (!path->skip_locking) {
|
if (!path->skip_locking) {
|
||||||
WARN_ON(!btrfs_tree_locked(path->nodes[level]));
|
btrfs_assert_tree_locked(path->nodes[level]);
|
||||||
btrfs_tree_lock(next);
|
btrfs_tree_lock(next);
|
||||||
btrfs_set_lock_blocking(next);
|
btrfs_set_lock_blocking(next);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
struct inode *btree_inode = root->fs_info->btree_inode;
|
||||||
if (btrfs_header_generation(buf) ==
|
if (btrfs_header_generation(buf) ==
|
||||||
root->fs_info->running_transaction->transid) {
|
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 */
|
/* ugh, clear_extent_buffer_dirty can be expensive */
|
||||||
btrfs_set_lock_blocking(buf);
|
btrfs_set_lock_blocking(buf);
|
||||||
|
@ -2361,7 +2361,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
|
||||||
|
|
||||||
btrfs_set_lock_blocking(buf);
|
btrfs_set_lock_blocking(buf);
|
||||||
|
|
||||||
WARN_ON(!btrfs_tree_locked(buf));
|
btrfs_assert_tree_locked(buf);
|
||||||
if (transid != root->fs_info->generation) {
|
if (transid != root->fs_info->generation) {
|
||||||
printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
|
printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
|
||||||
"found %llu running %llu\n",
|
"found %llu running %llu\n",
|
||||||
|
|
|
@ -4418,13 +4418,13 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
BUG_ON(!path);
|
BUG_ON(!path);
|
||||||
|
|
||||||
BUG_ON(!btrfs_tree_locked(parent));
|
btrfs_assert_tree_locked(parent);
|
||||||
parent_level = btrfs_header_level(parent);
|
parent_level = btrfs_header_level(parent);
|
||||||
extent_buffer_get(parent);
|
extent_buffer_get(parent);
|
||||||
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);
|
||||||
|
|
||||||
BUG_ON(!btrfs_tree_locked(node));
|
btrfs_assert_tree_locked(node);
|
||||||
level = btrfs_header_level(node);
|
level = btrfs_header_level(node);
|
||||||
extent_buffer_get(node);
|
extent_buffer_get(node);
|
||||||
path->nodes[level] = node;
|
path->nodes[level] = node;
|
||||||
|
|
|
@ -220,8 +220,8 @@ int btrfs_tree_unlock(struct extent_buffer *eb)
|
||||||
return 0;
|
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) ||
|
if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
|
||||||
spin_is_locked(&eb->lock);
|
assert_spin_locked(&eb->lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
|
|
||||||
int btrfs_tree_lock(struct extent_buffer *eb);
|
int btrfs_tree_lock(struct extent_buffer *eb);
|
||||||
int btrfs_tree_unlock(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_tree_lock(struct extent_buffer *eb);
|
||||||
int btrfs_try_spin_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_set_lock_blocking(struct extent_buffer *eb);
|
||||||
void btrfs_clear_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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue