Skip to contentSkip to conversation

multipath: Add new SPC-3 ALUA hardware handler

PATCH In review Hannes Reinecke 2 participants 3 messages Nov 15, 2007 – Nov 16, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 multipath: Add new SPC-3 ALUA hardware handler

This adds a new SPC-3 ALUA hardware handler for multipathing.

---
 drivers/md/Kconfig         |    7 +
 drivers/md/Makefile        |    2 +
 drivers/md/dm-mpath-alua.c |  681 ++++++++++++++++++++++++++++++++++++++++++++
 include/scsi/scsi.h        |    3 +
 4 files changed, 693 insertions(+), 0 deletions(-)
 create mode 100644 drivers/md/dm-mpath-alua.c
drivers/md/Kconfig +7 -0
index 9b6fbf0..2044fb4 100644
@@ -273,6 +273,13 @@ config DM_MULTIPATH_HP
         ---help---
           Multipath support for HP MSA (Active/Passive) series hardware.
 
+config DM_MULTIPATH_ALUA
+	tristate "SPC-3 ALUA multipath support (EXPERIMENTAL)"
+	depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL
+	---help---
+	  Multipath support for SPC-3 Asymmetric Logical Unit
+	  Access (ALUA).
+
 config DM_DELAY
 	tristate "I/O delaying target (EXPERIMENTAL)"
 	depends on BLK_DEV_DM && EXPERIMENTAL
drivers/md/Makefile +2 -0
index d9aa7ed..6b8fd78 100644
@@ -8,6 +8,7 @@ dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o
 dm-snapshot-objs := dm-snap.o dm-exception-store.o
 dm-mirror-objs	:= dm-log.o dm-raid1.o
 dm-rdac-objs	:= dm-mpath-rdac.o
+dm-alua-objs	:= dm-mpath-alua.o
 dm-hp-sw-objs	:= dm-mpath-hp-sw.o
 md-mod-objs     := md.o bitmap.o
 raid456-objs	:= raid5.o raid6algos.o raid6recov.o raid6tables.o \
@@ -38,6 +39,7 @@ obj-$(CONFIG_DM_MULTIPATH)	+= dm-multipath.o dm-round-robin.o
 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_ALUA)	+= dm-alua.o
 obj-$(CONFIG_DM_SNAPSHOT)	+= dm-snapshot.o
 obj-$(CONFIG_DM_MIRROR)		+= dm-mirror.o
 obj-$(CONFIG_DM_ZERO)		+= dm-zero.o
drivers/md/dm-mpath-alua.c new file +681 -0

681 lines not on this page · raw message

include/scsi/scsi.h +3 -0
index 702fcfe..cdd15c8 100644
@@ -91,6 +91,7 @@ extern const unsigned char scsi_command_size[8];
 #define PERSISTENT_RESERVE_OUT 0x5f
 #define REPORT_LUNS           0xa0
 #define MAINTENANCE_IN        0xa3
+#define MAINTENANCE_OUT       0xa4
 #define MOVE_MEDIUM           0xa5
 #define EXCHANGE_MEDIUM       0xa6
 #define READ_12               0xa8
@@ -110,6 +111,8 @@ extern const unsigned char scsi_command_size[8];
 #define	SAI_READ_CAPACITY_16  0x10
 /* values for maintenance in */
 #define MI_REPORT_TARGET_PGS  0x0a
+/* values for maintenance out */
+#define MO_SET_TARGET_PGS     0x0a
 
 /* Values for T10/04-262r7 */
 #define	ATA_16		      0x85	/* 16-byte pass-thru */
Signature · 1 line
1.5.3.2
#1 lore raw

Hi Hannes,

Quoted 3 lines · [email protected] (Hannes Reinecke) writes:

This adds a new SPC-3 ALUA hardware handler for multipathing.

<snip>

drivers/md/dm-mpath-alua.c line 38

Quoted 5 lines
drivers/md/dm-mpath-alua.c new file +5 -0
+#define TPGS_STATE_OPTIMIZED		0x0
+#define TPGS_STATE_NONOPTIMIZED		0x1
+#define TPGS_STATE_STANDBY		0x2
+#define TPGS_STATE_UNAVAILABLE		0x3
+#define TPGS_STATE_OFFLINE		0xe

