Skip to content

Commit 050a3e7

Browse files
author
Mikulas Patocka
committed
dm mpath: replace spin_lock_irqsave with spin_lock_irq
Replace spin_lock_irqsave/spin_unlock_irqrestore with spin_lock_irq/spin_unlock_irq at places where it is known that interrupts are enabled. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 parent 5c977f1 commit 050a3e7

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

drivers/md/dm-mpath.c

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -617,20 +617,19 @@ static void multipath_queue_bio(struct multipath *m, struct bio *bio)
617617
static struct pgpath *__map_bio(struct multipath *m, struct bio *bio)
618618
{
619619
struct pgpath *pgpath;
620-
unsigned long flags;
621620

622621
/* Do we need to select a new pgpath? */
623622
pgpath = READ_ONCE(m->current_pgpath);
624623
if (!pgpath || !mpath_double_check_test_bit(MPATHF_QUEUE_IO, m))
625624
pgpath = choose_pgpath(m, bio->bi_iter.bi_size);
626625

627626
if (!pgpath) {
628-
spin_lock_irqsave(&m->lock, flags);
627+
spin_lock_irq(&m->lock);
629628
if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
630629
__multipath_queue_bio(m, bio);
631630
pgpath = ERR_PTR(-EAGAIN);
632631
}
633-
spin_unlock_irqrestore(&m->lock, flags);
632+
spin_unlock_irq(&m->lock);
634633

635634
} else if (mpath_double_check_test_bit(MPATHF_QUEUE_IO, m) ||
636635
mpath_double_check_test_bit(MPATHF_PG_INIT_REQUIRED, m)) {
@@ -693,7 +692,6 @@ static void process_queued_io_list(struct multipath *m)
693692
static void process_queued_bios(struct work_struct *work)
694693
{
695694
int r;
696-
unsigned long flags;
697695
struct bio *bio;
698696
struct bio_list bios;
699697
struct blk_plug plug;
@@ -702,16 +700,16 @@ static void process_queued_bios(struct work_struct *work)
702700

703701
bio_list_init(&bios);
704702

705-
spin_lock_irqsave(&m->lock, flags);
703+
spin_lock_irq(&m->lock);
706704

707705
if (bio_list_empty(&m->queued_bios)) {
708-
spin_unlock_irqrestore(&m->lock, flags);
706+
spin_unlock_irq(&m->lock);
709707
return;
710708
}
711709

712710
bio_list_merge_init(&bios, &m->queued_bios);
713711

714-
spin_unlock_irqrestore(&m->lock, flags);
712+
spin_unlock_irq(&m->lock);
715713

716714
blk_start_plug(&plug);
717715
while ((bio = bio_list_pop(&bios))) {
@@ -1195,7 +1193,6 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc, char **argv)
11951193
struct dm_arg_set as;
11961194
unsigned int pg_count = 0;
11971195
unsigned int next_pg_num;
1198-
unsigned long flags;
11991196

12001197
as.argc = argc;
12011198
as.argv = argv;
@@ -1260,9 +1257,9 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc, char **argv)
12601257
goto bad;
12611258
}
12621259

1263-
spin_lock_irqsave(&m->lock, flags);
1260+
spin_lock_irq(&m->lock);
12641261
enable_nopath_timeout(m);
1265-
spin_unlock_irqrestore(&m->lock, flags);
1262+
spin_unlock_irq(&m->lock);
12661263

12671264
ti->num_flush_bios = 1;
12681265
ti->num_discard_bios = 1;
@@ -1297,23 +1294,21 @@ static void multipath_wait_for_pg_init_completion(struct multipath *m)
12971294
static void flush_multipath_work(struct multipath *m)
12981295
{
12991296
if (m->hw_handler_name) {
1300-
unsigned long flags;
1301-
13021297
if (!atomic_read(&m->pg_init_in_progress))
13031298
goto skip;
13041299

1305-
spin_lock_irqsave(&m->lock, flags);
1300+
spin_lock_irq(&m->lock);
13061301
if (atomic_read(&m->pg_init_in_progress) &&
13071302
!test_and_set_bit(MPATHF_PG_INIT_DISABLED, &m->flags)) {
1308-
spin_unlock_irqrestore(&m->lock, flags);
1303+
spin_unlock_irq(&m->lock);
13091304

13101305
flush_workqueue(kmpath_handlerd);
13111306
multipath_wait_for_pg_init_completion(m);
13121307

1313-
spin_lock_irqsave(&m->lock, flags);
1308+
spin_lock_irq(&m->lock);
13141309
clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags);
13151310
}
1316-
spin_unlock_irqrestore(&m->lock, flags);
1311+
spin_unlock_irq(&m->lock);
13171312
}
13181313
skip:
13191314
if (m->queue_mode == DM_TYPE_BIO_BASED)
@@ -1375,11 +1370,10 @@ static int fail_path(struct pgpath *pgpath)
13751370
static int reinstate_path(struct pgpath *pgpath)
13761371
{
13771372
int r = 0, run_queue = 0;
1378-
unsigned long flags;
13791373
struct multipath *m = pgpath->pg->m;
13801374
unsigned int nr_valid_paths;
13811375

1382-
spin_lock_irqsave(&m->lock, flags);
1376+
spin_lock_irq(&m->lock);
13831377

13841378
if (pgpath->is_active)
13851379
goto out;
@@ -1409,7 +1403,7 @@ static int reinstate_path(struct pgpath *pgpath)
14091403
schedule_work(&m->trigger_event);
14101404

14111405
out:
1412-
spin_unlock_irqrestore(&m->lock, flags);
1406+
spin_unlock_irq(&m->lock);
14131407
if (run_queue) {
14141408
dm_table_run_md_queue_async(m->ti->table);
14151409
process_queued_io_list(m);
@@ -1470,7 +1464,6 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
14701464
{
14711465
struct priority_group *pg;
14721466
unsigned int pgnum;
1473-
unsigned long flags;
14741467
char dummy;
14751468

14761469
if (!pgstr || (sscanf(pgstr, "%u%c", &pgnum, &dummy) != 1) || !pgnum ||
@@ -1479,7 +1472,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
14791472
return -EINVAL;
14801473
}
14811474

1482-
spin_lock_irqsave(&m->lock, flags);
1475+
spin_lock_irq(&m->lock);
14831476
list_for_each_entry(pg, &m->priority_groups, list) {
14841477
pg->bypassed = false;
14851478
if (--pgnum)
@@ -1493,7 +1486,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
14931486
}
14941487
m->next_pg = pg;
14951488
}
1496-
spin_unlock_irqrestore(&m->lock, flags);
1489+
spin_unlock_irq(&m->lock);
14971490

14981491
schedule_work(&m->trigger_event);
14991492
return 0;
@@ -1754,11 +1747,10 @@ static int multipath_end_io_bio(struct dm_target *ti, struct bio *clone,
17541747
static void multipath_presuspend(struct dm_target *ti)
17551748
{
17561749
struct multipath *m = ti->private;
1757-
unsigned long flags;
17581750

1759-
spin_lock_irqsave(&m->lock, flags);
1751+
spin_lock_irq(&m->lock);
17601752
m->is_suspending = true;
1761-
spin_unlock_irqrestore(&m->lock, flags);
1753+
spin_unlock_irq(&m->lock);
17621754
/* FIXME: bio-based shouldn't need to always disable queue_if_no_path */
17631755
if (m->queue_mode == DM_TYPE_BIO_BASED || !dm_noflush_suspending(m->ti))
17641756
queue_if_no_path(m, false, true, __func__);
@@ -1779,9 +1771,8 @@ static void multipath_postsuspend(struct dm_target *ti)
17791771
static void multipath_resume(struct dm_target *ti)
17801772
{
17811773
struct multipath *m = ti->private;
1782-
unsigned long flags;
17831774

1784-
spin_lock_irqsave(&m->lock, flags);
1775+
spin_lock_irq(&m->lock);
17851776
m->is_suspending = false;
17861777
if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)) {
17871778
set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
@@ -1793,7 +1784,7 @@ static void multipath_resume(struct dm_target *ti)
17931784
test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags),
17941785
test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags));
17951786

1796-
spin_unlock_irqrestore(&m->lock, flags);
1787+
spin_unlock_irq(&m->lock);
17971788
}
17981789

17991790
/*
@@ -1816,14 +1807,13 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
18161807
unsigned int status_flags, char *result, unsigned int maxlen)
18171808
{
18181809
int sz = 0, pg_counter, pgpath_counter;
1819-
unsigned long flags;
18201810
struct multipath *m = ti->private;
18211811
struct priority_group *pg;
18221812
struct pgpath *p;
18231813
unsigned int pg_num;
18241814
char state;
18251815

1826-
spin_lock_irqsave(&m->lock, flags);
1816+
spin_lock_irq(&m->lock);
18271817

18281818
/* Features */
18291819
if (type == STATUSTYPE_INFO)
@@ -1969,7 +1959,7 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
19691959
break;
19701960
}
19711961

1972-
spin_unlock_irqrestore(&m->lock, flags);
1962+
spin_unlock_irq(&m->lock);
19731963
}
19741964

