From: sagi grimberg <sagig@mellanox.com>
To: Mike Christie <michaelc@cs.wisc.edu>,
martin.petersen@oracle.com, Christoph Hellwig <hch@infradead.org>
Cc: nab@linux-iscsi.org, roland@kernel.org,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 1/3] scsi_cmnd: Introduce scsi_transfer_length helper
Date: Tue, 24 Jun 2014 16:01:10 +0300 [thread overview]
Message-ID: <53A97696.6040302@mellanox.com> (raw)
In-Reply-To: <53A920B2.9060503@cs.wisc.edu>
On 6/24/2014 9:54 AM, Mike Christie wrote:
> On 06/11/2014 04:09 AM, Sagi Grimberg wrote:
>> In case protection information exists on the wire
>> scsi transports should include it in the transfer
>> byte count (even if protection information does not
>> exist in the host memory space). This helper will
>> compute the total transfer length from the scsi
>> command data length and protection attributes.
>>
>> Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
>> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>> ---
>> include/scsi/scsi_cmnd.h | 17 +++++++++++++++++
>> 1 files changed, 17 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
>> index dd7c998..a100c6e 100644
>> --- a/include/scsi/scsi_cmnd.h
>> +++ b/include/scsi/scsi_cmnd.h
>> @@ -7,6 +7,7 @@
>> #include <linux/types.h>
>> #include <linux/timer.h>
>> #include <linux/scatterlist.h>
>> +#include <scsi/scsi_device.h>
>>
>> struct Scsi_Host;
>> struct scsi_device;
>> @@ -306,4 +307,20 @@ static inline void set_driver_byte(struct scsi_cmnd *cmd, char status)
>> cmd->result = (cmd->result & 0x00ffffff) | (status << 24);
>> }
>>
>> +static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
>> +{
>> + unsigned int xfer_len = blk_rq_bytes(scmd->request);
>> + unsigned int prot_op = scsi_get_prot_op(scmd);
>> + unsigned int sector_size = scmd->device->sector_size;
>> +
>> + switch (prot_op) {
>> + case SCSI_PROT_NORMAL:
>> + case SCSI_PROT_WRITE_STRIP:
>> + case SCSI_PROT_READ_INSERT:
>> + return xfer_len;
>> + }
>> +
>> + return xfer_len + (xfer_len >> ilog2(sector_size)) * 8;
>> +}
>> +
>> #endif /* _SCSI_SCSI_CMND_H */
>>
> I found the issue Christoph is hitting in the other thread.
>
> The problem is WRITE_SAME requests are setup so that req->__data_len is
> the value of the entire request when the setup is completed but during
> the setup process it's value changes
>
> So __data_len could be thousands of bytes but
> scsi_out(scsi_cmnd)->length for this case was only returning 512 which
> is the sector size. This is because sd_setup_-write_same_cmnd does:
>
>
> rq->__data_len = sdp->sector_size;
> ....
> scsi_setup_blk_pc_cmnd()
> ....
> rq->__data_len = nr_bytes;
>
> and scsi_setup_blk_pc_cmnd does scsi_init_io() -> scsi_init_sgtable()
> and that does
>
> sdb->length = blk_rq_bytes(req);
>
> and at this time because before we called scsi_setup_blk_pc_cmnd we set
> the __data_len to sector size, the sdb length is going to be only 512
> but the final request->__data_len is the total size of the operation.
Hey Christoph, Mike &MKP,
So just got first look in this thread, didn't have time to reproduce it yet.
Mike's analysis makes sense to me, I think the below change should
resolve this one.
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a100c6e..2afd9c2 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -309,7 +309,7 @@ static inline void set_driver_byte(struct scsi_cmnd
*cmd, char status)
static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
{
- unsigned int xfer_len = blk_rq_bytes(scmd->request);
+ unsigned int xfer_len = scsi_bufflen(scmd);
unsigned int prot_op = scsi_get_prot_op(scmd);
unsigned int sector_size = scmd->device->sector_size;
Moreover, since bidi and dif are adjacent, this will also needed:
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 3f46234..abf0c3e 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -386,12 +386,14 @@ static int iscsi_prep_scsi_cmd_pdu(struct
iscsi_task *task)
rc = iscsi_prep_bidi_ahs(task);
if (rc)
return rc;
+ transfer_length = scsi_in(sc)->length;
+ } else {
+ transfer_length = scsi_transfer_length(sc);
}
if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL)
task->protected = true;
- transfer_length = scsi_transfer_length(sc);
hdr->data_length = cpu_to_be32(transfer_length);
if (sc->sc_data_direction == DMA_TO_DEVICE) {
struct iscsi_r2t_info *r2t = &task->unsol_r2t;
Let me test and queue it up.
Sagi.
next prev parent reply other threads:[~2014-06-24 13:01 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
2014-06-24 14:03 ` Christoph Hellwig
[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 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 [this message]
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 ` [PATCH v2 3/3] TARGET/sbc,loopback: Adjust command data length in case pi exists on the wire Sagi Grimberg
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=53A97696.6040302@mellanox.com \
--to=sagig@mellanox.com \
--cc=hch@infradead.org \
--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.