Skip to content

Commit 17213ec

Browse files
committed
dm mpath: rework __map_bio()
so that it follows same pattern as request-based multipath_clone_and_map() Signed-off-by: Mike Snitzer <[email protected]>
1 parent f45f118 commit 17213ec

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

drivers/md/dm-mpath.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -574,40 +574,45 @@ static void multipath_release_clone(struct request *clone,
574574
* Map cloned bios (bio-based multipath)
575575
*/
576576

577-
static void multipath_queue_bio(struct multipath *m, struct bio *bio)
577+
static void __multipath_queue_bio(struct multipath *m, struct bio *bio)
578578
{
579-
unsigned long flags;
580-
581579
/* Queue for the daemon to resubmit */
582-
spin_lock_irqsave(&m->lock, flags);
583580
bio_list_add(&m->queued_bios, bio);
584581
if (!test_bit(MPATHF_QUEUE_IO, &m->flags))
585582
queue_work(kmultipathd, &m->process_queued_bios);
583+
}
584+
585+
static void multipath_queue_bio(struct multipath *m, struct bio *bio)
586+
{
587+
unsigned long flags;
588+
589+
spin_lock_irqsave(&m->lock, flags);
590+
__multipath_queue_bio(m, bio);
586591
spin_unlock_irqrestore(&m->lock, flags);
587592
}
588593

589594
static struct pgpath *__map_bio(struct multipath *m, struct bio *bio)
590595
{
591596
struct pgpath *pgpath;
592597
unsigned long flags;
593-
bool queue_io;
594598

595599
/* Do we need to select a new pgpath? */
596600
pgpath = READ_ONCE(m->current_pgpath);
597601
if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
598602
pgpath = choose_pgpath(m, bio->bi_iter.bi_size);
599603

600-
/* MPATHF_QUEUE_IO might have been cleared by choose_pgpath. */
601-
queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags);
604+
if (!pgpath) {
605+
spin_lock_irqsave(&m->lock, flags);
606+
if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
607+
__multipath_queue_bio(m, bio);
608+
pgpath = ERR_PTR(-EAGAIN);
609+
}
610+
spin_unlock_irqrestore(&m->lock, flags);
602611

603-
if ((pgpath && queue_io) ||
604-
(!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) {
612+
} else if (test_bit(MPATHF_QUEUE_IO, &m->flags) ||
613+
test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) {
605614
multipath_queue_bio(m, bio);
606-
607-
/* PG_INIT_REQUIRED cannot be set without QUEUE_IO */
608-
if (queue_io || test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags))
609-
pg_init_all_paths(m);
610-
615+
pg_init_all_paths(m);
611616
return ERR_PTR(-EAGAIN);
612617
}
613618

0 commit comments

Comments
 (0)