Commit:     4d2de3a50ce19af2008a90636436a1bf5b3b697b
Parent:     76d78300a6eb8b7f08e47703b7e68a659ffc2053
Author:     Tony Battersby <[EMAIL PROTECTED]>
AuthorDate: Tue Feb 5 10:36:10 2008 -0500
Committer:  James Bottomley <[EMAIL PROTECTED]>
CommitDate: Thu Feb 7 18:02:44 2008 -0600

    [SCSI] fix BUG when sum(scatterlist) > bufflen
    When sending a SCSI command to a tape drive via the SCSI Generic (sg)
    driver, if the command has a data transfer length more than
    scatter_elem_sz (32 KB default) and not a multiple of 512, then I either
    hit BUG_ON(!valid_dma_direction(direction)) in dma_unmap_sg() or else
    the command never completes (depending on the LLDD).
    When constructing scatterlists, the sg driver rounds up the scatterlist
    element sizes to be a multiple of 512.  This can result in
    sum(scatterlist lengths) > bufflen.  In this case, scsi_req_map_sg()
    incorrectly sets bio->bi_size to sum(scatterlist lengths) rather than to
    bufflen.  When the command completes, req_bio_endio() detects that
    bio->bi_size != 0, and so it doesn't call bio_endio().  This causes the
    command to be resubmitted, resulting in BUG_ON or the command never
    This patch makes scsi_req_map_sg() set bio->bi_size to bufflen rather
    than to sum(scatterlist lengths), which fixes the problem.
    Signed-off-by: Tony Battersby <[EMAIL PROTECTED]>
    Acked-by: Mike Christie <[EMAIL PROTECTED]>
    Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
 drivers/scsi/scsi_lib.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f243fc3..135c1d0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -301,7 +301,6 @@ static int scsi_req_map_sg(struct request *rq, struct 
scatterlist *sgl,
                page = sg_page(sg);
                off = sg->offset;
                len = sg->length;
-               data_len += len;
                while (len > 0 && data_len > 0) {
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to