]> www.infradead.org Git - users/hch/block.git/commitdiff
block: add a bvec_set_folio helper
authorChristoph Hellwig <hch@lst.de>
Wed, 25 Jan 2023 16:55:15 +0000 (17:55 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 25 Jan 2023 17:19:23 +0000 (18:19 +0100)
A smaller wrapper around bvec_set_page that takes a folio instead.
There are only two potential users for this in the tree, but the number
will grow in the future.

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

index 9e3dac51eb26b603ef45444309c3cb72e06cc125..f094512ce3bda9176f69e77de3f7eff9a7c92d0f 100644 (file)
@@ -50,6 +50,19 @@ static inline void bvec_set_page(struct bio_vec *bv, struct page *page,
        bv->bv_offset = offset;
 }
 
+/**
+ * bvec_set_folio - initialize a bvec based off a struct folio
+ * @bv:                bvec to initialize
+ * @page:      folio the bvec should point to
+ * @len:       length of the bvec
+ * @offset:    offset into the folio
+ */
+static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio,
+               unsigned int len, unsigned int offset)
+{
+       bvec_set_page(bv, &folio->page, len, offset);
+}
+
 struct bvec_iter {
        sector_t                bi_sector;      /* device address in 512 byte
                                                   sectors */