Re: [PATCH v7 4/5] buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback

Jan Kara <[email protected]> Thu, 30 Jul 2026 11:31:44 +0200
Newsgroups org.ozlabs.lists.linux-erofs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-xfs,org.kvack.linux-mm
Message-ID <p2a3kz5oyjzsrbjivphnxv3dcf3gkjgtibd36fgfajajrfn4jr@m43y3mfpv4kb>
On Thu 30-07-26 02:57:54, Tal Zussman wrote:
> Set BIO_COMPLETE_IN_TASK in __bh_submit() for write bios when the folio
> has dropbehind set, so that buffer_head writeback completions get
> deferred to task context where folio_end_dropbehind() can safely
> invalidate folios.
> 
> Read completions are not deferred since dropbehind invalidation for
> reads is handled synchronously by the reader.
> 
> Reviewed-by: Christoph Hellwig <[email protected]>
> Signed-off-by: Tal Zussman <[email protected]>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/buffer.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/buffer.c b/fs/buffer.c
> index 9af5f061a1f8..6f099847240e 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -1203,6 +1203,9 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
>  
>  	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
>  
> +	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
> +		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
> +
>  	if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
>  		buffer_set_crypto_ctx(bio, bh, GFP_NOIO);
>  
> 
> -- 
> 2.39.5
> 
-- 
Jan Kara <[email protected]>
SUSE Labs, CR