All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@fb.com>
To: <linux-fsdevel@vger.kernel.org>, <linux-block@vger.kernel.org>,
	<linux-nvme@lists.infradead.org>
Cc: <axboe@kernel.dk>, Kernel Team <Kernel-team@fb.com>, <hch@lst.de>,
	<willy@infradead.org>, <sagi@grimberg.me>,
	Keith Busch <kbusch@kernel.org>
Subject: [PATCH 07/12] block: allow copying pre-registered bvecs
Date: Thu, 30 Jun 2022 13:42:07 -0700	[thread overview]
Message-ID: <20220630204212.1265638-8-kbusch@fb.com> (raw)
In-Reply-To: <20220630204212.1265638-1-kbusch@fb.com>

From: Keith Busch <kbusch@kernel.org>

If a bio was initialized with bi_max_vecs, then append the requested
bvec instead of overriding it. This will allow mixing bvecs from
multiple sources.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 block/bio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index b0c85778257a..391cad726ff2 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1130,12 +1130,25 @@ void __bio_release_pages(struct bio *bio, bool mark_dirty)
 }
 EXPORT_SYMBOL_GPL(__bio_release_pages);
 
+static void bio_copy_bvec(struct bio *bio, struct iov_iter *iter)
+{
+	memcpy(&bio->bi_io_vec[bio->bi_vcnt], iter->bvec,
+	       iter->nr_segs * sizeof(struct bio_vec));
+	bio->bi_vcnt += iter->nr_segs;
+	bio->bi_iter.bi_size += iov_iter_count(iter);
+}
+
 void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
 {
 	size_t size = iov_iter_count(iter);
 
 	WARN_ON_ONCE(bio->bi_max_vecs);
 
+	if (bio->bi_max_vecs) {
+		bio_copy_bvec(bio, iter);
+		return;
+	}
+
 	if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
 		struct request_queue *q = bdev_get_queue(bio->bi_bdev);
 		size_t max_sectors = queue_max_zone_append_sectors(q);
-- 
2.30.2


  parent reply	other threads:[~2022-06-30 20:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 20:42 [PATCH 00/12] block: support for partial sector reads Keith Busch
2022-06-30 20:42 ` [PATCH 01/12] block: move direct io alignment check to common Keith Busch
2022-06-30 20:42 ` [PATCH 02/12] iomap: save copy of bdev for direct io Keith Busch
2022-06-30 20:42 ` [PATCH 03/12] iomap: get logical block size directly Keith Busch
2022-06-30 20:42 ` [PATCH 04/12] iomap: use common blkdev alignment check Keith Busch
2022-06-30 20:42 ` [PATCH 05/12] block: add bit bucket capabilities Keith Busch
2022-06-30 20:42 ` [PATCH 06/12] nvme: add support for bit buckets Keith Busch
2022-06-30 20:42 ` Keith Busch [this message]
2022-07-01  2:40   ` [PATCH 07/12] block: allow copying pre-registered bvecs Keith Busch
2022-06-30 20:42 ` [PATCH 08/12] block: add bio number of vecs helper for partials Keith Busch
2022-06-30 20:42 ` [PATCH 09/12] block: add partial sector parameter helper Keith Busch
2022-06-30 20:42 ` [PATCH 10/12] block: add direct-io partial sector read support Keith Busch
2022-06-30 20:42 ` [PATCH 11/12] iomap: " Keith Busch
2022-06-30 20:42 ` [PATCH 12/12] block: export and document bit_bucket attribute Keith Busch

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=20220630204212.1265638-8-kbusch@fb.com \
    --to=kbusch@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.