linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim
@ 2022-03-03  0:38 Niels Dossche
  2022-03-03 11:24 ` Johannes Thumshirn
  2022-03-04 13:46 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Niels Dossche @ 2022-03-03  0:38 UTC (permalink / raw)
  To: linux-btrfs
  Cc: Chris Mason, Josef Bacik, David Sterba, Niels Dossche,
	Johannes Thumshirn

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.

Suggested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---

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(+)

diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 294242c194d8..3122aad03e20 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -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)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim
  2022-03-03  0:38 [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim Niels Dossche
@ 2022-03-03 11:24 ` Johannes Thumshirn
  2022-03-04 13:46 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2022-03-03 11:24 UTC (permalink / raw)
  To: Niels Dossche, linux-btrfs; +Cc: Chris Mason, Josef Bacik, David Sterba

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim
  2022-03-03  0:38 [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim Niels Dossche
  2022-03-03 11:24 ` Johannes Thumshirn
@ 2022-03-04 13:46 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2022-03-04 13:46 UTC (permalink / raw)
  To: Niels Dossche
  Cc: linux-btrfs, Chris Mason, Josef Bacik, David Sterba, Johannes Thumshirn

On Thu, Mar 03, 2022 at 01:38:39AM +0100, Niels Dossche wrote:
> 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.
> 
> Suggested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-04 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03  0:38 [PATCH v2] btrfs: add lockdep_assert_held to need_preemptive_reclaim Niels Dossche
2022-03-03 11:24 ` Johannes Thumshirn
2022-03-04 13:46 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).