From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Andy Grover <agrover@redhat.com>, Christoph Hellwig <hch@lst.de>
Cc: target-devel <target-devel@vger.kernel.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [PATCH 5/7] iscsi-target: Fix iscsit_map_iovec cur_len + data_offset breakage
Date: Fri, 3 Jun 2011 18:18:16 -0700 [thread overview]
Message-ID: <1307150298-23921-6-git-send-email-nab@linux-iscsi.org> (raw)
In-Reply-To: <1307150298-23921-1-git-send-email-nab@linux-iscsi.org>
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch fixes two length + offset releated bugs in the new iscsit_map_iovec().
The first is where cur_len was being calculated incorrectly for the case type
SCF_SCSI_CONTROL_NONSG_IO_CDB with an sg->offset non zero offset.
The second adds the missing pg_off to kmap() when setting iov_base
from sg_page() with the current scatterlist pointer.
It also converts iscsit_map_iovec() to use sg_next() instead of
incremented the scatterlist pointer following lib/scatterlist.h
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
drivers/target/iscsi/iscsi_target.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 6ebc247..d84d52b 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -696,7 +696,7 @@ static int iscsit_map_iovec(
u32 data_offset,
u32 data_length)
{
- u32 i;
+ u32 i = 0;
struct scatterlist *sg;
unsigned int page_off;
@@ -705,20 +705,20 @@ static int iscsit_map_iovec(
* At this point, we also know each contains a page.
*/
sg = &cmd->t_mem_sg[data_offset / PAGE_SIZE];
- page_off = (data_offset % PAGE_SIZE) + sg->offset;
+ page_off = (data_offset % PAGE_SIZE);
cmd->first_data_sg = sg;
cmd->first_data_sg_off = page_off;
- i = 0;
while (data_length) {
- u32 cur_len = min_t(u32, data_length, (sg[i].length - page_off));
+ u32 cur_len = min_t(u32, data_length, sg->length - page_off);
- iov[i].iov_base = kmap(sg_page(&sg[i]));
+ iov[i].iov_base = kmap(sg_page(sg)) + sg->offset + page_off;
iov[i].iov_len = cur_len;
data_length -= cur_len;
page_off = 0;
+ sg = sg_next(sg);
i++;
}
--
1.7.2.5
next prev parent reply other threads:[~2011-06-04 1:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-04 1:18 [PATCH 0/7] iscsi-target: Bugfixes for t_mem_list -> t_mem_sg[] conversion Nicholas A. Bellinger
2011-06-04 1:18 ` [PATCH 1/7] iscsi-target: Fix iscsit_alloc_buffs() breakage with offset_in_page Nicholas A. Bellinger
2011-06-04 14:21 ` Christoph Hellwig
2011-06-07 21:43 ` Andy Grover
2011-06-04 1:18 ` [PATCH 2/7] iscsi-target: Fix padding breakage in iscsit_send_data_in Nicholas A. Bellinger
2011-06-04 1:18 ` [PATCH 3/7] iscsi-target: Clear map_sg usage for non ISTATE_SEND_DATAIN ops Nicholas A. Bellinger
2011-06-04 1:18 ` [PATCH 4/7] iscsi-target: Handle transport_generic_new_cmd failure Nicholas A. Bellinger
2011-06-04 14:00 ` Christoph Hellwig
2011-06-04 1:18 ` Nicholas A. Bellinger [this message]
2011-06-04 1:18 ` [PATCH 6/7] iscsi-target: Fix iscsit_fe_sendpage_sg breakage Nicholas A. Bellinger
2011-06-04 1:18 ` [PATCH 7/7] iscsi-target: Fix iscsit_do_crypto_hash_sg() bug 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=1307150298-23921-6-git-send-email-nab@linux-iscsi.org \
--to=nab@linux-iscsi.org \
--cc=agrover@redhat.com \
--cc=hch@lst.de \
--cc=linux-scsi@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox