From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: agk@redhat.com, hare@suse.de, babu.moger@netapp.com,
sekharan@us.ibm.com, linux-scsi@vger.kernel.org,
Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 3/3] dm mpath: add support for using previously attached scsi_dh
Date: Mon, 7 May 2012 23:19:07 -0400 [thread overview]
Message-ID: <1336447147-3830-2-git-send-email-snitzer@redhat.com> (raw)
In-Reply-To: <1336447147-3830-1-git-send-email-snitzer@redhat.com>
Use the previously attached scsi_dh if "default" is provided as the
hardware handler name (the new 'use_default_hw_handler' flag is set in
the multipath structure).
Leverage scsi_dh_attach's ability to increment the scsi_dh's reference
count if the same scsi_dh name is provided when attaching -- currently
attached scsi_dh name is determined with scsi_dh_attached_handler_name.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-mpath.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
Index: linux-2.6/drivers/md/dm-mpath.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-mpath.c
+++ linux-2.6/drivers/md/dm-mpath.c
@@ -63,6 +63,7 @@ struct multipath {
spinlock_t lock;
+ unsigned use_default_hw_handler:1;
const char *hw_handler_name;
char *hw_handler_params;
@@ -566,6 +567,7 @@ static struct pgpath *parse_path(struct
int r;
struct pgpath *p;
struct multipath *m = ti->private;
+ struct request_queue *q = NULL;
/* we need at least a path arg */
if (as->argc < 1) {
@@ -584,9 +586,16 @@ static struct pgpath *parse_path(struct
goto bad;
}
- if (m->hw_handler_name) {
- struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+ if (m->use_default_hw_handler || m->hw_handler_name)
+ q = bdev_get_queue(p->path.dev->bdev);
+
+ if (m->use_default_hw_handler) {
+ const char *attached_handler_name = scsi_dh_attached_handler_name(q);
+ if (attached_handler_name)
+ m->hw_handler_name = kstrdup(attached_handler_name, GFP_KERNEL);
+ }
+ if (m->hw_handler_name) {
r = scsi_dh_attach(q, m->hw_handler_name);
if (r == -EBUSY) {
/*
@@ -706,6 +715,7 @@ static int parse_hw_handler(struct dm_ar
unsigned hw_argc;
int ret;
struct dm_target *ti = m->ti;
+ const char *hw_handler_name;
static struct dm_arg _args[] = {
{0, 1024, "invalid number of hardware handler args"},
@@ -717,7 +727,13 @@ static int parse_hw_handler(struct dm_ar
if (!hw_argc)
return 0;
- m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);
+ hw_handler_name = dm_shift_arg(as);
+ if (!strncmp(hw_handler_name, "default", 8)) {
+ m->use_default_hw_handler = 1;
+ goto parse_hw_handler_params;
+ }
+
+ m->hw_handler_name = kstrdup(hw_handler_name, GFP_KERNEL);
if (!try_then_request_module(scsi_dh_handler_exist(m->hw_handler_name),
"scsi_dh_%s", m->hw_handler_name)) {
ti->error = "unknown hardware handler type";
@@ -725,6 +741,7 @@ static int parse_hw_handler(struct dm_ar
goto fail;
}
+parse_hw_handler_params:
if (hw_argc > 1) {
char *p;
int i, j, len = 4;
next prev parent reply other threads:[~2012-05-08 3:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-08 3:19 [PATCH 2/3] scsi_dh: add scsi_dh_attached_handler_name Mike Snitzer
2012-05-08 3:19 ` Mike Snitzer [this message]
2012-05-08 6:22 ` [PATCH 3/3] dm mpath: add support for using previously attached scsi_dh Hannes Reinecke
2012-05-08 13:36 ` Mike Snitzer
2012-05-08 14:05 ` Mike Snitzer
2012-05-08 16:20 ` Hannes Reinecke
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=1336447147-3830-2-git-send-email-snitzer@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=babu.moger@netapp.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=sekharan@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).