[PATCH 03/23] block: add a bvec_set_virt helper
Christoph Hellwig
hch at lst.de
Fri Feb 3 07:06:14 PST 2023
A small wrapper around bvec_set_page for callers that have a virtual
address.
Signed-off-by: Christoph Hellwig <hch at lst.de>
Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn at wdc.com>
---
include/linux/bvec.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 2bae1134499e7f..f2d22931f3030a 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -63,6 +63,18 @@ static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio,
bvec_set_page(bv, &folio->page, len, offset);
}
+/**
+ * bvec_set_virt - initialize a bvec based on a virtual address
+ * @bv: bvec to initialize
+ * @vaddr: virtual address to set the bvec to
+ * @len: length of the bvec
+ */
+static inline void bvec_set_virt(struct bio_vec *bv, void *vaddr,
+ unsigned int len)
+{
+ bvec_set_page(bv, virt_to_page(vaddr), len, offset_in_page(vaddr));
+}
+
struct bvec_iter {
sector_t bi_sector; /* device address in 512 byte
sectors */
--
2.39.0
More information about the Linux-nvme
mailing list