Skip to contentSkip to conversation

xfs: fix frozen file system assert in xfs_trans_alloc

PATCH Applied Christoph Hellwig 3 participants 5 messages Jul 31, 2025 – Aug 12, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix frozen file system assert in xfs_trans_alloc

Commit 83a80e95e797 ("xfs: decouple xfs_trans_alloc_empty from xfs_trans_alloc") move the place of the assert for a frozen file system after the sb_start_intwrite call that ensures it doesn't run on frozen file systems, and thus allows to incorrect trigger it.

Fix that by moving it back to where it belongs.

Fixes 83a80e95e797 ("xfs: decouple xfs_trans_alloc_empty from xfs_trans_alloc")
---
 fs/xfs/xfs_trans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_trans.c +1 -1
index 4917b7d390a3..9010dd682591 100644
@@ -253,8 +253,8 @@ xfs_trans_alloc(
 	 * by doing GFP_KERNEL allocations inside sb_start_intwrite().
 	 */
 retry:
-	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	tp = __xfs_trans_alloc(mp, flags);
+	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
 	if (error == -ENOSPC && want_retry) {
 		xfs_trans_cancel(tp);
Signature · 1 line
2.47.2
#1 lore raw
Quoted 19 lines · Christoph Hellwig

Commit 83a80e95e797 ("xfs: decouple xfs_trans_alloc_empty from xfs_trans_alloc") move the place of the assert for a frozen file system after the sb_start_intwrite call that ensures it doesn't run on frozen file systems, and thus allows to incorrect trigger it.

Fix that by moving it back to where it belongs.

Fixes 83a80e95e797 ("xfs: decouple xfs_trans_alloc_empty from xfs_trans_alloc")
---
 fs/xfs/xfs_trans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_trans.c +0 -0
index 4917b7d390a3..9010dd682591 100644

fs/xfs/xfs_trans.c xfs_trans_alloc( · line 257

Quoted 6 lines
fs/xfs/xfs_trans.c +1 -1
@@ -253,8 +253,8 @@ xfs_trans_alloc(
 	 * by doing GFP_KERNEL allocations inside sb_start_intwrite().
 	 */
 retry:
-	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	tp = __xfs_trans_alloc(mp, flags);
+	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);

Empty transactions can run during a freeze, so please put back the original warning and comment:

	/*
	 * Zero-reservation ("empty") transactions can't modify anything, so
	 * they're allowed to run while we're frozen.
	 */
	WARN_ON(resp->tr_logres > 0 &&
		mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);

--D

Quoted 7 lines
fs/xfs/xfs_trans.c +0 -0
 	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
 	if (error == -ENOSPC && want_retry) {
 		xfs_trans_cancel(tp);
Signature · 1 line
2.47.2
#2 lore raw
Quoted 7 lines · Darrick J. Wong

fs/xfs/xfs_trans.c xfs_trans_alloc( · line 257

Quoted 4 lines

retry:

fs/xfs/xfs_trans.c +1 -1
-	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	tp = __xfs_trans_alloc(mp, flags);
+	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);

Empty transactions can run during a freeze, so please put back the original warning and comment:

Empty transactions don't end up in this code path any more.

Reviewed-by
#3 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 7 lines · Darrick J. Wong

fs/xfs/xfs_trans.c xfs_trans_alloc( · line 257

Quoted 4 lines

retry:

fs/xfs/xfs_trans.c +1 -1
-	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
 	tp = __xfs_trans_alloc(mp, flags);
+	WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);

Empty transactions can run during a freeze, so please put back the original warning and comment:

Empty transactions don't end up in this code path any more.

Oh, hah, silly me, I forgot that also got changed by that patchset. :(

--D

maintainer Applied
#4 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

Commit 83a80e95e797 ("xfs: decouple xfs_trans_alloc_empty from xfs_trans_alloc") move the place of the assert for a frozen file system after the sb_start_intwrite call that ensures it doesn't run on frozen file systems, and thus allows to incorrect trigger it.

Fix that by moving it back to where it belongs.

[...]

Applied to for-next, thanks!

[1/1] xfs: fix frozen file system assert in xfs_trans_alloc

      commit: 647b3d59c768d7638dd17c78c8044178364383ca

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>