Commit d7c48feb authored by Hannes Reinecke's avatar Hannes Reinecke Committed by James Bottomley

[SCSI] scsi_dh_alua: Evaluate TPGS setting from inquiry data

Instead of issuing a standard inquiry from within the
alua device handler we can evaluate the TPGS setting from
the existing inquiry data of the sdev and save us the I/O.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent ac81c6a8
...@@ -127,43 +127,6 @@ static struct request *get_alua_req(struct scsi_device *sdev, ...@@ -127,43 +127,6 @@ static struct request *get_alua_req(struct scsi_device *sdev,
return rq; return rq;
} }
/*
* submit_std_inquiry - Issue a standard INQUIRY command
* @sdev: sdev the command should be send to
*/
static int submit_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
{
struct request *rq;
int err = SCSI_DH_RES_TEMP_UNAVAIL;
rq = get_alua_req(sdev, h->inq, ALUA_INQUIRY_SIZE, READ);
if (!rq)
goto done;
/* Prepare the command. */
rq->cmd[0] = INQUIRY;
rq->cmd[1] = 0;
rq->cmd[2] = 0;
rq->cmd[4] = ALUA_INQUIRY_SIZE;
rq->cmd_len = COMMAND_SIZE(INQUIRY);
rq->sense = h->sense;
memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
rq->sense_len = h->senselen = 0;
err = blk_execute_rq(rq->q, NULL, rq, 1);
if (err == -EIO) {
sdev_printk(KERN_INFO, sdev,
"%s: std inquiry failed with %x\n",
ALUA_DH_NAME, rq->errors);
h->senselen = rq->sense_len;
err = SCSI_DH_IO;
}
blk_put_request(rq);
done:
return err;
}
/* /*
* submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command
* @sdev: sdev the command should be sent to * @sdev: sdev the command should be sent to
...@@ -338,23 +301,17 @@ static unsigned submit_stpg(struct alua_dh_data *h) ...@@ -338,23 +301,17 @@ static unsigned submit_stpg(struct alua_dh_data *h)
} }
/* /*
* alua_std_inquiry - Evaluate standard INQUIRY command * alua_check_tpgs - Evaluate TPGS setting
* @sdev: device to be checked * @sdev: device to be checked
* *
* Just extract the TPGS setting to find out if ALUA * Examine the TPGS setting of the sdev to find out if ALUA
* is supported. * is supported.
*/ */
static int alua_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h) static int alua_check_tpgs(struct scsi_device *sdev, struct alua_dh_data *h)
{ {
int err; int err = SCSI_DH_OK;
err = submit_std_inquiry(sdev, h);
if (err != SCSI_DH_OK)
return err;
/* Check TPGS setting */ h->tpgs = scsi_device_tpgs(sdev);
h->tpgs = (h->inq[5] >> 4) & 0x3;
switch (h->tpgs) { switch (h->tpgs) {
case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT: case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT:
sdev_printk(KERN_INFO, sdev, sdev_printk(KERN_INFO, sdev,
...@@ -642,7 +599,7 @@ static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h) ...@@ -642,7 +599,7 @@ static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h)
{ {
int err; int err;
err = alua_std_inquiry(sdev, h); err = alua_check_tpgs(sdev, h);
if (err != SCSI_DH_OK) if (err != SCSI_DH_OK)
goto out; goto out;
......
...@@ -471,6 +471,11 @@ static inline int scsi_device_protection(struct scsi_device *sdev) ...@@ -471,6 +471,11 @@ static inline int scsi_device_protection(struct scsi_device *sdev)
return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0); return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
} }
static inline int scsi_device_tpgs(struct scsi_device *sdev)
{
return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0;
}
#define MODULE_ALIAS_SCSI_DEVICE(type) \ #define MODULE_ALIAS_SCSI_DEVICE(type) \
MODULE_ALIAS("scsi:t-" __stringify(type) "*") MODULE_ALIAS("scsi:t-" __stringify(type) "*")
#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
......
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