diff options
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_sbc.c | 2 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 12 | ||||
-rw-r--r-- | include/target/target_core_base.h | 1 |
4 files changed, 13 insertions, 6 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index fadad7c5f63..a49ef0a49fa 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -212,6 +212,10 @@ static void tcm_loop_submission_work(struct work_struct *work) se_cmd->se_cmd_flags |= SCF_BIDI; } + + if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) + se_cmd->prot_pto = true; + rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, scsi_bufflen(sc), tcm_loop_sam_attr(sc), diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index a1e75dd636a..c301d9b6874 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -634,7 +634,7 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb, { u8 protect = cdb[1] >> 5; - if (!cmd->t_prot_sg || !cmd->t_prot_nents) + if ((!cmd->t_prot_sg || !cmd->t_prot_nents) && cmd->prot_pto) return true; switch (dev->dev_attrib.pi_prot_type) { diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 4653d826e59..0a359fa82bd 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1365,6 +1365,13 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess target_put_sess_cmd(se_sess, se_cmd); return 0; } + + rc = target_setup_cmd_from_cdb(se_cmd, cdb); + if (rc != 0) { + transport_generic_request_failure(se_cmd, rc); + return 0; + } + /* * Save pointers for SGLs containing protection information, * if present. @@ -1374,11 +1381,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess se_cmd->t_prot_nents = sgl_prot_count; } - rc = target_setup_cmd_from_cdb(se_cmd, cdb); - if (rc != 0) { - transport_generic_request_failure(se_cmd, rc); - return 0; - } /* * When a non zero sgl_count has been passed perform SGL passthrough * mapping for pre-allocated fabric memory instead of having target diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 5ae92492d1e..82cb4ed06f7 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -570,6 +570,7 @@ struct se_cmd { enum target_prot_ho prot_handover; sense_reason_t pi_err; sector_t bad_sector; + bool prot_pto; }; struct se_ua { |