alua: Handle LBA_DEPENDENT state
authorHannes Reinecke <hare@suse.de>
Mon, 13 Sep 2010 09:06:13 +0000 (11:06 +0200)
committerHannes Reinecke <hare@suse.de>
Wed, 18 May 2011 11:42:16 +0000 (13:42 +0200)
SPC-4 added another state, LBA_DEPENDENT. This patch
adds basic support for it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/prioritizers/alua.c
libmultipath/prioritizers/alua_spc3.h

index e33e17c..4da3ee7 100644 (file)
 #define ALUA_PRIO_TPGS_FAILED                  4
 #define ALUA_PRIO_NO_INFORMATION               5
 
 #define ALUA_PRIO_TPGS_FAILED                  4
 #define ALUA_PRIO_NO_INFORMATION               5
 
+static const char * aas_string[] = {
+       [AAS_OPTIMIZED]         = "active/optimized",
+       [AAS_NON_OPTIMIZED]     = "active/non-optimized",
+       [AAS_STANDBY]           = "standby",
+       [AAS_UNAVAILABLE]       = "unavailable",
+       [AAS_LBA_DEPENDENT]     = "lba dependent",
+       [AAS_RESERVED]          = "invalid/reserved",
+       [AAS_OFFLINE]           = "offline",
+       [AAS_TRANSITIONING]     = "transitioning between states",
+};
+
+static const char *aas_print_string(int rc)
+{
+       rc &= 0x7f;
+
+       if (rc & 0x70)
+               return aas_string[AAS_RESERVED];
+       rc &= 0x0f;
+       if (rc > AAS_RESERVED && rc < AAS_OFFLINE)
+               return aas_string[AAS_RESERVED];
+       else
+               return aas_string[rc];
+}
+
 int
 get_alua_info(int fd)
 {
 int
 get_alua_info(int fd)
 {
-       char *  aas_string[] = {
-               [AAS_OPTIMIZED]         = "active/optimized",
-               [AAS_NON_OPTIMIZED]     = "active/non-optimized",
-               [AAS_STANDBY]           = "standby",
-               [AAS_UNAVAILABLE]       = "unavailable",
-               [AAS_TRANSITIONING]     = "transitioning between states",
-       };
        int     rc;
        int     tpg;
        int     aas;
        int     rc;
        int     tpg;
        int     aas;
@@ -56,8 +73,8 @@ get_alua_info(int fd)
                return -ALUA_PRIO_GETAAS_FAILED;
        aas = (rc & 0x0f);
 
                return -ALUA_PRIO_GETAAS_FAILED;
        aas = (rc & 0x0f);
 
-       condlog(3, "aas = [%s]",
-               (aas < 4) ? aas_string[aas] : "invalid/reserved");
+       condlog(3, "aas = %02x [%s]%s", rc, aas_print_string(rc),
+               (rc & 0x80) ? " [preferred]" : "");
        return rc;
 }
 
        return rc;
 }
 
@@ -81,6 +98,9 @@ int getprio (struct path * pp, char * args)
                        case AAS_NON_OPTIMIZED:
                                rc = 10;
                                break;
                        case AAS_NON_OPTIMIZED:
                                rc = 10;
                                break;
+                       case AAS_LBA_DEPENDENT:
+                               rc = 5;
+                               break;
                        case AAS_STANDBY:
                                rc = 1;
                                break;
                        case AAS_STANDBY:
                                rc = 1;
                                break;
index 4bbdded..e78b6c3 100644 (file)
@@ -273,6 +273,9 @@ struct rtpg_tp_dscr {
 #define AAS_NON_OPTIMIZED              0x1
 #define AAS_STANDBY                    0x2
 #define AAS_UNAVAILABLE                        0x3
 #define AAS_NON_OPTIMIZED              0x1
 #define AAS_STANDBY                    0x2
 #define AAS_UNAVAILABLE                        0x3
+#define AAS_LBA_DEPENDENT              0x4
+#define AAS_RESERVED                   0x5
+#define AAS_OFFLINE                    0xe
 #define AAS_TRANSITIONING              0xf
 
 #define TPG_STATUS_NONE                        0x0
 #define AAS_TRANSITIONING              0xf
 
 #define TPG_STATUS_NONE                        0x0
@@ -283,7 +286,8 @@ struct rtpg_tpg_dscr {
        unsigned char   b0;             /* x....... = pref(ered) port        */
                                        /* .xxx.... = reserved               */
                                        /* ....xxxx = asymetric access state */
        unsigned char   b0;             /* x....... = pref(ered) port        */
                                        /* .xxx.... = reserved               */
                                        /* ....xxxx = asymetric access state */
-       unsigned char   b1;             /* xxxx.... = reserved               */
+       unsigned char   b1;             /* xxx..... = reserved               */
+                                       /* ...x.... = LBA dependent support  */
                                        /* ....x... = unavailable support    */
                                        /* .....x.. = standby support        */
                                        /* ......x. = non-optimized support  */
                                        /* ....x... = unavailable support    */
                                        /* .....x.. = standby support        */
                                        /* ......x. = non-optimized support  */