btrfs: Fix a bug in try_release_subpage_extent_buffer()
PATCH 1/1 btrfs: Fix a bug in try_release_subpage_extent_buffer()
Call rcu_read_lock() before exiting the loop in try_release_subpage_extent_buffer() because there is a rcu_read_unlock() call past the loop. This has been detected by the Clang thread-safety analyzer. Compile-tested only.
--- fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent_io.c +1 -0
@@ -4507,6 +4507,7 @@ static int try_release_subpage_extent_buffer(struct folio *folio)*/ if (!test_and_clear_bit (EXTENT_BUFFER_TREE_REF , &eb->bflags)) {spin_unlock (&eb->refs_lock); +rcu_read_lock ();break ; }
Quoted 5 lines · Bart Van Assche
Call
rcu_read_lock()before exiting the loop intry_release_subpage_extent_buffer()because there is arcu_read_unlock()call past the loop. This has been detected by the Clang thread-safety analyzer. Compile-tested only.
Quoted 8 lines
Cc Boris Burkov <[email protected]>Cc Qu Wenruo <[email protected]>Cc Leo Martins <[email protected]>Cc Chris Mason <[email protected]>Cc David Sterba <[email protected]>Fixes ad580dfa388f ("btrfs: fix subpage deadlock in try_release_subpage_extent_buffer()")Signed-off-by Bart Van Assche <[email protected]>
Minor modification to follow our standard (e.g. no upper case after "btrfs: ", remove overblown CCs), and pushed to for-next branch.
Thanks,
Qu
Quoted 16 lines
--- fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+)fs/btrfs/extent_io.c +1
-0@@ -4507,6 +4507,7 @@ static int try_release_subpage_extent_buffer(struct folio *folio)*/ if (!test_and_clear_bit (EXTENT_BUFFER_TREE_REF , &eb->bflags)) {spin_unlock (&eb->refs_lock); +rcu_read_lock ();break ; }
Quoted 11 lines · Bart Van Assche
Call
rcu_read_lock()before exiting the loop intry_release_subpage_extent_buffer()because there is arcu_read_unlock()call past the loop. This has been detected by the Clang thread-safety analyzer. Compile-tested only.Cc Boris Burkov <[email protected]>Cc Qu Wenruo <[email protected]>Cc Leo Martins <[email protected]>Cc Chris Mason <[email protected]>Cc David Sterba <[email protected]>
LGTM, thank you.
Quoted 18 lines
Fixes ad580dfa388f ("btrfs: fix subpage deadlock in try_release_subpage_extent_buffer()")Signed-off-by Bart Van Assche <[email protected]>--- fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+)fs/btrfs/extent_io.c +1
-0@@ -4507,6 +4507,7 @@ static int try_release_subpage_extent_buffer(struct folio *folio)*/ if (!test_and_clear_bit (EXTENT_BUFFER_TREE_REF , &eb->bflags)) {spin_unlock (&eb->refs_lock); +rcu_read_lock ();break ; }