[PATCH v2 2/2] ext4: check return value of blkdev_issue_flush() when starting a fast commit

From: guolingxing

Date: Tue Oct 13 2026 - 04:25:10 EST


When the file system device differs from the journal device, a cache
flush is issued on the file system device before fast commit blocks
are written, but the return value is ignored. If the cache flush
fails, the fast commit blocks are written and the fast commit
completes anyway, even though the updates covered by the preceding
transactions may not be on stable storage yet, so the fast commit may
provide guarantees it cannot keep.

Check the return value of blkdev_issue_flush() and abort the fast
commit if the cache flush fails. ext4_fc_commit() will then fall back
to a full journal commit, so the caller still gets the expected
durability guarantees.

Since a cache flush failure now aborts the fast commit, also issue
the flush only when the journal barrier option is enabled, consistent
with the file system device flush issued during a full journal commit
and with the fast commit tail block flush. This keeps file systems
mounted with nobarrier working on devices with failing cache flushes.

Fixes: da0c5d2695265 ("ext4: issue fsdev cache flush before starting fast commit")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: guolingxing <guolingxing@xxxxxxxxxx>
---
fs/ext4/fast_commit.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 0cac890cf370..c669f4cd7d85 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -1425,8 +1425,12 @@ static int ext4_fc_perform_commit(journal_t *journal, tid_t commit_tid)
* Step 5: If file system device is different from journal device,
* issue a cache flush before we start writing fast commit blocks.
*/
- if (journal->j_fs_dev != journal->j_dev)
- blkdev_issue_flush(journal->j_fs_dev);
+ if (journal->j_fs_dev != journal->j_dev &&
+ journal->j_flags & JBD2_BARRIER) {
+ ret = blkdev_issue_flush(journal->j_fs_dev);
+ if (ret)
+ return ret;
+ }

blk_start_plug(&plug);
alloc_ctx = ext4_fc_lock(sb);
--
2.34.1