]> www.infradead.org Git - users/hch/block.git/commitdiff
block: add a bvec_set_virt helper
authorChristoph Hellwig <hch@lst.de>
Wed, 25 Jan 2023 16:55:28 +0000 (17:55 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 25 Jan 2023 17:20:53 +0000 (18:20 +0100)
A small wrapper around bvec_set_page for callers that have a virtual
address.

Signed-off-by: Christoph Hellwig <hch@lst.de>
include/linux/bvec.h

index f094512ce3bda9176f69e77de3f7eff9a7c92d0f..7031d83af02267a831447933e90a350fc86575ed 100644 (file)
@@ -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 */