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

From: Zhang Yi

Date: Mon Nov 02 2026 - 07:29:43 EST


On 11/1/2026 6:21 PM, guolingxing wrote:
> 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.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: guolingxing <guolingxing@xxxxxxxxxx>
> Reviewed-by: Jan Kara <jack@xxxxxxx>

Thank you for the fix. This looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@xxxxxxxxxx>

> ---
> Changes since v1:
> - Drop the incorrect Fixes tag. The conversion error was already lost
> before commit b82e384c7bb9, as pointed out by Jan Kara.
> - Collect Reviewed-by from Jan Kara.
>
> 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 734d856a6d478..2701452fa65ca 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -192,6 +192,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) {