btrfs: add lockdep_assert_held to need_preemptive_reclaim
PATCH v2 1/1 btrfs: add lockdep_assert_held to need_preemptive_reclaim
In a previous patch ("btrfs: extend locking to all space_info members accesses") the locking for the space_info members was extended in btrfs_preempt_reclaim_metadata_space because not all the member accesses that needed locks were actually locked (bytes_pinned et al).
It was then suggested to also add a call to lockdep_assert_held to need_preemptive_reclaim. This function also works with space_info members. As of now, it has only two callsites which both hold the lock. It was suggested to add this to be better safe than sorry regarding the locking on bytes_pinned et al, in order to prevent similar issues in the future.
---
Changes since v1:
* Made commit message clearer
* Changed initialization of thresh back to the original way
fs/btrfs/space-info.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/space-info.c +2 -0
@@ -737,6 +737,8 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,u64 thresh =div_factor_fine (space_info->total_bytes,90 );u64 used; +lockdep_assert_held (&space_info->lock); +/* If we're just plain full then async reclaim just slows us down. */ if ((space_info->bytes_used + space_info->bytes_reserved + global_rsv_size) >= thresh)
Signature · 1 line
2.35.1
Looks good,
Quoted 12 lines · Niels Dossche
In a previous patch ("btrfs: extend locking to all
space_infomembers accesses") the locking for thespace_infomembers was extended inbtrfs_preempt_reclaim_metadata_spacebecause not all the member accesses that needed locks were actually locked (bytes_pinnedet al).It was then suggested to also add a call to
lockdep_assert_heldtoneed_preemptive_reclaim. This function also works withspace_infomembers. As of now, it has only two callsites which both hold the lock. It was suggested to add this to be better safe than sorry regarding the locking onbytes_pinnedet al, in order to prevent similar issues in the future.
Quoted 2 lines
Suggested-by Johannes Thumshirn <[email protected]>Signed-off-by Niels Dossche <[email protected]>
Added to misc-next, thanks.