[PATCH] ext4: report unwritten extent conversion failures as writeback errors

From: guolingxing

Date: Thu Oct 15 2026 - 06:36:07 EST


When a data writeback bio completes successfully but the subsequent
unwritten extent conversion fails, ext4_end_io_end() does not record
the error in the inode's mapping writeback error state.

Bio failures are already recorded by ext4_end_bio(), but conversion
failures are not. When the conversion is processed asynchronously,
its return value is not propagated to userspace, so fsync() may
return success despite the failed conversion.

Record conversion errors with mapping_set_error() before
ext4_release_io_end() ends folio writeback and wakes waiters. This
allows fsync() to observe the failure.

Fixes: b82e384c7bb9 ("ext4: optimize locking for end_io extent conversion")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: guolingxing <guolingxing@xxxxxxxxxx>
---
fs/ext4/page-io.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 0236b6b9785a..2afa4c096156 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -189,6 +189,8 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
} else {
ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
+ if (ret < 0)
+ mapping_set_error(inode->i_mapping, ret);
}
if (ret < 0 && !ext4_emergency_state(sb) &&
io_end->flag & EXT4_IO_END_UNWRITTEN) {
--
2.34.1