All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4:Fix WARNING in ext4_journalled_invalidate_folio
@ 2026-09-14  2:19 shuo chen
  2026-09-14  2:38 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: shuo chen @ 2026-09-14  2:19 UTC (permalink / raw)
  To: tytso
  Cc: adilger.kernel, libaokun, jack, ojaswin, yi.zhang, linux-ext4,
	shuo chen, Farhad Alemi

when the bh's transaction is committing and the bh is part of the folio,
journal_unmap_buffer returns -EBUSY and triggers a warning.

Reported-by: Farhad Alemi <farhad.alemi@berkeley.edu>
Closes:https://lore.kernel.org/linux-ext4/CA+0ovCgxFN3TLpdS_O_Z48sARuQ-WR-JLDCqQWEmd9ELtkzddA@mail.gmail.com/T/
Signed-off-by: shuo chen <1289151713@qq.com>
---
 fs/ext4/inode.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c2c2d6ac7f3d..6bb94afd5100 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3429,7 +3429,27 @@ static void ext4_journalled_invalidate_folio(struct folio *folio,
 					   size_t offset,
 					   size_t length)
 {
-	WARN_ON(__ext4_journalled_invalidate_folio(folio, offset, length) < 0);
+	tid_t commit_tid;
+	int ret;
+	bool has_transaction;
+	journal_t *journal = EXT4_JOURNAL(folio->mapping->host);
+
+	while (1) {
+		ret = __ext4_journalled_invalidate_folio(folio, offset, length);
+		if (ret != -EBUSY) {
+			WARN_ON(ret < 0);
+			return;
+		}
+		has_transaction = false;
+		read_lock(&journal->j_state_lock);
+		if (journal->j_committing_transaction) {
+			commit_tid = journal->j_committing_transaction->t_tid;
+			has_transaction = true;
+		}
+		read_unlock(&journal->j_state_lock);
+		if (has_transaction)
+			jbd2_log_wait_commit(journal, commit_tid);
+	}
 }
 
 static bool ext4_release_folio(struct folio *folio, gfp_t wait)
-- 
2.55.0


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

end of thread, other threads:[~2026-09-14 18:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14  2:19 [PATCH] ext4:Fix WARNING in ext4_journalled_invalidate_folio shuo chen
2026-09-14  2:38 ` sashiko-bot
2026-09-14 10:13 ` Jan Kara
2026-09-14 16:41 ` [PATCH v2] " shuo chen
2026-09-14 17:07   ` sashiko-bot
2026-09-14 18:47   ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.