All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@mellanox.com>
To: michaelc@cs.wisc.edu, martin.petersen@oracle.com,
	nab@linux-iscsi.org, roland@kernel.org
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-rdma@vger.kernel.org
Subject: [PATCH v2 3/3] TARGET/sbc,loopback: Adjust command data length in case pi exists on the wire
Date: Wed, 11 Jun 2014 12:09:59 +0300	[thread overview]
Message-ID: <1402477799-24610-4-git-send-email-sagig@mellanox.com> (raw)
In-Reply-To: <1402477799-24610-1-git-send-email-sagig@mellanox.com>

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: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/target/loopback/tcm_loop.c |   15 ++++++++++++---
 drivers/target/target_core_sbc.c   |   15 +++++++++++++--
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index c886ad1..1f4c015 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -179,7 +179,7 @@ static void tcm_loop_submission_work(struct work_struct *work)
 	struct tcm_loop_hba *tl_hba;
 	struct tcm_loop_tpg *tl_tpg;
 	struct scatterlist *sgl_bidi = NULL;
-	u32 sgl_bidi_count = 0;
+	u32 sgl_bidi_count = 0, transfer_length;
 	int rc;
 
 	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)
 
 	}
 
-	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;
+		/*
+		 * 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,
 			&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,
 			scsi_sglist(sc), scsi_sg_count(sc),
 			sgl_bidi, sgl_bidi_count,
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index e022959..4b5716f 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -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_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);
 
 	return true;
-- 
1.7.1

  parent reply	other threads:[~2014-06-11  9:09 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11  9:09 [PATCH v2 0/3] Include protection information in transport header Sagi Grimberg
2014-06-11  9:09 ` [PATCH v2 1/3] scsi_cmnd: Introduce scsi_transfer_length helper Sagi Grimberg
2014-06-11 23:39   ` Martin K. Petersen
2014-06-23 21:24   ` Mike Christie
     [not found]     ` <53A89B0F.4040300-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2014-06-24  1:58       ` Martin K. Petersen
2014-06-25  1:17         ` Vladislav Bolkhovitin
2014-07-27  8:45           ` Boaz Harrosh
     [not found]   ` <1402477799-24610-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-06-24  6:54     ` Mike Christie
2014-06-24 12:53       ` Martin K. Petersen
     [not found]         ` <yq1mwd2h3ju.fsf-+q57XtR/GgMb6DWv4sQWN6xOck334EZe@public.gmane.org>
2014-06-24 13:08           ` Sagi Grimberg
2014-06-24 14:55             ` Christoph Hellwig
2014-06-24 15:29           ` sagi grimberg
2014-06-24 14:03         ` Christoph Hellwig
2014-06-24 16:08         ` Michael Christie
2014-06-24 16:27           ` Christoph Hellwig
2014-06-24 16:27           ` Sagi Grimberg
2014-06-24 16:30             ` Christoph Hellwig
     [not found]               ` <20140624163040.GA11499-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-06-24 17:00                 ` Mike Christie
2014-06-24 17:04                   ` Martin K. Petersen
2014-06-24 17:08                   ` Mike Christie
     [not found]                     ` <53A9B0A0.6000103-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2014-06-25  3:32                       ` Mike Christie
2014-06-25  8:48                         ` Sagi Grimberg
2014-06-25  9:17                           ` Christoph Hellwig
2014-06-25 10:32                           ` Sagi Grimberg
     [not found]                             ` <53AAA547.40300-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-06-25 11:35                               ` Christoph Hellwig
     [not found]                                 ` <20140625113536.GA30312-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-06-25 15:59                                   ` Michael Christie
2014-07-27  9:11                             ` Boaz Harrosh
     [not found]                               ` <53D4C22F.8050904-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-27 13:52                                 ` Christoph Hellwig
2014-08-06 12:15                               ` Sagi Grimberg
2014-06-25  9:14                         ` Christoph Hellwig
2014-06-25 11:29                           ` Martin K. Petersen
2014-06-24 16:31           ` Martin K. Petersen
     [not found]             ` <yq1fviugtgq.fsf-+q57XtR/GgMb6DWv4sQWN6xOck334EZe@public.gmane.org>
2014-06-24 17:05               ` Mike Christie
2014-06-24 13:01       ` sagi grimberg
2014-06-26 14:53   ` Bart Van Assche
     [not found]     ` <53AC3402.2080302-HInyCGIudOg@public.gmane.org>
2014-06-26 14:55       ` James Bottomley
2014-06-26 15:41         ` Atchley, Scott
2014-06-26 16:38           ` James Bottomley
     [not found]             ` <fbbc6688-5a52-4437-93b1-71e8ff84c36c-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2014-06-26 21:17               ` Atchley, Scott
2014-07-13 11:37   ` Christoph Hellwig
2014-07-13 11:40     ` Martin K. Petersen
2014-07-25 20:00     ` [PATCH] [SCSI] Make scsi_transfer_length take a scsi_data_buffer argument Martin K. Petersen
2014-07-25 21:19       ` Christoph Hellwig
2014-07-29 13:26         ` Christoph Hellwig
2014-08-06 12:12       ` Sagi Grimberg
2014-08-06 13:09         ` Sagi Grimberg
2014-08-06 15:49           ` Martin K. Petersen
2014-06-11  9:09 ` [PATCH v2 2/3] libiscsi, iser: Adjust data_length to include protection information Sagi Grimberg
2014-06-23 20:59   ` Christoph Hellwig
     [not found]     ` <20140623205948.GA15165-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-06-24  6:31       ` Mike Christie
     [not found]   ` <1402477799-24610-3-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-07-27 10:08     ` Boaz Harrosh
     [not found]       ` <53D4CFAB.3040804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-08-06 12:43         ` Sagi Grimberg
2014-08-06 13:25           ` Boaz Harrosh
2014-08-13 13:09             ` Sagi Grimberg
     [not found]               ` <53EB639C.3080307-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-08-14  7:17                 ` Boaz Harrosh
     [not found]           ` <53E22300.3090907-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-08-06 15:54             ` Martin K. Petersen
2014-06-11  9:09 ` Sagi Grimberg [this message]
2014-06-11 21:36 ` [PATCH v2 0/3] Include protection information in transport header Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402477799-24610-4-git-send-email-sagig@mellanox.com \
    --to=sagig@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michaelc@cs.wisc.edu \
    --cc=nab@linux-iscsi.org \
    --cc=roland@kernel.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.