SPC-3 (at least the draft, rev 23 I'm looking at) doesn't know an 'Offline' state - I think it's a SPC-4 feature. So maybe 'Unavailable' should be interpreted as path failure as well / instead?

<snip>

Quoted 30 lines
drivers/md/dm-mpath-alua.c new file +30 -0
+/*
+ * SET TARGET GROUP STATES endio handler
+ *
+ * We only have to test here if we should resubmit the command;
+ * any other error is assumed as a failure.
+ * Maybe we should analyze the sensebuffer here, too.
+ */
+static void stpg_endio(struct request *req, int error)
+{
+	struct hw_handler *hwh = req->end_io_data;
+	struct alua_handler *h = hwh->context;
+
+	switch(host_byte(error)) {
+	case DID_BUS_BUSY:
+		if (!h->retry)
+			break;
+		h->retry--;
+	case DID_REQUEUE:
+	case DID_IMM_RETRY:
+		dm_enqueue_hw_workq(hwh);
+		goto done;
+	}
+
+	if (had_failures(req, error)) {
+		if (h->tpgs & TPGS_MODE_IMPLICIT) {
+			/* Ignore errors; the array will figure it out */
+			DMWARN("%s: stpg failed %x, disabling explicit mode",
+			       h->path->dev->name, error);
+			h->tpgs &= ~TPGS_MODE_EXPLICIT;
+			dm_enqueue_hw_workq(hwh);

drivers/md/dm-mpath-alua.c line 521

Quoted 10 lines
drivers/md/dm-mpath-alua.c new file +10 -0
+		} else {
+			DMWARN("%s: stpg failed %x, disable path",
+			       h->path->dev->name, error);
+			dm_pg_init_complete(h->path, MP_FAIL_PATH);
+		}
+	} else {
+		DMWARN("%s: port group %02x new state %c",
+		       h->path->dev->name, h->group_id,
+		       print_alua_state(h->state) );
+		dm_pg_init_complete(h->path, 0);

Hmmm, maybe I'm just missing something so CMIIW, but I think the PG state should be retrieved once more before finally calling dm_pg_init_complete(), because the target might return the STPG command before the transition has completed (SPC-3, 6.31). This could confuse application clients?

Arne

#2 lore raw
Quoted 10 lines · Arne Redlich

Hi Hannes,

Quoted 3 lines · [email protected] (Hannes Reinecke) writes:

This adds a new SPC-3 ALUA hardware handler for multipathing.

<snip>

Quoted 10 lines

drivers/md/dm-mpath-alua.c line 38

Quoted 5 lines
drivers/md/dm-mpath-alua.c new file +5 -0
+#define TPGS_STATE_OPTIMIZED		0x0
+#define TPGS_STATE_NONOPTIMIZED		0x1
+#define TPGS_STATE_STANDBY		0x2
+#define TPGS_STATE_UNAVAILABLE		0x3
+#define TPGS_STATE_OFFLINE		0xe

SPC-3 (at least the draft, rev 23 I'm looking at) doesn't know an 'Offline' state - I think it's a SPC-4 feature. So maybe 'Unavailable' should be interpreted as path failure as well / instead?

It is SPC-4. And if the state is unavailable, we can try to activate it; spc3r23 says (5.8.2.4.5):
Therefore it may not be possible to transition from this state to either the active/optimized, active/non-optimized or standby states.

But consequently it _may_ be possible, so we should at least try. If that fails (ie if SET TARGET PORT GROUPS returns
an error) we'll fail the path anyway.
No harm in trying.

Quoted 40 lines

<snip>

Quoted 38 lines
drivers/md/dm-mpath-alua.c new file +38 -0
+/*
+ * SET TARGET GROUP STATES endio handler
+ *
+ * We only have to test here if we should resubmit the command;
+ * any other error is assumed as a failure.
+ * Maybe we should analyze the sensebuffer here, too.
+ */
+static void stpg_endio(struct request *req, int error)
+{
+	struct hw_handler *hwh = req->end_io_data;
+	struct alua_handler *h = hwh->context;
+
+	switch(host_byte(error)) {
+	case DID_BUS_BUSY:
+		if (!h->retry)
+			break;
+		h->retry--;
+	case DID_REQUEUE:
+	case DID_IMM_RETRY:
+		dm_enqueue_hw_workq(hwh);
+		goto done;
+	}
+
+	if (had_failures(req, error)) {
+		if (h->tpgs & TPGS_MODE_IMPLICIT) {
+			/* Ignore errors; the array will figure it out */
+			DMWARN("%s: stpg failed %x, disabling explicit mode",
+			       h->path->dev->name, error);
+			h->tpgs &= ~TPGS_MODE_EXPLICIT;
+			dm_enqueue_hw_workq(hwh);
+		} else {
+			DMWARN("%s: stpg failed %x, disable path",
+			       h->path->dev->name, error);
+			dm_pg_init_complete(h->path, MP_FAIL_PATH);
+		}
+	} else {
+		DMWARN("%s: port group %02x new state %c",
+		       h->path->dev->name, h->group_id,
Quoted 9 lines

drivers/md/dm-mpath-alua.c line 521

Quoted 2 lines
drivers/md/dm-mpath-alua.c new file +2 -0
+		       print_alua_state(h->state) );
+		dm_pg_init_complete(h->path, 0);

Hmmm, maybe I'm just missing something so CMIIW, but I think the PG state should be retrieved once more before finally calling dm_pg_init_complete(), because the target might return the STPG command before the transition has completed (SPC-3, 6.31). This could confuse application clients?

Hmm. Spec isn't exactly clear here. One would expect that these arrays would have set the T_SUP bit in REPORT TARGET PORT GROUPS, and set the ALUA state to 'TRANSITIONING' accordingly. But we catch the relevant sense codes as per SPC-3, so we should retry it properly.

And it's not that I've actually seen an array implementing this, so it's a bit academic currently.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html