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 <redacted>
Closes:https://lore.kernel.org/linux-ext4/CA+0ovCgxFN3TLpdS_O_Z48sARuQ-WR-JLDCqQWEmd9ELtkzddA@mail.gmail.com/T/ (local)
Signed-off-by: shuo chen <redacted>
---
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