From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <dsterba@suse.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 4/4] btrfs: convert: Avoid allocating metadata extent crossing stripe boundary
Date: Sat, 25 Jul 2015 09:18:54 +0800 [thread overview]
Message-ID: <55B2E3FE.5060706@cn.fujitsu.com> (raw)
In-Reply-To: <20150724123447.GX6306@twin.jikos.cz>
David Sterba wrote on 2015/07/24 14:34 +0200:
> On Thu, Jul 23, 2015 at 05:18:10PM +0800, Qu Wenruo wrote:
>> @@ -246,6 +247,14 @@ static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
>> continue;
>> }
>>
>> + if (metadata) {
>> + BUG_ON(num_bytes != root->nodesize);
>
> This caught my attention and looking at possible values of num_bytes,
> this can crash:
>
> 1291 for (last_byte = 0; last_byte < first_free; last_byte += sectorsize) {
> 1292 ret = custom_alloc_extent(root, sectorsize, 0, &key, 0);
>
> where sectorsize == num_bytes.
For that case, the last 0 means that's a data block,
and won't comes to the BUG_ON, as it is only designed for metadata.
And for metadata allocation, the size will only be nodes/leafsize
Thanks,
Qu
>
>> + if (check_crossing_stripes(start, num_bytes)) {
>> + last = round_down(start + num_bytes,
>> + BTRFS_STRIPE_LEN);
>> + continue;
>> + }
>> + }
>> clear_extent_dirty(&root->fs_info->free_space_cache,
>> start, start + num_bytes - 1, 0);
>>
>> @@ -1280,7 +1289,7 @@ static int create_ext2_image(struct btrfs_root *root, ext2_filsys ext2_fs,
>> * special, we can't rely on relocate_extents_range to relocate it.
>> */
>> for (last_byte = 0; last_byte < first_free; last_byte += sectorsize) {
>> - ret = custom_alloc_extent(root, sectorsize, 0, &key);
>> + ret = custom_alloc_extent(root, sectorsize, 0, &key, 0);
>
> Same here.
>
>> - ret = custom_alloc_extent(root, sectorsize, 0, &key);
>> + ret = custom_alloc_extent(root, sectorsize, 0, &key, 0);
>
> And here.
>
> I hope there's a way how to avoid the BUG_ON at all.
>
next prev parent reply other threads:[~2015-07-25 1:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 9:18 [PATCH 0/4] Metadata crossing stripe boundary fixes Qu Wenruo
2015-07-23 9:18 ` [PATCH 1/4] btrfs: print-tree: print stripe len of a chunk Qu Wenruo
2015-07-23 9:18 ` [PATCH 2/4] btrfs: fsck: Check if a metadata tree block crossing stripe boundary Qu Wenruo
2015-07-23 9:18 ` [PATCH 3/4] btrfs: extent-tree: Avoid allocating tree block that cross " Qu Wenruo
2015-07-23 9:18 ` [PATCH 4/4] btrfs: convert: Avoid allocating metadata extent crossing " Qu Wenruo
2015-07-24 12:34 ` David Sterba
2015-07-25 1:18 ` Qu Wenruo [this message]
2015-07-27 13:40 ` David Sterba
2015-07-24 12:35 ` [PATCH 0/4] Metadata crossing stripe boundary fixes 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=55B2E3FE.5060706@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.com \
--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;
as well as URLs for NNTP newsgroup(s).