public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <Naohiro.Aota@wdc.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/3] btrfs: zoned: fix write time activation failure for metadata block group
Date: Tue, 8 Jul 2025 05:04:35 +0000	[thread overview]
Message-ID: <DB6EQDA4RP4A.2KNYOLWFW6HYR@wdc.com> (raw)
In-Reply-To: <980ce4d7-fa7e-4320-8816-ab22d8021415@kernel.org>

On Mon Jul 7, 2025 at 12:33 PM JST, Damien Le Moal wrote:
> On 7/7/25 11:44 AM, Naohiro Aota wrote:
>> Since commit 13bb483d32ab ("btrfs: zoned: activate metadata block group on
>> write time"), we activate a metadata block group on the write time. If the
>
> on the write time -> at write time
>
>> zone capacity is small enough, we can allocate the entire region before the
>> first write. Then, we hit the btrfs_zoned_bg_is_full() in
>> btrfs_zone_activate() and the activation fails.
>> 
>> For a data block group, we already check the fullness condition in the
>> caller side. And, the fullness check is not necessary for metadata's
>> write-time activation. Replace it with a proper WARN.
>
> I am very confused by this explanation. If the BG is fully allocated before we
> issue the first write, we still need to activate that BG, no ? So why the
> WARN() ? That seems wrong to me. But I may not be understanding your
> explanation, which means you need to clarify it :)

We activate a data block group before the allocation to simplify the
write stage. So, activating a full block group should arise WARN.

OTOH, metadata block group is activated on the write stage. So, it is OK
to have a full block group to be activated. Instead, it is WARN when we
try to activate a partially written (meta_write_pointer != bg->start)
block group.

>
>> 
>> Fixes: 13bb483d32ab ("btrfs: zoned: activate metadata block group on write time")
>> CC: stable@vger.kernel.org # 6.6+
>> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
>> ---
>>  fs/btrfs/zoned.c | 11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>> 
>> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
>> index 6fb4d95412d6..9c354e84ab07 100644
>> --- a/fs/btrfs/zoned.c
>> +++ b/fs/btrfs/zoned.c
>> @@ -2169,10 +2169,13 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
>>  		goto out_unlock;
>>  	}
>>  
>> -	/* No space left */
>> -	if (btrfs_zoned_bg_is_full(block_group)) {
>> -		ret = false;
>> -		goto out_unlock;
>> +	if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) {
>> +		if (WARN_ON_ONCE(btrfs_zoned_bg_is_full(block_group))) {
>> +			ret = false;
>> +			goto out_unlock;
>> +		}
>> +	} else {
>> +		WARN_ON_ONCE(block_group->meta_write_pointer != block_group->start);
>>  	}
>>  
>>  	for (i = 0; i < map->num_stripes; i++) {

  reply	other threads:[~2025-07-08  5:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07  2:44 [PATCH 0/3] btrfs: zoned: limitt active zones to max_open_zones Naohiro Aota
2025-07-07  2:44 ` [PATCH 1/3] btrfs: zoned: do not select metadata BG as finish target Naohiro Aota
2025-07-07  3:29   ` Damien Le Moal
2025-07-07  7:34   ` Johannes Thumshirn
2025-07-07  2:44 ` [PATCH 2/3] btrfs: zoned: fix write time activation failure for metadata block group Naohiro Aota
2025-07-07  3:33   ` Damien Le Moal
2025-07-08  5:04     ` Naohiro Aota [this message]
2025-07-08  5:11       ` Damien Le Moal
2025-07-07  2:44 ` [PATCH 3/3] btrfs: zoned: limit active zones to max_open_zones Naohiro Aota
2025-07-07  3:40   ` Damien Le Moal
2025-07-08  5:16     ` Naohiro Aota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB6EQDA4RP4A.2KNYOLWFW6HYR@wdc.com \
    --to=naohiro.aota@wdc.com \
    --cc=dlemoal@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox