@@ -574,40 +574,45 @@ static void multipath_release_clone(struct request *clone,
574
574
* Map cloned bios (bio-based multipath)
575
575
*/
576
576
577
- static void multipath_queue_bio (struct multipath * m , struct bio * bio )
577
+ static void __multipath_queue_bio (struct multipath * m , struct bio * bio )
578
578
{
579
- unsigned long flags ;
580
-
581
579
/* Queue for the daemon to resubmit */
582
- spin_lock_irqsave (& m -> lock , flags );
583
580
bio_list_add (& m -> queued_bios , bio );
584
581
if (!test_bit (MPATHF_QUEUE_IO , & m -> flags ))
585
582
queue_work (kmultipathd , & m -> process_queued_bios );
583
+ }
584
+
585
+ static void multipath_queue_bio (struct multipath * m , struct bio * bio )
586
+ {
587
+ unsigned long flags ;
588
+
589
+ spin_lock_irqsave (& m -> lock , flags );
590
+ __multipath_queue_bio (m , bio );
586
591
spin_unlock_irqrestore (& m -> lock , flags );
587
592
}
588
593
589
594
static struct pgpath * __map_bio (struct multipath * m , struct bio * bio )
590
595
{
591
596
struct pgpath * pgpath ;
592
597
unsigned long flags ;
593
- bool queue_io ;
594
598
595
599
/* Do we need to select a new pgpath? */
596
600
pgpath = READ_ONCE (m -> current_pgpath );
597
601
if (!pgpath || !test_bit (MPATHF_QUEUE_IO , & m -> flags ))
598
602
pgpath = choose_pgpath (m , bio -> bi_iter .bi_size );
599
603
600
- /* MPATHF_QUEUE_IO might have been cleared by choose_pgpath. */
601
- queue_io = test_bit (MPATHF_QUEUE_IO , & m -> flags );
604
+ if (!pgpath ) {
605
+ spin_lock_irqsave (& m -> lock , flags );
606
+ if (test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags )) {
607
+ __multipath_queue_bio (m , bio );
608
+ pgpath = ERR_PTR (- EAGAIN );
609
+ }
610
+ spin_unlock_irqrestore (& m -> lock , flags );
602
611
603
- if (( pgpath && queue_io ) ||
604
- (! pgpath && test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags ) )) {
612
+ } else if (test_bit ( MPATHF_QUEUE_IO , & m -> flags ) ||
613
+ test_bit (MPATHF_PG_INIT_REQUIRED , & m -> flags )) {
605
614
multipath_queue_bio (m , bio );
606
-
607
- /* PG_INIT_REQUIRED cannot be set without QUEUE_IO */
608
- if (queue_io || test_bit (MPATHF_PG_INIT_REQUIRED , & m -> flags ))
609
- pg_init_all_paths (m );
610
-
615
+ pg_init_all_paths (m );
611
616
return ERR_PTR (- EAGAIN );
612
617
}
613
618
0 commit comments