From: Damien Le Moal <dlemoal@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
linux-btrfs@vger.kernel.org
Cc: "David Sterba" <dsterba@suse.cz>,
"Qu Wenruo" <quwenruo.btrfs@gmx.com>,
"Naohiro Aota" <naohiro.aota@wdc.com>, 韩于惟 <hrx@bupt.moe>
Subject: Re: [PATCH] btrfs: zoned: don't skip block group profile checks on conv zones
Date: Mon, 12 Feb 2024 10:59:18 +0900 [thread overview]
Message-ID: <c34e93ef-8bc1-4e53-b009-0d8fc150e635@kernel.org> (raw)
In-Reply-To: <534c381d897ad3f29948594014910310fe504bbc.1707475586.git.johannes.thumshirn@wdc.com>
On 2/9/24 19:46, Johannes Thumshirn wrote:
> On a zoned filesystem with conventional zones, we're skipping the block
> group profile checks for the conventional zones.
>
> This allows converting a zoned filesystem's data block groups to RAID when
> all of the zones backing the chunk are on conventional zones. But this
> will lead to problems, once we're trying to allocate chunks backed by
> sequential zones.
>
> So also check for conventional zones when loading a block group's profile
> on them.
>
> Reported-by: 韩于惟 <hrx@bupt.moe>
Let's keep using the roman alphabet for names please...
Yuwei,
Not all kernel developers can read Chinese, so please sign your emails with your
name written in roman alphabet.
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/zoned.c | 30 +++++++++++++++++++++++++++---
> 1 file changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index d9716456bce0..5beb6b936e61 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -1369,8 +1369,10 @@ static int btrfs_load_block_group_single(struct btrfs_block_group *bg,
> return -EIO;
> }
>
> - bg->alloc_offset = info->alloc_offset;
> - bg->zone_capacity = info->capacity;
> + if (info->alloc_offset != WP_CONVENTIONAL) {
> + bg->alloc_offset = info->alloc_offset;
> + bg->zone_capacity = info->capacity;
> + }
> if (test_bit(0, active))
> set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &bg->runtime_flags);
> return 0;
> @@ -1406,6 +1408,16 @@ static int btrfs_load_block_group_dup(struct btrfs_block_group *bg,
> return -EIO;
> }
>
> + if (zone_info[0].alloc_offset == WP_CONVENTIONAL) {
> + zone_info[0].alloc_offset = bg->alloc_offset;
> + zone_info[0].capacity = bg->length;
> + }
> +
> + if (zone_info[1].alloc_offset == WP_CONVENTIONAL) {
> + zone_info[1].alloc_offset = bg->alloc_offset;
> + zone_info[1].capacity = bg->length;
> + }
> +
> if (test_bit(0, active) != test_bit(1, active)) {
> if (!btrfs_zone_activate(bg))
> return -EIO;
> @@ -1458,6 +1470,9 @@ static int btrfs_load_block_group_raid1(struct btrfs_block_group *bg,
> zone_info[1].capacity);
> }
>
> + if (zone_info[0].alloc_offset == WP_CONVENTIONAL)
> + zone_info[0].alloc_offset = bg->alloc_offset;
> +
> if (zone_info[0].alloc_offset != WP_MISSING_DEV)
> bg->alloc_offset = zone_info[0].alloc_offset;
> else
> @@ -1479,6 +1494,11 @@ static int btrfs_load_block_group_raid0(struct btrfs_block_group *bg,
> return -EINVAL;
> }
>
> + for (int i = 0; i < map->num_stripes; i++) {
> + if (zone_info[i].alloc_offset == WP_CONVENTIONAL)
> + zone_info[i].alloc_offset = bg->alloc_offset;
> + }
> +
> for (int i = 0; i < map->num_stripes; i++) {
> if (zone_info[i].alloc_offset == WP_MISSING_DEV ||
> zone_info[i].alloc_offset == WP_CONVENTIONAL)
> @@ -1511,6 +1531,11 @@ static int btrfs_load_block_group_raid10(struct btrfs_block_group *bg,
> return -EINVAL;
> }
>
> + for (int i = 0; i < map->num_stripes; i++) {
> + if (zone_info[i].alloc_offset == WP_CONVENTIONAL)
> + zone_info[i].alloc_offset = bg->alloc_offset;
> + }
> +
> for (int i = 0; i < map->num_stripes; i++) {
> if (zone_info[i].alloc_offset == WP_MISSING_DEV ||
> zone_info[i].alloc_offset == WP_CONVENTIONAL)
> @@ -1605,7 +1630,6 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
> } else if (map->num_stripes == num_conventional) {
> cache->alloc_offset = last_alloc;
> set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags);
> - goto out;
> }
> }
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2024-02-12 1:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 10:46 [PATCH] btrfs: zoned: don't skip block group profile checks on conv zones Johannes Thumshirn
2024-02-09 14:29 ` Naohiro Aota
2024-02-12 9:48 ` Johannes Thumshirn
2024-02-12 1:59 ` Damien Le Moal [this message]
2024-02-12 4:00 ` HAN Yuwei
2024-02-12 11:26 ` David Sterba
-- strict thread matches above, loose matches on Subject: below --
2024-02-13 8:16 Johannes Thumshirn
2024-02-13 21:58 ` Boris Burkov
2024-02-14 15:59 ` Naohiro Aota
2024-02-14 18:11 ` 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=c34e93ef-8bc1-4e53-b009-0d8fc150e635@kernel.org \
--to=dlemoal@kernel.org \
--cc=dsterba@suse.cz \
--cc=hrx@bupt.moe \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=quwenruo.btrfs@gmx.com \
/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