home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / kernel-2.0 / scsi / readme.st < prev   
Encoding:
Text File  |  1996-07-11  |  14.3 KB  |  315 lines

  1. This file contains brief information about the SCSI tape driver.
  2. Last modified: Wed May  1 11:51:35 1996 by root@kai.makisara.fi
  3.  
  4.  
  5. BASICS
  6.  
  7. The driver is generic, i.e., it does not contain any code tailored
  8. to any specific tape drive. The tape parameters can be specified with
  9. one of the following three methods:
  10.  
  11. 1. Each user can specify the tape parameters he/she wants to use
  12. directly with ioctls. This is administratively a very simple and
  13. flexible method and applicable to single-user workstations. However,
  14. in a multiuser environment the next user finds the tape parameters in
  15. state the previous user left them.
  16.  
  17. 2. The system manager (root) can define default values for some tape
  18. parameters, like block size and density using the MTSETDRVBUFFER ioctl.
  19. These parameters can be programmed to come into effect either when a
  20. new tape is loaded into the drive or if writing begins at the
  21. beginning of the tape. The second method is applicable if the tape
  22. drive performs auto-detection of the tape format well (like some
  23. QIC-drives). The result is that any tape can be read, writing can be
  24. continued using existing format, and the default format is used if
  25. the tape is rewritten from the beginning (or a new tape is written
  26. for the first time). The first method is applicable if the drive
  27. does not perform auto-detection well enough and there is a single
  28. "sensible" mode for the device. An example is a DAT drive that is
  29. used only in variable block mode (I don't know if this is sensible
  30. or not :-).
  31.  
  32. The user can override the parameters defined by the system
  33. manager. The changes persist until the defaults again come into
  34. effect.
  35.  
  36. 3. Up to four modes can be defined and selected using the minor number
  37. (bits 5 and 6). Mode 0 corresponds to the defaults discussed
  38. above. Additional modes are dormant until they are defined by the
  39. system manager (root). When specification of a new mode is started,
  40. the configuration of mode 0 is used to provide a starting point for
  41. definition of the new mode.
  42.  
  43. Using the modes allows the system manager to give the users choices
  44. over some of the buffering parameters not directly accessible to the
  45. users (buffered and asynchronous writes). The modes also allow choices
  46. between formats in multi-tape operations (the explicitly overridden
  47. parameters are reset when a new tape is loaded).
  48.  
  49. If more than one mode is used, all modes should contain definitions
  50. for the same set of parameters.
  51.  
  52. Many Unices contain internal tables that associate different modes to
  53. supported devices. The Linux SCSI tape driver does not contain such
  54. tables (and will not do that in future). Instead of that, a utility
  55. program can be made that fetches the inquiry data sent by the device,
  56. scans its database, and sets up the modes using the ioctls. Another
  57. alternative is to make a small script that uses mt to set the defaults
  58. tailored to the system.
  59.  
  60.  
  61. The driver supports fixed and variable block size (within buffer
  62. limits). Both the auto-rewind (minor equals device number) and
  63. non-rewind devices (minor is 128 + device number) are implemented.
  64.  
  65. Support is provided for changing the tape partition and partitioning
  66. of the tape with one or two partitions. By default support for
  67. partitioned tape is disabled for each driver and it can be enabled
  68. with the ioctl MTSETDRVBUFFER.
  69.  
  70. By default the driver writes one filemark when the device is closed after
  71. writing and the last operation has been a write. Two filemarks can be
  72. optionally written. In both cases end of data is signified by
  73. returning zero bytes for two consecutive reads.
  74.  
  75. The compile options are defined in the file linux/drivers/scsi/st_options.h.
  76.  
  77.  
  78. BUFFERING
  79.  
  80. The driver uses tape buffers allocated either at system initialization
  81. or at run-time when needed. One buffer is used for each open tape
  82. device. The size of the buffers is selectable at compile and/or boot
  83. time. The buffers are used to store the data being transferred to/from
  84. the SCSI adapter. The following buffering options are selectable at
  85. compile time and/or at run time (via ioctl):
  86.  
  87. Buffering of data across write calls in fixed block mode (define
  88. ST_BUFFER_WRITES). This should be disabled if reliable detection of
  89. end of medium (EOM) for fixed block mode is desired.
  90.  
  91. Asynchronous writing. Writing the buffer contents to the tape is
  92. started and the write call returns immediately. The status is checked
  93. at the next tape operation. Should not used if reliable EOM detection
  94. is desired.
  95.  
  96. Read ahead for fixed block mode (ST_READ_AHEAD). Filling the buffer is
  97. attempted even if the user does not want to get all of the data at
  98. this read command. Should be disabled for those drives that don't like
  99. a filemark to truncate a read request or that don't like backspacing.
  100.  
  101. The buffer size is defined (in 1024 byte units) by ST_BUFFER_BLOCKS or
  102. at boot time. If this size is not enough, the driver tries to allocate
  103. a large enough temporary buffer that is released when the device is
  104. closed. The maximum buffer size is defined by the kernel memory
  105. allocation (currently 256 kB for Alphas and 128 kB for other
  106. architectures).
  107.  
  108. Allocation of the buffers is done at run-time when they are
  109. needed. Allocation of the specified number of buffers can be done at
  110. initialization if ST_RUNTIME_BUFFERS is defined non-zero. The
  111. advantage of run-time allocation is that memory is not wasted for
  112. buffers not being used. The disadvantage is that there may not be
  113. memory available at the time when a buffer is needed for the first
  114. time (once a buffer is allocated, it is not released).
  115.  
  116. The maximum number of buffers allocated at initialization is defined by
  117. ST_MAX_BUFFERS. One buffer is allocated for each drive detected when
  118. the driver is initialized up to the maximum. The minimum number of
  119. allocated buffers is ST_EXTRA_DEVS (in hosts.h). This ensures some
  120. functionality also for the drives found after tape driver
  121. initialization (a SCSI adapter driver is loaded as a module). The
  122. default for ST_EXTRA_DEVS is two. The driver tries to allocate new
  123. buffers at run-time if necessary.
  124.  
  125. The threshold for triggering asynchronous write in fixed block mode
  126. is defined by ST_WRITE_THRESHOLD. This may be optimized for each
  127. use pattern. The default triggers asynchronous write after three
  128. default sized writes (10 kB) from tar.
  129.  
  130.  
  131. BOOT TIME CONFIGURATION
  132.  
  133. The buffer size, write threshold, and the maximum number of allocated buffers
  134. are configurable at boot time using, e.g., the LILO command line. The option
  135. syntax is the following:
  136.  
  137.            st=aa[,bb[,cc]]
  138.  
  139. where
  140.   aa is the buffer size in 1024 byte units
  141.   bb is the write threshold in 1024 byte units
  142.   cc is the maximum number of tape buffers to allocate (the number of
  143.         buffers is bounded also by the number of drives detected)
  144.  
  145.  
  146. IOCTLS
  147.  
  148. The tape is positioned and the drive parameters are set with ioctls
  149. defined in mtio.h The tape control program 'mt' uses these ioctls. Try
  150. to find an mt that supports all of the Linux SCSI tape ioctls and
  151. opens the device for writing if the tape contents will be modified
  152. (look for a package mt-st* from the Linux ftp sites; the GNU mt does
  153. not open for writing for, e.g., erase).
  154.  
  155. The supported ioctls are:
  156.  
  157. The following use the structure mtop:
  158.  
  159. MTFSF   Space forward over count filemarks. Tape positioned after filemark.
  160. MTFSFM  As above but tape positioned before filemark.
  161. MTBSF    Space backward over count filemarks. Tape positioned before
  162.         filemark.
  163. MTBSFM  As above but ape positioned after filemark.
  164. MTFSR   Space forward over count records.
  165. MTBSR   Space backward over count records.
  166. MTFSS   Space forward over count setmarks.
  167. MTBSS   Space backward over count setmarks.
  168. MTWEOF  Write count filemarks.
  169. MTWSM   Write count setmarks.
  170. MTREW   Rewind tape.
  171. MTOFFL  Set device off line (often rewind plus eject).
  172. MTNOP   Do nothing except flush the buffers.
  173. MTRETEN Re-tension tape.
  174. MTEOM   Space to end of recorded data.
  175. MTERASE Erase tape.
  176. MTSEEK    Seek to tape block count. Uses Tandberg-compatible seek (QFA)
  177.         for SCSI-1 drives and SCSI-2 seek for SCSI-2 drives. The file and
  178.     block numbers in the status are not valid after a seek.
  179. MTSETBLK Set the drive block size. Setting to zero sets the drive into
  180.         variable block mode (if applicable).
  181. MTSETDENSITY Sets the drive density code to arg. See drive
  182.         documentation for available codes.
  183. MTLOCK and MTUNLOCK Explicitly lock/unlock the tape drive door.
  184. MTLOAD and MTUNLOAD Explicitly load and unload the tape.
  185. MTCOMPRESSION Sets compressing or uncompressing drive mode using the
  186.     SCSI mode page 15. Note that some drives other methods for
  187.     control of compression. Some drives (like the Exabytes) use
  188.     density codes for compression control. Some drives use another
  189.     mode page but this page has not been implemented in the
  190.     driver.
  191. MTSETPART Moves the tape to the partition given by the argument at the
  192.     next tape operation. The block at which the tape is positioned
  193.     is the block where the tape was previously positioned in the
  194.     new active partition unless the next tape operation is
  195.     MTSEEK. In this case the tape is moved directly to the block
  196.     specified by MTSEEK. MTSETPART is inactive unless
  197.     MT_ST_CAN_PARTITIONS set.
  198. MTMKPART Formats the tape with one partition (argument zero) or two
  199.     partitions (the argument gives in megabytes the size of
  200.     partition 1 that is physically the first partition of the
  201.     tape). The drive has to support partitions with size specified
  202.     by the initiator. Inactive unless MT_ST_CAN_PARTITIONS set.
  203. MTSETDRVBUFFER
  204.     Is used for several purposes. The command is obtained from count
  205.         with mask MT_SET_OPTIONS, the low order bits are used as argument.
  206.     This command is only allowed for the superuser (root). The
  207.     subcommands are:
  208.     0
  209.            The drive buffer option is set to the argument. Zero means
  210.            no buffering.
  211.         MT_ST_BOOLEANS
  212.            Sets the buffering options. The bits are the new states
  213.            (enabled/disabled) the following options (in the
  214.        parenthesis is specified whether the option is global or
  215.        can be specified differently for each mode):
  216.          MT_ST_BUFFER_WRITES write buffering (mode)
  217.          MT_ST_ASYNC_WRITES asynchronous writes (mode)
  218.              MT_ST_READ_AHEAD  read ahead (mode)
  219.              MT_ST_TWO_FM writing of two filemarks (global)
  220.          MT_ST_FAST_EOM using the SCSI spacing to EOD (global)
  221.          MT_ST_AUTO_LOCK automatic locking of the drive door (global)
  222.              MT_ST_DEF_WRITES the defaults are meant only for writes (mode)
  223.          MT_ST_CAN_BSR backspacing over more than one records can
  224.         be used for repositioning the tape (global)
  225.          MT_ST_NO_BLKLIMS the driver does not ask the block limits
  226.         from the drive (block size can be changed only to
  227.         variable) (global)
  228.          MT_ST_CAN_PARTITIONS enables support for partitioned
  229.         tapes (global)
  230.          MT_ST_SCSI2LOGICAL the logical block number is used in
  231.         the MTSEEK and MTIOCPOS for SCSI-2 drives instead of
  232.         the device dependent address. It is recommended to set
  233.         this flag unless there are tapes using the device
  234.         dependent (from the old times) (global)
  235.          MT_ST_DEBUGGING debugging (global; debugging must be
  236.         compiled into the driver)
  237.     MT_ST_SETBOOLEANS
  238.     MT_ST_CLEARBOOLEANS
  239.        Sets or clears the option bits.
  240.         MT_ST_WRITE_THRESHOLD
  241.            Sets the write threshold for this device to kilobytes
  242.            specified by the lowest bits.
  243.     MT_ST_DEF_BLKSIZE
  244.        Defines the default block size set automatically. Value
  245.        0xffffff means that the default is not used any more.
  246.     MT_ST_DEF_DENSITY
  247.     MT_ST_DEF_DRVBUFFER
  248.     MT_ST_DEF_COMPRESSION
  249.        Used to set or clear the density (8 bits), drive buffer
  250.        state (3 bits), and compression (single bit). If the value is
  251.        MT_ST_CLEAR_DEFAULT (0xfffff), the default will not be used
  252.        any more. Otherwise the lower-most bits of the value contain
  253.        the new value of the parameter.
  254.  
  255. The following ioctl uses the structure mtpos:
  256. MTIOCPOS Reads the current position from the drive. Uses
  257.         Tandberg-compatible QFA for SCSI-1 drives and the SCSI-2
  258.         command for the SCSI-2 drives.
  259.  
  260. The following ioctl uses the structure mtget to return the status:
  261. MTIOCGET Returns some status information.
  262.         The file number and block number within file are returned. The
  263.         block is -1 when it can't be determined (e.g., after MTBSF).
  264.         The drive type is either MTISSCSI1 or MTISSCSI2.
  265.         The number of recovered errors since the previous status call
  266.         is stored in the lower word of the field mt_erreg.
  267.         The current block size and the density code are stored in the field
  268.         mt_dsreg (shifts for the subfields are MT_ST_BLKSIZE_SHIFT and
  269.         MT_ST_DENSITY_SHIFT).
  270.     The GMT_xxx status bits reflect the drive status. GMT_DR_OPEN
  271.     is set if there is no tape in the drive. GMT_EOD means either
  272.     end of recorded data or end of tape. GMT_EOT means end of tape.
  273.  
  274. The following ioctls use the structure mtlocation that contains both
  275. the block number and the partition number. These ioctls are available
  276. only for SCSI-2 tape drives and the block number is the
  277. device-independent logical block number defined by the standard.
  278.  
  279. MTGETLOC Returns the current block and partition number.
  280. MTSETLOC Sets the tape to the block and partition specified by the
  281.     arguments.
  282.  
  283.  
  284. MISCELLANEOUS COMPILE OPTIONS
  285.  
  286. The recovered write errors are considered fatal if ST_RECOVERED_WRITE_FATAL
  287. is defined.
  288.  
  289. The maximum number of tape devices is determined by the define
  290. ST_MAX_TAPES. If more tapes are detected at driver initialization, the
  291. maximum is adjusted accordingly.
  292.  
  293. Immediate return from tape positioning SCSI commands can be enabled by
  294. defining ST_NOWAIT. If this is defined, the user should take care that
  295. the next tape operation is not started before the previous one has
  296. finished. The drives and SCSI adapters should handle this condition
  297. gracefully, but some drive/adapter combinations are known to hang the
  298. SCSI bus in this case.
  299.  
  300. The MTEOM command is by default implemented as spacing over 32767
  301. filemarks. With this method the file number in the status is
  302. correct. The user can request using direct spacing to EOD by setting
  303. ST_FAST_EOM 1 (or using the MT_ST_OPTIONS ioctl). In this case the file
  304. number will be invalid.
  305.  
  306. When using read ahead or buffered writes the position within the file
  307. may not be correct after the file is closed (correct position may
  308. require backspacing over more than one record). The correct position
  309. within file can be obtained if ST_IN_FILE_POS is defined at compile
  310. time or the MT_ST_CAN_BSR bit is set for the drive with an ioctl.
  311. (The driver always backs over a filemark crossed by read ahead if the
  312. user does not request data that far.)
  313.  
  314. Kai M{kisara
  315.