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
..
2007-04-01 10:10:04 -05:00
2008-01-11 18:22:30 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-02-06 10:41:01 -08:00
2008-02-06 10:41:01 -08:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-25 09:22:12 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-02-06 10:41:01 -08:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-02-03 17:28:22 +02:00
2008-02-03 17:28:22 +02:00
2008-01-11 18:27:59 -06:00
2007-05-31 17:30:04 -04:00
2008-01-30 13:03:40 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2008-01-23 13:44:31 -06:00
2008-01-30 13:14:02 -06:00
2007-10-19 11:53:42 -07:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2007-07-18 11:16:32 -05:00
2008-02-03 17:28:22 +02:00
2008-02-07 18:02:42 -06:00
2007-07-14 19:12:15 -05:00
2008-01-30 13:03:40 -06:00
2008-01-23 11:29:29 -06:00
2007-07-31 10:44:01 -05:00
2008-01-30 13:14:02 -06:00
2007-05-31 17:30:04 -04:00
2008-01-30 13:14:02 -06:00
2006-11-15 16:43:50 -06:00
2008-01-30 13:14:02 -06:00
2008-01-30 13:14:02 -06:00
2007-10-19 23:22:55 +02:00
2008-01-30 13:14:02 -06:00