@@ -136,14 +136,6 @@ static int get_swap_bios(void)
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 ;
@@ -581,7 +573,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
581
573
struct dm_target_io * tio ;
582
574
struct bio * clone ;
583
575
584
- clone = bio_alloc_clone (NULL , bio , GFP_NOIO , & md -> io_bs );
576
+ clone = bio_alloc_clone (NULL , bio , GFP_NOIO , & md -> mempools -> io_bs );
585
577
/* Set default bdev, but target must bio_set_dev() before issuing IO */
586
578
clone -> bi_bdev = md -> disk -> part0 ;
587
579
@@ -628,7 +620,8 @@ static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti,
628
620
} else {
629
621
struct mapped_device * md = ci -> io -> md ;
630
622
631
- clone = bio_alloc_clone (NULL , ci -> bio , gfp_mask , & md -> bs );
623
+ clone = bio_alloc_clone (NULL , ci -> bio , gfp_mask ,
624
+ & md -> mempools -> bs );
632
625
if (!clone )
633
626
return NULL ;
634
627
/* Set default bdev, but target must bio_set_dev() before issuing IO */
@@ -1876,8 +1869,7 @@ static void cleanup_mapped_device(struct mapped_device *md)
1876
1869
{
1877
1870
if (md -> wq )
1878
1871
destroy_workqueue (md -> wq );
1879
- bioset_exit (& md -> bs );
1880
- bioset_exit (& md -> io_bs );
1872
+ dm_free_md_mempools (md -> mempools );
1881
1873
1882
1874
if (md -> dax_dev ) {
1883
1875
dax_remove_host (md -> disk );
@@ -2049,48 +2041,6 @@ static void free_dev(struct mapped_device *md)
2049
2041
kvfree (md );
2050
2042
}
2051
2043
2052
- static int __bind_mempools (struct mapped_device * md , struct dm_table * t )
2053
- {
2054
- struct dm_md_mempools * p = dm_table_get_md_mempools (t );
2055
- int ret = 0 ;
2056
-
2057
- if (dm_table_bio_based (t )) {
2058
- /*
2059
- * The md may already have mempools that need changing.
2060
- * If so, reload bioset because front_pad may have changed
2061
- * because a different table was loaded.
2062
- */
2063
- bioset_exit (& md -> bs );
2064
- bioset_exit (& md -> io_bs );
2065
-
2066
- } else if (bioset_initialized (& md -> bs )) {
2067
- /*
2068
- * There's no need to reload with request-based dm
2069
- * because the size of front_pad doesn't change.
2070
- * Note for future: If you are to reload bioset,
2071
- * prep-ed requests in the queue may refer
2072
- * to bio from the old bioset, so you must walk
2073
- * through the queue to unprep.
2074
- */
2075
- goto out ;
2076
- }
2077
-
2078
- BUG_ON (!p ||
2079
- bioset_initialized (& md -> bs ) ||
2080
- bioset_initialized (& md -> io_bs ));
2081
-
2082
- ret = bioset_init_from_src (& md -> bs , & p -> bs );
2083
- if (ret )
2084
- goto out ;
2085
- ret = bioset_init_from_src (& md -> io_bs , & p -> io_bs );
2086
- if (ret )
2087
- bioset_exit (& md -> bs );
2088
- out :
2089
- /* mempool bind completed, no longer need any mempools in the table */
2090
- dm_table_free_md_mempools (t );
2091
- return ret ;
2092
- }
2093
-
2094
2044
/*
2095
2045
* Bind a table to the device.
2096
2046
*/
@@ -2144,12 +2094,28 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,
2144
2094
* immutable singletons - used to optimize dm_mq_queue_rq.
2145
2095
*/
2146
2096
md -> immutable_target = dm_table_get_immutable_target (t );
2147
- }
2148
2097
2149
- ret = __bind_mempools (md , t );
2150
- if (ret ) {
2151
- old_map = ERR_PTR (ret );
2152
- goto out ;
2098
+ /*
2099
+ * There is no need to reload with request-based dm because the
2100
+ * size of front_pad doesn't change.
2101
+ *
2102
+ * Note for future: If you are to reload bioset, prep-ed
2103
+ * requests in the queue may refer to bio from the old bioset,
2104
+ * so you must walk through the queue to unprep.
2105
+ */
2106
+ if (!md -> mempools ) {
2107
+ md -> mempools = t -> mempools ;
2108
+ t -> mempools = NULL ;
2109
+ }
2110
+ } else {
2111
+ /*
2112
+ * The md may already have mempools that need changing.
2113
+ * If so, reload bioset because front_pad may have changed
2114
+ * because a different table was loaded.
2115
+ */
2116
+ dm_free_md_mempools (md -> mempools );
2117
+ md -> mempools = t -> mempools ;
2118
+ t -> mempools = NULL ;
2153
2119
}
2154
2120
2155
2121
ret = dm_table_set_restrictions (t , md -> queue , limits );
0 commit comments