@@ -92,12 +92,6 @@ struct multipath {
92
92
93
93
unsigned queue_mode ;
94
94
95
- /*
96
- * We must use a mempool of dm_mpath_io structs so that we
97
- * can resubmit bios on error.
98
- */
99
- mempool_t * mpio_pool ;
100
-
101
95
struct mutex work_mutex ;
102
96
struct work_struct trigger_event ;
103
97
@@ -115,8 +109,6 @@ struct dm_mpath_io {
115
109
116
110
typedef int (* action_fn ) (struct pgpath * pgpath );
117
111
118
- static struct kmem_cache * _mpio_cache ;
119
-
120
112
static struct workqueue_struct * kmultipathd , * kmpath_handlerd ;
121
113
static void trigger_event (struct work_struct * work );
122
114
static void activate_path (struct work_struct * work );
@@ -209,7 +201,6 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
209
201
init_waitqueue_head (& m -> pg_init_wait );
210
202
mutex_init (& m -> work_mutex );
211
203
212
- m -> mpio_pool = NULL ;
213
204
m -> queue_mode = DM_TYPE_NONE ;
214
205
215
206
m -> ti = ti ;
@@ -229,16 +220,7 @@ static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m)
229
220
m -> queue_mode = DM_TYPE_MQ_REQUEST_BASED ;
230
221
else
231
222
m -> queue_mode = DM_TYPE_REQUEST_BASED ;
232
- }
233
-
234
- if (m -> queue_mode == DM_TYPE_REQUEST_BASED ) {
235
- unsigned min_ios = dm_get_reserved_rq_based_ios ();
236
-
237
- m -> mpio_pool = mempool_create_slab_pool (min_ios , _mpio_cache );
238
- if (!m -> mpio_pool )
239
- return - ENOMEM ;
240
- }
241
- else if (m -> queue_mode == DM_TYPE_BIO_BASED ) {
223
+ } else if (m -> queue_mode == DM_TYPE_BIO_BASED ) {
242
224
INIT_WORK (& m -> process_queued_bios , process_queued_bios );
243
225
/*
244
226
* bio-based doesn't support any direct scsi_dh management;
@@ -263,7 +245,6 @@ static void free_multipath(struct multipath *m)
263
245
264
246
kfree (m -> hw_handler_name );
265
247
kfree (m -> hw_handler_params );
266
- mempool_destroy (m -> mpio_pool );
267
248
kfree (m );
268
249
}
269
250
@@ -272,38 +253,6 @@ static struct dm_mpath_io *get_mpio(union map_info *info)
272
253
return info -> ptr ;
273
254
}
274
255
275
- static struct dm_mpath_io * set_mpio (struct multipath * m , union map_info * info )
276
- {
277
- struct dm_mpath_io * mpio ;
278
-
279
- if (!m -> mpio_pool ) {
280
- /* Use blk-mq pdu memory requested via per_io_data_size */
281
- mpio = get_mpio (info );
282
- memset (mpio , 0 , sizeof (* mpio ));
283
- return mpio ;
284
- }
285
-
286
- mpio = mempool_alloc (m -> mpio_pool , GFP_ATOMIC );
287
- if (!mpio )
288
- return NULL ;
289
-
290
- memset (mpio , 0 , sizeof (* mpio ));
291
- info -> ptr = mpio ;
292
-
293
- return mpio ;
294
- }
295
-
296
- static void clear_request_fn_mpio (struct multipath * m , union map_info * info )
297
- {
298
- /* Only needed for non blk-mq (.request_fn) multipath */
299
- if (m -> mpio_pool ) {
300
- struct dm_mpath_io * mpio = info -> ptr ;
301
-
302
- info -> ptr = NULL ;
303
- mempool_free (mpio , m -> mpio_pool );
304
- }
305
- }
306
-
307
256
static size_t multipath_per_bio_data_size (void )
308
257
{
309
258
return sizeof (struct dm_mpath_io ) + sizeof (struct dm_bio_details );
@@ -530,16 +479,17 @@ static bool must_push_back_bio(struct multipath *m)
530
479
/*
531
480
* Map cloned requests (request-based multipath)
532
481
*/
533
- static int __multipath_map (struct dm_target * ti , struct request * clone ,
534
- union map_info * map_context ,
535
- struct request * rq , struct request * * __clone )
482
+ static int multipath_clone_and_map (struct dm_target * ti , struct request * rq ,
483
+ union map_info * map_context ,
484
+ struct request * * __clone )
536
485
{
537
486
struct multipath * m = ti -> private ;
538
487
int r = DM_MAPIO_REQUEUE ;
539
- size_t nr_bytes = clone ? blk_rq_bytes ( clone ) : blk_rq_bytes (rq );
488
+ size_t nr_bytes = blk_rq_bytes (rq );
540
489
struct pgpath * pgpath ;
541
490
struct block_device * bdev ;
542
- struct dm_mpath_io * mpio ;
491
+ struct dm_mpath_io * mpio = get_mpio (map_context );
492
+ struct request * clone ;
543
493
544
494
/* Do we need to select a new pgpath? */
545
495
pgpath = lockless_dereference (m -> current_pgpath );
@@ -556,42 +506,23 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
556
506
return r ;
557
507
}
558
508
559
- mpio = set_mpio (m , map_context );
560
- if (!mpio )
561
- /* ENOMEM, requeue */
562
- return r ;
563
-
509
+ memset (mpio , 0 , sizeof (* mpio ));
564
510
mpio -> pgpath = pgpath ;
565
511
mpio -> nr_bytes = nr_bytes ;
566
512
567
513
bdev = pgpath -> path .dev -> bdev ;
568
514
569
- if (clone ) {
570
- /*
571
- * Old request-based interface: allocated clone is passed in.
572
- * Used by: .request_fn stacked on .request_fn path(s).
573
- */
574
- clone -> q = bdev_get_queue (bdev );
575
- clone -> rq_disk = bdev -> bd_disk ;
576
- clone -> cmd_flags |= REQ_FAILFAST_TRANSPORT ;
577
- } else {
578
- /*
579
- * blk-mq request-based interface; used by both:
580
- * .request_fn stacked on blk-mq path(s) and
581
- * blk-mq stacked on blk-mq path(s).
582
- */
583
- clone = blk_mq_alloc_request (bdev_get_queue (bdev ),
584
- rq_data_dir (rq ), BLK_MQ_REQ_NOWAIT );
585
- if (IS_ERR (clone )) {
586
- /* EBUSY, ENODEV or EWOULDBLOCK: requeue */
587
- clear_request_fn_mpio (m , map_context );
588
- return r ;
589
- }
590
- clone -> bio = clone -> biotail = NULL ;
591
- clone -> rq_disk = bdev -> bd_disk ;
592
- clone -> cmd_flags |= REQ_FAILFAST_TRANSPORT ;
593
- * __clone = clone ;
515
+ clone = blk_get_request (bdev_get_queue (bdev ),
516
+ rq -> cmd_flags | REQ_NOMERGE ,
517
+ GFP_ATOMIC );
518
+ if (IS_ERR (clone )) {
519
+ /* EBUSY, ENODEV or EWOULDBLOCK: requeue */
520
+ return r ;
594
521
}
522
+ clone -> bio = clone -> biotail = NULL ;
523
+ clone -> rq_disk = bdev -> bd_disk ;
524
+ clone -> cmd_flags |= REQ_FAILFAST_TRANSPORT ;
525
+ * __clone = clone ;
595
526
596
527
if (pgpath -> pg -> ps .type -> start_io )
597
528
pgpath -> pg -> ps .type -> start_io (& pgpath -> pg -> ps ,
@@ -600,22 +531,9 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
600
531
return DM_MAPIO_REMAPPED ;
601
532
}
602
533
603
- static int multipath_map (struct dm_target * ti , struct request * clone ,
604
- union map_info * map_context )
605
- {
606
- return __multipath_map (ti , clone , map_context , NULL , NULL );
607
- }
608
-
609
- static int multipath_clone_and_map (struct dm_target * ti , struct request * rq ,
610
- union map_info * map_context ,
611
- struct request * * clone )
612
- {
613
- return __multipath_map (ti , NULL , map_context , rq , clone );
614
- }
615
-
616
534
static void multipath_release_clone (struct request * clone )
617
535
{
618
- blk_mq_free_request (clone );
536
+ blk_put_request (clone );
619
537
}
620
538
621
539
/*
@@ -1187,7 +1105,7 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv)
1187
1105
ti -> num_write_same_bios = 1 ;
1188
1106
if (m -> queue_mode == DM_TYPE_BIO_BASED )
1189
1107
ti -> per_io_data_size = multipath_per_bio_data_size ();
1190
- else if ( m -> queue_mode == DM_TYPE_MQ_REQUEST_BASED )
1108
+ else
1191
1109
ti -> per_io_data_size = sizeof (struct dm_mpath_io );
1192
1110
1193
1111
return 0 ;
@@ -1610,7 +1528,6 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
1610
1528
if (ps -> type -> end_io )
1611
1529
ps -> type -> end_io (ps , & pgpath -> path , mpio -> nr_bytes );
1612
1530
}
1613
- clear_request_fn_mpio (m , map_context );
1614
1531
1615
1532
return r ;
1616
1533
}
@@ -2060,7 +1977,6 @@ static struct target_type multipath_target = {
2060
1977
.module = THIS_MODULE ,
2061
1978
.ctr = multipath_ctr ,
2062
1979
.dtr = multipath_dtr ,
2063
- .map_rq = multipath_map ,
2064
1980
.clone_and_map_rq = multipath_clone_and_map ,
2065
1981
.release_clone_rq = multipath_release_clone ,
2066
1982
.rq_end_io = multipath_end_io ,
@@ -2080,11 +1996,6 @@ static int __init dm_multipath_init(void)
2080
1996
{
2081
1997
int r ;
2082
1998
2083
- /* allocate a slab for the dm_mpath_ios */
2084
- _mpio_cache = KMEM_CACHE (dm_mpath_io , 0 );
2085
- if (!_mpio_cache )
2086
- return - ENOMEM ;
2087
-
2088
1999
r = dm_register_target (& multipath_target );
2089
2000
if (r < 0 ) {
2090
2001
DMERR ("request-based register failed %d" , r );
@@ -2120,8 +2031,6 @@ static int __init dm_multipath_init(void)
2120
2031
bad_alloc_kmultipathd :
2121
2032
dm_unregister_target (& multipath_target );
2122
2033
bad_register_target :
2123
- kmem_cache_destroy (_mpio_cache );
2124
-
2125
2034
return r ;
2126
2035
}
2127
2036
@@ -2131,7 +2040,6 @@ static void __exit dm_multipath_exit(void)
2131
2040
destroy_workqueue (kmultipathd );
2132
2041
2133
2042
dm_unregister_target (& multipath_target );
2134
- kmem_cache_destroy (_mpio_cache );
2135
2043
}
2136
2044
2137
2045
module_init (dm_multipath_init );
0 commit comments