From: Jens Axboe Date: Thu, 7 Jun 2018 20:42:05 +0000 (-0600) Subject: block: add bioset_init_from_src() helper X-Git-Tag: v4.18-rc1~36^2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=28e89fd914a22e8a64f05ae2f0048b06165f371b;p=users%2Fhch%2Fxfs.git block: add bioset_init_from_src() helper Add a helper that allows a caller to initialize a new bio_set, using the settings from an existing bio_set. Reported-by: Venkat R.B Tested-by: Venkat R.B Tested-by: Li Wang Reviewed-by: Mike Snitzer Signed-off-by: Jens Axboe --- diff --git a/block/bio.c b/block/bio.c index 595663e0281a..bf516d873ce9 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1967,6 +1967,24 @@ bad: } EXPORT_SYMBOL(bioset_init); +/* + * Initialize and setup a new bio_set, based on the settings from + * another bio_set. + */ +int bioset_init_from_src(struct bio_set *bs, struct bio_set *src) +{ + int flags; + + flags = 0; + if (src->bvec_pool.min_nr) + flags |= BIOSET_NEED_BVECS; + if (src->rescue_workqueue) + flags |= BIOSET_NEED_RESCUER; + + return bioset_init(bs, src->bio_pool.min_nr, src->front_pad, flags); +} +EXPORT_SYMBOL(bioset_init_from_src); + #ifdef CONFIG_BLK_CGROUP /** diff --git a/include/linux/bio.h b/include/linux/bio.h index 810a8bee8f85..84abd1706dcb 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -417,6 +417,7 @@ enum { extern int bioset_init(struct bio_set *, unsigned int, unsigned int, int flags); extern void bioset_exit(struct bio_set *); extern int biovec_init_pool(mempool_t *pool, int pool_entries); +extern int bioset_init_from_src(struct bio_set *bs, struct bio_set *src); extern struct bio *bio_alloc_bioset(gfp_t, unsigned int, struct bio_set *); extern void bio_put(struct bio *);