All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>, dm-devel@redhat.com
Subject: [PATCH v2 11/13] dm-mpath: Micro-optimize the hot path
Date: Thu, 27 Apr 2017 10:11:24 -0700	[thread overview]
Message-ID: <20170427171126.26814-12-bart.vanassche@sandisk.com> (raw)
In-Reply-To: <20170427171126.26814-1-bart.vanassche@sandisk.com>

Instead of checking MPATHF_QUEUE_IF_NO_PATH,
MPATHF_SAVED_QUEUE_IF_NO_PATH and the no_flush flag to decide whether
or not to push back a request if there are no paths available, only
clear MPATHF_QUEUE_IF_NO_PATH in queue_if_no_path() if no_flush has
not been set. The result is that only a single bit has to be tested
in the hot path to decide whether or not a request must be pushed
back and also that m->lock does not have to be taken in the hot path.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
 drivers/md/dm-mpath.c | 70 ++++++++-------------------------------------------
 1 file changed, 11 insertions(+), 59 deletions(-)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 286d74593b2c..5a3200332eb1 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -442,47 +442,6 @@ static struct pgpath *choose_pgpath(struct multipath *m, size_t nr_bytes)
 }
 
 /*
- * Check whether bios must be queued in the device-mapper core rather
- * than here in the target.
- *
- * If m->queue_if_no_path and m->saved_queue_if_no_path hold the
- * same value then we are not between multipath_presuspend()
- * and multipath_resume() calls and we have no need to check
- * for the DMF_NOFLUSH_SUSPENDING flag.
- */
-static bool __must_push_back(struct multipath *m)
-{
-	return ((test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) !=
-		 test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)) &&
-		dm_noflush_suspending(m->ti));
-}
-
-static bool must_push_back_rq(struct multipath *m)
-{
-	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));
-	spin_unlock_irqrestore(&m->lock, flags);
-
-	return r;
-}
-
-static bool must_push_back_bio(struct multipath *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;
-}
-
-/*
  * Map cloned requests (request-based multipath)
  */
 static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
@@ -503,7 +462,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 		pgpath = choose_pgpath(m, nr_bytes);
 
 	if (!pgpath) {
-		if (must_push_back_rq(m)) {
+		if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
 			pr_debug("no path - requeueing\n");
 			return DM_MAPIO_DELAY_REQUEUE;
 		}
@@ -581,9 +540,9 @@ static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_m
 	}
 
 	if (!pgpath) {
-		if (!must_push_back_bio(m))
-			return -EIO;
-		return DM_MAPIO_REQUEUE;
+		if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
+			return DM_MAPIO_REQUEUE;
+		return -EIO;
 	}
 
 	mpio->pgpath = pgpath;
@@ -675,7 +634,7 @@ static int queue_if_no_path(struct multipath *m, bool queue_if_no_path,
 		else
 			clear_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags);
 	}
-	if (queue_if_no_path)
+	if (queue_if_no_path || dm_noflush_suspending(m->ti))
 		set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
 	else
 		clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
@@ -1526,12 +1485,9 @@ static int do_end_io(struct multipath *m, struct request *clone,
 	if (mpio->pgpath)
 		fail_path(mpio->pgpath);
 
-	if (!atomic_read(&m->nr_valid_paths)) {
-		if (!test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
-			if (!must_push_back_rq(m))
-				r = -EIO;
-		}
-	}
+	if (atomic_read(&m->nr_valid_paths) == 0 &&
+	    !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
+		r = -EIO;
 
 	return r;
 }
@@ -1572,13 +1528,9 @@ static int do_end_io_bio(struct multipath *m, struct bio *clone,
 	if (mpio->pgpath)
 		fail_path(mpio->pgpath);
 
-	if (!atomic_read(&m->nr_valid_paths)) {
-		if (!test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
-			if (!must_push_back_bio(m))
-				return -EIO;
-			return DM_ENDIO_REQUEUE;
-		}
-	}
+	if (atomic_read(&m->nr_valid_paths) == 0 &&
+	    !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
+		return -EIO;
 
 	/* Queue for the daemon to resubmit */
 	dm_bio_restore(get_bio_details_from_bio(clone), clone);
-- 
2.12.2

  parent reply	other threads:[~2017-04-27 17:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27 17:11 [PATCH v2 00/13] Device mapper and dm-mpath patches Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 01/13] dm-mpath: Split activate_path() Bart Van Assche
2017-04-27 17:11   ` Bart Van Assche
2017-04-28  5:59   ` [dm-devel] " Hannes Reinecke
2017-04-28  5:59     ` Hannes Reinecke
2017-04-27 17:11 ` [PATCH v2 02/13] dm-mpath: Avoid that path removal can trigger an infinite loop Bart Van Assche
2017-04-27 17:11   ` Bart Van Assche
2017-04-28  5:59   ` [dm-devel] " Hannes Reinecke
2017-04-28  5:59     ` Hannes Reinecke
2017-04-27 17:11 ` [PATCH v2 03/13] dm-mpath: Delay requeuing while path initialization is in progress Bart Van Assche
2017-04-27 17:11   ` Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 04/13] dm-rq: Adjust requeuing delays Bart Van Assche
2017-04-27 19:16   ` Mike Snitzer
2017-04-27 19:52     ` Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 05/13] dm-mpath: Make it easier to analyze requeuing behavior Bart Van Assche
2017-04-27 19:29   ` Mike Snitzer
2017-04-27 19:57     ` Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 06/13] dm-rq: Check blk_mq_register_dev() return value Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 07/13] dm, persistence: Remove an unused argument from dm_block_manager_create() Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 08/13] dm: Verify suspend_locking assumptions at runtime Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 09/13] dm-mpath: Verify locking " Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 10/13] dm: Introduce enum dm_queue_mode Bart Van Assche
2017-04-27 17:11 ` Bart Van Assche [this message]
2017-04-27 20:39   ` [PATCH v2 11/13] dm-mpath: Micro-optimize the hot path Mike Snitzer
2017-04-27 17:11 ` [PATCH v2 12/13] dm-mpath: Introduce assign_bit() Bart Van Assche
2017-04-27 17:11 ` [PATCH v2 13/13] dm, dm-mpath: Make it easier to detect unintended I/O request flushes Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170427171126.26814-12-bart.vanassche@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.