block/bio-integrity: simplify the way of calculate nr_pages
PATCH 1/1 block/bio-integrity: simplify the way of calculate nr_pages
Remove unnecessary start/end variables.
Signed-off-by Bob Liu <[email protected]>
--- block/bio-integrity.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
block/bio-integrity.c +1 -4
@@ -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);
Signature · 1 line
2.9.5
Jens Axboe
maintainerQuoted 20 lines · Bob Liu
Remove unnecessary start/end variables.
Signed-off-by Bob Liu <[email protected]>--- block/bio-integrity.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)block/bio-integrity.c +0
-1@@ -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;
block/bio-integrity.c bool bio_integrity_prep(struct bio *bio) · line 243
Quoted 7 lines
block/bio-integrity.c +1
-3@@ -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.
Signature · 1 line
Jens Axboe