All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandra Seetharaman <sekharan@us.ibm.com>
To: dm-devel@redhat.com, linux-scsi@vger.kernel.org
Cc: andmike@us.ibm.com, michaelc@cs.wisc.edu,
	Chandra Seetharaman <sekharan@us.ibm.com>,
	jens.axboe@oracle.com
Subject: [PATCH 9/9] scsi_dh: add scsi device handler to dm
Date: Wed, 23 Jan 2008 16:32:35 -0800	[thread overview]
Message-ID: <20080124003235.18871.72293.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080124003010.18871.84095.sendpatchset@localhost.localdomain>

Subject: scsi_dh: add scsi device handler to dm

From: Mike Anderson <andmike@linux.vnet.ibm.com>

This patch adds a dm hardware handler that can control SCSI device
handlers.

SCSI Hardware handler for a specific device type can be invokes by using
this handler.

For example, to use the lsi_rdac SCSI hardware handler, one would specify
        hardware_handler        "2 scsi_dh lsi_rdac"
in the device section of /etc/multipath.conf.

Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
---

 drivers/md/Kconfig            |    6 	6 +	0 -	0 !
 drivers/md/Makefile           |    2 	2 +	0 -	0 !
 drivers/md/dm-mpath-scsi-dh.c |  185 	185 +	0 -	0 !
 3 files changed, 193 insertions(+)

Index: linux-2.6.24-rc8/drivers/md/Kconfig
===================================================================
--- linux-2.6.24-rc8.orig/drivers/md/Kconfig
+++ linux-2.6.24-rc8/drivers/md/Kconfig
@@ -273,6 +273,12 @@ config DM_MULTIPATH_HP
         ---help---
           Multipath support for HP MSA (Active/Passive) series hardware.
 
+config DM_MULTIPATH_SCSI_DH
+        tristate "SCSI Device Handler support (EXPERIMENTAL)"
+        depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL
+        ---help---
+          Multipath support for SCSI Device Handlers.
+
 config DM_DELAY
 	tristate "I/O delaying target (EXPERIMENTAL)"
 	depends on BLK_DEV_DM && EXPERIMENTAL
Index: linux-2.6.24-rc8/drivers/md/Makefile
===================================================================
--- linux-2.6.24-rc8.orig/drivers/md/Makefile
+++ linux-2.6.24-rc8/drivers/md/Makefile
@@ -9,6 +9,7 @@ dm-snapshot-objs := dm-snap.o dm-excepti
 dm-mirror-objs	:= dm-log.o dm-raid1.o
 dm-rdac-objs	:= dm-mpath-rdac.o
 dm-hp-sw-objs	:= dm-mpath-hp-sw.o
+dm-scsi-dh-objs := dm-mpath-scsi-dh.o
 md-mod-objs     := md.o bitmap.o
 raid456-objs	:= raid5.o raid6algos.o raid6recov.o raid6tables.o \
 		   raid6int1.o raid6int2.o raid6int4.o \
@@ -38,6 +39,7 @@ obj-$(CONFIG_DM_MULTIPATH)	+= dm-multipa
 obj-$(CONFIG_DM_MULTIPATH_EMC)	+= dm-emc.o
 obj-$(CONFIG_DM_MULTIPATH_HP)	+= dm-hp-sw.o
 obj-$(CONFIG_DM_MULTIPATH_RDAC)	+= dm-rdac.o
+obj-$(CONFIG_DM_MULTIPATH_SCSI_DH) += dm-scsi-dh.o
 obj-$(CONFIG_DM_SNAPSHOT)	+= dm-snapshot.o
 obj-$(CONFIG_DM_MIRROR)		+= dm-mirror.o
 obj-$(CONFIG_DM_ZERO)		+= dm-zero.o
Index: linux-2.6.24-rc8/drivers/md/dm-mpath-scsi-dh.c
===================================================================
--- /dev/null
+++ linux-2.6.24-rc8/drivers/md/dm-mpath-scsi-dh.c
@@ -0,0 +1,185 @@
+/*
+ * SCSI Device handler
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ * 	Author: Mike Anderson <andmike@linux.vnet.ibm.com>
+ */
+
+#define DM_MSG_PREFIX "multipath scsi_dh"
+
+#include "dm.h"
+#include "dm-hw-handler.h"
+
+struct scsi_dh_context {
+	char		*hw_handler_name;
+	struct dm_path	*path;
+};
+
+static int scsi_dh_create(struct hw_handler *hwh, unsigned argc, char **argv)
+{
+	struct scsi_dh_context *c;
+
+	c = kzalloc(sizeof(*c), GFP_KERNEL);
+	if (!c)
+		return -ENOMEM;
+	if (argc == 1) {
+		c->hw_handler_name = kstrdup(argv[0], GFP_KERNEL);
+		if (c->hw_handler_name)
+			request_module("scsi_dh_%s", c->hw_handler_name);
+	}
+
+	hwh->context = c;
+
+	return 0;
+}
+
+static void scsi_dh_destroy(struct hw_handler *hwh)
+{
+	struct scsi_dh_context *c = hwh->context;
+	kfree(c->hw_handler_name);
+	kfree(c);
+	hwh->context = NULL;
+	return;
+}
+
+static unsigned scsi_dh_error(struct hw_handler *hwh, struct bio *bio)
+{
+	/* Try default handler */
+	return dm_scsi_err_handler(hwh, bio);
+}
+
+
+static void pg_init_done(struct request *req, int err)
+{
+	struct scsi_dh_context *c = req->end_io_data;
+	int ret = 0;
+
+	if (blkerr_transport_err(req->errors)) {
+		/*
+		 * Old dm behavior had us fail a path on any error.
+		 * In future patches, since we have finer grained errors now,
+		 * we do not have to fail the path on the first transient
+		 * error.
+		 */
+		ret = MP_FAIL_PATH;
+		goto out;
+	}
+
+	/* device or driver problems */
+	switch (req->errors) {
+	case BLKERR_OK:
+		break;
+	case BLKERR_NOSYS:
+		if (!c->hw_handler_name)
+			break;
+		DMERR("Cannot failover device because hw-%s may not be "
+		      "loaded.", c->hw_handler_name);
+		/*
+		 * Fail path for now, so we do not ping poing
+		 */
+		ret = MP_FAIL_PATH;
+		break;
+	case BLKERR_DEV_TEMP_BUSY:
+		/*
+		 * Probably doing something like FW upgrade on the
+		 * controller so try the other pg.
+		 */
+		ret = MP_BYPASS_PG;
+		break;
+	/* TODO: For BLKERR_RETRY we should wait a couple seconds */
+	case BLKERR_RETRY:
+	case BLKERR_IMM_RETRY:
+	case BLKERR_RES_TEMP_UNAVAIL:
+		break;
+	default:
+		/*
+		 * We probably do not want to fail the path for a device
+		 * error, but this is what the old dm did. In future
+		 * patches we can do more advanced handling.
+		 */
+		ret = MP_FAIL_PATH;
+	}
+
+out:
+	dm_pg_init_complete(c->path, ret);
+	__blk_put_request(req->q, req);
+	return;
+}
+
+static void scsi_dh_pg_init(struct hw_handler *hwh, unsigned bypassed,
+			struct dm_path *path)
+{
+	struct scsi_dh_context *c = hwh->context;
+	struct request *req;
+
+	req = blk_get_request(bdev_get_queue(path->dev->bdev), 1, GFP_NOIO);
+	if (!req) {
+		/* FIXME: Add retry */
+		dm_pg_init_complete(path, MP_FAIL_PATH);
+		return;
+	}
+
+	req->cmd[0] = REQ_LB_OP_TRANSITION;
+	req->cmd_type = REQ_TYPE_LINUX_BLOCK;
+	c->path = path;
+	req->end_io_data = c;
+	/* TODO: does this need to be configurable or is it HW specific? */
+	req->retries = 5;
+	blk_execute_rq_nowait(req->q, NULL, req, 1, pg_init_done);
+}
+
+#define SCSI_DH_NAME "scsi_dh"
+#define SCSI_DH_VER "0.1"
+
+static struct hw_handler_type scsi_dh_handler = {
+	.name = SCSI_DH_NAME,
+	.module = THIS_MODULE,
+	.create = scsi_dh_create,
+	.destroy = scsi_dh_destroy,
+	.pg_init = scsi_dh_pg_init,
+	.error = scsi_dh_error,
+};
+
+static int __init scsi_dh_init(void)
+{
+	int r;
+
+	r = dm_register_hw_handler(&scsi_dh_handler);
+	if (r < 0) {
+		DMERR("%s: register failed %d", SCSI_DH_NAME, r);
+		return r;
+	}
+
+	DMINFO("%s: version %s loaded", SCSI_DH_NAME, SCSI_DH_VER);
+	return 0;
+}
+
+static void __exit scsi_dh_exit(void)
+{
+	int r = dm_unregister_hw_handler(&scsi_dh_handler);
+
+	if (r < 0)
+		DMERR("%s: unregister failed %d", SCSI_DH_NAME, r);
+}
+
+module_init(scsi_dh_init);
+module_exit(scsi_dh_exit);
+
+MODULE_DESCRIPTION("DM Multipath SCSI Device Handler support");
+MODULE_AUTHOR("Mike Anderson <andmike@linux.vnet.ibm.com");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(SCSI_DH_VER);

