public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix undersized l_iclog_roundoff values
@ 2026-03-05  4:26 Darrick J. Wong
  2026-03-05 14:06 ` Christoph Hellwig
  2026-03-12  8:38 ` Carlos Maiolino
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2026-03-05  4:26 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

If the superblock doesn't list a log stripe unit, we set the incore log
roundoff value to 512.  This leads to corrupt logs and unmountable
filesystems in generic/617 on a disk with 4k physical sectors...

XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Torn write (CRC failure) detected at log block 0x318e. Truncating head block from 0x3197.
XFS (sda1): failed to locate log tail
XFS (sda1): log mount/recovery failed: error -74
XFS (sda1): log mount failed
XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
XFS (sda1): Ending clean mount

...on the current xfsprogs for-next which has a broken mkfs.  xfs_info
shows this...

meta-data=/dev/sda1              isize=512    agcount=4, agsize=644992 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=1
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=1
         =                       exchange=1   metadir=1
data     =                       bsize=4096   blocks=2579968, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1, parent=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=4096  sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
         =                       rgcount=0    rgsize=268435456 extents
         =                       zoned=0      start=0 reserved=0

...observe that the log section has sectsz=4096 sunit=0, which means
that the roundoff factor is 512, not 4096 as you'd expect.  We should
fix mkfs not to generate broken filesystems, but anyone can fuzz the
ondisk superblock so we should be more cautious.  I think the inadequate
logic predates commit a6a65fef5ef8d0, but that's clearly going to
require a different backport.

Cc: <stable@vger.kernel.org> # v5.14
Fixes: a6a65fef5ef8d0 ("xfs: log stripe roundoff is a property of the log")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 fs/xfs/xfs_log.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index b96f262ba1391e..f807f8f4f70584 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1357,6 +1357,8 @@ xlog_alloc_log(
 
 	if (xfs_has_logv2(mp) && mp->m_sb.sb_logsunit > 1)
 		log->l_iclog_roundoff = mp->m_sb.sb_logsunit;
+	else if (mp->m_sb.sb_logsectsize > 0)
+		log->l_iclog_roundoff = mp->m_sb.sb_logsectsize;
 	else
 		log->l_iclog_roundoff = BBSIZE;
 

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

* Re: [PATCH] xfs: fix undersized l_iclog_roundoff values
  2026-03-05  4:26 [PATCH] xfs: fix undersized l_iclog_roundoff values Darrick J. Wong
@ 2026-03-05 14:06 ` Christoph Hellwig
  2026-03-12  8:38 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-03-05 14:06 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Carlos Maiolino, xfs

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH] xfs: fix undersized l_iclog_roundoff values
  2026-03-05  4:26 [PATCH] xfs: fix undersized l_iclog_roundoff values Darrick J. Wong
  2026-03-05 14:06 ` Christoph Hellwig
@ 2026-03-12  8:38 ` Carlos Maiolino
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Maiolino @ 2026-03-12  8:38 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Wed, 04 Mar 2026 20:26:20 -0800, Darrick J. Wong wrote:
> If the superblock doesn't list a log stripe unit, we set the incore log
> roundoff value to 512.  This leads to corrupt logs and unmountable
> filesystems in generic/617 on a disk with 4k physical sectors...
> 
> XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
> XFS (sda1): Torn write (CRC failure) detected at log block 0x318e. Truncating head block from 0x3197.
> XFS (sda1): failed to locate log tail
> XFS (sda1): log mount/recovery failed: error -74
> XFS (sda1): log mount failed
> XFS (sda1): Mounting V5 Filesystem ff3121ca-26e6-4b77-b742-aaff9a449e1c
> XFS (sda1): Ending clean mount
> 
> [...]

Applied to for-next, thanks!

[1/1] xfs: fix undersized l_iclog_roundoff values
      commit: 52a8a1ba883defbfe3200baa22cf4cd21985d51a

Best regards,
-- 
Carlos Maiolino <cem@kernel.org>


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  4:26 [PATCH] xfs: fix undersized l_iclog_roundoff values Darrick J. Wong
2026-03-05 14:06 ` Christoph Hellwig
2026-03-12  8:38 ` Carlos Maiolino

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