linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/bio-integrity: simplify the way of calculate nr_pages
@ 2020-02-24 13:12 Bob Liu
  2020-02-24 16:40 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Liu @ 2020-02-24 13:12 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, martin.petersen, Bob Liu

Remove unnecessary start/end variables.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
---
 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;
 
 	/* Allocate bio integrity payload and integrity vectors */
 	bip = bio_integrity_alloc(bio, GFP_NOIO, nr_pages);
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block/bio-integrity: simplify the way of calculate nr_pages
  2020-02-24 13:12 [PATCH] block/bio-integrity: simplify the way of calculate nr_pages Bob Liu
@ 2020-02-24 16:40 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-02-24 16:40 UTC (permalink / raw)
  To: Bob Liu, linux-block; +Cc: martin.petersen

On 2/24/20 6:12 AM, Bob Liu wrote:
> Remove unnecessary start/end variables.
> 
> Signed-off-by: Bob Liu <bob.liu@oracle.com>
> ---
>  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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-24 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 13:12 [PATCH] block/bio-integrity: simplify the way of calculate nr_pages Bob Liu
2020-02-24 16:40 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).