Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.7 09/26] btrfs: add and use helper to check if block group is used
       [not found] <20240229154851.2849367-1-sashal@kernel.org>
@ 2024-02-29 15:48 ` Sasha Levin
  2024-02-29 15:52   ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2024-02-29 15:48 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Filipe Manana, Johannes Thumshirn, Josef Bacik, Boris Burkov,
	David Sterba, Sasha Levin, clm, linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit 1693d5442c458ae8d5b0d58463b873cd879569ed ]

Add a helper function to determine if a block group is being used and make
use of it at btrfs_delete_unused_bgs(). This helper will also be used in
future code changes.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/block-group.c | 3 +--
 fs/btrfs/block-group.h | 7 +++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 6e5dc68ff661f..0dd979c4db037 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1524,8 +1524,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
 		}
 
 		spin_lock(&block_group->lock);
-		if (block_group->reserved || block_group->pinned ||
-		    block_group->used || block_group->ro ||
+		if (btrfs_is_block_group_used(block_group) || block_group->ro ||
 		    list_is_singular(&block_group->list)) {
 			/*
 			 * We want to bail if we made new allocations or have
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index 2bdbcb834f954..089979981e4aa 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -255,6 +255,13 @@ static inline u64 btrfs_block_group_end(struct btrfs_block_group *block_group)
 	return (block_group->start + block_group->length);
 }
 
+static inline bool btrfs_is_block_group_used(const struct btrfs_block_group *bg)
+{
+	lockdep_assert_held(&bg->lock);
+
+	return (bg->used > 0 || bg->reserved > 0 || bg->pinned > 0);
+}
+
 static inline bool btrfs_is_block_group_data_only(
 					struct btrfs_block_group *block_group)
 {
-- 
2.43.0


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

* Re: [PATCH AUTOSEL 6.7 09/26] btrfs: add and use helper to check if block group is used
  2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 09/26] btrfs: add and use helper to check if block group is used Sasha Levin
@ 2024-02-29 15:52   ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2024-02-29 15:52 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Filipe Manana, Johannes Thumshirn,
	Josef Bacik, Boris Burkov, David Sterba, clm, linux-btrfs

On Thu, Feb 29, 2024 at 10:48:28AM -0500, Sasha Levin wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> [ Upstream commit 1693d5442c458ae8d5b0d58463b873cd879569ed ]
> 
> Add a helper function to determine if a block group is being used and make
> use of it at btrfs_delete_unused_bgs(). This helper will also be used in
> future code changes.

The patch is not a prerequisite for any other stable patch, right? Then
please drop if from all versions, it's a simple cleanup.

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

end of thread, other threads:[~2024-02-29 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20240229154851.2849367-1-sashal@kernel.org>
2024-02-29 15:48 ` [PATCH AUTOSEL 6.7 09/26] btrfs: add and use helper to check if block group is used Sasha Levin
2024-02-29 15:52   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox