Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Feb 1996 11:15:07 +0100 (MET)
From:      Philippe Causse <caussep@sphynx.fdn.fr>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        hackers@FreeBSD.org, delaitt@cpc.wmin.ac.uk, jdp@polstra.com
Subject:   Re: Patches from 2.1-RELEASE
Message-ID:  <Pine.BSF.3.91.960206100521.378A-100000@sphynx.fdn.fr>
In-Reply-To: <199602060357.OAA19150@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help

Hello Bruce !
Glad you replied :-)

Here are the answers to your questions. (I left the original quote for 
people reading new to this discussion)

On Tue, 6 Feb 1996, Bruce Evans wrote:

> >1] tape-patch:
> >~~~~~~~~~~~~~~
> >  Some SCSI-1 tape drives like Archive 2150S, Tandberg-??? _DO_
> >implement a mode called QFA (Quick File Access) which allow quick
> >positionning on a given block number (counted 1 from the begining of
> >tape).  This feature was available when I ran Linux two years ago.  An
> >equivalent set of commands also exist on SCSI-2 tape drives but I
> >don't have any hardware to test it on.  Before releasing this patch, I
> >grabbed the 2.2-current "st.c", so this patch also adds the retension 
> >command.
> 
> The `tell' command but not the `seek' command worked on my WangDat 3100
> SCSI-2 DAT tape under Linux a couple of years ago.

Linux used (and implemented only) QFA commands in its tape driver. It
should probably have used the SCSI-2 command set to control your DAT. 

> 
> >CAVEATS: I don't know if these commands are specific to the Archive
> >Viper-150 (aka 2150S). If so, they should probably go to the rogues
> >gallery; anyhow they have a SCSI-2 equivalent (but with different
> >encoding).
> 
> Where can I find the different encoding?

By encoding I meant different command codes & different command block
structures (not the old classic SCSI-1 24bits addressing scheme).

I found the SCSI-1 and SCSI-2 (text only) documentation on the net using 
Archie. To avoid flooding you mailbox, I'll just quote a part of it in 
this mail. If you want the full text, I can e-mail it to you as a MIME 
attachment. Please, don't hesitate to ask! (300K for SCSI-2, 84K for SCSI-1)

The commands we are interested in are "LOCATE" and "READ POSITION". Both 
are optional commands, so they may not be supported by your DAT either!

------------------[ EXTRACT FROM THE SCSI-2 SPECS ]-------------------

10.2 Command descriptions for sequential-access devices

The commands for sequential-access devices shall be as shown in table
174.

              Table 174 - Commands for sequential-access devices
