From: Mike Christie <michaelc@cs.wisc.edu>
To: Jeremy Linton <jli@greshamstorage.com>
Cc: akpm@linux-foundation.org, James.Bottomley@steeleye.com,
linux-scsi@vger.kernel.org
Subject: Re: [patch 07/30] Incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers.
Date: Mon, 13 Aug 2007 13:00:11 -0500 [thread overview]
Message-ID: <46C09C2B.9050207@cs.wisc.edu> (raw)
In-Reply-To: <46C07455.7000903@greshamstorage.com>
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]
Jeremy Linton wrote:
> akpm@linux-foundation.org wrote:
>> From: Jeremy Linton <jli@greshamstorage.com>
>>
>> Any function which use scsi_execute_async() and transfers "odd" sized
>> data
>> that doesn't align correctly with the segment sizes may have its transfer
>> length padded out to the closest segment size.
> I would like to strongly suggest that Mike Christie's patch be used
> instead.
> http://www.mail-archive.com/linux-scsi@vger.kernel.org/msg06032.html
>
>
> I finally hit the case he was talking about (the block layer retries 0
> length commands caused by a size mismatch) and its ugly. I'm not really
> sure why my initial tests weren't hitting that case, I was trying to
> understand why some blocks were getting an extra command generated while
> others weren't. Sufficient to say, his patch fixes both problems, the
> incorrect transfer lengths and the extra 0 length transfer being generated.
>
I am having trouble inlining the patch properly with my mailer. Here is
the patch from that thread attached if James or Andrew needs it.
[-- Attachment #2: usebufflen.patch --]
[-- Type: text/x-patch, Size: 1465 bytes --]
sg's may have setup a the buffer with a different length than
the transfer length so we should be using the bufflen passed
in as the request's data len.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5f95570..30ae831 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -301,7 +301,7 @@ static int scsi_req_map_sg(struct reques
{
struct request_queue *q = rq->q;
int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
- unsigned int data_len = 0, len, bytes, off;
+ unsigned int data_len = bufflen, len, bytes, off;
struct page *page;
struct bio *bio = NULL;
int i, err, nr_vecs = 0;
@@ -310,10 +310,15 @@ static int scsi_req_map_sg(struct reques
page = sgl[i].page;
off = sgl[i].offset;
len = sgl[i].length;
- data_len += len;
- while (len > 0) {
+ while (len > 0 && data_len > 0) {
+ /*
+ * sg sends a scatterlist that is larger than
+ * the data_len it wants transferred for certain
+ * IO sizes
+ */
bytes = min_t(unsigned int, len, PAGE_SIZE - off);
+ bytes = min(bytes, data_len);
if (!bio) {
nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
@@ -345,12 +350,13 @@ static int scsi_req_map_sg(struct reques
page++;
len -= bytes;
+ data_len -=bytes;
off = 0;
}
}
rq->buffer = rq->data = NULL;
- rq->data_len = data_len;
+ rq->data_len = bufflen;
return 0;
free_bios:
prev parent reply other threads:[~2007-08-13 18:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-10 21:50 [patch 07/30] Incorrect SCSI transfer length computation from odd sized scsi_execute_async() transfers akpm
2007-08-13 15:10 ` Jeremy Linton
2007-08-13 18:00 ` Mike Christie [this message]
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=46C09C2B.9050207@cs.wisc.edu \
--to=michaelc@cs.wisc.edu \
--cc=James.Bottomley@steeleye.com \
--cc=akpm@linux-foundation.org \
--cc=jli@greshamstorage.com \
--cc=linux-scsi@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.