Commit 40bb61a7 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi_dh_alua: switch to scsi_execute_req_flags()

All commands are issued synchronously, so no need to open-code
scsi_execute_req_flags() anymore. And we can get rid of the
static sense code structure element. scsi_execute_req_flags()
will be setting REQ_QUIET and REQ_PREEMPT, but that is
perfectly fine as we're evaluating and logging any errors
ourselves and we really need to send the command even if
the device is quiesced.
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarEwan Milne <emilne@redhat.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent dd5cc408
...@@ -75,7 +75,6 @@ struct alua_dh_data { ...@@ -75,7 +75,6 @@ struct alua_dh_data {
unsigned char *buff; unsigned char *buff;
int bufflen; int bufflen;
unsigned char transition_tmo; unsigned char transition_tmo;
unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_device *sdev; struct scsi_device *sdev;
activate_complete callback_fn; activate_complete callback_fn;
void *callback_data; void *callback_data;
...@@ -101,71 +100,30 @@ static int realloc_buffer(struct alua_dh_data *h, unsigned len) ...@@ -101,71 +100,30 @@ static int realloc_buffer(struct alua_dh_data *h, unsigned len)
return 0; return 0;
} }
static struct request *get_alua_req(struct scsi_device *sdev,
void *buffer, unsigned buflen, int rw)
{
struct request *rq;
struct request_queue *q = sdev->request_queue;
rq = blk_get_request(q, rw, GFP_NOIO);
if (IS_ERR(rq)) {
sdev_printk(KERN_INFO, sdev,
"%s: blk_get_request failed\n", __func__);
return NULL;
}
blk_rq_set_block_pc(rq);
if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_NOIO)) {
blk_put_request(rq);
sdev_printk(KERN_INFO, sdev,
"%s: blk_rq_map_kern failed\n", __func__);
return NULL;
}
rq->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
REQ_FAILFAST_DRIVER;
rq->retries = ALUA_FAILOVER_RETRIES;
rq->timeout = ALUA_FAILOVER_TIMEOUT * HZ;
return rq;
}
/* /*
* submit_rtpg - Issue a REPORT TARGET GROUP STATES command * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
* @sdev: sdev the command should be sent to * @sdev: sdev the command should be sent to
*/ */
static unsigned submit_rtpg(struct scsi_device *sdev, unsigned char *buff, static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
int bufflen, unsigned char *sense, int flags) int bufflen, struct scsi_sense_hdr *sshdr, int flags)
{ {
struct request *rq; u8 cdb[COMMAND_SIZE(MAINTENANCE_IN)];
int err = 0; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
REQ_FAILFAST_DRIVER;
rq = get_alua_req(sdev, buff, bufflen, READ);
if (!rq) {
err = DRIVER_BUSY << 24;
goto done;
}
/* Prepare the command. */ /* Prepare the command. */
rq->cmd[0] = MAINTENANCE_IN; memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_IN));
cdb[0] = MAINTENANCE_IN;
if (!(flags & ALUA_RTPG_EXT_HDR_UNSUPP)) if (!(flags & ALUA_RTPG_EXT_HDR_UNSUPP))
rq->cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT; cdb[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT;
else else
rq->cmd[1] = MI_REPORT_TARGET_PGS; cdb[1] = MI_REPORT_TARGET_PGS;
put_unaligned_be32(bufflen, &rq->cmd[6]); put_unaligned_be32(bufflen, &cdb[6]);
rq->cmd_len = COMMAND_SIZE(MAINTENANCE_IN);
return scsi_execute_req_flags(sdev, cdb, DMA_FROM_DEVICE,
rq->sense = sense; buff, bufflen, sshdr,
memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); ALUA_FAILOVER_TIMEOUT * HZ,
rq->sense_len = 0; ALUA_FAILOVER_RETRIES, NULL, req_flags);
blk_execute_rq(rq->q, NULL, rq, 1);
if (rq->errors)
err = rq->errors;
blk_put_request(rq);
done:
return err;
} }
/* /*
...@@ -175,40 +133,30 @@ static unsigned submit_rtpg(struct scsi_device *sdev, unsigned char *buff, ...@@ -175,40 +133,30 @@ static unsigned submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
* to 'active/optimized' and let the array firmware figure out * to 'active/optimized' and let the array firmware figure out
* the states of the remaining groups. * the states of the remaining groups.
*/ */
static unsigned submit_stpg(struct scsi_device *sdev, int group_id, static int submit_stpg(struct scsi_device *sdev, int group_id,
unsigned char *sense) struct scsi_sense_hdr *sshdr)
{ {
struct request *rq; u8 cdb[COMMAND_SIZE(MAINTENANCE_OUT)];
unsigned char stpg_data[8]; unsigned char stpg_data[8];
int stpg_len = 8; int stpg_len = 8;
int err = 0; int req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
REQ_FAILFAST_DRIVER;
/* Prepare the data buffer */ /* Prepare the data buffer */
memset(stpg_data, 0, stpg_len); memset(stpg_data, 0, stpg_len);
stpg_data[4] = TPGS_STATE_OPTIMIZED & 0x0f; stpg_data[4] = TPGS_STATE_OPTIMIZED & 0x0f;
put_unaligned_be16(group_id, &stpg_data[6]); put_unaligned_be16(group_id, &stpg_data[6]);
rq = get_alua_req(sdev, stpg_data, stpg_len, WRITE);
if (!rq)
return DRIVER_BUSY << 24;
/* Prepare the command. */ /* Prepare the command. */
rq->cmd[0] = MAINTENANCE_OUT; memset(cdb, 0x0, COMMAND_SIZE(MAINTENANCE_OUT));
rq->cmd[1] = MO_SET_TARGET_PGS; cdb[0] = MAINTENANCE_OUT;
put_unaligned_be32(stpg_len, &rq->cmd[6]); cdb[1] = MO_SET_TARGET_PGS;
rq->cmd_len = COMMAND_SIZE(MAINTENANCE_OUT); put_unaligned_be32(stpg_len, &cdb[6]);
rq->sense = sense; return scsi_execute_req_flags(sdev, cdb, DMA_TO_DEVICE,
memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); stpg_data, stpg_len,
rq->sense_len = 0; sshdr, ALUA_FAILOVER_TIMEOUT * HZ,
ALUA_FAILOVER_RETRIES, NULL, req_flags);
blk_execute_rq(rq->q, NULL, rq, 1);
if (rq->errors)
err = rq->errors;
blk_put_request(rq);
return err;
} }
/* /*
...@@ -398,14 +346,14 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_ ...@@ -398,14 +346,14 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int wait_
expiry = round_jiffies_up(jiffies + h->transition_tmo * HZ); expiry = round_jiffies_up(jiffies + h->transition_tmo * HZ);
retry: retry:
retval = submit_rtpg(sdev, h->buff, h->bufflen, h->sense, h->flags); retval = submit_rtpg(sdev, h->buff, h->bufflen, &sense_hdr, h->flags);
if (retval) { if (retval) {
if (!scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE, if (!scsi_sense_valid(&sense_hdr)) {
&sense_hdr)) {
sdev_printk(KERN_INFO, sdev, sdev_printk(KERN_INFO, sdev,
"%s: rtpg failed, result %d\n", "%s: rtpg failed, result %d\n",
ALUA_DH_NAME, retval); ALUA_DH_NAME, retval);
if (driver_byte(retval) == DRIVER_BUSY) if (driver_byte(retval) == DRIVER_ERROR)
return SCSI_DH_DEV_TEMP_BUSY; return SCSI_DH_DEV_TEMP_BUSY;
return SCSI_DH_IO; return SCSI_DH_IO;
} }
...@@ -568,15 +516,14 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_dh_data *h) ...@@ -568,15 +516,14 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_dh_data *h)
ALUA_DH_NAME, h->state); ALUA_DH_NAME, h->state);
return SCSI_DH_NOSYS; return SCSI_DH_NOSYS;
} }
retval = submit_stpg(sdev, h->group_id, h->sense); retval = submit_stpg(sdev, h->group_id, &sense_hdr);
if (retval) { if (retval) {
if (!scsi_normalize_sense(h->sense, SCSI_SENSE_BUFFERSIZE, if (!scsi_sense_valid(&sense_hdr)) {
&sense_hdr)) {
sdev_printk(KERN_INFO, sdev, sdev_printk(KERN_INFO, sdev,
"%s: stpg failed, result %d", "%s: stpg failed, result %d",
ALUA_DH_NAME, retval); ALUA_DH_NAME, retval);
if (driver_byte(retval) == DRIVER_BUSY) if (driver_byte(retval) == DRIVER_ERROR)
return SCSI_DH_DEV_TEMP_BUSY; return SCSI_DH_DEV_TEMP_BUSY;
} else { } else {
sdev_printk(KERN_INFO, h->sdev, "%s: stpg failed\n", sdev_printk(KERN_INFO, h->sdev, "%s: stpg failed\n",
......
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