Commit 1814f2e3 authored by Mike Snitzer's avatar Mike Snitzer

dm mpath: add locking to multipath_resume and must_push_back

Multiple flags were being tested without locking.  Protect against
non-atomic bit changes in m->flags by holding m->lock (while testing or
setting the queue_if_no_path related flags).
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 99f3c90d
...@@ -507,13 +507,27 @@ static bool __must_push_back(struct multipath *m) ...@@ -507,13 +507,27 @@ static bool __must_push_back(struct multipath *m)
static bool must_push_back_rq(struct multipath *m) static bool must_push_back_rq(struct multipath *m)
{ {
return (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) || bool r;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
r = (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) ||
__must_push_back(m)); __must_push_back(m));
spin_unlock_irqrestore(&m->lock, flags);
return r;
} }
static bool must_push_back_bio(struct multipath *m) static bool must_push_back_bio(struct multipath *m)
{ {
return __must_push_back(m); bool r;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
r = __must_push_back(m);
spin_unlock_irqrestore(&m->lock, flags);
return r;
} }
/* /*
...@@ -1680,12 +1694,14 @@ static void multipath_postsuspend(struct dm_target *ti) ...@@ -1680,12 +1694,14 @@ static void multipath_postsuspend(struct dm_target *ti)
static void multipath_resume(struct dm_target *ti) static void multipath_resume(struct dm_target *ti)
{ {
struct multipath *m = ti->private; struct multipath *m = ti->private;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)) if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags))
set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
else else
clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
smp_mb__after_atomic(); spin_unlock_irqrestore(&m->lock, flags);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment