2024-03-25 04:07:43

by Sasha Levin

[permalink] [raw]
Subject: [PATCH 5.10 005/238] btrfs: add and use helper to check if block group is used

From: Filipe Manana <[email protected]>

[ 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 <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Reviewed-by: Boris Burkov <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
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 c4e3c1a5de059..9a7c7e0f7c233 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1393,8 +1393,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 4c7614346f724..0d02b75f9e7e3 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -196,6 +196,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



2024-03-26 00:40:12

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH 5.10 005/238] btrfs: add and use helper to check if block group is used

On Sun, Mar 24, 2024 at 07:36:33PM -0400, Sasha Levin wrote:
> From: Filipe Manana <[email protected]>
>
> [ 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 <[email protected]>
> Reviewed-by: Josef Bacik <[email protected]>
> Reviewed-by: Boris Burkov <[email protected]>
> Signed-off-by: Filipe Manana <[email protected]>
> Reviewed-by: David Sterba <[email protected]>
> Signed-off-by: David Sterba <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>

Please drop this patch from all stable branches unless it's a
prerequisite for some other patch. This is clearly a cleanup.

2024-03-28 10:42:45

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 5.10 005/238] btrfs: add and use helper to check if block group is used

Hi!

> > From: Filipe Manana <[email protected]>
> >
> > [ 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 <[email protected]>
> > Reviewed-by: Josef Bacik <[email protected]>
> > Reviewed-by: Boris Burkov <[email protected]>
> > Signed-off-by: Filipe Manana <[email protected]>
> > Reviewed-by: David Sterba <[email protected]>
> > Signed-off-by: David Sterba <[email protected]>
> > Signed-off-by: Sasha Levin <[email protected]>
>
> Please drop this patch from all stable branches unless it's a
> prerequisite for some other patch. This is clearly a cleanup.

This was reported multiple times, and you have even said you have
dropped the patch. What went wrong here?

Best regards,
Pavel

Date: Mon, 18 Mar 2024 10:18:36 -0400
From: Sasha Levin <[email protected]>
Subject: Re: [PATCH AUTOSEL 5.10 1/7] btrfs: add and use helper to check if block group is used

On Mon, Mar 11, 2024 at 10:05:40PM +0100, David Sterba wrote:
> On Mon, Mar 11, 2024 at 10:00:43PM +0100, Pavel Machek wrote:
> > Hi!
> >
> > > From: Filipe Manana <[email protected]>
> > >
> > > [ 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.
> >
> > Does not fix a bug and does not seem to be preparation for anything,
> > so probably should not be here.
>
> Agreed, this patch does not belong to stable and I objected in
> https://lore.kernel.org/all/[email protected]/
>
> for version 6.7 and all other stable versions.

Dropped, thanks!

--
Thanks,
Sasha

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


Attachments:
(No filename) (2.05 kB)
signature.asc (201.00 B)
Download all attachments