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

From: Jan Kara

Date: Mon Oct 19 2026 - 06:04:24 EST


On Thu 15-10-26 10:29:43, 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.
>
> Fixes: b82e384c7bb9 ("ext4: optimize locking for end_io extent conversion")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: guolingxing <guolingxing@xxxxxxxxxx>

I don't think the Fixes tag is correct. Even before b82e384c7bb9 we seem to
have been dropping the error on the floor. But otherwise feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> 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
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR