From: Dave Chinner <dgc@kernel.org>
To: Kyuwon Cho <kyuwon.cho@skku.edu>
Cc: Carlos Maiolino <cem@kernel.org>,
Dave Chinner <dchinner@redhat.com>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: initialize AIL head for a zeroed log
Date: Fri, 4 Dec 2026 08:32:46 +1100 [thread overview]
Message-ID: <axHf_uNhO38LK5vw@dread> (raw)
In-Reply-To: <179621433268.2670992.10410960334637658373@skku.edu>
On Fri, Dec 04, 2026 at 01:51:04AM +0900, Kyuwon Cho wrote:
> 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;
No, that's not right. Setting up the initial log state is done via
xlog_set_state(), and if we don't have a valid record header to pull
the state from, then the journal should be considered corrupt.
i.e. totally zeroed logs are an ancient Irix mkfs behaviour, and has
never been done with linux based xfsprogs utilities. All journals
created by Linux mkfs.xfs have a unmount record stamped in them so
they have an identifying UUID in them to associate them correctly
with the parent filesystem.
LLMs are teaching us that having untested/untestable legacy support
in code modern code bases is a significant source of bugs, so
I think we should just reject totally zeroed logs as
corrupt. Clearly we have -nothing- that actually tests
mounting a filesystem with a totally zeroed log.
As we are close to removing the deprecated V4 format altogether, it
doesn't make sense to me to jump through hoops to try to correctly
handle ancient on-disk formats that most likely don't exist in the
wild anymore. Let's just reject filesystems with totally zeroed
logs.
-Dave.
--
Dave Chinner
dgc@kernel.org
prev parent reply other threads:[~2026-12-03 21:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 16:51 [PATCH] xfs: initialize AIL head for a zeroed log Kyuwon Cho
2026-12-03 21:32 ` Dave Chinner [this message]
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=axHf_uNhO38LK5vw@dread \
--to=dgc@kernel.org \
--cc=cem@kernel.org \
--cc=dchinner@redhat.com \
--cc=kyuwon.cho@skku.edu \
--cc=linux-xfs@vger.kernel.org \
/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