]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iomap: add a bioset pointer to iomap_read_folio_ops
authorChristoph Hellwig <hch@lst.de>
Mon, 23 Feb 2026 13:20:13 +0000 (05:20 -0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 10 Mar 2026 09:29:03 +0000 (10:29 +0100)
Optionally allocate the bio from the bioset provided in
iomap_read_folio_ops.  If no bioset is provided, fs_bio_set is still
used, which is the standard bioset for file systems.

Based on a patch from Goldwyn Rodrigues <rgoldwyn@suse.com>.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260223132021.292832-14-hch@lst.de
Tested-by: Anuj Gupta <anuj20.g@samsung.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/bio.c
include/linux/iomap.h

index 903cb9fe759e79911e401e08fc7760a1e6982669..259a2bf95a43aae50ed934899fafc95d15cb0e53 100644 (file)
@@ -24,11 +24,19 @@ static void iomap_bio_submit_read(const struct iomap_iter *iter,
        submit_bio(ctx->read_ctx);
 }
 
+static struct bio_set *iomap_read_bio_set(struct iomap_read_folio_ctx *ctx)
+{
+       if (ctx->ops && ctx->ops->bio_set)
+               return ctx->ops->bio_set;
+       return &fs_bio_set;
+}
+
 static void iomap_read_alloc_bio(const struct iomap_iter *iter,
                struct iomap_read_folio_ctx *ctx, size_t plen)
 {
        const struct iomap *iomap = &iter->iomap;
        unsigned int nr_vecs = DIV_ROUND_UP(iomap_length(iter), PAGE_SIZE);
+       struct bio_set *bio_set = iomap_read_bio_set(ctx);
        struct folio *folio = ctx->cur_folio;
        gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL);
        gfp_t orig_gfp = gfp;
@@ -47,9 +55,11 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter,
         * having to deal with partial page reads.  This emulates what
         * do_mpage_read_folio does.
         */
-       bio = bio_alloc(iomap->bdev, bio_max_segs(nr_vecs), REQ_OP_READ, gfp);
+       bio = bio_alloc_bioset(iomap->bdev, bio_max_segs(nr_vecs), REQ_OP_READ,
+                       gfp, bio_set);
        if (!bio)
-               bio = bio_alloc(iomap->bdev, 1, REQ_OP_READ, orig_gfp);
+               bio = bio_alloc_bioset(iomap->bdev, 1, REQ_OP_READ, orig_gfp,
+                               bio_set);
        if (ctx->rac)
                bio->bi_opf |= REQ_RAHEAD;
        bio->bi_iter.bi_sector = iomap_sector(iomap, iter->pos);
index b2b9e649a3b8636f6600097efea8cd3209bbe0e0..387a1174522ff111bd4b5e3b92209d60f72711a4 100644 (file)
@@ -515,6 +515,12 @@ struct iomap_read_ops {
         */
        void (*submit_read)(const struct iomap_iter *iter,
                        struct iomap_read_folio_ctx *ctx);
+
+       /*
+        * Optional, allows filesystem to specify own bio_set, so new bio's
+        * can be allocated from the provided bio_set.
+        */
+       struct bio_set *bio_set;
 };
 
 /*