Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: "Марк Коренберг" <socketpair@gmail.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [RFE] xfs_growfs: option to clamp growth to an AG boundary
Date: Mon, 23 Feb 2026 08:23:20 -0800	[thread overview]
Message-ID: <20260223162320.GB2390353@frogsfrogsfrogs> (raw)
In-Reply-To: <CAEmTpZGcBvxsMP6Qg4zcUd-D4M9-jmzS=+9ZsY2RemRDTDQcQg@mail.gmail.com>

On Mon, Feb 23, 2026 at 02:48:48PM +0500, Марк Коренберг wrote:
> Hi,
> 
> I ran into an issue after growing an XFS filesystem where the final
> allocation group (last AG) ended up very small. Most workloads were
> fine, but large reflink-heavy copies started failing. In my case,
> copying a ClickHouse data directory with:
> 
> `cp -a --reflink=always ...`
> 
> fails on a filesystem with a tiny last AG. Using --reflink=auto

How does it fail?

--D

> doesn’t help either, because `cp` doesn’t fall back to a non-reflink
> copy if the reflink attempt fails.
> 
> To work around this, I had to write scripts that compute a “safe”
> target size before running xfs_growfs. The alignment I needed is a bit
> awkward:
> 
> 1. Round the LV size up to the next multiple of the filesystem AG
> size, so the grown filesystem ends exactly on an AG boundary (no
> partial/tiny last AG).
> 
> 2. Then round the LV size down to the LVM extents size (4 MiB in my
> case). Rounding up to the LVM granularity can reintroduce a tiny last
> AG.
> If the automatically chosen AG size were aligned to that granularity,
> step (2) wouldn’t be necessary.
> 
> This feels like something xfsprogs could support directly. My proposals:
> 
> 1. xfs_growfs: add an option to print an “optimal grow target size”:
> the current(new) block device size rounded **down** to a multiple of
> the AG size.
> A --json output mode would make this easy to consume from scripts.
> 
> 2. AG size calculation/alignment: when choosing an automatic AG size,
> always round it down to an alignment such as 4 MiB, or (preferably)
> consider the underlying device/LVM extent size when it can be
> detected, instead of using a constant.
> 
> 3. Docs (mkfs + AG sizing): when specifying AG size manually,
> recommend: choosing filesystem sizing so the final size is an integer
> multiple of AG size (i.e., no partial last AG), and aligning the AG
> size to the underlying allocation granularity (e.g., LVM
> extent/segment size) when applicable.
> 
> 4. Docs (xfs_growfs): add a note that it’s highly preferable to grow
> the filesystem in multiples of the existing AG size, to avoid a tiny
> last AG.
> 
> 5. Optional grow mode: add a xfs_growfs mode/switch that grows “as
> much as possible”, but clamps the resulting filesystem size **down**
> to an AG boundary, and reports how much space is left unused (e.g., “X
> bytes left unallocated to avoid a partial final AG”).
> 
> This might sound like a corner case, but it’s easy to hit in practice
> when the block device is resized to just arbitrary chosen size then
> xfs_growfs expands to consume the whole device.
> 
> Thanks,
> Mark
> 

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23  9:48 [RFE] xfs_growfs: option to clamp growth to an AG boundary Марк Коренберг
2026-02-23 16:23 ` Darrick J. Wong [this message]
2026-02-23 19:29   ` Марк Коренберг
2026-02-23 23:08     ` Darrick J. Wong
2026-02-24  6:17       ` Марк Коренберг
2026-02-24 15:01       ` Christoph Hellwig
2026-02-24 19:44         ` Darrick J. Wong
2026-02-24 22:25           ` Darrick J. Wong
2026-02-25 14:21             ` Christoph Hellwig
2026-02-24 15:02 ` Christoph Hellwig
2026-02-24 19:49   ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2026-02-25  8:21 Lukas Herbolt

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=20260223162320.GB2390353@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=socketpair@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