-- 

----------------------------------------------------------------------
    Chandra Seetharaman               | Be careful what you choose....
              - sekharan@us.ibm.com   |      .......you may get it.
----------------------------------------------------------------------

      parent reply	other threads:[~2008-01-24  0:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-24  0:30 [PATCH 0/9] scsi_dh: Move dm device handler to SCSI layer Chandra Seetharaman
2008-01-24  0:30 ` [PATCH 1/9] scsi_dh: add REQ_LB_OP_TRANSITION and errors Chandra Seetharaman
2008-01-24  0:30 ` [PATCH 2/9] scsi_dh: change sd_prep_fn to call common code Chandra Seetharaman
2008-01-24  0:30 ` [PATCH 3/9] scsi_dh: scsi handling of REQ_LB_OP_TRANSITION Chandra Seetharaman
2008-02-01 20:00   ` Mike Christie
2008-02-04 18:59     ` Chandra Seetharaman
2008-02-04 19:02     ` James Bottomley
2008-02-06 19:00       ` Mike Anderson
2008-02-06 20:52         ` James Bottomley
2008-01-24  0:31 ` [PATCH 4/9] scsi_dh: add skeleton for SCSI Device Handlers Chandra Seetharaman
2008-02-01 19:53   ` Mike Christie
2008-02-01 20:27     ` Mike Anderson
2008-02-04 18:54     ` Chandra Seetharaman
2008-01-24  0:31 ` [PATCH 5/9] scsi_dh: add EMC Clariion device handler Chandra Seetharaman
2008-01-24  0:31 ` [PATCH 6/9] scsi_dh: add hp sw " Chandra Seetharaman
2008-01-24  0:32 ` [PATCH 7/9] scsi_dh: Add support for SDEV_PASSIVE Chandra Seetharaman
2008-02-04 18:58   ` James Bottomley
2008-02-04 20:15     ` Chandra Seetharaman
2008-02-04 20:28       ` James Bottomley
2008-02-04 21:19         ` Chandra Seetharaman
2008-02-09 12:45           ` Matthew Wilcox
2008-02-11 18:27             ` Chandra Seetharaman
2008-02-11 19:18               ` Matthew Wilcox
2008-02-28  1:03                 ` Chandra Seetharaman
2008-02-05 20:04         ` Mike Christie
2008-02-05 21:56           ` Mike Anderson
2008-02-06  0:46             ` Chandra Seetharaman
2008-02-07 10:08             ` no INQUIRY from userspace please (was Re: [PATCH 7/9] scsi_dh: Add support for SDEV_PASSIVE) Stefan Richter
2008-02-07 15:01               ` James Bottomley
2008-02-07 17:05                 ` no INQUIRY from userspace please Stefan Richter
2008-02-07 17:13                   ` Stefan Richter
2008-02-19 20:53                     ` Douglas Gilbert
2008-03-04  9:06                       ` Hannes Reinecke
2008-02-07 20:42                 ` no INQUIRY from userspace please (was Re: [PATCH 7/9] scsi_dh: Add support for SDEV_PASSIVE) Luben Tuikov
2008-02-04 20:26     ` [PATCH 7/9] scsi_dh: Add support for SDEV_PASSIVE Mike Anderson
2008-01-24  0:32 ` [PATCH 8/9] scsi_dh: add lsi rdac device handler Chandra Seetharaman
2008-01-24  0:32 ` Chandra Seetharaman [this message]

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=20080124003235.18871.72293.sendpatchset@localhost.localdomain \
    --to=sekharan@us.ibm.com \
    --cc=andmike@us.ibm.com \
    --cc=dm-devel@redhat.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    /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.