Hastened by the looming freeze in the 2.3 series of development kernels, a patch to the SCSI mid level is attached. The patch is against version 2.3.12 . It: - increases the sense_buffer from 16 to 64 bytes - adds a residual byte counter. The sense_buffer increase leapfrogs SCSI 2 compliance (minimum 18 bytes) to pick up sense information written to byte 56 in "SCSI-3". It also picks up a lot of useful vendor information. The residual byte counter is the difference between the number of data bytes requested to be transferred and the actual number transferred. Gerard Roudier has pointed out that the "Modify Data Pointer" message can invalidate this count but in the vast majority of cases it is very useful information to scanner and cdrom "ripping" applications (e.g. SANE and cdparanoia) amongst others. The changes are in the scsi_cmnd structure increasing its size from 300 to 352 bytes. Grepping the scsi sub-system code shows that the vast majority of it is well prepared for a sense_buffer increase (by using sizeof(SCpnt->sense_buffer) ). The sg driver is effected (see below) and the "gdth" driver has a memset (to 0) that assumes the sense_buffer is 16 bytes long (probably harmless). The residual byte counter is new and initialized to 0. Several scsi adapter maintainers have indicated that they can easily supply this number. [One reason for this is that most other OSes in this area require such a count.] This patch has been (regression) tested on my system which runs Advansys adapters (PCI ultra wide + ISA), a variety of SCSI disks, CD players (including a writer) and a scanner. If people wish to test this patch then they should pick a new sg driver (version 2.3.35) at: http://www.torque.net/sg [see test version] . That new sg driver is being separately submitted to Alan Cox. Doug Gilbert
--- linux/drivers/scsi/scsi.h Fri Jul 30 18:37:18 1999 +++ linux/drivers/scsi/scsi.hsbres Thu Aug 5 23:02:45 1999 @@ -570,11 +570,14 @@ reconnects. Probably == sector size */ + int resid; /* Number of bytes requested to be + transferred less actual number + transferred (0 if not supported) */ struct request request; /* A copy of the command we are working on */ - unsigned char sense_buffer[16]; /* Sense for this command, + unsigned char sense_buffer[64]; /* Sense for this command, needed */ unsigned flags; --- linux/drivers/scsi/scsi.c Fri Jun 11 07:44:50 1999 +++ linux/drivers/scsi/scsi.csbres Thu Aug 5 23:24:55 1999 @@ -1077,6 +1077,7 @@ SCpnt->use_sg = 0; /* Reset the scatter-gather flag */ SCpnt->old_use_sg = 0; SCpnt->transfersize = 0; + SCpnt->resid = 0; SCpnt->underflow = 0; SCpnt->cmd_len = 0; @@ -1238,7 +1239,7 @@ SCpnt->old_use_sg = 0; SCpnt->transfersize = 0; /* No default transfer size */ SCpnt->cmd_len = 0; - + SCpnt->resid = 0; SCpnt->underflow = 0; /* Do not flag underflow conditions */ /* Since not everyone seems to set the device info correctly @@ -1962,6 +1963,7 @@ SCpnt->old_cmd_len = 0; SCpnt->underflow = 0; SCpnt->transfersize = 0; + SCpnt->resid = 0; SCpnt->serial_number = 0; SCpnt->serial_number_at_timeout = 0; SCpnt->host_scribble = NULL; @@ -3288,7 +3290,7 @@ } } } - printk("wait_for_request = %p\n", wait_for_request); + printk("wait_for_request = %p\n", &wait_for_request); #endif /* CONFIG_SCSI_LOGGING */ /* } */ #endif /* CONFIG_PROC_FS */ }