Re: [PATCH 14/19] dm-integrity: use bio_add_virt_nofail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, 30 Apr 2025, Christoph Hellwig wrote:

> Convert the __bio_add_page(..., virt_to_page(), ...) pattern to the
> bio_add_virt_nofail helper implementing it, and do the same for the
> similar pattern using bio_add_page for adding the first segment after
> a bio allocation as that can't fail either.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>

Acked-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>

> ---
>  drivers/md/dm-integrity.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
> index 2a283feb3319..9dca9dbabfaa 100644
> --- a/drivers/md/dm-integrity.c
> +++ b/drivers/md/dm-integrity.c
> @@ -2557,14 +2557,8 @@ static void dm_integrity_inline_recheck(struct work_struct *w)
>  		char *mem;
>  
>  		outgoing_bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_READ, GFP_NOIO, &ic->recheck_bios);
> -
> -		r = bio_add_page(outgoing_bio, virt_to_page(outgoing_data), ic->sectors_per_block << SECTOR_SHIFT, 0);
> -		if (unlikely(r != (ic->sectors_per_block << SECTOR_SHIFT))) {
> -			bio_put(outgoing_bio);
> -			bio->bi_status = BLK_STS_RESOURCE;
> -			bio_endio(bio);
> -			return;
> -		}
> +		bio_add_virt_nofail(outgoing_bio, outgoing_data,
> +				ic->sectors_per_block << SECTOR_SHIFT);
>  
>  		bip = bio_integrity_alloc(outgoing_bio, GFP_NOIO, 1);
>  		if (IS_ERR(bip)) {
> @@ -3211,7 +3205,8 @@ static void integrity_recalc_inline(struct work_struct *w)
>  
>  	bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_READ, GFP_NOIO, &ic->recalc_bios);
>  	bio->bi_iter.bi_sector = ic->start + SB_SECTORS + range.logical_sector;
> -	__bio_add_page(bio, virt_to_page(recalc_buffer), range.n_sectors << SECTOR_SHIFT, offset_in_page(recalc_buffer));
> +	bio_add_virt_nofail(bio, recalc_buffer,
> +			range.n_sectors << SECTOR_SHIFT);
>  	r = submit_bio_wait(bio);
>  	bio_put(bio);
>  	if (unlikely(r)) {
> @@ -3228,7 +3223,8 @@ static void integrity_recalc_inline(struct work_struct *w)
>  
>  	bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_WRITE, GFP_NOIO, &ic->recalc_bios);
>  	bio->bi_iter.bi_sector = ic->start + SB_SECTORS + range.logical_sector;
> -	__bio_add_page(bio, virt_to_page(recalc_buffer), range.n_sectors << SECTOR_SHIFT, offset_in_page(recalc_buffer));
> +	bio_add_virt_nofail(bio, recalc_buffer,
> +			range.n_sectors << SECTOR_SHIFT);
>  
>  	bip = bio_integrity_alloc(bio, GFP_NOIO, 1);
>  	if (unlikely(IS_ERR(bip))) {
> -- 
> 2.47.2
> 
> 





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux