summaryrefslogtreecommitdiff
path: root/include/linux/bvec.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-02-03 18:06:12 +0300
committerJens Axboe <axboe@kernel.dk>2023-02-03 18:20:54 +0300
commitd58cdfae6a22e5079656c487aad669597a0635c8 (patch)
treeb2cfec440f8e45d1b2e75feecf6737b0681870db /include/linux/bvec.h
parent3f13ab7c80fdb0ada86a8e3e818960bc1ccbaa59 (diff)
downloadlinux-d58cdfae6a22e5079656c487aad669597a0635c8.tar.xz
block: factor out a bvec_set_page helper
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 <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20230203150634.3199647-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/bvec.h')
-rw-r--r--include/linux/bvec.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 7939b345ee7f..a7b7c016b9a3 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -34,6 +34,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 */