Skip to content

Commit 97e8663

Browse files
Zygo Blaxellkdave
authored andcommitted
btrfs: don't set lock_owner when locking extent buffer for reading
In 196d59a "btrfs: switch extent buffer tree lock to rw_semaphore" the functions for tree read locking were rewritten, and in the process the read lock functions started setting eb->lock_owner = current->pid. Previously lock_owner was only set in tree write lock functions. Read locks are shared, so they don't have exclusive ownership of the underlying object, so setting lock_owner to any single value for a read lock makes no sense. It's mostly harmless because write locks and read locks are mutually exclusive, and none of the existing code in btrfs (btrfs_init_new_buffer and print_eb_refs_lock) cares what nonsense is written in lock_owner when no writer is holding the lock. KCSAN does care, and will complain about the data race incessantly. Remove the assignments in the read lock functions because they're useless noise. Fixes: 196d59a ("btrfs: switch extent buffer tree lock to rw_semaphore") CC: [email protected] # 5.15+ Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Zygo Blaxell <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 19ab78c commit 97e8663

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

fs/btrfs/locking.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void __btrfs_tree_read_lock(struct extent_buffer *eb, enum btrfs_lock_nesting ne
4545
start_ns = ktime_get_ns();
4646

4747
down_read_nested(&eb->lock, nest);
48-
eb->lock_owner = current->pid;
4948
trace_btrfs_tree_read_lock(eb, start_ns);
5049
}
5150

@@ -62,7 +61,6 @@ void btrfs_tree_read_lock(struct extent_buffer *eb)
6261
int btrfs_try_tree_read_lock(struct extent_buffer *eb)
6362
{
6463
if (down_read_trylock(&eb->lock)) {
65-
eb->lock_owner = current->pid;
6664
trace_btrfs_try_tree_read_lock(eb);
6765
return 1;
6866
}
@@ -90,7 +88,6 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
9088
void btrfs_tree_read_unlock(struct extent_buffer *eb)
9189
{
9290
trace_btrfs_tree_read_unlock(eb);
93-
eb->lock_owner = 0;
9491
up_read(&eb->lock);
9592
}
9693

0 commit comments

Comments
 (0)