Commit a53becc9 authored by Chandra Seetharaman's avatar Chandra Seetharaman Committed by James Bottomley

[SCSI] dh_rdac: Use WWID from C8 page instead of Subsystem id from C4 page to identify storage

rdac hardware handler uses "Subsystem Identifier" from C4 inquiry page
to uniquely identify a storage. The problem with that is that if any
any of the bytes are non-ascii, subsys_id will all be spaces (hex
0x20). This creates lot of problems especially when there are multiple
rdac storages are connected to the server.

Use "Storage Array Unique Identifier" from C8 inquiry page, which is the
world wide unique identifier for the storage array, to uniquely identify
the storage.
Signed-off-by: default avatarChandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent e466e1c6
...@@ -128,25 +128,7 @@ struct c4_inquiry { ...@@ -128,25 +128,7 @@ struct c4_inquiry {
u8 reserved[2]; u8 reserved[2];
}; };
struct rdac_controller { #define UNIQUE_ID_LEN 16
u8 subsys_id[SUBSYS_ID_LEN];
u8 slot_id[SLOT_ID_LEN];
int use_ms10;
struct kref kref;
struct list_head node; /* list of all controllers */
union {
struct rdac_pg_legacy legacy;
struct rdac_pg_expanded expanded;
} mode_select;
u8 index;
u8 array_name[ARRAY_LABEL_LEN];
spinlock_t ms_lock;
int ms_queued;
struct work_struct ms_work;
struct scsi_device *ms_sdev;
struct list_head ms_head;
};
struct c8_inquiry { struct c8_inquiry {
u8 peripheral_info; u8 peripheral_info;
u8 page_code; /* 0xC8 */ u8 page_code; /* 0xC8 */
...@@ -159,12 +141,30 @@ struct c8_inquiry { ...@@ -159,12 +141,30 @@ struct c8_inquiry {
u8 vol_user_label_len; u8 vol_user_label_len;
u8 vol_user_label[60]; u8 vol_user_label[60];
u8 array_uniq_id_len; u8 array_uniq_id_len;
u8 array_unique_id[16]; u8 array_unique_id[UNIQUE_ID_LEN];
u8 array_user_label_len; u8 array_user_label_len;
u8 array_user_label[60]; u8 array_user_label[60];
u8 lun[8]; u8 lun[8];
}; };
struct rdac_controller {
u8 array_id[UNIQUE_ID_LEN];
int use_ms10;
struct kref kref;
struct list_head node; /* list of all controllers */
union {
struct rdac_pg_legacy legacy;
struct rdac_pg_expanded expanded;
} mode_select;
u8 index;
u8 array_name[ARRAY_LABEL_LEN];
spinlock_t ms_lock;
int ms_queued;
struct work_struct ms_work;
struct scsi_device *ms_sdev;
struct list_head ms_head;
};
struct c2_inquiry { struct c2_inquiry {
u8 peripheral_info; u8 peripheral_info;
u8 page_code; /* 0xC2 */ u8 page_code; /* 0xC2 */
...@@ -369,16 +369,16 @@ static void release_controller(struct kref *kref) ...@@ -369,16 +369,16 @@ static void release_controller(struct kref *kref)
kfree(ctlr); kfree(ctlr);
} }
static struct rdac_controller *get_controller(u8 *subsys_id, u8 *slot_id, static struct rdac_controller *get_controller(int index, char *array_name,
char *array_name) u8 *array_id)
{ {
struct rdac_controller *ctlr, *tmp; struct rdac_controller *ctlr, *tmp;
spin_lock(&list_lock); spin_lock(&list_lock);
list_for_each_entry(tmp, &ctlr_list, node) { list_for_each_entry(tmp, &ctlr_list, node) {
if ((memcmp(tmp->subsys_id, subsys_id, SUBSYS_ID_LEN) == 0) && if ((memcmp(tmp->array_id, array_id, UNIQUE_ID_LEN) == 0) &&
(memcmp(tmp->slot_id, slot_id, SLOT_ID_LEN) == 0)) { (tmp->index == index)) {
kref_get(&tmp->kref); kref_get(&tmp->kref);
spin_unlock(&list_lock); spin_unlock(&list_lock);
return tmp; return tmp;
...@@ -389,16 +389,10 @@ static struct rdac_controller *get_controller(u8 *subsys_id, u8 *slot_id, ...@@ -389,16 +389,10 @@ static struct rdac_controller *get_controller(u8 *subsys_id, u8 *slot_id,
goto done; goto done;
/* initialize fields of controller */ /* initialize fields of controller */
memcpy(ctlr->subsys_id, subsys_id, SUBSYS_ID_LEN); memcpy(ctlr->array_id, array_id, UNIQUE_ID_LEN);
memcpy(ctlr->slot_id, slot_id, SLOT_ID_LEN); ctlr->index = index;
memcpy(ctlr->array_name, array_name, ARRAY_LABEL_LEN); memcpy(ctlr->array_name, array_name, ARRAY_LABEL_LEN);
/* update the controller index */
if (slot_id[1] == 0x31)
ctlr->index = 0;
else
ctlr->index = 1;
kref_init(&ctlr->kref); kref_init(&ctlr->kref);
ctlr->use_ms10 = -1; ctlr->use_ms10 = -1;
ctlr->ms_queued = 0; ctlr->ms_queued = 0;
...@@ -444,7 +438,7 @@ static int submit_inquiry(struct scsi_device *sdev, int page_code, ...@@ -444,7 +438,7 @@ static int submit_inquiry(struct scsi_device *sdev, int page_code,
} }
static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h, static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
char *array_name) char *array_name, u8 *array_id)
{ {
int err, i; int err, i;
struct c8_inquiry *inqp; struct c8_inquiry *inqp;
...@@ -463,6 +457,8 @@ static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h, ...@@ -463,6 +457,8 @@ static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
*(array_name+i) = inqp->array_user_label[(2*i)+1]; *(array_name+i) = inqp->array_user_label[(2*i)+1];
*(array_name+ARRAY_LABEL_LEN-1) = '\0'; *(array_name+ARRAY_LABEL_LEN-1) = '\0';
memset(array_id, 0, UNIQUE_ID_LEN);
memcpy(array_id, inqp->array_unique_id, inqp->array_uniq_id_len);
} }
return err; return err;
} }
...@@ -504,16 +500,20 @@ static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h) ...@@ -504,16 +500,20 @@ static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)
} }
static int initialize_controller(struct scsi_device *sdev, static int initialize_controller(struct scsi_device *sdev,
struct rdac_dh_data *h, char *array_name) struct rdac_dh_data *h, char *array_name, u8 *array_id)
{ {
int err; int err, index;
struct c4_inquiry *inqp; struct c4_inquiry *inqp;
err = submit_inquiry(sdev, 0xC4, sizeof(struct c4_inquiry), h); err = submit_inquiry(sdev, 0xC4, sizeof(struct c4_inquiry), h);
if (err == SCSI_DH_OK) { if (err == SCSI_DH_OK) {
inqp = &h->inq.c4; inqp = &h->inq.c4;
h->ctlr = get_controller(inqp->subsys_id, inqp->slot_id, /* get the controller index */
array_name); if (inqp->slot_id[1] == 0x31)
index = 0;
else
index = 1;
h->ctlr = get_controller(index, array_name, array_id);
if (!h->ctlr) if (!h->ctlr)
err = SCSI_DH_RES_TEMP_UNAVAIL; err = SCSI_DH_RES_TEMP_UNAVAIL;
} }
...@@ -835,6 +835,7 @@ static int rdac_bus_attach(struct scsi_device *sdev) ...@@ -835,6 +835,7 @@ static int rdac_bus_attach(struct scsi_device *sdev)
unsigned long flags; unsigned long flags;
int err; int err;
char array_name[ARRAY_LABEL_LEN]; char array_name[ARRAY_LABEL_LEN];
char array_id[UNIQUE_ID_LEN];
scsi_dh_data = kzalloc(sizeof(*scsi_dh_data) scsi_dh_data = kzalloc(sizeof(*scsi_dh_data)
+ sizeof(*h) , GFP_KERNEL); + sizeof(*h) , GFP_KERNEL);
...@@ -849,11 +850,11 @@ static int rdac_bus_attach(struct scsi_device *sdev) ...@@ -849,11 +850,11 @@ static int rdac_bus_attach(struct scsi_device *sdev)
h->lun = UNINITIALIZED_LUN; h->lun = UNINITIALIZED_LUN;
h->state = RDAC_STATE_ACTIVE; h->state = RDAC_STATE_ACTIVE;
err = get_lun_info(sdev, h, array_name); err = get_lun_info(sdev, h, array_name, array_id);
if (err != SCSI_DH_OK) if (err != SCSI_DH_OK)
goto failed; goto failed;
err = initialize_controller(sdev, h, array_name); err = initialize_controller(sdev, h, array_name, array_id);
if (err != SCSI_DH_OK) if (err != SCSI_DH_OK)
goto failed; goto failed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment