Skip to content

Commit 926317d

Browse files
Dinesh IsraniNicholas Bellinger
authored andcommitted
target: Don't override EXTENDED_COPY xcopy_pt_cmd SCSI status code
This patch addresses a bug where a local EXTENDED_COPY WRITE or READ backend I/O request would always return SAM_STAT_CHECK_CONDITION, even if underlying xcopy_pt_cmd->se_cmd generated a different SCSI status code. ESX host environments expect to hit SAM_STAT_RESERVATION_CONFLICT for certain scenarios, and SAM_STAT_CHECK_CONDITION results in non-retriable status for these cases. Tested on v4.1.y with ESX v5.5u2+ with local IBLOCK backend copy. Reported-by: Nixon Vincent <nixon.vincent@calsoftinc.com> Tested-by: Nixon Vincent <nixon.vincent@calsoftinc.com> Cc: Nixon Vincent <nixon.vincent@calsoftinc.com> Tested-by: Dinesh Israni <ddi@datera.io> Signed-off-by: Dinesh Israni <ddi@datera.io> Cc: Dinesh Israni <ddi@datera.io> Cc: stable@vger.kernel.org # 3.14+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 449a137 commit 926317d

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/target/target_core_xcopy.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ static int target_xcopy_read_source(
662662
rc = target_xcopy_setup_pt_cmd(xpt_cmd, xop, src_dev, &cdb[0],
663663
remote_port, true);
664664
if (rc < 0) {
665+
ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
665666
transport_generic_free_cmd(se_cmd, 0);
666667
return rc;
667668
}
@@ -673,6 +674,7 @@ static int target_xcopy_read_source(
673674

674675
rc = target_xcopy_issue_pt_cmd(xpt_cmd);
675676
if (rc < 0) {
677+
ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
676678
transport_generic_free_cmd(se_cmd, 0);
677679
return rc;
678680
}
@@ -723,6 +725,7 @@ static int target_xcopy_write_destination(
723725
remote_port, false);
724726
if (rc < 0) {
725727
struct se_cmd *src_cmd = &xop->src_pt_cmd->se_cmd;
728+
ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
726729
/*
727730
* If the failure happened before the t_mem_list hand-off in
728731
* target_xcopy_setup_pt_cmd(), Reset memory + clear flag so that
@@ -738,6 +741,7 @@ static int target_xcopy_write_destination(
738741

739742
rc = target_xcopy_issue_pt_cmd(xpt_cmd);
740743
if (rc < 0) {
744+
ec_cmd->scsi_status = xpt_cmd->se_cmd.scsi_status;
741745
se_cmd->se_cmd_flags &= ~SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC;
742746
transport_generic_free_cmd(se_cmd, 0);
743747
return rc;
@@ -824,10 +828,14 @@ static void target_xcopy_do_work(struct work_struct *work)
824828
out:
825829
xcopy_pt_undepend_remotedev(xop);
826830
kfree(xop);
827-
828-
pr_warn_ratelimited("target_xcopy_do_work: rc: %d, Setting X-COPY CHECK_CONDITION"
829-
" -> sending response\n", rc);
830-
ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
831+
/*
832+
* Don't override an error scsi status if it has already been set
833+
*/
834+
if (ec_cmd->scsi_status == SAM_STAT_GOOD) {
835+
pr_warn_ratelimited("target_xcopy_do_work: rc: %d, Setting X-COPY"
836+
" CHECK_CONDITION -> sending response\n", rc);
837+
ec_cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
838+
}
831839
target_complete_cmd(ec_cmd, SAM_STAT_CHECK_CONDITION);
832840
}
833841

0 commit comments

Comments
 (0)