public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: linux-block@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 3/4] block: don't bother iter advancing a fully done bio
Date: Wed, 13 Oct 2021 10:49:36 -0600	[thread overview]
Message-ID: <20211013164937.985367-4-axboe@kernel.dk> (raw)
In-Reply-To: <20211013164937.985367-1-axboe@kernel.dk>

If we're completing nbytes and nbytes is the size of the bio, don't bother
with calling into the iterator increment helpers. Just clear the bio
size and we're done.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/bio.c         |  4 ++--
 include/linux/bio.h | 13 +++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index a3c9ff23a036..874ff235aff7 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1289,7 +1289,7 @@ EXPORT_SYMBOL(submit_bio_wait);
  *
  * @bio will then represent the remaining, uncompleted portion of the io.
  */
-void bio_advance(struct bio *bio, unsigned bytes)
+void __bio_advance(struct bio *bio, unsigned bytes)
 {
 	if (bio_integrity(bio))
 		bio_integrity_advance(bio, bytes);
@@ -1297,7 +1297,7 @@ void bio_advance(struct bio *bio, unsigned bytes)
 	bio_crypt_advance(bio, bytes);
 	bio_advance_iter(bio, &bio->bi_iter, bytes);
 }
-EXPORT_SYMBOL(bio_advance);
+EXPORT_SYMBOL(__bio_advance);
 
 void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
 			struct bio *src, struct bvec_iter *src_iter)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 62d684b7dd4c..44b543e7baf6 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -119,6 +119,17 @@ static inline void bio_advance_iter_single(const struct bio *bio,
 		bvec_iter_advance_single(bio->bi_io_vec, iter, bytes);
 }
 
+extern void __bio_advance(struct bio *, unsigned);
+
+static inline void bio_advance(struct bio *bio, unsigned int nbytes)
+{
+	if (nbytes == bio->bi_iter.bi_size) {
+		bio->bi_iter.bi_size = 0;
+		return;
+	}
+	__bio_advance(bio, nbytes);
+}
+
 #define __bio_for_each_segment(bvl, bio, iter, start)			\
 	for (iter = (start);						\
 	     (iter).bi_size &&						\
@@ -381,8 +392,6 @@ static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
 struct request_queue;
 
 extern int submit_bio_wait(struct bio *bio);
-extern void bio_advance(struct bio *, unsigned);
-
 extern void bio_init(struct bio *bio, struct bio_vec *table,
 		     unsigned short max_vecs);
 extern void bio_uninit(struct bio *);
-- 
2.33.0


  parent reply	other threads:[~2021-10-13 16:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 16:49 [PATCHSET 0/4] Various block optimizations Jens Axboe
2021-10-13 16:49 ` [PATCH 1/4] block: provide helpers for rq_list manipulation Jens Axboe
2021-10-13 17:11   ` Christoph Hellwig
2021-10-13 17:47     ` Jens Axboe
2021-10-13 16:49 ` [PATCH 2/4] block: inline fast path of driver tag allocation Jens Axboe
2021-10-13 17:22   ` Christoph Hellwig
2021-10-13 17:46     ` Jens Axboe
2021-10-13 17:57       ` Christoph Hellwig
2021-10-13 18:07         ` Jens Axboe
2021-10-13 16:49 ` Jens Axboe [this message]
2021-10-13 17:26   ` [PATCH 3/4] block: don't bother iter advancing a fully done bio Christoph Hellwig
2021-10-13 17:46     ` Jens Axboe
2021-10-13 16:49 ` [PATCH 4/4] block: move update request helpers into blk-mq.c Jens Axboe
2021-10-13 17:32   ` Christoph Hellwig
2021-10-13 17:46     ` Jens Axboe
2021-10-13 17:54       ` Christoph Hellwig
2021-10-13 17:57         ` Jens Axboe
2021-10-14  5:00           ` Christoph Hellwig
2021-10-14 15:14             ` Jens Axboe

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=20211013164937.985367-4-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --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