+=====================================-============-======-============+
|  Command name                       | Operation  | Type |  Subclause |
|                                     |   code     |      |            |
|-------------------------------------+------------+------+------------|
| CHANGE DEFINITION                   |    40h     |   O  |   8.2.1    |
| COMPARE                             |    39h     |   O  |   8.2.2    |
| COPY                                |    18h     |   O  |   8.2.3    |
| COPY AND VERIFY                     |    3Ah     |   O  |   8.2.4    |
| ERASE                               |    19h     |   M  |  10.2.1    |
| INQUIRY                             |    12h     |   M  |   8.2.5    |
| LOAD UNLOAD                         |    1Bh     |   O  |  10.2.2    |
| LOCATE                              |    2Bh     |   O  |  10.2.3    |
| LOG SELECT                          |    4Ch     |   O  |   8.2.6    |
| LOG SENSE                           |    4Dh     |   O  |   8.2.7    |
| MODE SELECT(6)                      |    15h     |   M  |   8.2.8    |
| MODE SELECT(10)                     |    55h     |   O  |   8.2.9    |
| MODE SENSE(6)                       |    1Ah     |   M  |   8.2.10   |
| MODE SENSE(10)                      |    5Ah     |   O  |   8.2.11   |
| PREVENT ALLOW MEDIUM REMOVAL        |    1Eh     |   O  |   9.2.4    |
| READ                                |    08h     |   M  |  10.2.4    |
| READ BLOCK LIMITS                   |    05h     |   M  |  10.2.5    |
| READ BUFFER                         |    3Ch     |   O  |   8.2.12   |
| READ POSITION                       |    34h     |   O  |  10.2.6    |
| READ REVERSE                        |    0Fh     |   O  |  10.2.7    |
| RECEIVE DIAGNOSTIC RESULTS          |    1Ch     |   O  |   8.2.13   |
| RECOVER BUFFERED DATA               |    14h     |   O  |  10.2.8    |
| RELEASE UNIT                        |    17h     |   M  |  10.2.9    |
| REQUEST SENSE                       |    03h     |   M  |   8.2.14   |
| RESERVE UNIT                        |    16h     |   M  |  10.2.10   |
| REWIND                              |    01h     |   M  |  10.2.11   |
| SEND DIAGNOSTIC                     |    1Dh     |   M  |   8.2.15   |
| SPACE                               |    11h     |   M  |  10.2.12   |
| TEST UNIT READY                     |    00h     |   M  |   8.2.16   |
| VERIFY                              |    13h     |   O  |  10.2.13   |
| WRITE                               |    0Ah     |   M  |  10.2.14   |
| WRITE BUFFER                        |    3Bh     |   O  |   8.2.17   |
| WRITE FILEMARKS                     |    10h     |   M  |  10.2.15   |
|----------------------------------------------------------------------|
|Key:  M = command implementation is mandatory.                        |
|      O = command implementation is optional.                         |
+======================================================================+


The following command codes are vendor-specific: 02h, 06h, 07h, 09h,
0Ch, and 0Eh.  All other command codes for sequential-access devices
are reserved for future standardization.

----------------------------------------------------------------------
NB: QFA_SEEK_BLOCK = 0x0C, QFA_REQUEST_BLOCK = 0x02 -> Vendor specific!


Now, the encoding (aka command format) for LOCATE and READ POSITION:

------------------[ EXTRACT FROM THE SCSI-2 SPECS ]-------------------
10.2.3 LOCATE command

LOCATE command (see table 177) causes the target to position the
logical unit to the specified block address in a specified partition. 
Upon completion, the logical position shall be before the specified
location.  Prior to performing the locate operation, the target shall
ensure that all buffered data, filemarks, and setmarks have been
transferred to the medium.

                          Table 177 - LOCATE command
+=====-========-========-========-========-========-========-========-========+
|  Bit|   7    |   6    |   5    |   4    |   3    |   2    |   1    |   0    |
|Byte |        |        |        |        |        |        |        |        |
|=====+=======================================================================|
| 0   |                           Operation code (2Bh)                        |
|-----+-----------------------------------------------------------------------|
| 1   |    Logical unit number   |      Reserved   |   BT   |   CP   | Immed  |
|-----+-----------------------------------------------------------------------|
| 2   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 3   | (MSB)                                                                 |
|-----+---                                                                 ---|
| 4   |                                                                       |
|-----+---                        Block address                            ---|
| 5   |                                                                       |
|-----+---                                                                 ---|
| 6   |                                                                 (LSB) |
|-----+-----------------------------------------------------------------------|
| 7   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 8   |                           Partition                                   |
|-----+-----------------------------------------------------------------------|
| 9   |                           Control                                     |
+=============================================================================+


A block address type (BT) bit of one indicates the value in the block
address field shall be interpreted as a device-specific value.  A BT
bit of zero indicates the value in the block address field shall be
interpreted as an SCSI logical block address.

A change partition (CP) bit of one indicates that a change to the
partition specified in the partition field is to occur prior to
positioning to the block specified in the block address field.  A CP
bit of zero indicates no partition change is to be made and the
partition field is to be ignored.

An immediate (Immed) bit of zero indicates that the target shall not
return status until the locate operation has completed.  An Immed bit
of one indicates that the target shall return status as soon as all
buffered commands have completed execution and the command descriptor
block of the LOCATE command has been validated.  If CHECK CONDITION
status is returned for a LOCATE command with an Immed bit of one, the
locate operation shall not be performed.

The block address field (see 10.1.6) specifies the block address to
which the target shall position the medium based on the current setting
of the BT bit.

The partition field specifies which partition to select if the CP bit
is one.  Refer to the sequential-access device model (see 10.1.3) and
the medium partition pages (see 10.3.3.2 and 10.3.3.3) for additional
information about partitioning.

10.2.6 READ POSITION command

The READ POSITION command (see table 181) reports the current position
of the logical unit and any data blocks in the buffer.  No medium
movement shall occur as a result of the command.  

                      Table 181 - READ POSITION command
+=====-========-========-========-========-========-========-========-========+
|  Bit|   7    |   6    |   5    |   4    |   3    |   2    |   1    |   0    |
|Byte |        |        |        |        |        |        |        |        |
|=====+=======================================================================|
| 0   |                           Operation code (34h)                        |
|-----+-----------------------------------------------------------------------|
| 1   |   Logical unit number    |             Reserved              |   BT   |
|-----+-----------------------------------------------------------------------|
| 2   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 3   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 4   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 5   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 6   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 7   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 8   |                           Reserved                                    |
|-----+-----------------------------------------------------------------------|
| 9   |                           Control                                     |
+=============================================================================+


A block address type (BT) bit of one requests the target to return its
current first block location and last block location as a device-
specific value.  A BT bit of zero requests the target to return the
first block location and the last block location as an SCSI logical
block address (relative to a partition).  

If the logical unit is not capable of reporting block locations, the
BPU bit shall be set to one in the returned data.  Support for this
option of the READ POSITION command is indicated by a BIS bit set to
one in the device configuration page (see 10.3.3.1).

The READ POSITION data shown in table 182 shall be returned.

                    Table 182 - READ POSITION data format
+=====-========-========-========-========-========-========-========-========+
|  Bit|   7    |   6    |   5    |   4    |   3    |   2    |   1    |   0    |
|Byte |        |        |        |        |        |        |        |        |
|=====+========+========+==========================+========+=================|
| 0   |  BOP   |   EOP  |        Reserved          |  BPU   |     Reserved    |
|-----+-----------------------------------------------------------------------|
| 1   |                          Partition number                             |
|-----+-----------------------------------------------------------------------|
| 2   |                          Reserved                                     |
|-----+-----------------------------------------------------------------------|
| 3   |                          Reserved                                     |
|-----+-----------------------------------------------------------------------|
| 4   | (MSB)                                                                 |
|- - -+---                       First block location                      ---|
| 7   |                                                                 (LSB) |
|-----+-----------------------------------------------------------------------|
| 8   | (MSB)                                                                 |
|- - -+---                       Last block location                       ---|
| 11  |                                                                 (LSB) |
|-----+-----------------------------------------------------------------------|
| 12  |                          Reserved                                     |
|-----+-----------------------------------------------------------------------|
| 13  | (MSB)                                                                 |
|- - -+---                       Number of blocks in buffer                ---|
| 15  |                                                                 (LSB) |
|-----+-----------------------------------------------------------------------|
| 16  | (MSB)                                                                 |
|- - -+---                       Number of bytes in buffer                 ---|
| 19  |                                                                 (LSB) |
+=============================================================================+


A beginning of partition (BOP) bit of one indicates that the logical
unit is at the beginning-of-partition in the current partition.  A BOP
bit of zero indicates that the current logical position is not at the
beginning-of-partition.  

An end of partition (EOP) bit of one indicates that the logical unit is
positioned between early-warning and end-of-partition in the current
partition.  An EOP bit of zero indicates that the current logical
position is not between early-warning and end-of-partition.

   NOTE 143 The BOP and EOP indications are not necessarily a result of a
   physical tape marker (e.g. reflective marker). 

