aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2011-08-24 04:51:13 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-08-30 15:26:49 -0400
commitd7c48feb38a5cb6d863d69fd5ef6c309971ebe31 (patch)
treecb2701400ab0992ecb7d8e84d3d9f70d38bbb51c /drivers
parentac81c6a832a8769d1cc7ffda361aa3dc3d8f06dc (diff)
[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: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c55
1 files changed, 6 insertions, 49 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 6fec9fe5dc39..432677889eae 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -128,43 +128,6 @@ static struct request *get_alua_req(struct scsi_device *sdev,
128} 128}
129 129
130/* 130/*
131 * submit_std_inquiry - Issue a standard INQUIRY command
132 * @sdev: sdev the command should be send to
133 */
134static int submit_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
135{
136 struct request *rq;
137 int err = SCSI_DH_RES_TEMP_UNAVAIL;
138
139 rq = get_alua_req(sdev, h->inq, ALUA_INQUIRY_SIZE, READ);
140 if (!rq)
141 goto done;
142
143 /* Prepare the command. */
144 rq->cmd[0] = INQUIRY;
145 rq->cmd[1] = 0;
146 rq->cmd[2] = 0;
147 rq->cmd[4] = ALUA_INQUIRY_SIZE;
148 rq->cmd_len = COMMAND_SIZE(INQUIRY);
149
150 rq->sense = h->sense;
151 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
152 rq->sense_len = h->senselen = 0;
153
154 err = blk_execute_rq(rq->q, NULL, rq, 1);
155 if (err == -EIO) {
156 sdev_printk(KERN_INFO, sdev,
157 "%s: std inquiry failed with %x\n",
158 ALUA_DH_NAME, rq->errors);
159 h->senselen = rq->sense_len;
160 err = SCSI_DH_IO;
161 }
162 blk_put_request(rq);
163done:
164 return err;
165}
166
167/*
168 * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command 131 * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command
169 * @sdev: sdev the command should be sent to 132 * @sdev: sdev the command should be sent to
170 */ 133 */
@@ -338,23 +301,17 @@ static unsigned submit_stpg(struct alua_dh_data *h)
338} 301}
339 302
340/* 303/*
341 * alua_std_inquiry - Evaluate standard INQUIRY command 304 * alua_check_tpgs - Evaluate TPGS setting
342 * @sdev: device to be checked 305 * @sdev: device to be checked
343 * 306 *
344 * Just extract the TPGS setting to find out if ALUA 307 * Examine the TPGS setting of the sdev to find out if ALUA
345 * is supported. 308 * is supported.
346 */ 309 */
347static int alua_std_inquiry(struct scsi_device *sdev, struct alua_dh_data *h) 310static int alua_check_tpgs(struct scsi_device *sdev, struct alua_dh_data *h)
348{ 311{
349 int err; 312 int err = SCSI_DH_OK;
350
351 err = submit_std_inquiry(sdev, h);
352
353 if (err != SCSI_DH_OK)
354 return err;
355 313
356 /* Check TPGS setting */ 314 h->tpgs = scsi_device_tpgs(sdev);
357 h->tpgs = (h->inq[5] >> 4) & 0x3;
358 switch (h->tpgs) { 315 switch (h->tpgs) {
359 case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT: 316 case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT:
360 sdev_printk(KERN_INFO, sdev, 317 sdev_printk(KERN_INFO, sdev,
@@ -642,7 +599,7 @@ static int alua_initialize(struct scsi_device *sdev, struct alua_dh_data *h)
642{ 599{
643 int err; 600 int err;
644 601
645 err = alua_std_inquiry(sdev, h); 602 err = alua_check_tpgs(sdev, h);
646 if (err != SCSI_DH_OK) 603 if (err != SCSI_DH_OK)
647 goto out; 604 goto out;
648 605