19751965
static int multipath_message(struct dm_target *ti, unsigned int argc, char **argv,
@@ -1979,7 +1969,6 @@ static int multipath_message(struct dm_target *ti, unsigned int argc, char **arg
19791969
dev_t dev;
19801970
struct multipath *m = ti->private;
19811971
action_fn action;
1982-
unsigned long flags;
19831972

19841973
mutex_lock(&m->work_mutex);
19851974

@@ -1991,9 +1980,9 @@ static int multipath_message(struct dm_target *ti, unsigned int argc, char **arg
19911980
if (argc == 1) {
19921981
if (!strcasecmp(argv[0], "queue_if_no_path")) {
19931982
r = queue_if_no_path(m, true, false, __func__);
1994-
spin_lock_irqsave(&m->lock, flags);
1983+
spin_lock_irq(&m->lock);
19951984
enable_nopath_timeout(m);
1996-
spin_unlock_irqrestore(&m->lock, flags);
1985+
spin_unlock_irq(&m->lock);
19971986
goto out;
19981987
} else if (!strcasecmp(argv[0], "fail_if_no_path")) {
19991988
r = queue_if_no_path(m, false, false, __func__);
@@ -2096,10 +2085,9 @@ static int probe_active_paths(struct multipath *m)
20962085
{
20972086
struct pgpath *pgpath;
20982087
struct priority_group *pg = NULL;
2099-
unsigned long flags;
21002088
int r = 0;
21012089

2102-
spin_lock_irqsave(&m->lock, flags);
2090+
spin_lock_irq(&m->lock);
21032091
if (test_bit(MPATHF_DELAY_PG_SWITCH, &m->flags)) {
21042092
wait_event_lock_irq(m->probe_wait,
21052093
!test_bit(MPATHF_DELAY_PG_SWITCH, &m->flags),
@@ -2117,7 +2105,7 @@ static int probe_active_paths(struct multipath *m)
21172105
goto skip_probe;
21182106
set_bit(MPATHF_DELAY_PG_SWITCH, &m->flags);
21192107
pg = m->last_probed_pg = m->current_pg;
2120-
spin_unlock_irqrestore(&m->lock, flags);
2108+
spin_unlock_irq(&m->lock);
21212109

21222110
list_for_each_entry(pgpath, &pg->pgpaths, list) {
21232111
if (pg != READ_ONCE(m->current_pg) ||
@@ -2132,7 +2120,7 @@ static int probe_active_paths(struct multipath *m)
21322120
}
21332121

21342122
out:
2135-
spin_lock_irqsave(&m->lock, flags);
2123+
spin_lock_irq(&m->lock);
21362124
clear_bit(MPATHF_DELAY_PG_SWITCH, &m->flags);
21372125
if (test_and_clear_bit(MPATHF_NEED_PG_SWITCH, &m->flags)) {
21382126
m->current_pgpath = NULL;
@@ -2141,7 +2129,7 @@ static int probe_active_paths(struct multipath *m)
21412129
skip_probe:
21422130
if (r == 0 && !atomic_read(&m->nr_valid_paths))
21432131
r = -ENOTCONN;
2144-
spin_unlock_irqrestore(&m->lock, flags);
2132+
spin_unlock_irq(&m->lock);
21452133
if (pg)
21462134
wake_up(&m->probe_wait);
21472135
return r;
@@ -2154,7 +2142,6 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
21542142
{
21552143
struct multipath *m = ti->private;
21562144
struct pgpath *pgpath;
2157-
unsigned long flags;
21582145
int r;
21592146

21602147
if (_IOC_TYPE(cmd) == DM_IOCTL) {
@@ -2182,21 +2169,21 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
21822169
} else {
21832170
/* No path is available */
21842171
r = -EIO;
2185-
spin_lock_irqsave(&m->lock, flags);
2172+
spin_lock_irq(&m->lock);
21862173
if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
21872174
r = -ENOTCONN;
2188-
spin_unlock_irqrestore(&m->lock, flags);
2175+
spin_unlock_irq(&m->lock);
21892176
}
21902177

21912178
if (r == -ENOTCONN) {
21922179
if (!READ_ONCE(m->current_pg)) {
21932180
/* Path status changed, redo selection */
21942181
(void) choose_pgpath(m, 0);
21952182
}
2196-
spin_lock_irqsave(&m->lock, flags);
2183+
spin_lock_irq(&m->lock);
21972184
if (test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags))
21982185
(void) __pg_init_all_paths(m);
2199-
spin_unlock_irqrestore(&m->lock, flags);
2186+
spin_unlock_irq(&m->lock);
22002187
dm_table_run_md_queue_async(m->ti->table);
22012188
process_queued_io_list(m);
22022189
}

0 commit comments

Comments
 (0)