A block position unknown (BPU) bit of one indicates that the first and
last block locations are not known or cannot be obtained.  A BPU bit of
zero indicates that the first and last block location fields contain
valid position information.

The partition number field reports the partition number for the current
logical position.  If the logical unit only supports one partition for
the medium, this field shall be set to zero.

The first block location field indicates the block address associated
with the current logical position.  The value shall indicate the block
address of the next data block to be transferred between the initiator
and the target if a READ or WRITE command is issued.

The last block location field indicates the block address (see 10.1.6)
associated with the next block to be transferred from the buffer to the
medium.  The value shall indicate the block address of the next data
block to be transferred between the buffer and the medium.  If the
buffer does not contain a whole block of data or is empty, the value
reported for the last block location shall be equal to the value
reported for the first block location.

   NOTE 144 The information provided by the first and last block location
   fields can be used in conjunction with the LOCATE command to position the
   medium at the appropriate logical block on another device in the case of
   unrecoverable errors on the first device.

The number of blocks in buffer field indicates the number of data
blocks in the target's buffer that have not been written to the medium.

The number of bytes in buffer field indicates the total number of data
bytes in the target's buffer that have not been written to the medium.

----------------------------------------------------------------------

Sorry, I don't remember excatly where I grabbed the SCSI-2 specs, but 
it's available somewhere on the net. Anyway, I send you a copy of it.

Now, the floppy stuff...

> 
> >2] floppy-patch:
> >~~~~~~~~~~~~~~~~
> > ...
> >2-b) High-speed:
> >  The speed increase comes from two changes: the increased number of
> >sectors (since the rotational speed is the same) and spiral formatting
> >with a cylinder skew of 2 to compensate the head switching time.
> 
> I don't like cylinder skew or interleave for floppies.  The driver
> should keep track of the next (accessible) sector and schedule i/o's to
> access the sectors in the best possible order.  If the skews and
> interleaves are nonstandard, then the driver has to do extra work to
> detect and adjust for them.

Well, I don't really understand the point here... This patch is
essentially for tar/pax/dump/mcopy, not for using a floppy filesystem
Although I _did_ make a UFS floppy, it works pretty well. Just add the
proper values in the floppy disk's label before news'ing.

If cylinder-skew were not physically implemented (using a spiral
formatting), then speedup on linear access would be possible only by
changing the sector access order when writing to the floppy. This
would make the floppy incompatible with other systems.

> Skew and interleave helps for dumb drivers of course.

I mean the raw floppy device, since performing linear access on a
floppy is best done with the /dev/rfd[0-1] interface. Using the block
device in that context is nonsense.

> 
> >it back!!! (this is used for spiral formatting). The default head
> >settle time is "hz/16" which is far too big to get the benefit of
> >spiral formatting.  I replaced it with "hz/FDSEEKWAIT". A good value
> 
> hz/16 is 6 (giving a timeout of 50+ to 60 msec).  This is much too large.
> It was hz/50 in rev.1.1 of fd.c (giving a timeout of (10+ to 20 msec).
> This may be too small.  I think the standard is 15 msec.  The kernel
			 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That's right indeed but for 5"1/4. (According to an old tech-manual of a 
360K TEAC floppy drive). 3"1/2 drives are quicker to settle, probably due 
to a smaller inertia in their stepping motor / head motion system. Old 
5"1/4 used a steal belt for head motion but smart 3"1/2 now use an 
endless screw attached to the stepping motor plus a lot of
lightweight (nylon) mechanical parts to reduce inertia.

> has poor support for timeouts this small.  The timeout has to be 3 ticks
> to guarantee that it is > 15 msec.  I made it hz/32 in rev.1.30 to get
> this.  Then someone made it hz/16 in rev.1.43 "to avoid annoying messages".

And miss a whole revolution at the same time... :( considerably
degrading performance.

> 
> >of FDSEEKWAIT is 64, though it runs okay with 128 but 64 is safer :-)
> 
> hz/64 is 1 (0+ to 10 msec timeout) while hz/128 is 0 (also 0+ to 10
> msec timeout because timeout() doesn't believe that you want a timeout
> of 0 ticks and increases it to 1 tick :-).

Well.. it worked indeed !!! Lucky am I ? But I admit I stuck to hz/64
since it's enough to keep up with track stepping.

> 
> I've worked on floppy drivers that didn't worry about head settle.  This
> is usually OK on old, slow systems.  It is safer if the driver schedules

Do you mean 486DX2-66 is an "old slow system" ???

> i/o.  Then the driver never should never attempt to access a sector too
> soon after seeking because the access would usually fail and a whole
> disk revolution would be wasted.

Sure, but waiting too much before writing misses the expected sector
and a whole revolution is wasted as well. That's why standard floppies
have a rate of 32K/s instead of the 49K/s peak performance. Note that
the theoretical performance is (for a drive 3"1/2 HD, with 1.6Mb
formatting) 50K/s.
	300 RPM = 5 RPS, 1 track of 20 sectors = 10K
	10K * 5 -> 50 K/S : That's FDC_500KBPS in fd.c
This does not take any track/cylinder skewing into account.
So 32K/s is only 64% efficient :(

> 
> >The fdformat program has been changed to do spiral formatting.  It
> >accepts two new parameters: track and cylinder skew. Track skew
> >(defaults to zero) is almost useless since the head switching time is
> >neglectable . Cylinder skew is sensitive: I obtained the best
> >performances with a value of 2 (the default) on an unloaded system.
> 
> The best skew is probably drive-dependent.  On one of my floppy drives
> (a 5.25 inch TEAC (?) drive bought in 1988) with standard 1.2MB
> formatting, it is possible to read sector N on one cylinder, then seek
> to the next cylinder and read sector N+2, except when N is the last or
> the second last sector, it is possible to read the first sector on the
> next track!  On all my other PC floppy drives (a couple of 5.25 inch
> ones and a couple of 3.5 inch ones), it is only possible to read
> sector N+3 or N+4 after seeking.  This is easy to compensate for in

That's why I added an option to specify the skew. 2 is the best value
for my 3"1/4 drive (3 seems more suitable to my 1.2M 5"1/4). It may be
a good idea to let fdformat guess the best cylinder-skew parameter.
One important thing: before I changed hz/16 to hz/FDSEEKWAIT with
FDSEEKWAIT=64, I couldn't increase performances and the best skew was
arround 7. Transfer rate was near 42K/s. Still over M$-DOG performance
but far from the 49K/s...

> drivers that schedule the i/o, but it costs a sector time or 3 per
> revolution, as would uncompensated for cylinder skew.  In dumb drivers
> it can waste a lot of time, e.g., under DOG copying a bunch of small
> files to an uncached floppy took about a minute with the fast drive
> and about 8 minutes with a slow drive.

It depends also on the disk controller's type.  Mine is a stock NEC
765 but new 82077 (with FIFO) are really faster.

Spiral formatting doesn't affect M$-DOG copying. When copying small
files, there's no time penality. When copying large files, it's really
faster...

You didn't tell me what you think about adding the 1.6Mb format in the
format table & device list. Is it worth doing it ?

BTW, since spiral formatting is handled entirely in the fdformat
program, I could just leave cylinder_skey=0; as the default and let
the user's supply the parameter, or make the program guess the `best'
value.

> 
> Bruce
> 

Regards,
Philippe.

----------------------------------------------------------------------
FreeBSD, NetBSD, Linux: Il y a moins bien, mais c'est plus cher...
                        You can get worse, but it's more expensive...
----------------------------------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.960206100521.378A-100000>