From: Christoph Hellwig <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ilya Dryomov <[email protected]>,
"Michael S. Tsirkin" <[email protected]>,
Jason Wang <[email protected]>,
Minchan Kim <[email protected]>,
Sergey Senozhatsky <[email protected]>,
Keith Busch <[email protected]>, Sagi Grimberg <[email protected]>,
Chaitanya Kulkarni <[email protected]>,
"Martin K. Petersen" <[email protected]>,
David Howells <[email protected]>,
Marc Dionne <[email protected]>,
Xiubo Li <[email protected]>, Steve French <[email protected]>,
Trond Myklebust <[email protected]>,
Anna Schumaker <[email protected]>,
Mike Marshall <[email protected]>,
Andrew Morton <[email protected]>,
"David S. Miller" <[email protected]>,
Eric Dumazet <[email protected]>,
Jakub Kicinski <[email protected]>, Paolo Abeni <[email protected]>,
Chuck Lever <[email protected]>,
[email protected], [email protected],
[email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected], [email protected],
[email protected]
Subject: [PATCH 01/23] block: factor out a bvec_set_page helper
Date: Mon, 30 Jan 2023 10:21:35 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Add a helper to initialize a bvec based of a page pointer. This will help
removing various open code bvec initializations.
Signed-off-by: Christoph Hellwig <[email protected]>
---
block/bio-integrity.c | 7 +------
block/bio.c | 12 ++----------
include/linux/bvec.h | 15 +++++++++++++++
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 3f5685c00e360b..a3776064c52a16 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -124,23 +124,18 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
unsigned int len, unsigned int offset)
{
struct bio_integrity_payload *bip = bio_integrity(bio);
- struct bio_vec *iv;
if (bip->bip_vcnt >= bip->bip_max_vcnt) {
printk(KERN_ERR "%s: bip_vec full\n", __func__);
return 0;
}
- iv = bip->bip_vec + bip->bip_vcnt;
-
if (bip->bip_vcnt &&
bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
&bip->bip_vec[bip->bip_vcnt - 1], offset))
return 0;
- iv->bv_page = page;
- iv->bv_len = len;
- iv->bv_offset = offset;
+ bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
bip->bip_vcnt++;
return len;
diff --git a/block/bio.c b/block/bio.c
index d7fbc7adfc50aa..71e411a0c12950 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1029,10 +1029,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
if (bio->bi_vcnt >= queue_max_segments(q))
return 0;
- bvec = &bio->bi_io_vec[bio->bi_vcnt];
- bvec->bv_page = page;
- bvec->bv_len = len;
- bvec->bv_offset = offset;
+ bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, offset);
bio->bi_vcnt++;
bio->bi_iter.bi_size += len;
return len;
@@ -1108,15 +1105,10 @@ EXPORT_SYMBOL_GPL(bio_add_zone_append_page);
void __bio_add_page(struct bio *bio, struct page *page,
unsigned int len, unsigned int off)
{
- struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt];
-
WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
WARN_ON_ONCE(bio_full(bio, len));
- bv->bv_page = page;
- bv->bv_offset = off;
- bv->bv_len = len;
-
+ bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, off);
bio->bi_iter.bi_size += len;
bio->bi_vcnt++;
}
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 35c25dff651a5e..9e3dac51eb26b6 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -35,6 +35,21 @@ struct bio_vec {
unsigned int bv_offset;
};
+/**
+ * bvec_set_page - initialize a bvec based off a struct page
+ * @bv: bvec to initialize
+ * @page: page the bvec should point to
+ * @len: length of the bvec
+ * @offset: offset into the page
+ */
+static inline void bvec_set_page(struct bio_vec *bv, struct page *page,
+ unsigned int len, unsigned int offset)
+{
+ bv->bv_page = page;
+ bv->bv_len = len;
+ bv->bv_offset = offset;
+}
+
struct bvec_iter {
sector_t bi_sector; /* device address in 512 byte
sectors */
--
2.39.0
next prev parent reply other threads:[~2023-01-30 9:23 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 9:21 add bvec initialization helpers Christoph Hellwig
2023-01-30 9:21 ` Christoph Hellwig [this message]
2023-01-30 11:55 ` [PATCH 01/23] block: factor out a bvec_set_page helper Johannes Thumshirn
2023-01-30 17:09 ` Bart Van Assche
2023-01-30 19:24 ` Bart Van Assche
2023-01-31 13:45 ` Christoph Hellwig
2023-01-31 4:47 ` Jakub Kicinski
2023-01-31 5:00 ` Matthew Wilcox
2023-01-31 5:28 ` Matthew Wilcox
2023-01-31 5:52 ` Jakub Kicinski
2023-01-31 6:55 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 02/23] block: add a bvec_set_folio helper Christoph Hellwig
2023-01-30 11:54 ` Johannes Thumshirn
2023-01-31 6:55 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 03/23] block: add a bvec_set_virt helper Christoph Hellwig
2023-01-30 12:08 ` Johannes Thumshirn
2023-01-31 6:55 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 04/23] sd: factor out a sd_set_special_bvec helper Christoph Hellwig
2023-01-31 6:56 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 05/23] target: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-31 6:56 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 06/23] nvmet: " Christoph Hellwig
2023-01-30 12:07 ` Johannes Thumshirn
2023-01-31 6:57 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 07/23] nvme: use bvec_set_virt to initialize special_vec Christoph Hellwig
2023-01-30 12:09 ` Johannes Thumshirn
2023-01-31 6:58 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 08/23] rbd: use bvec_set_page to initialize the copy up bvec Christoph Hellwig
2023-01-30 17:47 ` Ilya Dryomov
2023-01-30 9:21 ` [PATCH 09/23] virtio_blk: use bvec_set_virt to initialize special_vec Christoph Hellwig
2023-01-30 15:17 ` Michael S. Tsirkin
2023-01-31 3:22 ` Jason Wang
2023-01-31 6:57 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 10/23] zram: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 13:31 ` Johannes Thumshirn
2023-01-31 2:34 ` Sergey Senozhatsky
2023-01-30 9:21 ` [PATCH 11/23] afs: use bvec_set_folio to initialize a bvec Christoph Hellwig
2023-01-30 9:21 ` [PATCH 12/23] ceph: use bvec_set_page " Christoph Hellwig
2023-01-30 18:02 ` Ilya Dryomov
2023-01-31 1:51 ` Xiubo Li
2023-01-30 9:21 ` [PATCH 13/23] cifs: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 15:56 ` Paulo Alcantara
2023-01-30 9:21 ` [PATCH 14/23] coredump: use bvec_set_page to initialize a bvec Christoph Hellwig
2023-01-30 9:21 ` [PATCH 15/23] nfs: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 9:21 ` [PATCH 16/23] orangefs: use bvec_set_{page,folio} " Christoph Hellwig
2023-01-30 9:21 ` [PATCH 17/23] splice: use bvec_set_page to initialize a bvec Christoph Hellwig
2023-01-30 9:21 ` [PATCH 18/23] io_uring: " Christoph Hellwig
2023-01-31 6:59 ` Chaitanya Kulkarni
2023-01-30 9:21 ` [PATCH 19/23] swap: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 9:21 ` [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec Christoph Hellwig
2023-01-30 9:21 ` [PATCH 21/23] sunrpc: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 15:38 ` Chuck Lever III
2023-01-30 9:21 ` [PATCH 22/23] vring: use bvec_set_page to initialize a bvec Christoph Hellwig
2023-01-30 15:19 ` Michael S. Tsirkin
2023-01-31 2:31 ` Jason Wang
2023-01-30 9:21 ` [PATCH 23/23] net-ceph: use bvec_set_page to initialize bvecs Christoph Hellwig
2023-01-30 18:20 ` Ilya Dryomov
2023-01-30 10:31 ` [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec David Howells
2023-01-30 10:33 ` Christoph Hellwig
2023-01-30 11:24 ` David Howells
2023-01-30 12:18 ` Christoph Hellwig
2023-01-30 10:33 ` [PATCH 01/23] block: factor out a bvec_set_page helper David Howells
2023-01-30 10:36 ` Christoph Hellwig
2023-01-30 18:35 ` Ilya Dryomov
2023-01-30 15:58 ` [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec David Howells
2023-01-30 15:59 ` [PATCH 11/23] afs: use bvec_set_folio " David Howells
-- strict thread matches above, loose matches on Subject: below --
2023-02-03 15:06 add bvec initialization helpers v2 Christoph Hellwig
2023-02-03 15:06 ` [PATCH 01/23] block: factor out a bvec_set_page helper Christoph Hellwig
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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