Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
@ 2026-10-12 11:47 guolingxing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: guolingxing @ 2026-10-12 11:47 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
system device to make sure all checkpointed data are on permanent
storage before it updates the log tail in the superblock.  However
the return value of blkdev_issue_flush() is ignored so if the flush
fails, we still advance the log tail.  After a crash the journal
recovery will consider the checkpointed transactions as committed
and skip the replay while their data may have never reached the
disk, which may lead to a filesystem corruption.

Abort the journal when the flush fails, similar to how we abort
when detecting writeback errors of the file system device.

Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/checkpoint.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 513273712010..9bbce4c8cadb 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -346,8 +346,14 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
 	 * need this to guarantee correctness.  Fortunately
 	 * jbd2_cleanup_journal_tail() doesn't get called all that often.
 	 */
-	if (journal->j_flags & JBD2_BARRIER)
-		blkdev_issue_flush(journal->j_fs_dev);
+	if (journal->j_flags & JBD2_BARRIER) {
+		int err = blkdev_issue_flush(journal->j_fs_dev);
+
+		if (err) {
+			jbd2_journal_abort(journal, err);
+			return err;
+		}
+	}
 
 	return __jbd2_update_log_tail(journal, first_tid, blocknr);
 }
-- 
2.34.1


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

end of thread, other threads:[~2026-10-13 12:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
2026-10-12 12:10   ` sashiko-bot
2026-10-12 15:31   ` Jan Kara
2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
2026-10-12 12:16   ` sashiko-bot
2026-10-12 15:33   ` Jan Kara
2026-10-12 12:03 ` [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing sashiko-bot
2026-10-12 15:29 ` Jan Kara
2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
2026-10-13  1:50     ` sashiko-bot
2026-10-13  1:40   ` [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
2026-10-13  1:48     ` sashiko-bot
2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
2026-10-13  1:49     ` sashiko-bot
2026-10-13 12:20     ` Jan Kara

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