* [PATCH] xfs: do not let tr_atomic_ioend raise the minimum log size
@ 2026-11-13 4:30 Hengyu Liang
2026-11-16 8:54 ` John Garry
0 siblings, 1 reply; 3+ messages in thread
From: Hengyu Liang @ 2026-11-13 4:30 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Darrick J. Wong, John Garry, Christoph Hellwig, linux-xfs,
linux-kernel, stable
Commit b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
added the tr_atomic_ioend reservation and made
xfs_log_calc_trans_resv_for_minlogblocks() copy it from the running
filesystem.
However, the copy has the current log count of tr_itruncate. On a
filesystem with rmapbt and without reflink that count is 4, while the
function puts the old count of 2 back for tr_itruncate itself. As of
now, the minimum log size of such a filesystem is larger than the one
its mkfs.xfs used, and the filesystem does not mount any more when its
log has the old minimum size.
The issue can be reproduced with mkfs.xfs from xfsprogs 5.13:
truncate -s 512M xfs.img
mkfs.xfs -m rmapbt=1,reflink=0 xfs.img
mount -o loop xfs.img /mnt
Before commit b1e09178b73a ("xfs: commit CoW-based atomic writes
atomically"), the mount succeeds.
After that commit, it fails with EINVAL:
XFS (loop0): Log size 878 blocks too small, minimum size is 962 blocks
XFS (loop0): AAIEEE! Log failed size checks. Abort!
This patch will use the old log count for the copy as well. These
filesystems have no reflink, so they never use this reservation.
Fixes: b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
Cc: stable@vger.kernel.org # v6.16
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
---
mkfs.xfs 4.9 to 5.13 give such a log to an rmapbt=1,reflink=0
filesystem below 1 GiB, or up to 16 GiB with -d su=256k,sw=4.
Application impact (Ubuntu 26.04 user space): udisks2 2.10.91 is asked
to mount a filesystem made as above ("udisksctl mount -b /dev/vda"). On
v6.15, it mounts it at /run/media/root/STICK513. On v6.16, it fails
with "Error mounting /dev/vda ... wrong fs type, bad option, bad
superblock".
Tested on xfs for-next with 45 images made by mkfs.xfs 4.9 to 6.6: 26
do not mount without this patch, all mount with it, and the largest
reservation is the same as on v6.15.
fs/xfs/libxfs/xfs_log_rlimit.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c
index 37712b2f8757..9454c91e9fb3 100644
--- a/fs/xfs/libxfs/xfs_log_rlimit.c
+++ b/fs/xfs/libxfs/xfs_log_rlimit.c
@@ -128,6 +128,8 @@ xfs_log_calc_trans_resv_for_minlogblocks(
resv->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
resv->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
resv->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
+ /* tr_atomic_ioend starts as a copy of tr_itruncate. */
+ resv->tr_atomic_ioend.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
}
/*
base-commit: 48326a2382d80715475d10ce98734ac65d2d2150
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: do not let tr_atomic_ioend raise the minimum log size
2026-11-13 4:30 [PATCH] xfs: do not let tr_atomic_ioend raise the minimum log size Hengyu Liang
@ 2026-11-16 8:54 ` John Garry
2026-11-16 20:24 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: John Garry @ 2026-11-16 8:54 UTC (permalink / raw)
To: linux-xfs, Dave Chinner
On 11/13/26 04:30, Hengyu Liang wrote:
> Commit b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
> added the tr_atomic_ioend reservation and made
> xfs_log_calc_trans_resv_for_minlogblocks() copy it from the running
> filesystem.
>
> However, the copy has the current log count of tr_itruncate. On a
> filesystem with rmapbt and without reflink that count is 4, while the
> function puts the old count of 2 back for tr_itruncate itself. As of
> now, the minimum log size of such a filesystem is larger than the one
> its mkfs.xfs used, and the filesystem does not mount any more when its
> log has the old minimum size.
>
> The issue can be reproduced with mkfs.xfs from xfsprogs 5.13:
>
> truncate -s 512M xfs.img
> mkfs.xfs -m rmapbt=1,reflink=0 xfs.img
> mount -o loop xfs.img /mnt
>
> Before commit b1e09178b73a ("xfs: commit CoW-based atomic writes
> atomically"), the mount succeeds.
>
> After that commit, it fails with EINVAL:
>
> XFS (loop0): Log size 878 blocks too small, minimum size is 962 blocks
> XFS (loop0): AAIEEE! Log failed size checks. Abort!
>
> This patch will use the old log count for the copy as well. These
> filesystems have no reflink, so they never use this reservation.
>
> Fixes: b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
> Cc: stable@vger.kernel.org # v6.16
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
> ---
> mkfs.xfs 4.9 to 5.13 give such a log to an rmapbt=1,reflink=0
> filesystem below 1 GiB, or up to 16 GiB with -d su=256k,sw=4.
>
> Application impact (Ubuntu 26.04 user space): udisks2 2.10.91 is asked
> to mount a filesystem made as above ("udisksctl mount -b /dev/vda"). On
> v6.15, it mounts it at /run/media/root/STICK513. On v6.16, it fails
> with "Error mounting /dev/vda ... wrong fs type, bad option, bad
> superblock".
>
> Tested on xfs for-next with 45 images made by mkfs.xfs 4.9 to 6.6: 26
> do not mount without this patch, all mount with it, and the largest
> reservation is the same as on v6.15.
>
> fs/xfs/libxfs/xfs_log_rlimit.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c
> index 37712b2f8757..9454c91e9fb3 100644
> --- a/fs/xfs/libxfs/xfs_log_rlimit.c
> +++ b/fs/xfs/libxfs/xfs_log_rlimit.c
> @@ -128,6 +128,8 @@ xfs_log_calc_trans_resv_for_minlogblocks(
> resv->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
> resv->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
> resv->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
> + /* tr_atomic_ioend starts as a copy of tr_itruncate. */
> + resv->tr_atomic_ioend.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
I have to admit that I am not really familiar with this log code.
Darrick was, but unfortunately he is no involved. The change looks sane,
even though we are partially overwriting resv->tr_atomic_ioend (from
when it is set earlier in the same function). Dave Chinner may be able
to kindly help review.
Thanks,
John
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: do not let tr_atomic_ioend raise the minimum log size
2026-11-16 8:54 ` John Garry
@ 2026-11-16 20:24 ` Dave Chinner
0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2026-11-16 20:24 UTC (permalink / raw)
To: John Garry; +Cc: linux-xfs
On Mon, Nov 16, 2026 at 08:54:27AM +0000, John Garry wrote:
> On 11/13/26 04:30, Hengyu Liang wrote:
> > Commit b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
> > added the tr_atomic_ioend reservation and made
> > xfs_log_calc_trans_resv_for_minlogblocks() copy it from the running
> > filesystem.
> >
> > However, the copy has the current log count of tr_itruncate. On a
> > filesystem with rmapbt and without reflink that count is 4, while the
> > function puts the old count of 2 back for tr_itruncate itself. As of
> > now, the minimum log size of such a filesystem is larger than the one
> > its mkfs.xfs used, and the filesystem does not mount any more when its
> > log has the old minimum size.
> >
> > The issue can be reproduced with mkfs.xfs from xfsprogs 5.13:
> >
> > truncate -s 512M xfs.img
> > mkfs.xfs -m rmapbt=1,reflink=0 xfs.img
> > mount -o loop xfs.img /mnt
> >
> > Before commit b1e09178b73a ("xfs: commit CoW-based atomic writes
> > atomically"), the mount succeeds.
> >
> > After that commit, it fails with EINVAL:
> >
> > XFS (loop0): Log size 878 blocks too small, minimum size is 962 blocks
> > XFS (loop0): AAIEEE! Log failed size checks. Abort!
> >
> > This patch will use the old log count for the copy as well. These
> > filesystems have no reflink, so they never use this reservation.
> >
> > Fixes: b1e09178b73a ("xfs: commit CoW-based atomic writes atomically")
> > Cc: stable@vger.kernel.org # v6.16
> > Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
> > ---
> > mkfs.xfs 4.9 to 5.13 give such a log to an rmapbt=1,reflink=0
> > filesystem below 1 GiB, or up to 16 GiB with -d su=256k,sw=4.
> >
> > Application impact (Ubuntu 26.04 user space): udisks2 2.10.91 is asked
> > to mount a filesystem made as above ("udisksctl mount -b /dev/vda"). On
> > v6.15, it mounts it at /run/media/root/STICK513. On v6.16, it fails
> > with "Error mounting /dev/vda ... wrong fs type, bad option, bad
> > superblock".
> >
> > Tested on xfs for-next with 45 images made by mkfs.xfs 4.9 to 6.6: 26
> > do not mount without this patch, all mount with it, and the largest
> > reservation is the same as on v6.15.
> >
> > fs/xfs/libxfs/xfs_log_rlimit.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c
> > index 37712b2f8757..9454c91e9fb3 100644
> > --- a/fs/xfs/libxfs/xfs_log_rlimit.c
> > +++ b/fs/xfs/libxfs/xfs_log_rlimit.c
> > @@ -128,6 +128,8 @@ xfs_log_calc_trans_resv_for_minlogblocks(
> > resv->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
> > resv->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
> > resv->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
> > + /* tr_atomic_ioend starts as a copy of tr_itruncate. */
> > + resv->tr_atomic_ioend.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
>
> I have to admit that I am not really familiar with this log code. Darrick
> was, but unfortunately he is no involved. The change looks sane, even though
> we are partially overwriting resv->tr_atomic_ioend (from when it is set
> earlier in the same function). Dave Chinner may be able to kindly help
> review.
I'm not sure that it fixes the issue, because the min log
size calculation should not contain the tr_atomic_ioend reservation
size at all, regardless of it's value. The minlogsize calc is for
compatibility with kernels that predate atomic writes completely,
so adding that reservation to the calc just seems wrong.
There are more fundamental problems with the atomic ioend
reservation, though, starting with the 'use truncate as a default'
behaviour, then changing it later.
I've been forced to look at this .... mess over the past couple of
weeks because the journal format validation work I've been doing has
tripped over reservation recalculation issues. Growfs (and recovery
of growfs op) needs to recalculate a bunch of transaction
reservation values (e.g. all the new rt btree stuff), and the atomic
write reservations are currently not able to be recalculated
atomically and safely on a running filesystem.
Atomic write reservations are also broken w.r.t. remount based size
changes because running a minlogsize calc on a running filesystem
temporarily changes mount wide constants for the purposes of
recalculating the reservations. Remount doesn't stop reads from
occurring, so various metadata pulled in from disk won't be
correctly validated whilst the minlogsize calc is being run....
A week ago I changed the atomic write reservation code to replace
the "set default then calculate a different value later" behaviour
with a single calcuation based on the current log size to avoid
user-adjustable atomic write size limits having impact on journal
size limits. I think it will address the above problem, too, but
I'll have to go check...
-Dave.
--
Dave Chinner
dgc@kernel.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-16 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 4:30 [PATCH] xfs: do not let tr_atomic_ioend raise the minimum log size Hengyu Liang
2026-11-16 8:54 ` John Garry
2026-11-16 20:24 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox