Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 68808
b: refs/heads/master
c: bd441de
h: refs/heads/master
v: v3
  • Loading branch information
Mike Christie authored and James Bottomley committed Oct 12, 2007
1 parent 7bc7297 commit abf527f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 358147403d1506ee43335c152fa3864d90f5ef6e
refs/heads/master: bd441deaf341c524b28fd72831ebf6fef88f1c41
14 changes: 10 additions & 4 deletions trunk/drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
{
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;
Expand All @@ -310,10 +310,15 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
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);
Expand Down Expand Up @@ -345,12 +350,13 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,

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:
Expand Down

0 comments on commit abf527f

Please sign in to comment.