public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Nirjhar Roy (IBM)" <nirjhar@linux.ibm.com>
Cc: djwong@kernel.org, hch@infradead.org, cem@kernel.org,
	david@fromorbit.com, linux-xfs@vger.kernel.org,
	fstests@vger.kernel.org, ritesh.list@gmail.com,
	ojaswin@linux.ibm.com, nirjhar.roy.lists@gmail.com,
	hsiangkao@linux.alibaba.com
Subject: Re: [RFC v1 4/4] xfs: Add support to shrink multiple empty realtime groups
Date: Wed, 18 Feb 2026 22:23:25 -0800	[thread overview]
Message-ID: <aZasXfB-GUiGT4yc@infradead.org> (raw)
In-Reply-To: <1a3d14a03083b031ec831a3e748d9002fab23504.1771418537.git.nirjhar.roy.lists@gmail.com>

Just q quick glance, no real review:

> +int
> +xfs_group_get_active_refcount(struct xfs_group *xg)
> +{
> +	ASSERT(xg);
> +	return atomic_read(&xg->xg_active_ref);
> +}
> +
> +int
> +xfs_group_get_passive_refcount(struct xfs_group *xg)
> +{
> +	ASSERT(xg);
> +	return atomic_read(&xg->xg_ref);

Using "get" to read a refcount value is very confusing.  Looking
at the users I'm tempted to say just open code these and the
ag/rtg wrappers.

> -	rtg = xfs_rtgroup_grab(mp, prev_rgcount - 1);
> +	if (prev_rgcount >= mp->m_sb.sb_rgcount)
> +		rgno = mp->m_sb.sb_rgcount - 1;
> +	else
> +		rgno = prev_rgcount - 1;
> +	rtg = xfs_rtgroup_grab(mp, rgno);

Throw in a comment that this is about grow/shrink?

> +void

Stick to the unique XFS style here and in other places, please.

> +xfs_rtgroup_activate(struct xfs_rtgroup	*rtg)
> +{
> +	ASSERT(!xfs_rtgroup_is_active(rtg));
> +	init_waitqueue_head(&rtg_group(rtg)->xg_active_wq);
> +	atomic_set(&rtg_group(rtg)->xg_active_ref, 1);
> +	xfs_add_frextents(rtg_mount(rtg),
> +			xfs_rtgroup_extents(rtg_mount(rtg), rtg_rgno(rtg)));
> +}
> +
> +int
> +xfs_rtgroup_deactivate(struct xfs_rtgroup	*rtg)

It might also make sense to explain what activate/deactive means here.

> +{
> +	ASSERT(rtg);
> +
> +	int			error = 0;

No need for the assert, and code goes after declarations.

> +	xfs_rgnumber_t		rgno = rtg_rgno(rtg);
> +	struct	xfs_mount	*mp = rtg_mount(rtg);
> +	xfs_rtxnum_t		rtextents =
> +			xfs_rtgroup_extents(mp, rgno);

This assignment fits onto a single line easily.

> +	ASSERT(xfs_rtgroup_is_active(rtg));
> +	ASSERT(rtg_rgno(rtg) < mp->m_sb.sb_rgcount);
> +
> +	if (!xfs_rtgroup_is_empty(rtg))
> +		return -ENOTEMPTY;
> +	/*
> +	 * Manually reduce/reserve 1 realtime group worth of
> +	 * free realtime extents from the global counters. This is necessary
> +	 * in order to prevent a race where, some rtgs have been temporarily
> +	 * offlined but the delayed allocator has already promised some bytes
> +	 * and later the real extent/block allocation is failing due to
> +	 * the rtgs(s) being offline.
> +	 * If the overall shrink fails, we will restore the values.

Formatting: use up all 80 characters.

> +	xfs_rgnumber_t          rgno = rtg_rgno(rtg);
> +
> +	struct xfs_rtalloc_args args = {

Weird empty line between the declarations.

> +bool xfs_rtgroup_is_empty(struct xfs_rtgroup *rtg);
> +
> +#define for_each_rgno_range_reverse(agno, old_rgcount, new_rgcount) \
> +	for ((agno) = ((old_rgcount) - 1); (typeof(old_rgcount))(agno) >= \
> +		((typeof(old_rgcount))(new_rgcount) - 1); (agno)--)

I don't think this is helpful vs just open coding the loop.  The mix
of ag and rg naming is also a bit odd.

> +	for_each_rgno_range_reverse(rgno, old_rgcount, new_rgcount + 1) {
> +		rtg = xfs_rtgroup_get(mp, rgno);

Given that we have this pattern a bit, maybe add a reverse version
of xfs_group_next_range to encapsulate it?


Highlevel note:  this seems to only cover classic bitmap based RTGs,
and not zoned ones.  You might want to look into the latter because
they're actually much simpler, and with the zoned GC code we actually
have a super nice way to move data out of the RTG.  I'd be happy to
supple you a code sniplet for the latter.

  reply	other threads:[~2026-02-19  6:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19  5:57 xfs: Add support for multi rtgroup shrink+removal Nirjhar Roy (IBM)
2026-02-19  6:03 ` [RFC v1 0/4] xfs: Add support to shrink multiple empty rtgroups Nirjhar Roy (IBM)
2026-02-19  6:03   ` [RFC v1 1/4] xfs: Re-introduce xg_active_wq field in struct xfs_group Nirjhar Roy (IBM)
2026-02-19  6:13     ` Christoph Hellwig
2026-02-19  6:03   ` [RFC v1 2/4] xfs: Introduce xfs_rtginodes_ensure_all() Nirjhar Roy (IBM)
2026-02-19  6:15     ` Christoph Hellwig
2026-02-25  5:18       ` Nirjhar Roy (IBM)
2026-02-19  6:03   ` [RFC v1 3/4] xfs: Add a new state for shrinking Nirjhar Roy (IBM)
2026-02-19  6:03   ` [RFC v1 4/4] xfs: Add support to shrink multiple empty realtime groups Nirjhar Roy (IBM)
2026-02-19  6:23     ` Christoph Hellwig [this message]
2026-02-25  5:17       ` Nirjhar Roy (IBM)
2026-02-25 14:24         ` Christoph Hellwig
2026-02-26 12:59           ` Nirjhar Roy (IBM)
2026-02-23 11:29   ` [RFC v1 0/4] xfs: Add support to shrink multiple empty rtgroups Nirjhar Roy (IBM)
2026-03-18 14:43   ` Nirjhar Roy (IBM)
2026-03-18 15:20     ` Christoph Hellwig
2026-02-19  6:08 ` [PATCH v1] xfs_growfs: Allow shrink of realtime XFS Nirjhar Roy (IBM)
2026-02-19  6:10 ` [PATCH v1 0/7] Add multi rtgroup grow and shrink tests Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 1/7] xfs: Introduce _require_realtime_xfs_{shrink,grow} pre-condition Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 2/7] xfs: Introduce helpers to count the number of bitmap and summary inodes Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 3/7] xfs: Add realtime group grow tests Nirjhar Roy (IBM)
2026-02-19  6:40     ` Christoph Hellwig
2026-02-25  5:24       ` Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 4/7] xfs: Add multi rt group grow + shutdown + recovery tests Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 5/7] xfs: Add realtime group shrink tests Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 6/7] xfs: Add multi rt group shrink + shutdown + recovery tests Nirjhar Roy (IBM)
2026-02-19  6:10   ` [PATCH v1 7/7] xfs: Add parallel back to back grow/shrink tests Nirjhar Roy (IBM)
2026-02-19 12:55   ` [PATCH v1 0/7] Add multi rtgroup grow and shrink tests Carlos Maiolino
2026-02-19 14:40     ` Nirjhar Roy (IBM)
2026-02-19 14:55       ` Carlos Maiolino
2026-02-19 15:49         ` Darrick J. Wong
2026-02-19 16:35           ` Carlos Maiolino
2026-02-20 11:24           ` Nirjhar Roy (IBM)
2026-02-20 16:10             ` Darrick J. Wong
2026-02-20 18:12               ` Nirjhar Roy (IBM)
2026-02-24 13:04                 ` Carlos Maiolino
2026-02-20 11:20         ` Nirjhar Roy (IBM)
2026-02-20 16:15           ` Darrick J. Wong
2026-02-19 14:56     ` Andrey Albershteyn
2026-02-20 14:07     ` Konstantin Ryabitsev
2026-02-24 13:02       ` Carlos Maiolino

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=aZasXfB-GUiGT4yc@infradead.org \
    --to=hch@infradead.org \
    --cc=cem@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nirjhar.roy.lists@gmail.com \
    --cc=nirjhar@linux.ibm.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.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