Commit aa73237d authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: target/core: Always call transport_complete_callback() upon failure

COMPARE AND WRITE command execution starts with a call of
sbc_compare_and_write(). That function locks the caw_sem member in the
backend device data structure and submits a read request to the backend
driver. Upon successful completion of the read compare_and_write_callback()
gets called. That last function compares the data that has been read. If it
matches transport_complete_callback is set to compare_and_write_post and a
write request is submitted. compare_and_write_post() submits a write request
to the backend driver.

XDWRITEREAD command execution starts with sbc_execute_rw() submitting a
read to the backend device. Upon successful completion of the read the
xdreadwrite_callback() gets called. That function xors the data that has
been read with the data in the data-out buffer and stores the result in
the data-in buffer.

Call transport_complete_callback() not only if COMPARE AND WRITE fails but
also if XDWRITEREAD fails. This makes the code more systematic. Make sure
that the callback functions handle (cmd, false, NULL) argument triples fine.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 81b6ca6d
...@@ -360,6 +360,10 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success, ...@@ -360,6 +360,10 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success,
unsigned int offset; unsigned int offset;
sense_reason_t ret = TCM_NO_SENSE; sense_reason_t ret = TCM_NO_SENSE;
int i, count; int i, count;
if (!success)
return 0;
/* /*
* From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command * From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command
* *
...@@ -426,7 +430,7 @@ static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success, ...@@ -426,7 +430,7 @@ static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success,
sense_reason_t ret = TCM_NO_SENSE; sense_reason_t ret = TCM_NO_SENSE;
spin_lock_irq(&cmd->t_state_lock); spin_lock_irq(&cmd->t_state_lock);
if (cmd->transport_state & CMD_T_SENT) { if (success) {
*post_ret = 1; *post_ret = 1;
if (cmd->scsi_status == SAM_STAT_CHECK_CONDITION) if (cmd->scsi_status == SAM_STAT_CHECK_CONDITION)
......
...@@ -1778,7 +1778,7 @@ EXPORT_SYMBOL(target_submit_tmr); ...@@ -1778,7 +1778,7 @@ EXPORT_SYMBOL(target_submit_tmr);
void transport_generic_request_failure(struct se_cmd *cmd, void transport_generic_request_failure(struct se_cmd *cmd,
sense_reason_t sense_reason) sense_reason_t sense_reason)
{ {
int ret = 0, post_ret = 0; int ret = 0;
pr_debug("-----[ Storage Engine Exception; sense_reason %d\n", pr_debug("-----[ Storage Engine Exception; sense_reason %d\n",
sense_reason); sense_reason);
...@@ -1789,13 +1789,8 @@ void transport_generic_request_failure(struct se_cmd *cmd, ...@@ -1789,13 +1789,8 @@ void transport_generic_request_failure(struct se_cmd *cmd,
*/ */
transport_complete_task_attr(cmd); transport_complete_task_attr(cmd);
/* if (cmd->transport_complete_callback)
* Handle special case for COMPARE_AND_WRITE failure, where the cmd->transport_complete_callback(cmd, false, NULL);
* callback is expected to drop the per device ->caw_sem.
*/
if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) &&
cmd->transport_complete_callback)
cmd->transport_complete_callback(cmd, false, &post_ret);
if (transport_check_aborted_status(cmd, 1)) if (transport_check_aborted_status(cmd, 1))
return; return;
......
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