From: Hans Holmberg <Hans.Holmberg@wdc.com>
To: Christoph Hellwig <hch@lst.de>, Carlos Maiolino <cem@kernel.org>
Cc: Damien Le Moal <dlemoal@kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 1/7] xfs: delay opening the GC zone
Date: Tue, 31 Mar 2026 08:03:26 +0000 [thread overview]
Message-ID: <37a95bca-e146-40bb-ae77-e6522a295fe3@wdc.com> (raw)
In-Reply-To: <20260330054533.3856339-2-hch@lst.de>
On 30/03/2026 07:45, Christoph Hellwig wrote:
> The code that selects a new GC zone when the previous one is full also
> handles a zone not being set at all. Make use of that to simplify the
> logic in xfs_zone_gc_mount.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_zone_gc.c | 45 ++++++++++++++++++++------------------------
> 1 file changed, 20 insertions(+), 25 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
> index 0ff710fa0ee7..f076f66c5d57 100644
> --- a/fs/xfs/xfs_zone_gc.c
> +++ b/fs/xfs/xfs_zone_gc.c
> @@ -527,7 +527,7 @@ xfs_zone_gc_select_victim(
> return true;
> }
>
> -static struct xfs_open_zone *
> +static int
> xfs_zone_gc_steal_open(
> struct xfs_zone_info *zi)
> {
> @@ -538,15 +538,18 @@ xfs_zone_gc_steal_open(
> if (!found || oz->oz_allocated < found->oz_allocated)
> found = oz;
> }
> -
> - if (found) {
> - found->oz_is_gc = true;
> - list_del_init(&found->oz_entry);
> - zi->zi_nr_open_zones--;
> + if (!found) {
> + spin_unlock(&zi->zi_open_zones_lock);
> + return -EIO;
> }
>
> + trace_xfs_zone_gc_target_opened(found->oz_rtg);
> + found->oz_is_gc = true;
> + list_del_init(&found->oz_entry);
> + zi->zi_nr_open_zones--;
> + zi->zi_open_gc_zone = found;
> spin_unlock(&zi->zi_open_zones_lock);
> - return found;
> + return 0;
> }
>
> static struct xfs_open_zone *
> @@ -1177,31 +1180,24 @@ xfs_zone_gc_mount(
> {
> struct xfs_zone_info *zi = mp->m_zone_info;
> struct xfs_zone_gc_data *data;
> - struct xfs_open_zone *oz;
> int error;
>
> /*
> - * If there are no free zones available for GC, pick the open zone with
> + * If there are no free zones available for GC, or the number of open
> + * zones has reached the open zone limit, pick the open zone with
> * the least used space to GC into. This should only happen after an
> - * unclean shutdown near ENOSPC while GC was ongoing.
> - *
> - * We also need to do this for the first gc zone allocation if we
> - * unmounted while at the open limit.
> + * unclean shutdown while GC was ongoing. Otherwise a GC zone will
> + * be selected from the free zone pool on demand.
> */
> if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_FREE) ||
> - zi->zi_nr_open_zones == mp->m_max_open_zones)
> - oz = xfs_zone_gc_steal_open(zi);
> - else
> - oz = xfs_open_zone(mp, WRITE_LIFE_NOT_SET, true);
> - if (!oz) {
> - xfs_warn(mp, "unable to allocate a zone for gc");
> - error = -EIO;
> - goto out;
> + zi->zi_nr_open_zones >= mp->m_max_open_zones) {
> + error = xfs_zone_gc_steal_open(zi);
> + if (error) {
> + xfs_warn(mp, "unable to steal an open zone for gc");
> + return error;
> + }
> }
>
> - trace_xfs_zone_gc_target_opened(oz->oz_rtg);
> - zi->zi_open_gc_zone = oz;
> -
> data = xfs_zone_gc_data_alloc(mp);
> if (!data) {
> error = -ENOMEM;
> @@ -1224,7 +1220,6 @@ xfs_zone_gc_mount(
> kfree(data);
> out_put_gc_zone:
> xfs_open_zone_put(zi->zi_open_gc_zone);
> -out:
> return error;
> }
>
Looks good,
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
next prev parent reply other threads:[~2026-03-31 8:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 5:44 cleanup open GC zone handling Christoph Hellwig
2026-03-30 5:44 ` [PATCH 1/7] xfs: delay opening the GC zone Christoph Hellwig
2026-03-30 12:16 ` Carlos Maiolino
2026-03-30 13:12 ` Christoph Hellwig
2026-03-30 13:20 ` Carlos Maiolino
2026-03-31 8:03 ` Hans Holmberg [this message]
2026-03-31 9:39 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 2/7] xfs: add a separate tracepoint for stealing an open zone for GC Christoph Hellwig
2026-03-30 12:19 ` Carlos Maiolino
2026-03-31 8:03 ` Hans Holmberg
2026-03-31 9:40 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 3/7] xfs: put the open zone later xfs_open_zone_put Christoph Hellwig
2026-03-30 12:24 ` Carlos Maiolino
2026-03-31 8:04 ` Hans Holmberg
2026-03-31 9:41 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 4/7] xfs: rename xfs_zone_gc_iter_next to xfs_zone_gc_iter_irec Christoph Hellwig
2026-03-30 12:26 ` Carlos Maiolino
2026-03-31 8:05 ` Hans Holmberg
2026-03-31 9:42 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 5/7] xfs: refactor GC zone selection helpers Christoph Hellwig
2026-03-30 12:28 ` Carlos Maiolino
2026-03-31 8:07 ` Hans Holmberg
2026-03-31 9:43 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 6/7] xfs: streamline GC zone selection Christoph Hellwig
2026-03-30 12:45 ` Carlos Maiolino
2026-03-31 8:22 ` Hans Holmberg
2026-03-31 9:48 ` Damien Le Moal
2026-03-30 5:44 ` [PATCH 7/7] xfs: reduce special casing for the open GC zone Christoph Hellwig
2026-03-30 13:00 ` Carlos Maiolino
2026-03-31 8:37 ` Hans Holmberg
2026-03-31 9:53 ` Damien Le Moal
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=37a95bca-e146-40bb-ae77-e6522a295fe3@wdc.com \
--to=hans.holmberg@wdc.com \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@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