From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796333575; b=xELNHz4DsT8JHSBaWliuuJT1khFYycw0LrboDZfe7KaR3A1zuhr5iNs6htPnvBmo7pYP kX1bczRhOMZxSCMPzMzG8xgVVCIAGQ6tMLXnip9l7F8NPPUEXMuEeKBCbO4J9l2dZ85f4 u59QSWUeEBXQbpk9YOe1ZiDGXcMyDuy0oOLli7F/zD+rSaKyNtI530qUWb61sqRXMUY1S g61xhzlPX5kILPq7+I1r+V780BULV4G0j48L2y375THWgj0+QQhUXn8xsYg8LJfEmvCpu ypdR0kFeFAfO7XG6f9k+iJp44pKH3I07XTqW8h071Jb6DQL9oSk3up6diZ428vH7FkA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796333575; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=Bpi3lU1yu34dd1gLYPHu1yKP35ALA8aiAOVnFmAZ2pk=; b=T2sREY65OJJTw+W5pOwro/sWrm8BEpNrsSONQWioY9eKY3nvo7c6wDY4inRf2ZggqUDU 0til1k+VbD2qKNi5wxVCIHgrsCc6hlLNpCj4bH6ycbXaHwbK17CJJIJ39CEjsL2LpAUKL tORsS78lVbTdCF1FPFtG8PQXt+LYxCJqStuWl4+RAAlhnwdzHY/y3uOUe20UT5TUrOarz N/6WBVuy92Hpms7FguX8FYx7xaYD6/hcZub5WUVOfl8QuA2bLO+vDvqp0I4x7zqJMOjgf X5uKV9fiCnW+iGN/1uwzSwgrNkToDtpCvsX4/nbdX3FyVPipKJDHzrBP7soHtI+urQw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MPBh4jtu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6DDB606A32C for ; Thu, 3 Dec 2026 21:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MPBh4jtu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26EDA1F000C2; Thu, 3 Dec 2026 21:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796333575; bh=Bpi3lU1yu34dd1gLYPHu1yKP35ALA8aiAOVnFmAZ2pk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=MPBh4jtup1d86ywj1QxjKJQyq845WfNBc1L8fGOcxKdK6fGdIA8rJJOz/woRoSOS2 Y92+NYWd3EDo1ydfS+y5OFmhl5RGOFTCwB6wfKAm03k7VCkJZpNnjzlpQ+GcBR5lBK 9Xs5jGZnCcpyn4AfiRLOjhRb8rX3AKE4p+592u1THdWveIb/5x6cFHG330bF7W3BaJ cp52DTYcSLsauOSGxS72iCByxJbtVoyrFzOO6tlA78YHeQWGChxz9oueNQFuN8lJ04 12Yj7ktfOrhwz6BVeOf9hqfIhzVbIZ5JFfLWvMlSy1bVq2IY8inb6pmmTqR7ujEHGt gbGfaGZehlB/w== Date: Fri, 4 Dec 2026 08:32:46 +1100 From: Dave Chinner To: Kyuwon Cho Cc: Carlos Maiolino , Dave Chinner , linux-xfs@vger.kernel.org Subject: Re: [PATCH] xfs: initialize AIL head for a zeroed log Message-ID: References: <179621433268.2670992.10410960334637658373@skku.edu> X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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