fix and cleanup device mapper bioset initialization
Subsystems (2)
Hi Mike,
the first patch fixes the device mapper bioset to restore the previous behavior of preallocating biosets instead of allocating them at bind time, and to actually allocate pools for the integrity data. The others are cleanups on top of that.
Diffstat:
block/bio.c | 20 ------- drivers/md/dm-core.h | 14 ++++- drivers/md/dm-rq.c | 3 - drivers/md/dm-table.c | 66 ++++++++++++++---------- drivers/md/dm.c | 136 +++++++++----------------------------------------- drivers/md/dm.h | 5 - include/linux/bio.h | 1 7 files changed, 78 insertions(+), 167 deletions(-)
PATCH 1/4 dm: fix bio_set allocation
The use of bioset_init_from_src mean that the pre-allocated pools weren't used for anything except parameter passing, and the integrity pool creation got completely lost for the actual live mapped_device. Fix that by assigning the actual preallocated dm_md_mempools to the mapped_device and using that for I/O instead of creating new mempools.
--- drivers/md/dm-core.h | 11 ++++-- drivers/md/dm-rq.c | 2 +- drivers/md/dm-table.c | 11 ------ drivers/md/dm.c | 84 +++++++++++++------------------------------ drivers/md/dm.h | 2 -- 5 files changed, 35 insertions(+), 75 deletions(-)
drivers/md/dm-core.h +9 -2
@@ -33,6 +33,14 @@ struct dm_kobject_holder {* access their members! */ +/* +* For mempools pre-allocation at the table loading time. +*/ +struct dm_md_mempools { +struct bio_set bs; +struct bio_set io_bs; +}; +struct mapped_device {struct mutex suspend_lock;
@@ -110,8 +118,7 @@ struct mapped_device {/* * io objects are allocated from here. */ -struct bio_set io_bs; -struct bio_set bs; +struct dm_md_mempools *mempools;/* kobject and completion */ struct dm_kobject_holder kobj_holder;
drivers/md/dm-rq.c +1 -1
@@ -319,7 +319,7 @@ static int setup_clone(struct request *clone, struct request *rq, {int r; - r =blk_rq_prep_clone (clone, rq, &tio->md->bs, gfp_mask, + r =blk_rq_prep_clone (clone, rq, &tio->md->mempools->bs, gfp_mask, dm_rq_bio_constructor, tio);if (r)return r;
drivers/md/dm-table.c +0 -11
@@ -1038,17 +1038,6 @@ static int dm_table_alloc_md_mempools(struct dm_table *t, struct mapped_device *return 0 ; } -void dm_table_free_md_mempools (struct dm_table *t) -{ -dm_free_md_mempools (t->mempools); - t->mempools =NULL ; -} - -struct dm_md_mempools *dm_table_get_md_mempools (struct dm_table *t) -{ -return t->mempools; -} -static int setup_indexes (struct dm_table *t) {int i;
drivers/md/dm.c +25 -59
121 lines not on this page · raw message
drivers/md/dm.h +0 -2
@@ -71,8 +71,6 @@ struct dm_target *dm_table_get_immutable_target(struct dm_table *t);struct dm_target *dm_table_get_wildcard_target (struct dm_table *t);bool dm_table_bio_based (struct dm_table *t);bool dm_table_request_based (struct dm_table *t); -void dm_table_free_md_mempools (struct dm_table *t); -struct dm_md_mempools *dm_table_get_md_mempools (struct dm_table *t);void dm_lock_md_type (struct mapped_device *md);void dm_unlock_md_type (struct mapped_device *md);
Signature · 1 line
2.30.2
PATCH 2/4 block: remove bioset_init_from_src
In reply to Christoph HellwigUnused now, and the interface never really made a whole lot of sense to start with.
--- block/bio.c | 20 -------------------- include/linux/bio.h | 1 - 2 files changed, 21 deletions(-)
block/bio.c +0 -20
@@ -1745,26 +1745,6 @@ int bioset_init(struct bio_set *bs, }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 ; -if (src->cache) - flags |=BIOSET_PERCPU_CACHE ; - -return bioset_init (bs, src->bio_pool.min_nr, src->front_pad, flags); -} -EXPORT_SYMBOL (bioset_init_from_src); -static int __init init_bio (void ) {int i;
include/linux/bio.h +0 -1
@@ -403,7 +403,6 @@ 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); struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask,
Signature · 1 line
2.30.2
PATCH 3/4 dm: unexport dm_get_reserved_rq_based_ios
In reply to Christoph Hellwigdm_get_reserved_rq_based_ios is only used in the core dm code, so remove the export.
--- drivers/md/dm-rq.c | 1 - 1 file changed, 1 deletion(-)
drivers/md/dm-rq.c +0 -1
@@ -43,7 +43,6 @@ unsigned dm_get_reserved_rq_based_ios(void)return __dm_get_module_param (&reserved_rq_based_ios,RESERVED_REQUEST_BASED_IOS ,DM_RESERVED_MAX_IOS ); } -EXPORT_SYMBOL_GPL (dm_get_reserved_rq_based_ios);static unsigned dm_get_blk_mq_nr_hw_queues (void ) {
Signature · 1 line
2.30.2
PATCH 4/4 dm: refactor dm_md_mempool allocation
In reply to Christoph HellwigThe current split between dm_table_alloc_md_mempools and dm_alloc_md_mempools is rather arbitrary, so merge the two into one easy to follow function.
--- drivers/md/dm-core.h | 3 +++ drivers/md/dm-table.c | 57 +++++++++++++++++++++++++++++++------------ drivers/md/dm.c | 52 --------------------------------------- drivers/md/dm.h | 3 --- 4 files changed, 44 insertions(+), 71 deletions(-)
drivers/md/dm-core.h +3 -0
@@ -230,6 +230,9 @@ struct dm_target_io {sector_t old_sector;struct bio clone; }; +#define DM_TARGET_IO_BIO_OFFSET (offsetof(struct dm_target_io, clone)) +#define DM_IO_BIO_OFFSET \ + (offsetof(struct dm_target_io, clone) + offsetof(struct dm_io, tio))/* * dm_target_io flags
drivers/md/dm-table.c +41 -16
79 lines not on this page · raw message
drivers/md/dm.c +0 -52
64 lines not on this page · raw message
drivers/md/dm.h +0 -3
@@ -218,9 +218,6 @@ void dm_kcopyd_exit(void);/* * Mempool operations */ -struct dm_md_mempools *dm_alloc_md_mempools (struct mapped_device *md,enum dm_queue_mode type, -unsigned per_io_data_size,unsigned min_pool_size, -bool integrity,bool poll);void dm_free_md_mempools (struct dm_md_mempools *pools);/*
Signature · 1 line
2.30.2
Mike Snitzer
maintainerQuoted 8 lines · Christoph Hellwig
Hi Mike,
the first patch fixes the device mapper bioset to restore the previous behavior of preallocating biosets instead of allocating them at bind time, and to actually allocate pools for the integrity data. The others are cleanups on top of that.
Diffstat:
Quoted 9 lines
block/bio.c | 20 ------- drivers/md/dm-core.h | 14 ++++- drivers/md/dm-rq.c | 3 - drivers/md/dm-table.c | 66 ++++++++++++++---------- drivers/md/dm.c | 136 +++++++++----------------------------------------- drivers/md/dm.h | 5 - include/linux/bio.h | 1 7 files changed, 78 insertions(+), 167 deletions(-)
All looks good to me. Are you OK with me picking up the first 3 to send to Linus for 5.19-rc2 (given the integrity bioset fix)?
And hold patch 4 until 5.20 merge? Or would you prefer that cleanup to land now too?
Mike
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 4 lines · Mike Snitzer
All looks good to me. Are you OK with me picking up the first 3 to send to Linus for 5.19-rc2 (given the integrity bioset fix)?
And hold patch 4 until 5.20 merge?
Sounds good to me.
Quoted 1 line
Or would you prefer that cleanup to land now too?
I don't think Linus would like that :) In fact even patch 3 might be 5.20 material.
Mike Snitzer
maintainerQuoted 4 lines · Christoph Hellwig
Quoted 3 lines · Mike Snitzer
All looks good to me. Are you OK with me picking up the first 3 to send to Linus for 5.19-rc2 (given the integrity bioset fix)?
Quoted 8 lines
Quoted 1 line
And hold patch 4 until 5.20 merge?
Sounds good to me.
Quoted 1 line
Or would you prefer that cleanup to land now too?
I don't think Linus would like that :) In fact even patch 3 might be 5.20 material.
Ha, yeah I agree. I'll just send the first 2 (likely tomorrow after more testing today).
Thanks.