From: Christoph Hellwig <hch@infradead.org>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 5/8] btrfs: zoned: activate metadata block group on write time
Date: Mon, 24 Jul 2023 08:12:28 -0700 [thread overview]
Message-ID: <ZL6U3DYVw9JHLUC6@infradead.org> (raw)
In-Reply-To: <2f8e30f966cfd9e06b0745a691bd1a5566aab780.1690171333.git.naohiro.aota@wdc.com>
On Mon, Jul 24, 2023 at 01:18:34PM +0900, Naohiro Aota wrote:
> Since metadata write-out is always allocated sequentially, when we need to
> write to a non-active block group, we can wait for the ongoing IOs to
> complete, activate a new block group, and then proceed with writing to the
> new block group.
Somewhat unrelated, but isn't the same true for data as well, and maybe
in a follow on the same activation policy should apply there as well?
I guess it won't quite work without much work as reservations are tied
to a BG, but it would seem like the better scheme.
> + if (test_bit(BTRFS_FS_ACTIVE_ZONE_TRACKING, &fs_info->flags)) {
Just a more or less cosmetic nit: there is a lot of code in this
branch, and I wonder if the active zone tracking code would benefit
from being split out into one or more helpers.
> + bool is_system = cache->flags & BTRFS_BLOCK_GROUP_SYSTEM;
> +
> + spin_lock(&cache->lock);
> + if (test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
> + &cache->runtime_flags)) {
> + spin_unlock(&cache->lock);
> + return true;
> + }
> +
> + spin_unlock(&cache->lock);
What is the point of the cache->lock crticial section here? The
information can be out of date as soon as you drop the lock, so it
looks superflous to me.
> + if (fs_info->treelog_bg == cache->start) {
> + if (!btrfs_zone_activate(cache)) {
> + int ret_fin = btrfs_zone_finish_one_bg(fs_info);
> +
> + if (ret_fin != 1 || !btrfs_zone_activate(cache))
> + return false;
The ret_fin variable here doesn't seem to be actually needed.
> + }
> + } else if ((!is_system && fs_info->active_meta_bg != cache) ||
> + (is_system && fs_info->active_system_bg != cache)) {
> + struct btrfs_block_group *tgt = is_system ?
> + fs_info->active_system_bg : fs_info->active_meta_bg;
There's a lot of checks for is_system here and later on in the
logic. If we had a helper for this, you could just pass in a bg double
pointer argument that the callers sets to &fs_info->active_system_bg or
&fs_info->active_meta_bg and simplify a lot of the logic.
next prev parent reply other threads:[~2023-07-24 15:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 4:18 [PATCH 0/8] btrfs: zoned: write-time activation of metadata block group Naohiro Aota
2023-07-24 4:18 ` [PATCH 1/8] btrfs: zoned: introduce block_group context for submit_eb_page() Naohiro Aota
2023-07-24 15:00 ` Christoph Hellwig
2023-07-25 5:44 ` Naohiro Aota
2023-07-24 4:18 ` [PATCH 2/8] btrfs: zoned: defer advancing meta_write_pointer Naohiro Aota
2023-07-24 15:04 ` Christoph Hellwig
2023-07-25 8:59 ` Naohiro Aota
2023-07-26 13:06 ` hch
2023-07-24 4:18 ` [PATCH 3/8] btrfs: zoned: update meta_write_pointer on zone finish Naohiro Aota
2023-07-24 15:04 ` Christoph Hellwig
2023-07-25 9:01 ` Naohiro Aota
2023-07-24 4:18 ` [PATCH 4/8] btrfs: zoned: reserve zones for an active metadata/system block group Naohiro Aota
2023-07-24 15:06 ` Christoph Hellwig
2023-07-25 9:07 ` Naohiro Aota
2023-07-26 13:07 ` hch
2023-07-24 4:18 ` [PATCH 5/8] btrfs: zoned: activate metadata block group on write time Naohiro Aota
2023-07-24 6:24 ` kernel test robot
2023-07-24 7:36 ` kernel test robot
2023-07-24 7:57 ` kernel test robot
2023-07-24 15:12 ` Christoph Hellwig [this message]
2023-07-25 9:28 ` Naohiro Aota
2023-07-26 13:10 ` hch
2023-07-24 4:18 ` [PATCH 6/8] btrfs: zoned: no longer count fresh BG region as zone unusable Naohiro Aota
2023-07-24 4:18 ` [PATCH 7/8] btrfs: zoned: don't activate non-DATA BG on allocation Naohiro Aota
2023-07-24 4:18 ` [PATCH 8/8] btrfs: zoned: re-enable metadata over-commit for zoned mode 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=ZL6U3DYVw9JHLUC6@infradead.org \
--to=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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;
as well as URLs for NNTP newsgroup(s).