Re: [PATCH 04/19] buffer: clear BH_Write_EIO when a buffer is forgotten

Jan Kara <[email protected]> Tue, 4 Aug 2026 10:29:04 +0200
Newsgroups dev.linux.lists.gfs2,dev.linux.lists.ocfs2-devel,org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <qjkgzks3sq57h2lek2ra75yqu46bh7uijesiddpcqvrxrdcmq4@cit3oay5pm3g>
On Sat 01-08-26 18:00:48, Chao Shi wrote:
> BH_Write_EIO records that the last write of this buffer failed.  It is
> cleared when the buffer is submitted for write again - see the
> test_set_buffer_req() check in __bh_submit() - but a filesystem freeing a
> metadata block never submits it again.  It calls bforget() and hands the
> block back to the allocator, so the flag outlives the block it refers to.
> 
> That does not matter much today, because the write error is also recorded
> by clearing BH_Uptodate and the buffer is discarded soon after.  It starts
> to matter in the rest of this series, which stops clearing BH_Uptodate on
> write error and makes BH_Write_EIO the way a failed metadata write is
> reported.
> 
> bforget() is where a filesystem says it no longer cares about this
> buffer's contents, so clear the error there alongside the dirty flag.
> 
> Suggested-by: Jan Kara <[email protected]>
> Signed-off-by: Chao Shi <[email protected]>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

								Honza

> ---
>  fs/buffer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 04fcc34e4fa6..7889c30d8715 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -1091,6 +1091,7 @@ EXPORT_SYMBOL(__brelse);
>  void __bforget(struct buffer_head *bh)
>  {
>  	clear_buffer_dirty(bh);
> +	clear_buffer_write_io_error(bh);
>  	remove_assoc_queue(bh);
>  	__brelse(bh);
>  }
> -- 
> 2.43.0
> 
-- 
Jan Kara <[email protected]>
SUSE Labs, CR