]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
block: Fix __blkdev_issue_zeroout loop
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 6 Jul 2017 11:21:15 +0000 (20:21 +0900)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Jul 2017 15:43:20 +0000 (09:43 -0600)
commit615d22a51c04856efe62af6e1d5b450aaf5cc2c0
tree2d80a79b5a229c70969784fe3b1408e32b32679c
parent8a05aa4ce3bf767b7bd72851da89c23d084d1ecb
block: Fix __blkdev_issue_zeroout loop

The BIO issuing loop in __blkdev_issue_zeroout() is allocating BIOs
with a maximum number of bvec (pages) equal to

min(nr_sects, (sector_t)BIO_MAX_PAGES)

This works since the requested number of bvecs will always be limited
to the absolute maximum number supported (BIO_MAX_PAGES), but this is
ineficient as too many bvec entries may be requested due to the
different units being used in the min() operation (number of sectors vs
number of pages).
To fix this, introduce the helper __blkdev_sectors_to_bio_pages() to
correctly calculate the number of bvecs for zeroout BIOs as the issuing
loop progresses. The calculation is done using consistent units and
makes sure that the number of pages return is at least 1 (for cases
where the number of sectors is less that the number of sectors in
a page).

Also remove a trailing space after the bit shift in the internal loop
min() call.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-lib.c