Most of times all pages are just added to bio, and nothing is left, so not necessary to call into iov_iter_revert(). Same with block size alignment handling. Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/bio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/bio.c b/block/bio.c index 816d412c06e9..09a5e71a0372 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1262,8 +1262,11 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) if (bio->bi_bdev) { size_t trim = size & (bdev_logical_block_size(bio->bi_bdev) - 1); - iov_iter_revert(iter, trim); - size -= trim; + + if (trim) { + iov_iter_revert(iter, trim); + size -= trim; + } } if (unlikely(!size)) { @@ -1286,7 +1289,8 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) offset = 0; } - iov_iter_revert(iter, left); + if (left) + iov_iter_revert(iter, left); out: while (i < nr_pages) bio_release_page(bio, pages[i++]); -- 2.41.0