summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2020-06-11 02:19:56 +0200
committerMike Snitzer <snitzer@redhat.com>2020-07-13 17:47:32 +0200
commit17213ec1806199ab528655946af144abc37d89fb (patch)
tree6f3e7a63cde158b0d1f98310b1b0be26c0fa0879 /drivers/md
parentdm mpath: factor out multipath_queue_bio (diff)
downloadlinux-17213ec1806199ab528655946af144abc37d89fb.tar.xz
linux-17213ec1806199ab528655946af144abc37d89fb.zip
dm mpath: rework __map_bio()
so that it follows same pattern as request-based multipath_clone_and_map() Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-mpath.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 4b48183c6b5c..ab6ccd619573 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -574,15 +574,20 @@ static void multipath_release_clone(struct request *clone,
* 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 */
- spin_lock_irqsave(&m->lock, flags);
bio_list_add(&m->queued_bios, bio);
if (!test_bit(MPATHF_QUEUE_IO, &m->flags))
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);
}
@@ -590,24 +595,24 @@ static struct pgpath *__map_bio(struct multipath *m, struct bio *bio)
{
struct pgpath *pgpath;
unsigned long flags;
- bool queue_io;
/* Do we need to select a new pgpath? */
pgpath = READ_ONCE(m->current_pgpath);
if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
pgpath = choose_pgpath(m, bio->bi_iter.bi_size);
- /* MPATHF_QUEUE_IO might have been cleared by choose_pgpath. */
- queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags);
+ if (!pgpath) {
+ 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) ||
- (!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) {
+ } else if (test_bit(MPATHF_QUEUE_IO, &m->flags) ||
+ test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) {
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);
}