From: Qu Wenruo <wqu@suse.com>
To: Filipe Manana <fdmanana@kernel.org>, Yuwei Han <hrx@bupt.moe>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs-progs: convert: prevent data chunks to go beyond device size
Date: Fri, 31 Oct 2025 07:02:00 +1030 [thread overview]
Message-ID: <bf9bf126-9bfb-4fc5-9494-fd71cff83049@suse.com> (raw)
In-Reply-To: <CAL3q7H66j2NczLbXj6ZJmy_fu1uPHMHfG_Xit-Kgw7_V+0VSdw@mail.gmail.com>
在 2025/10/30 23:54, Filipe Manana 写道:
> On Thu, Oct 30, 2025 at 4:17 AM Yuwei Han <hrx@bupt.moe> wrote:
>>
>>
>>
>> 在 2025/10/25 07:30, Qu Wenruo 写道:
>>> [BUG]
>>> There is a bug report that kernel is rejecting a converted btrfs that
>>> has dev extents beyond device boundary.
>>>
>>> The invovled device extent is at 999627694980, length is 30924800,
>>> meanwhile the device is 999658557440.
>>>
>>> The device is size not aligned to 64K, meanwhile the dev extent is
>>> aligned to 64K.
>>>
>>> [CAUSE]
>>> For converted btrfs, the source fs has all its freedom to choose its
>>> size, as long as it's aligned to the fs block size.
>>>
>>> So when adding new converted data block groups we need to do extra
>>> alignment, but in make_convert_data_block_groups() we are rounding up
>>> the end, which can exceed the device size.
>>>
>>> [FIX]
>>> Instead of rounding up to stripe boundary, rounding it down to prevent
>>> going beyond the device boundary.
>>>
>> Reported-by: Andieqqq <zeige265975@gmail.com>
>
> While at it, also add a Link tag pointing to the report....
Sorry, no public report available.
I got a lot of private reports forwarded from Yuwei, as a lot of people
behind the Great Firewall are not used to github/mail to report a bug.
And this is one example of such private report.
Thanks,
Qu
>
>> Signed-off-by: Qu Wenruo
>> <wqu@suse.com>
>>> ---
>>> convert/main.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/convert/main.c b/convert/main.c
>>> index e279e3d40c5f..5c40c08ddd72 100644
>>> --- a/convert/main.c
>>> +++ b/convert/main.c
>>> @@ -948,8 +948,8 @@ static int make_convert_data_block_groups(struct btrfs_trans_handle *trans,
>>> u64 cur_backup = cur;
>>>
>>> len = min(max_chunk_size,
>>> - round_up(cache->start + cache->size,
>>> - BTRFS_STRIPE_LEN) - cur);
>>> + round_down(cache->start + cache->size,
>>> + BTRFS_STRIPE_LEN) - cur);
>>> ret = btrfs_alloc_data_chunk(trans, fs_info, &cur_backup, len);
>>> if (ret < 0)
>>> break;
>>
next prev parent reply other threads:[~2025-10-30 20:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 23:30 [PATCH] btrfs-progs: convert: prevent data chunks to go beyond device size Qu Wenruo
2025-10-30 4:16 ` Yuwei Han
2025-10-30 13:24 ` Filipe Manana
2025-10-30 20:32 ` Qu Wenruo [this message]
2025-10-31 2:47 ` David Sterba
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=bf9bf126-9bfb-4fc5-9494-fd71cff83049@suse.com \
--to=wqu@suse.com \
--cc=fdmanana@kernel.org \
--cc=hrx@bupt.moe \
--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