Linux XFS filesystem development
 help / color / mirror / Atom feed
* [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

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