Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] xfs: initialize AIL head for a zeroed log
@ 2026-12-03 16:51 Kyuwon Cho
  2026-12-03 21:32 ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-12-03 16:51 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: Dave Chinner, linux-xfs

For a totally zeroed log, xlog_find_tail() keeps l_tail_lsn at its
initialized 1:0 value but leaves ail_head_lsn at zero. The first CIL
checkpoint then returns the apparent distance from 0:0 to 1:N to the
byte-count grant heads. That distance underflows, grows both grant heads by
roughly 4 GiB, and makes later transactions wait forever for log space.

Initialize the AIL head from the already initialized tail LSN in the
zeroed-log path.

Fixes: c1220522ef40 ("xfs: grant heads track byte counts, not LSNs")
Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

The reproducer mounts a crafted XFS image with a totally zeroed log,
creates a fragmented file, and requests an online bmbt rebuild. Mounting
the image and requesting repair require root in the initial namespace.

The decoded trace is:

  INFO: task test blocked for more than 122 seconds
  xlog_grant_head_wait (fs/xfs/xfs_log.c:217)
  xlog_grant_head_check (fs/xfs/xfs_log.c:279)
  xfs_log_reserve (fs/xfs/xfs_log.c:387)
  xfs_trans_alloc (fs/xfs/xfs_trans.c:174 fs/xfs/xfs_trans.c:260)
  xchk_setup_inode_bmap (fs/xfs/scrub/bmap.c:100)
  xfs_scrub_metadata (fs/xfs/scrub/scrub.c:709)
  xfs_ioc_scrub_metadata (fs/xfs/scrub/scrub.c:813)
  xfs_file_ioctl (fs/xfs/xfs_ioctl.c:1537)

With this patch, the zeroed-log mount and scrub sequence completes
without a log-grant hang on fe6ff8d5d675. The patch also builds on the
current XFS tree at a6d9628b631d.

 fs/xfs/xfs_log_recover.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 457617979668..f61255094ef3 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1264,6 +1264,8 @@ xlog_find_tail(
 
 		if (xlog_get_cycle(offset) == 0) {
 			*tail_blk = 0;
+			log->l_ailp->ail_head_lsn =
+					atomic64_read(&log->l_tail_lsn);
 			/* leave all other log inited values alone */
 			goto done;
 		}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 16:51 [PATCH] xfs: initialize AIL head for a zeroed log Kyuwon Cho
2026-12-03 21:32 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox