Thread (2 messages) 2 messages, 2 authors, 2021-09-22

Re: [PATCH] btrfs: assert that extent buffers are write locked instead of only locked

From: David Sterba <hidden>
Date: 2021-09-22 19:45:11

On Wed, Sep 22, 2021 at 10:36:45AM +0100, fdmanana@kernel.org wrote:
From: Filipe Manana <redacted>

We currently use lockdep_assert_held() at btrfs_assert_tree_locked(), and
that checks that we hold a lock either in read mode or write mode.

However in all contextes we use btrfs_assert_tree_locked(), we actually
want to check if we are holding a write lock on the extent buffer's rw
semaphore - it would be a bug if in any of those contextes we were holding
a read lock instead.

So change btrfs_assert_tree_locked() to use lockdep_assert_held_write()
instead and, to make it more explicit, rename btrfs_assert_tree_locked()
to btrfs_assert_tree_write_locked(), so that it's clear we want to check
we are holding a write lock.

For now there are no contextes where we want to assert that we must have
a read lock, but in case that is needed in the future, we can add a new
helper function that just calls out lockdep_assert_held_read().

Signed-off-by: Filipe Manana <redacted>
Added to misc-next, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help