Re: New 2.6.24.2 SG_IO SCSI problems

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mark Hounschell
Date: Wednesday, March 5, 2008 - 4:58 am

Mike Christie wrote:


Backport
76d78300a6eb8b7f08e47703b7e68a659ffc2053
to 2.6.24


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: Mike Christie <michaelc@cs.wisc.edu>

--- linux-2.6.24.2/drivers/scsi/scsi_lib.c	2008-02-10 23:51:11.000000000
-0600
+++ linux-2.6.24.2.work/drivers/scsi/scsi_lib.c	2008-02-22
16:20:09.000000000 -0600
@@ -298,7 +298,6 @@ static int scsi_req_map_sg(struct reques
 		page = sg_page(sg);
 		off = sg->offset;
 		len = sg->length;
- 		data_len += len;

 		while (len > 0 && data_len > 0) {
 			/*


Did this ever get sent to the stable team?

Regards
Mark
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Thu Feb 21, 8:15 am)
Re: New 2.6.24.2 SG_IO SCSI problems, James Bottomley, (Thu Feb 21, 8:41 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Thu Feb 21, 9:21 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Fri Feb 22, 3:03 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mike Christie, (Fri Feb 22, 9:50 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mike Christie, (Fri Feb 22, 9:59 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Fri Feb 22, 10:56 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Fri Feb 22, 2:38 pm)
Re: New 2.6.24.2 SG_IO SCSI problems, Mike Christie, (Fri Feb 22, 3:25 pm)
Re: New 2.6.24.2 SG_IO SCSI problems, Tony Battersby, (Fri Feb 22, 3:48 pm)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Sat Feb 23, 4:16 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Wed Mar 5, 4:58 am)
Re: New 2.6.24.2 SG_IO SCSI problems, James Bottomley, (Wed Mar 5, 8:44 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mark Hounschell, (Wed Mar 5, 9:28 am)
Re: New 2.6.24.2 SG_IO SCSI problems, Mike Christie, (Wed Mar 5, 10:13 am)