NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/37403



The following reply was made to PR kern/37403; it has been noted by GNATS.

From: Jesse Peterson <jpeterson275%comcast.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/37403
Date: Thu, 22 Oct 2009 16:40:47 -0700

 After looking into this even more I've come to the conclusion that this drive
 has some quirks. The major quirk that this PR is about is its odd MODE SELECT
 block size handling. Basically one cannot set the block size to 0 (variable-
 block mode) in the MODE SELECT. One receives a CHECK CONDITION. However within
 the drive's READ BLOCK LIMITs (2 <= blksize <= 16777215) you can change the
 drive's blocking size.
 
 That said the st(4) drive makes an assumption/guess on variable sized blocks
 at the end of the open() call. Which of course fails and since one needs to
 open the device to ioctl() to change the block size there's a bit of a catch-
 22 in there. So the I made a patch, below, which adds a quirk to use the 
drive's
 MODE SENSEd media block size instead of guessing variable block size.
 
 Perhaps a better approach would be to try variable then fall-back on media-size
 (which has the possibility of working not just for this quirky drive but others
 with similar problems). I have a vision of a one-day unified SCSI/ATAPI tape
 driver. :)
 
 The manual (which describes the drive's ATAPI command interface and of most
 interest its description of the MODE SENSE and MODE SELECT commands) says that
 the drive should support a zero blocksize (variable) setting and together with
 the "fixed" bit in the READ/WRITE CDBs should be enough to use it. However
 we get CHECK CONDITIONs when I try to set it. This happens over USB Bulk-Only
 and IEEE 1394 SBP-2, so I doubt it would be any different when ATAPI-attached.
 
 Manual linked here:
 http://sony.storagesupport.com/node/394
 
 
 See also related PR kern/42214.
 
 Patch: 
 
 --- st.c.orig  2008-11-19 18:50:27.000000000 -0800
 +++ st.c       2009-10-22 16:34:41.000000000 -0700
 @@ -306,6 +306,13 @@
                {0, 0, 0},                             /* minor 8-11 */
                {0, 0, 0}                              /* minor 12-15 */
        }}},
 +      {{T_SEQUENTIAL, T_REMOV,
 +       "SONY", "SDX-420C", "0103"},     {ST_Q_BLKMEDIA, 0, {
 +              {0, 0, 0},                             /* minor 0-3 */
 +              {0, 0, 0},                             /* minor 4-7 */
 +              {0, 0, 0},                             /* minor 8-11 */
 +              {0, 0, 0}                              /* minor 12-15 */
 +      }}},
  };
  
  #define NOEJECT 0
 @@ -1020,14 +1027,24 @@
                    ("Used media_blksize of %d\n", st->media_blksize));
                goto done;
        }
 -      /*
 -       * We're getting no hints from any direction.  Choose variable-
 -       * length blocks arbitrarily.
 -       */
 -      st->flags &= ~ST_FIXEDBLOCKS;
 -      st->blksize = 0;
 -      SC_DEBUG(st->sc_periph, SCSIPI_DB3,
 -          ("Give up and default to variable mode\n"));
 +      else if (st->quirks & ST_Q_BLKMEDIA)
 +      {
 +              st->flags |= ST_FIXEDBLOCKS;
 +              st->blksize = st->media_blksize;
 +              SC_DEBUG(st->sc_periph, SCSIPI_DB3,
 +                      ("Used media_blksize of %d\n", st->media_blksize));
 +      }
 +      else
 +      {
 +              /*
 +               * We're getting no hints from any direction.  Choose variable-
 +               * length blocks arbitrarily.
 +               */
 +              st->flags &= ~ST_FIXEDBLOCKS;
 +              st->blksize = 0;
 +              SC_DEBUG(st->sc_periph, SCSIPI_DB3,
 +                      ("Give up and default to variable mode\n"));
 +      }
  
  done:
        /*
 --- stvar.h.orig       2008-04-28 13:23:58.000000000 -0700
 +++ stvar.h    2009-10-22 16:35:17.000000000 -0700
 @@ -79,6 +79,7 @@
  #define       ST_Q_NOPREVENT          0x0020  /* does not support PREVENT */
  #define       ST_Q_ERASE_NOIMM        0x0040  /* drive rejects ERASE/w Immed 
bit */
  #define       ST_Q_NOFILEMARKS        0x0080  /* can only write 0 filemarks */
 +#define       ST_Q_BLKMEDIA           0x0100  /* try the media/sense block 
size */
        u_int page_0_size;
  #define       MAX_PAGE_0_SIZE 64
        struct modes modes[4];
 


Home | Main Index | Thread Index | Old Index