@@ -335,6 +335,8 @@ static int pg_init_all_paths(struct multipath *m)
335
335
336
336
static void __switch_pg (struct multipath * m , struct priority_group * pg )
337
337
{
338
+ lockdep_assert_held (& m -> lock );
339
+
338
340
m -> current_pg = pg ;
339
341
340
342
/* Must we initialise the PG first, and queue I/O till it's ready? */
@@ -382,7 +384,9 @@ static struct pgpath *choose_pgpath(struct multipath *m, size_t nr_bytes)
382
384
unsigned bypassed = 1 ;
383
385
384
386
if (!atomic_read (& m -> nr_valid_paths )) {
387
+ spin_lock_irqsave (& m -> lock , flags );
385
388
clear_bit (MPATHF_QUEUE_IO , & m -> flags );
389
+ spin_unlock_irqrestore (& m -> lock , flags );
386
390
goto failed ;
387
391
}
388
392
@@ -422,8 +426,11 @@ static struct pgpath *choose_pgpath(struct multipath *m, size_t nr_bytes)
422
426
continue ;
423
427
pgpath = choose_path_in_pg (m , pg , nr_bytes );
424
428
if (!IS_ERR_OR_NULL (pgpath )) {
425
- if (!bypassed )
429
+ if (!bypassed ) {
430
+ spin_lock_irqsave (& m -> lock , flags );
426
431
set_bit (MPATHF_PG_INIT_DELAY_RETRY , & m -> flags );
432
+ spin_unlock_irqrestore (& m -> lock , flags );
433
+ }
427
434
return pgpath ;
428
435
}
429
436
}
@@ -1662,9 +1669,9 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone,
1662
1669
1663
1670
spin_lock_irqsave (& m -> lock , flags );
1664
1671
bio_list_add (& m -> queued_bios , clone );
1665
- spin_unlock_irqrestore (& m -> lock , flags );
1666
1672
if (!test_bit (MPATHF_QUEUE_IO , & m -> flags ))
1667
1673
queue_work (kmultipathd , & m -> process_queued_bios );
1674
+ spin_unlock_irqrestore (& m -> lock , flags );
1668
1675
1669
1676
r = DM_ENDIO_INCOMPLETE ;
1670
1677
done :
@@ -1938,6 +1945,7 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
1938
1945
{
1939
1946
struct multipath * m = ti -> private ;
1940
1947
struct pgpath * current_pgpath ;
1948
+ unsigned long flags ;
1941
1949
int r ;
1942
1950
1943
1951
current_pgpath = READ_ONCE (m -> current_pgpath );
@@ -1965,8 +1973,10 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
1965
1973
/* Path status changed, redo selection */
1966
1974
(void ) choose_pgpath (m , 0 );
1967
1975
}
1976
+ spin_lock_irqsave (& m -> lock , flags );
1968
1977
if (test_bit (MPATHF_PG_INIT_REQUIRED , & m -> flags ))
1969
- pg_init_all_paths (m );
1978
+ (void ) __pg_init_all_paths (m );
1979
+ spin_unlock_irqrestore (& m -> lock , flags );
1970
1980
dm_table_run_md_queue_async (m -> ti -> table );
1971
1981
process_queued_io_list (m );
1972
1982
}
0 commit comments