Re: [PATCH 05/19] buffer: discard BH_Write_EIO along with the rest of the buffer state

From: Jan Kara

Date: Tue Aug 04 2026 - 04:33:21 EST


On Sat 01-08-26 18:00:49, Chao Shi wrote:
> discard_buffer() strips the state that describes where a buffer lives and
> what has happened to it, because after an invalidate none of it applies any
> more. BH_Write_EIO belongs in that set for the same reason: it describes a
> write of the data that is being thrown away.
>
> Leaving it set means a buffer_head reused for a different block starts life
> carrying somebody else's write error. Like the bforget() change, this is
> mostly theoretical today and becomes load bearing once the rest of the
> series makes BH_Write_EIO the report of a failed metadata write.
>
> Suggested-by: Jan Kara <jack@xxxxxxx>
> Signed-off-by: Chao Shi <coshi036@xxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> fs/buffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 7889c30d8715..50a63d964815 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -1518,7 +1518,7 @@ EXPORT_SYMBOL(folio_set_bh);
> /* Bits that are cleared during an invalidate */
> #define BUFFER_FLAGS_DISCARD \
> (1 << BH_Mapped | 1 << BH_New | 1 << BH_Req | \
> - 1 << BH_Delay | 1 << BH_Unwritten)
> + 1 << BH_Delay | 1 << BH_Unwritten | 1 << BH_Write_EIO)
>
> static void discard_buffer(struct buffer_head * bh)
> {
> --
> 2.43.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR