public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Ed Tsai <ed.tsai@mediatek.com>, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH V2 1/2] block: don't call into iov_iter_revert if nothing is left
Date: Thu,  9 Nov 2023 16:28:20 +0800	[thread overview]
Message-ID: <20231109082827.2276696-2-ming.lei@redhat.com> (raw)
In-Reply-To: <20231109082827.2276696-1-ming.lei@redhat.com>

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@redhat.com>
---
 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


  reply	other threads:[~2023-11-09  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09  8:28 [PATCH V2 0/2] block: try to make aligned bio in case of big chunk IO Ming Lei
2023-11-09  8:28 ` Ming Lei [this message]
2023-11-09 14:35   ` [PATCH V2 1/2] block: don't call into iov_iter_revert if nothing is left Christoph Hellwig
2023-11-09  8:28 ` [PATCH V2 2/2] block: try to make aligned bio in case of big chunk IO Ming Lei
2023-11-09 14:39   ` Christoph Hellwig
2023-11-09 19:30   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231109082827.2276696-2-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=ed.tsai@mediatek.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox