Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.19/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- Fix DM core's bioset initialization so that blk integrity pool is
properly setup. Remove now unused bioset_init_from_src.

- Fix DM zoned hang from locking imbalance due to needless check in
clone_endio().

* tag 'for-5.19/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm: fix zoned locking imbalance due to needless check in clone_endio
block: remove bioset_init_from_src
dm: fix bio_set allocation

+46 -111
-20
block/bio.c
··· 1747 1747 } 1748 1748 EXPORT_SYMBOL(bioset_init); 1749 1749 1750 - /* 1751 - * Initialize and setup a new bio_set, based on the settings from 1752 - * another bio_set. 1753 - */ 1754 - int bioset_init_from_src(struct bio_set *bs, struct bio_set *src) 1755 - { 1756 - int flags; 1757 - 1758 - flags = 0; 1759 - if (src->bvec_pool.min_nr) 1760 - flags |= BIOSET_NEED_BVECS; 1761 - if (src->rescue_workqueue) 1762 - flags |= BIOSET_NEED_RESCUER; 1763 - if (src->cache) 1764 - flags |= BIOSET_PERCPU_CACHE; 1765 - 1766 - return bioset_init(bs, src->bio_pool.min_nr, src->front_pad, flags); 1767 - } 1768 - EXPORT_SYMBOL(bioset_init_from_src); 1769 - 1770 1750 static int __init init_bio(void) 1771 1751 { 1772 1752 int i;
+9 -2
drivers/md/dm-core.h
··· 33 33 * access their members! 34 34 */ 35 35 36 + /* 37 + * For mempools pre-allocation at the table loading time. 38 + */ 39 + struct dm_md_mempools { 40 + struct bio_set bs; 41 + struct bio_set io_bs; 42 + }; 43 + 36 44 struct mapped_device { 37 45 struct mutex suspend_lock; 38 46 ··· 118 110 /* 119 111 * io objects are allocated from here. 120 112 */ 121 - struct bio_set io_bs; 122 - struct bio_set bs; 113 + struct dm_md_mempools *mempools; 123 114 124 115 /* kobject and completion */ 125 116 struct dm_kobject_holder kobj_holder;
+1 -1
drivers/md/dm-rq.c
··· 319 319 { 320 320 int r; 321 321 322 - r = blk_rq_prep_clone(clone, rq, &tio->md->bs, gfp_mask, 322 + r = blk_rq_prep_clone(clone, rq, &tio->md->mempools->bs, gfp_mask, 323 323 dm_rq_bio_constructor, tio); 324 324 if (r) 325 325 return r;
-11
drivers/md/dm-table.c
··· 1038 1038 return 0; 1039 1039 } 1040 1040 1041 - void dm_table_free_md_mempools(struct dm_table *t) 1042 - { 1043 - dm_free_md_mempools(t->mempools); 1044 - t->mempools = NULL; 1045 - } 1046 - 1047 - struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t) 1048 - { 1049 - return t->mempools; 1050 - } 1051 - 1052 1041 static int setup_indexes(struct dm_table *t) 1053 1042 { 1054 1043 int i;
+36 -74
drivers/md/dm.c
··· 136 136 return latch; 137 137 } 138 138 139 - /* 140 - * For mempools pre-allocation at the table loading time. 141 - */ 142 - struct dm_md_mempools { 143 - struct bio_set bs; 144 - struct bio_set io_bs; 145 - }; 146 - 147 139 struct table_device { 148 140 struct list_head list; 149 141 refcount_t count; ··· 573 581 struct dm_target_io *tio; 574 582 struct bio *clone; 575 583 576 - clone = bio_alloc_clone(NULL, bio, GFP_NOIO, &md->io_bs); 584 + clone = bio_alloc_clone(NULL, bio, GFP_NOIO, &md->mempools->io_bs); 577 585 /* Set default bdev, but target must bio_set_dev() before issuing IO */ 578 586 clone->bi_bdev = md->disk->part0; 579 587 ··· 620 628 } else { 621 629 struct mapped_device *md = ci->io->md; 622 630 623 - clone = bio_alloc_clone(NULL, ci->bio, gfp_mask, &md->bs); 631 + clone = bio_alloc_clone(NULL, ci->bio, gfp_mask, 632 + &md->mempools->bs); 624 633 if (!clone) 625 634 return NULL; 626 635 /* Set default bdev, but target must bio_set_dev() before issuing IO */ ··· 1016 1023 struct dm_io *io = tio->io; 1017 1024 struct mapped_device *md = io->md; 1018 1025 1019 - if (likely(bio->bi_bdev != md->disk->part0)) { 1020 - struct request_queue *q = bdev_get_queue(bio->bi_bdev); 1021 - 1022 - if (unlikely(error == BLK_STS_TARGET)) { 1023 - if (bio_op(bio) == REQ_OP_DISCARD && 1024 - !bdev_max_discard_sectors(bio->bi_bdev)) 1025 - disable_discard(md); 1026 - else if (bio_op(bio) == REQ_OP_WRITE_ZEROES && 1027 - !q->limits.max_write_zeroes_sectors) 1028 - disable_write_zeroes(md); 1029 - } 1030 - 1031 - if (static_branch_unlikely(&zoned_enabled) && 1032 - unlikely(blk_queue_is_zoned(q))) 1033 - dm_zone_endio(io, bio); 1026 + if (unlikely(error == BLK_STS_TARGET)) { 1027 + if (bio_op(bio) == REQ_OP_DISCARD && 1028 + !bdev_max_discard_sectors(bio->bi_bdev)) 1029 + disable_discard(md); 1030 + else if (bio_op(bio) == REQ_OP_WRITE_ZEROES && 1031 + !bdev_write_zeroes_sectors(bio->bi_bdev)) 1032 + disable_write_zeroes(md); 1034 1033 } 1034 + 1035 + if (static_branch_unlikely(&zoned_enabled) && 1036 + unlikely(blk_queue_is_zoned(bdev_get_queue(bio->bi_bdev)))) 1037 + dm_zone_endio(io, bio); 1035 1038 1036 1039 if (endio) { 1037 1040 int r = endio(ti, bio, &error); ··· 1865 1876 { 1866 1877 if (md->wq) 1867 1878 destroy_workqueue(md->wq); 1868 - bioset_exit(&md->bs); 1869 - bioset_exit(&md->io_bs); 1879 + dm_free_md_mempools(md->mempools); 1870 1880 1871 1881 if (md->dax_dev) { 1872 1882 dax_remove_host(md->disk); ··· 2037 2049 kvfree(md); 2038 2050 } 2039 2051 2040 - static int __bind_mempools(struct mapped_device *md, struct dm_table *t) 2041 - { 2042 - struct dm_md_mempools *p = dm_table_get_md_mempools(t); 2043 - int ret = 0; 2044 - 2045 - if (dm_table_bio_based(t)) { 2046 - /* 2047 - * The md may already have mempools that need changing. 2048 - * If so, reload bioset because front_pad may have changed 2049 - * because a different table was loaded. 2050 - */ 2051 - bioset_exit(&md->bs); 2052 - bioset_exit(&md->io_bs); 2053 - 2054 - } else if (bioset_initialized(&md->bs)) { 2055 - /* 2056 - * There's no need to reload with request-based dm 2057 - * because the size of front_pad doesn't change. 2058 - * Note for future: If you are to reload bioset, 2059 - * prep-ed requests in the queue may refer 2060 - * to bio from the old bioset, so you must walk 2061 - * through the queue to unprep. 2062 - */ 2063 - goto out; 2064 - } 2065 - 2066 - BUG_ON(!p || 2067 - bioset_initialized(&md->bs) || 2068 - bioset_initialized(&md->io_bs)); 2069 - 2070 - ret = bioset_init_from_src(&md->bs, &p->bs); 2071 - if (ret) 2072 - goto out; 2073 - ret = bioset_init_from_src(&md->io_bs, &p->io_bs); 2074 - if (ret) 2075 - bioset_exit(&md->bs); 2076 - out: 2077 - /* mempool bind completed, no longer need any mempools in the table */ 2078 - dm_table_free_md_mempools(t); 2079 - return ret; 2080 - } 2081 - 2082 2052 /* 2083 2053 * Bind a table to the device. 2084 2054 */ ··· 2090 2144 * immutable singletons - used to optimize dm_mq_queue_rq. 2091 2145 */ 2092 2146 md->immutable_target = dm_table_get_immutable_target(t); 2093 - } 2094 2147 2095 - ret = __bind_mempools(md, t); 2096 - if (ret) { 2097 - old_map = ERR_PTR(ret); 2098 - goto out; 2148 + /* 2149 + * There is no need to reload with request-based dm because the 2150 + * size of front_pad doesn't change. 2151 + * 2152 + * Note for future: If you are to reload bioset, prep-ed 2153 + * requests in the queue may refer to bio from the old bioset, 2154 + * so you must walk through the queue to unprep. 2155 + */ 2156 + if (!md->mempools) { 2157 + md->mempools = t->mempools; 2158 + t->mempools = NULL; 2159 + } 2160 + } else { 2161 + /* 2162 + * The md may already have mempools that need changing. 2163 + * If so, reload bioset because front_pad may have changed 2164 + * because a different table was loaded. 2165 + */ 2166 + dm_free_md_mempools(md->mempools); 2167 + md->mempools = t->mempools; 2168 + t->mempools = NULL; 2099 2169 } 2100 2170 2101 2171 ret = dm_table_set_restrictions(t, md->queue, limits);
-2
drivers/md/dm.h
··· 71 71 struct dm_target *dm_table_get_wildcard_target(struct dm_table *t); 72 72 bool dm_table_bio_based(struct dm_table *t); 73 73 bool dm_table_request_based(struct dm_table *t); 74 - void dm_table_free_md_mempools(struct dm_table *t); 75 - struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t); 76 74 77 75 void dm_lock_md_type(struct mapped_device *md); 78 76 void dm_unlock_md_type(struct mapped_device *md);
-1
include/linux/bio.h
··· 403 403 extern int bioset_init(struct bio_set *, unsigned int, unsigned int, int flags); 404 404 extern void bioset_exit(struct bio_set *); 405 405 extern int biovec_init_pool(mempool_t *pool, int pool_entries); 406 - extern int bioset_init_from_src(struct bio_set *bs, struct bio_set *src); 407 406 408 407 struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs, 409 408 unsigned int opf, gfp_t gfp_mask,