Re: [PATCH v2 12/21] fat: check for a metadata write error with buffer_write_io_error()

From: Jan Kara

Date: Wed Aug 26 2026 - 03:52:20 EST


On Thu 06-08-26 12:58:35, Chao Shi wrote:
> fat_sync_bhs() waits for the writes it issued and then tests
> !buffer_uptodate() to find the ones that failed. That relies on the write
> completion handler clearing BH_Uptodate on error, which this series
> removes: a buffer whose write failed still holds the data the filesystem
> asked to be written, so declaring it not up to date is wrong and makes
> callers re-read it.
>
> Test BH_Write_EIO, which is what the completion handler sets and what this
> code actually wants to know.
>
> No behaviour change today - a failed write sets BH_Write_EIO and clears
> BH_Uptodate together. It stops being a no-op at the end of the series,
> where the new test is the one that still works.
>
> Acked-by: Weidong Zhu <weizhu@xxxxxxx>
> Signed-off-by: Chao Shi <coshi036@xxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> fs/fat/misc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/fat/misc.c b/fs/fat/misc.c
> index be18f6b5819b..4a4cd0111e47 100644
> --- a/fs/fat/misc.c
> +++ b/fs/fat/misc.c
> @@ -356,7 +356,7 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
>
> for (i = 0; i < nr_bhs; i++) {
> wait_on_buffer(bhs[i]);
> - if (!err && !buffer_uptodate(bhs[i]))
> + if (!err && buffer_write_io_error(bhs[i]))
> err = -EIO;
> }
> return err;
> --
> 2.43.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR