Tony Battersby 4d2de3a50c [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
completing.

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 <tonyb@cybernetics.com>
Acked-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2008-02-07 18:02:44 -06:00
..
2008-02-07 04:24:01 -05:00
2008-02-05 09:44:23 -08:00
2008-02-06 10:41:15 -08:00
2008-02-07 09:47:00 +00:00
2008-02-05 09:44:13 -08:00
2008-02-07 10:10:28 +00:00
2008-02-04 23:50:03 +11:00
2008-02-03 17:21:01 +02:00
2008-02-07 08:42:23 -08:00
2008-02-07 10:20:31 -08:00
2008-02-06 10:41:01 -08:00
2008-01-31 11:25:51 +11:00
2008-02-06 10:41:08 -08:00
2008-02-03 17:30:25 +02:00
2008-02-01 23:12:19 -05:00
2008-02-06 10:41:07 -08:00