Skip to content

Commit b5b8e29

Browse files
Sagi GrimbergNicholas Bellinger
authored andcommitted
Target/dif: Introduce protection-passthough-only mode
Some transports (iSCSI/iSER/SRP/FC) support hardware INSERT/STRIP capabilities while other transports like loopback/vhost-scsi need perform this is software. This patch allows fabrics using SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC to signal the early LUN scan handling case where PROTECT CDB bits are set, but no fabric buffer has been provided. For transports which use generic new command these buffers have yet to be allocated. Also this way, target may support protection information against legacy initiators (writes are inserted and reads are stripped). (Only set prot_pto for loopback during early special case - nab) Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 80dcd0c commit b5b8e29

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ static void tcm_loop_submission_work(struct work_struct *work)
212212
se_cmd->se_cmd_flags |= SCF_BIDI;
213213

214214
}
215+
216+
if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
217+
se_cmd->prot_pto = true;
218+
215219
rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd,
216220
&tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
217221
scsi_bufflen(sc), tcm_loop_sam_attr(sc),

‎drivers/target/target_core_sbc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
634634
{
635635
u8 protect = cdb[1] >> 5;
636636

637-
if (!cmd->t_prot_sg || !cmd->t_prot_nents)
637+
if ((!cmd->t_prot_sg || !cmd->t_prot_nents) && cmd->prot_pto)
638638
return true;
639639

640640
switch (dev->dev_attrib.pi_prot_type) {

‎drivers/target/target_core_transport.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,13 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
13651365
target_put_sess_cmd(se_sess, se_cmd);
13661366
return 0;
13671367
}
1368+
1369+
rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1370+
if (rc != 0) {
1371+
transport_generic_request_failure(se_cmd, rc);
1372+
return 0;
1373+
}
1374+
13681375
/*
13691376
* Save pointers for SGLs containing protection information,
13701377
* if present.
@@ -1374,11 +1381,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
13741381
se_cmd->t_prot_nents = sgl_prot_count;
13751382
}
13761383

1377-
rc = target_setup_cmd_from_cdb(se_cmd, cdb);
1378-
if (rc != 0) {
1379-
transport_generic_request_failure(se_cmd, rc);
1380-
return 0;
1381-
}
13821384
/*
13831385
* When a non zero sgl_count has been passed perform SGL passthrough
13841386
* mapping for pre-allocated fabric memory instead of having target

‎include/target/target_core_base.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ struct se_cmd {
570570
enum target_prot_ho prot_handover;
571571
sense_reason_t pi_err;
572572
sector_t bad_sector;
573+
bool prot_pto;
573574
};
574575

575576
struct se_ua {

0 commit comments

Comments
 (0)