@@ -1621,12 +1621,16 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
1621
1621
if (pgpath )
1622
1622
fail_path (pgpath );
1623
1623
1624
- if (atomic_read (& m -> nr_valid_paths ) == 0 &&
1625
- !must_push_back_rq (m )) {
1626
- if (error == BLK_STS_IOERR )
1627
- dm_report_EIO (m );
1628
- /* complete with the original error */
1629
- r = DM_ENDIO_DONE ;
1624
+ if (!atomic_read (& m -> nr_valid_paths )) {
1625
+ unsigned long flags ;
1626
+ spin_lock_irqsave (& m -> lock , flags );
1627
+ if (!must_push_back_rq (m )) {
1628
+ if (error == BLK_STS_IOERR )
1629
+ dm_report_EIO (m );
1630
+ /* complete with the original error */
1631
+ r = DM_ENDIO_DONE ;
1632
+ }
1633
+ spin_unlock_irqrestore (& m -> lock , flags );
1630
1634
}
1631
1635
}
1632
1636
@@ -1656,15 +1660,19 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone,
1656
1660
if (pgpath )
1657
1661
fail_path (pgpath );
1658
1662
1659
- if (atomic_read (& m -> nr_valid_paths ) == 0 &&
1660
- !test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags )) {
1661
- if (__must_push_back (m )) {
1662
- r = DM_ENDIO_REQUEUE ;
1663
- } else {
1664
- dm_report_EIO (m );
1665
- * error = BLK_STS_IOERR ;
1663
+ if (!atomic_read (& m -> nr_valid_paths )) {
1664
+ spin_lock_irqsave (& m -> lock , flags );
1665
+ if (!test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags )) {
1666
+ if (__must_push_back (m )) {
1667
+ r = DM_ENDIO_REQUEUE ;
1668
+ } else {
1669
+ dm_report_EIO (m );
1670
+ * error = BLK_STS_IOERR ;
1671
+ }
1672
+ spin_unlock_irqrestore (& m -> lock , flags );
1673
+ goto done ;
1666
1674
}
1667
- goto done ;
1675
+ spin_unlock_irqrestore ( & m -> lock , flags ) ;
1668
1676
}
1669
1677
1670
1678
spin_lock_irqsave (& m -> lock , flags );
@@ -1962,10 +1970,11 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
1962
1970
}
1963
1971
} else {
1964
1972
/* No path is available */
1973
+ r = - EIO ;
1974
+ spin_lock_irqsave (& m -> lock , flags );
1965
1975
if (test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags ))
1966
1976
r = - ENOTCONN ;
1967
- else
1968
- r = - EIO ;
1977
+ spin_unlock_irqrestore (& m -> lock , flags );
1969
1978
}
1970
1979
1971
1980
if (r == - ENOTCONN ) {
@@ -2036,8 +2045,15 @@ static int multipath_busy(struct dm_target *ti)
2036
2045
return true;
2037
2046
2038
2047
/* no paths available, for blk-mq: rely on IO mapping to delay requeue */
2039
- if (!atomic_read (& m -> nr_valid_paths ) && test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags ))
2040
- return (m -> queue_mode != DM_TYPE_REQUEST_BASED );
2048
+ if (!atomic_read (& m -> nr_valid_paths )) {
2049
+ unsigned long flags ;
2050
+ spin_lock_irqsave (& m -> lock , flags );
2051
+ if (test_bit (MPATHF_QUEUE_IF_NO_PATH , & m -> flags )) {
2052
+ spin_unlock_irqrestore (& m -> lock , flags );
2053
+ return (m -> queue_mode != DM_TYPE_REQUEST_BASED );
2054
+ }
2055
+ spin_unlock_irqrestore (& m -> lock , flags );
2056
+ }
2041
2057
2042
2058
/* Guess which priority_group will be used at next mapping time */
2043
2059
pg = READ_ONCE (m -> current_pg );
0 commit comments