lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 7d971038 authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Greg Kroah-Hartman

TARGET/sbc,loopback: Adjust command data length in case pi exists on the wire

commit e2a4f55c upstream.

In various areas of the code, it is assumed that
se_cmd->data_length describes pure data. In case
that protection information exists over the wire
(protect bits is are on) the target core re-calculates
the data length from the CDB and the backed device
block size (instead of each transport peeking in the cdb).

Modify loopback device to include protection information
in the transferred data length (like other scsi transports).
Signed-off-by: default avatarSagi Grimberg <sagig@mellanox.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 04423dde
...@@ -179,7 +179,7 @@ static void tcm_loop_submission_work(struct work_struct *work) ...@@ -179,7 +179,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
struct tcm_loop_hba *tl_hba; struct tcm_loop_hba *tl_hba;
struct tcm_loop_tpg *tl_tpg; struct tcm_loop_tpg *tl_tpg;
struct scatterlist *sgl_bidi = NULL; struct scatterlist *sgl_bidi = NULL;
u32 sgl_bidi_count = 0; u32 sgl_bidi_count = 0, transfer_length;
int rc; int rc;
tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
...@@ -213,12 +213,21 @@ static void tcm_loop_submission_work(struct work_struct *work) ...@@ -213,12 +213,21 @@ static void tcm_loop_submission_work(struct work_struct *work)
} }
if (!scsi_prot_sg_count(sc) && scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) transfer_length = scsi_transfer_length(sc);
if (!scsi_prot_sg_count(sc) &&
scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) {
se_cmd->prot_pto = true; se_cmd->prot_pto = true;
/*
* loopback transport doesn't support
* WRITE_GENERATE, READ_STRIP protection
* information operations, go ahead unprotected.
*/
transfer_length = scsi_bufflen(sc);
}
rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, 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, &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun,
scsi_bufflen(sc), tcm_loop_sam_attr(sc), transfer_length, tcm_loop_sam_attr(sc),
sc->sc_data_direction, 0, sc->sc_data_direction, 0,
scsi_sglist(sc), scsi_sg_count(sc), scsi_sglist(sc), scsi_sg_count(sc),
sgl_bidi, sgl_bidi_count, sgl_bidi, sgl_bidi_count,
......
...@@ -665,8 +665,19 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb, ...@@ -665,8 +665,19 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
cmd->prot_type = dev->dev_attrib.pi_prot_type; cmd->prot_type = dev->dev_attrib.pi_prot_type;
cmd->prot_length = dev->prot_length * sectors; cmd->prot_length = dev->prot_length * sectors;
pr_debug("%s: prot_type=%d, prot_length=%d prot_op=%d prot_checks=%d\n",
__func__, cmd->prot_type, cmd->prot_length, /**
* In case protection information exists over the wire
* we modify command data length to describe pure data.
* The actual transfer length is data length + protection
* length
**/
if (protect)
cmd->data_length = sectors * dev->dev_attrib.block_size;
pr_debug("%s: prot_type=%d, data_length=%d, prot_length=%d "
"prot_op=%d prot_checks=%d\n",
__func__, cmd->prot_type, cmd->data_length, cmd->prot_length,
cmd->prot_op, cmd->prot_checks); cmd->prot_op, cmd->prot_checks);
return true; return true;
......
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