Skip to content

Commit 5728777

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: add a bioset pointer to iomap_read_folio_ops
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>
1 parent 6810365 commit 5728777

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

fs/iomap/bio.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ static void iomap_bio_submit_read(const struct iomap_iter *iter,
2424
submit_bio(ctx->read_ctx);
2525
}
2626

27+
static struct bio_set *iomap_read_bio_set(struct iomap_read_folio_ctx *ctx)
28+
{
29+
if (ctx->ops && ctx->ops->bio_set)
30+
return ctx->ops->bio_set;
31+
return &fs_bio_set;
32+
}
33+
2734
static void iomap_read_alloc_bio(const struct iomap_iter *iter,
2835
struct iomap_read_folio_ctx *ctx, size_t plen)
2936
{
3037
const struct iomap *iomap = &iter->iomap;
3138
unsigned int nr_vecs = DIV_ROUND_UP(iomap_length(iter), PAGE_SIZE);
39+
struct bio_set *bio_set = iomap_read_bio_set(ctx);
3240
struct folio *folio = ctx->cur_folio;
3341
gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL);
3442
gfp_t orig_gfp = gfp;
@@ -47,9 +55,11 @@ static void iomap_read_alloc_bio(const struct iomap_iter *iter,
4755
* having to deal with partial page reads. This emulates what
4856
* do_mpage_read_folio does.
4957
*/
50-
bio = bio_alloc(iomap->bdev, bio_max_segs(nr_vecs), REQ_OP_READ, gfp);
58+
bio = bio_alloc_bioset(iomap->bdev, bio_max_segs(nr_vecs), REQ_OP_READ,
59+
gfp, bio_set);
5160
if (!bio)
52-
bio = bio_alloc(iomap->bdev, 1, REQ_OP_READ, orig_gfp);
61+
bio = bio_alloc_bioset(iomap->bdev, 1, REQ_OP_READ, orig_gfp,
62+
bio_set);
5363
if (ctx->rac)
5464
bio->bi_opf |= REQ_RAHEAD;
5565
bio->bi_iter.bi_sector = iomap_sector(iomap, iter->pos);

include/linux/iomap.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ struct iomap_read_ops {
515515
*/
516516
void (*submit_read)(const struct iomap_iter *iter,
517517
struct iomap_read_folio_ctx *ctx);
518+
519+
/*
520+
* Optional, allows filesystem to specify own bio_set, so new bio's
521+
* can be allocated from the provided bio_set.
522+
*/
523+
struct bio_set *bio_set;
518524
};
519525

520526
/*

0 commit comments

Comments
 (0)