Hi,

After having battled with a DVD-RAM that does not (properly
at least) support WRITE_6 for some time, I started looking at
the 10/6 byte command logic in sd. It is not clear what the
intended effect of the 'ten' flag is.

sd_init_onedisk() unconditionally sets the 'ten' flag and
requests are queued as READ_10/WRITE_10 if it is set _and_
we want to transfer more than 256 blocks or go beyond
a block size that fits in the _6 variants.

The overhead of using a 10 byte command data block versus
the 6 byte equivalent is not worth worrying about IMHO.
Therefore I propose the following change to be made:

Always use WRITE_10/READ_10 when the 'ten' flag is set.
For devices that do not support it, the behaviour will
be to reverse to WRITE_6/READ_6 upon the first failed
read/write. An alternative solution would be to probe
the device in sd_init_onedisk() and set the flag conditionally.

Attached patch is against 2.2.14-pre9.

-- 
*  Jens Axboe <[EMAIL PROTECTED]>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk
--- linux-2.2.14-pre9/drivers/scsi/sd.c Wed Dec  1 22:02:17 1999
+++ linux/drivers/scsi/sd.c     Thu Dec  2 20:32:19 1999
@@ -483,13 +483,17 @@
         * would be a ten byte read where only a six byte read was supported.
         * Also, on a system where READ CAPACITY failed, we have have read
         * past the end of the disk.
+        *
+        * Don't screw with the ten byte flag unless we are certain that
+        * the drive does not understand the command /axboe
         */
 
        if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) {
-           if (rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].ten) {
+           if (rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].ten &&
+               SCpnt->sense_buffer[12] == 0x20) {
                rscsi_disks[DEVICE_NR(SCpnt->request.rq_dev)].ten = 0;
-               requeue_sd_request(SCpnt);
-               result = 0;
+           requeue_sd_request(SCpnt);
+           result = 0;
            } else {
                /* ???? */
            }
@@ -1016,7 +1020,7 @@
        this_count = this_count << 1;
     }
 
-    if (((this_count > 0xff) ||  (block > 0x1fffff)) && rscsi_disks[dev].ten)
+    if (((this_count > 0xff) ||  (block > 0x1fffff)) || rscsi_disks[dev].ten)
     {
        if (this_count > 0xffff)
            this_count = 0xffff;

Reply via email to