Re: [PATCH] block/bio-integrity: simplify the way of calculate nr_pages

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

 



On 2/24/20 6:12 AM, Bob Liu wrote:
> Remove unnecessary start/end variables.
> 
> Signed-off-by: Bob Liu <bob.liu@xxxxxxxxxx>
> ---
>  block/bio-integrity.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index bf62c25..575df98 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -202,7 +202,6 @@ bool bio_integrity_prep(struct bio *bio)
>  	struct blk_integrity *bi = blk_get_integrity(bio->bi_disk);
>  	struct request_queue *q = bio->bi_disk->queue;
>  	void *buf;
> -	unsigned long start, end;
>  	unsigned int len, nr_pages;
>  	unsigned int bytes, offset, i;
>  	unsigned int intervals;
> @@ -241,9 +240,7 @@ bool bio_integrity_prep(struct bio *bio)
>  		goto err_end_io;
>  	}
>  
> -	end = (((unsigned long) buf) + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
> -	start = ((unsigned long) buf) >> PAGE_SHIFT;
> -	nr_pages = end - start;
> +	nr_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;

This is incorrect if you straddle a page boundary, the existing code is
correct.

-- 
Jens Axboe




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux