Skip to content

Commit b9447ef

Browse files
committed
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>
1 parent 4e06bdd commit b9447ef

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎fs/btrfs/ctree.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
277277
if (*cow_ret == buf)
278278
unlock_orig = 1;
279279

280-
WARN_ON(!btrfs_tree_locked(buf));
280+
btrfs_assert_tree_locked(buf);
281281

282282
if (parent)
283283
parent_start = parent->start;
@@ -2365,7 +2365,7 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
23652365
if (slot >= btrfs_header_nritems(upper) - 1)
23662366
return 1;
23672367

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

23702370
right = read_node_slot(root, upper, slot + 1);
23712371
btrfs_tree_lock(right);
@@ -2562,7 +2562,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
25622562
if (right_nritems == 0)
25632563
return 1;
25642564

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

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

41024102
next = read_node_slot(root, c, slot);
41034103
if (!path->skip_locking) {
4104-
WARN_ON(!btrfs_tree_locked(c));
4104+
btrfs_assert_tree_locked(c);
41054105
btrfs_tree_lock(next);
41064106
btrfs_set_lock_blocking(next);
41074107
}
@@ -4126,7 +4126,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
41264126
reada_for_search(root, path, level, slot, 0);
41274127
next = read_node_slot(root, next, 0);
41284128
if (!path->skip_locking) {
4129-
WARN_ON(!btrfs_tree_locked(path->nodes[level]));
4129+
btrfs_assert_tree_locked(path->nodes[level]);
41304130
btrfs_tree_lock(next);
41314131
btrfs_set_lock_blocking(next);
41324132
}

‎fs/btrfs/disk-io.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
857857
struct inode *btree_inode = root->fs_info->btree_inode;
858858
if (btrfs_header_generation(buf) ==
859859
root->fs_info->running_transaction->transid) {
860-
WARN_ON(!btrfs_tree_locked(buf));
860+
btrfs_assert_tree_locked(buf);
861861

862862
/* ugh, clear_extent_buffer_dirty can be expensive */
863863
btrfs_set_lock_blocking(buf);
@@ -2361,7 +2361,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
23612361

23622362
btrfs_set_lock_blocking(buf);
23632363

2364-
WARN_ON(!btrfs_tree_locked(buf));
2364+
btrfs_assert_tree_locked(buf);
23652365
if (transid != root->fs_info->generation) {
23662366
printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
23672367
"found %llu running %llu\n",

‎fs/btrfs/extent-tree.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4418,13 +4418,13 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
44184418
path = btrfs_alloc_path();
44194419
BUG_ON(!path);
44204420

4421-
BUG_ON(!btrfs_tree_locked(parent));
4421+
btrfs_assert_tree_locked(parent);
44224422
parent_level = btrfs_header_level(parent);
44234423
extent_buffer_get(parent);
44244424
path->nodes[parent_level] = parent;
44254425
path->slots[parent_level] = btrfs_header_nritems(parent);
44264426

4427-
BUG_ON(!btrfs_tree_locked(node));
4427+
btrfs_assert_tree_locked(node);
44284428
level = btrfs_header_level(node);
44294429
extent_buffer_get(node);
44304430
path->nodes[level] = node;

‎fs/btrfs/locking.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ int btrfs_tree_unlock(struct extent_buffer *eb)
220220
return 0;
221221
}
222222

223-
int btrfs_tree_locked(struct extent_buffer *eb)
223+
void btrfs_assert_tree_locked(struct extent_buffer *eb)
224224
{
225-
return test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags) ||
226-
spin_is_locked(&eb->lock);
225+
if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
226+
assert_spin_locked(&eb->lock);
227227
}

‎fs/btrfs/locking.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
int btrfs_tree_lock(struct extent_buffer *eb);
2323
int btrfs_tree_unlock(struct extent_buffer *eb);
24-
int btrfs_tree_locked(struct extent_buffer *eb);
2524

2625
int btrfs_try_tree_lock(struct extent_buffer *eb);
2726
int btrfs_try_spin_lock(struct extent_buffer *eb);
2827

2928
void btrfs_set_lock_blocking(struct extent_buffer *eb);
3029
void btrfs_clear_lock_blocking(struct extent_buffer *eb);
30+
void btrfs_assert_tree_locked(struct extent_buffer *eb);
3131
#endif

0 commit comments

Comments
 (0)