Commit 17213ec1 authored by Mike Snitzer's avatar Mike Snitzer

dm mpath: rework __map_bio()

so that it follows same pattern as request-based
multipath_clone_and_map()
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent f45f1186
...@@ -574,15 +574,20 @@ static void multipath_release_clone(struct request *clone, ...@@ -574,15 +574,20 @@ static void multipath_release_clone(struct request *clone,
* Map cloned bios (bio-based multipath) * Map cloned bios (bio-based multipath)
*/ */
static void multipath_queue_bio(struct multipath *m, struct bio *bio) static void __multipath_queue_bio(struct multipath *m, struct bio *bio)
{ {
unsigned long flags;
/* Queue for the daemon to resubmit */ /* Queue for the daemon to resubmit */
spin_lock_irqsave(&m->lock, flags);
bio_list_add(&m->queued_bios, bio); bio_list_add(&m->queued_bios, bio);
if (!test_bit(MPATHF_QUEUE_IO, &m->flags)) if (!test_bit(MPATHF_QUEUE_IO, &m->flags))
queue_work(kmultipathd, &m->process_queued_bios); queue_work(kmultipathd, &m->process_queued_bios);
}
static void multipath_queue_bio(struct multipath *m, struct bio *bio)
{
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
__multipath_queue_bio(m, bio);
spin_unlock_irqrestore(&m->lock, flags); spin_unlock_irqrestore(&m->lock, flags);
} }
...@@ -590,24 +595,24 @@ static struct pgpath *__map_bio(struct multipath *m, struct bio *bio) ...@@ -590,24 +595,24 @@ static struct pgpath *__map_bio(struct multipath *m, struct bio *bio)
{ {
struct pgpath *pgpath; struct pgpath *pgpath;
unsigned long flags; unsigned long flags;
bool queue_io;
/* Do we need to select a new pgpath? */ /* Do we need to select a new pgpath? */
pgpath = READ_ONCE(m->current_pgpath); pgpath = READ_ONCE(m->current_pgpath);
if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags)) if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
pgpath = choose_pgpath(m, bio->bi_iter.bi_size); pgpath = choose_pgpath(m, bio->bi_iter.bi_size);
/* MPATHF_QUEUE_IO might have been cleared by choose_pgpath. */ if (!pgpath) {
queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags); spin_lock_irqsave(&m->lock, flags);
if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
__multipath_queue_bio(m, bio);
pgpath = ERR_PTR(-EAGAIN);
}
spin_unlock_irqrestore(&m->lock, flags);
if ((pgpath && queue_io) || } else if (test_bit(MPATHF_QUEUE_IO, &m->flags) ||
(!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) { test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) {
multipath_queue_bio(m, bio); multipath_queue_bio(m, bio);
/* PG_INIT_REQUIRED cannot be set without QUEUE_IO */
if (queue_io || test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags))
pg_init_all_paths(m); pg_init_all_paths(m);
return ERR_PTR(-EAGAIN); return ERR_PTR(-EAGAIN);
} }
......
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