Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) The SCSI Tape Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) This file contains brief information about the SCSI tape driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) The driver is currently maintained by Kai Mäkisara (email
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Kai.Makisara@kolumbus.fi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) Last modified: Tue Feb  9 21:54:16 2016 by kai.makisara
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) Basics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) The driver is generic, i.e., it does not contain any code tailored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) to any specific tape drive. The tape parameters can be specified with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) one of the following three methods:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 1. Each user can specify the tape parameters he/she wants to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) directly with ioctls. This is administratively a very simple and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) flexible method and applicable to single-user workstations. However,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) in a multiuser environment the next user finds the tape parameters in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) state the previous user left them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 2. The system manager (root) can define default values for some tape
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) parameters, like block size and density using the MTSETDRVBUFFER ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) These parameters can be programmed to come into effect either when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) new tape is loaded into the drive or if writing begins at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) beginning of the tape. The second method is applicable if the tape
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) drive performs auto-detection of the tape format well (like some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) QIC-drives). The result is that any tape can be read, writing can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) continued using existing format, and the default format is used if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) the tape is rewritten from the beginning (or a new tape is written
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) for the first time). The first method is applicable if the drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) does not perform auto-detection well enough and there is a single
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) "sensible" mode for the device. An example is a DAT drive that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) used only in variable block mode (I don't know if this is sensible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) or not :-).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) The user can override the parameters defined by the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) manager. The changes persist until the defaults again come into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 3. By default, up to four modes can be defined and selected using the minor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) number (bits 5 and 6). The number of modes can be changed by changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) ST_NBR_MODE_BITS in st.h. Mode 0 corresponds to the defaults discussed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) above. Additional modes are dormant until they are defined by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) system manager (root). When specification of a new mode is started,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) the configuration of mode 0 is used to provide a starting point for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) definition of the new mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) Using the modes allows the system manager to give the users choices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) over some of the buffering parameters not directly accessible to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) users (buffered and asynchronous writes). The modes also allow choices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) between formats in multi-tape operations (the explicitly overridden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) parameters are reset when a new tape is loaded).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) If more than one mode is used, all modes should contain definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) for the same set of parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) Many Unices contain internal tables that associate different modes to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) supported devices. The Linux SCSI tape driver does not contain such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) tables (and will not do that in future). Instead of that, a utility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) program can be made that fetches the inquiry data sent by the device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) scans its database, and sets up the modes using the ioctls. Another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) alternative is to make a small script that uses mt to set the defaults
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) tailored to the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) The driver supports fixed and variable block size (within buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) limits). Both the auto-rewind (minor equals device number) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) non-rewind devices (minor is 128 + device number) are implemented.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) In variable block mode, the byte count in write() determines the size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) of the physical block on tape. When reading, the drive reads the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) tape block and returns to the user the data if the read() byte count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) is at least the block size. Otherwise, error ENOMEM is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) In fixed block mode, the data transfer between the drive and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) driver is in multiples of the block size. The write() byte count must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) be a multiple of the block size. This is not required when reading but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) may be advisable for portability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) Support is provided for changing the tape partition and partitioning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) of the tape with one or two partitions. By default support for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) partitioned tape is disabled for each driver and it can be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) with the ioctl MTSETDRVBUFFER.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) By default the driver writes one filemark when the device is closed after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) writing and the last operation has been a write. Two filemarks can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) optionally written. In both cases end of data is signified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) returning zero bytes for two consecutive reads.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) Writing filemarks without the immediate bit set in the SCSI command block acts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) as a synchronization point, i.e., all remaining data form the drive buffers is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) written to tape before the command returns. This makes sure that write errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) are caught at that point, but this takes time. In some applications, several
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) consecutive files must be written fast. The MTWEOFI operation can be used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) write the filemarks without flushing the drive buffer. Writing filemark at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) close() is always flushing the drive buffers. However, if the previous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) operation is MTWEOFI, close() does not write a filemark. This can be used if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) the program wants to close/open the tape device between files and wants to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) skip waiting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) If rewind, offline, bsf, or seek is done and previous tape operation was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) write, a filemark is written before moving tape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) The compile options are defined in the file linux/drivers/scsi/st_options.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 4. If the open option O_NONBLOCK is used, open succeeds even if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) drive is not ready. If O_NONBLOCK is not used, the driver waits for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) the drive to become ready. If this does not happen in ST_BLOCK_SECONDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) seconds, open fails with the errno value EIO. With O_NONBLOCK the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) device can be opened for writing even if there is a write protected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) tape in the drive (commands trying to write something return error if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) attempted).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Minor Numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) The tape driver currently supports up to 2^17 drives if 4 modes for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) each drive are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) The minor numbers consist of the following bit fields::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)     dev_upper non-rew mode dev-lower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)     20 -  8     7    6 5  4      0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) The non-rewind bit is always bit 7 (the uppermost bit in the lowermost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) byte). The bits defining the mode are below the non-rewind bit. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) remaining bits define the tape device number. This numbering is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) backward compatible with the numbering used when the minor number was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) only 8 bits wide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) Sysfs Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) The driver creates the directory /sys/class/scsi_tape and populates it with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) directories corresponding to the existing tape devices. There are autorewind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) and non-rewind entries for each mode. The names are stxy and nstxy, where x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) is the tape number and y a character corresponding to the mode (none, l, m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) a). For example, the directories for the first tape device are (assuming four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) modes): st0  nst0  st0l  nst0l  st0m  nst0m  st0a  nst0a.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) Each directory contains the entries: default_blksize  default_compression
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) default_density  defined  dev  device  driver. The file 'defined' contains 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if the mode is defined and zero if not defined. The files 'default_*' contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) the defaults set by the user. The value -1 means the default is not set. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) file 'dev' contains the device numbers corresponding to this device. The links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 'device' and 'driver' point to the SCSI device and driver entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) Each directory also contains the entry 'options' which shows the currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) enabled driver and mode options. The value in the file is a bit mask where the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) bit definitions are the same as those used with MTSETDRVBUFFER in setting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) A link named 'tape' is made from the SCSI device directory to the class
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) directory corresponding to the mode 0 auto-rewind device (e.g., st0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) Sysfs and Statistics for Tape Devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) =====================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) The st driver maintains statistics for tape drives inside the sysfs filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) The following method can be used to locate the statistics that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) available (assuming that sysfs is mounted at /sys):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 1. Use opendir(3) on the directory /sys/class/scsi_tape
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 2. Use readdir(3) to read the directory contents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 3. Use regcomp(3)/regexec(3) to match directory entries to the extended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)    regular expression "^st[0-9]+$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 4. Access the statistics from the /sys/class/scsi_tape/<match>/stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)    directory (where <match> is a directory entry from /sys/class/scsi_tape
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)    that matched the extended regular expression)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) The reason for using this approach is that all the character devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) pointing to the same tape drive use the same statistics. That means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) that st0 would have the same statistics as nst0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) The directory contains the following statistics files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 1.  in_flight
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)       - The number of I/Os currently outstanding to this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 2.  io_ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)       - The amount of time spent waiting (in nanoseconds) for all I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)         to complete (including read and write). This includes tape movement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)         commands such as seeking between file or set marks and implicit tape
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)         movement such as when rewind on close tape devices are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 3.  other_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)       - The number of I/Os issued to the tape drive other than read or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)         write commands. The time taken to complete these commands uses the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)         following calculation io_ms-read_ms-write_ms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 4.  read_byte_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)       - The number of bytes read from the tape drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 5.  read_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)       - The number of read requests issued to the tape drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 6.  read_ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)       - The amount of time (in nanoseconds) spent waiting for read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)         requests to complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 7.  write_byte_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)       - The number of bytes written to the tape drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 8.  write_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)       - The number of write requests issued to the tape drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 9.  write_ns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)       - The amount of time (in nanoseconds) spent waiting for write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)         requests to complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 10. resid_cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)       - The number of times during a read or write we found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	the residual amount to be non-zero. This should mean that a program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	is issuing a read larger thean the block size on tape. For write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	not all data made it to tape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) .. Note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)    The in_flight value is incremented when an I/O starts the I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)    itself is not added to the statistics until it completes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) The total of read_cnt, write_cnt, and other_cnt may not total to the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) value as iodone_cnt at the device level. The tape statistics only count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) I/O issued via the st module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) When read the statistics may not be temporally consistent while I/O is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) progress. The individual values are read and written to atomically however
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) when reading them back via sysfs they may be in the process of being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) updated when starting an I/O or when it is completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) The value shown in in_flight is incremented before any statstics are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) updated and decremented when an I/O completes after updating statistics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) The value of in_flight is 0 when there are no I/Os outstanding that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) issued by the st driver. Tape statistics do not take into account any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) I/O performed via the sg device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) BSD and Sys V Semantics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) The user can choose between these two behaviours of the tape driver by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) defining the value of the symbol ST_SYSV. The semantics differ when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) file being read is closed. The BSD semantics leaves the tape where it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) currently is whereas the SYS V semantics moves the tape past the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) filemark unless the filemark has just been crossed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) The default is BSD semantics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) Buffering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) The driver tries to do transfers directly to/from user space. If this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) is not possible, a driver buffer allocated at run-time is used. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) direct i/o is not possible for the whole transfer, the driver buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) is used (i.e., bounce buffers for individual pages are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) used). Direct i/o can be impossible because of several reasons, e.g.:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) - one or more pages are at addresses not reachable by the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) - the number of pages in the transfer exceeds the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)   scatter/gather segments permitted by the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) - one or more pages can't be locked into memory (should not happen in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)   any reasonable situation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) The size of the driver buffers is always at least one tape block. In fixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) block mode, the minimum buffer size is defined (in 1024 byte units) by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ST_FIXED_BUFFER_BLOCKS. With small block size this allows buffering of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) several blocks and using one SCSI read or write to transfer all of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) blocks. Buffering of data across write calls in fixed block mode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) allowed if ST_BUFFER_WRITES is non-zero and direct i/o is not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) Buffer allocation uses chunks of memory having sizes 2^n * (page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) size). Because of this the actual buffer size may be larger than the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) minimum allowable buffer size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) NOTE that if direct i/o is used, the small writes are not buffered. This may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) cause a surprise when moving from 2.4. There small writes (e.g., tar without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) -b option) may have had good throughput but this is not true any more with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 2.6. Direct i/o can be turned off to solve this problem but a better solution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) is to use bigger write() byte counts (e.g., tar -b 64).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) Asynchronous writing. Writing the buffer contents to the tape is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) started and the write call returns immediately. The status is checked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) at the next tape operation. Asynchronous writes are not done with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) direct i/o and not in fixed block mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) Buffered writes and asynchronous writes may in some rare cases cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) problems in multivolume operations if there is not enough space on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) tape after the early-warning mark to flush the driver buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) Read ahead for fixed block mode (ST_READ_AHEAD). Filling the buffer is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) attempted even if the user does not want to get all of the data at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) this read command. Should be disabled for those drives that don't like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) a filemark to truncate a read request or that don't like backspacing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) Scatter/gather buffers (buffers that consist of chunks non-contiguous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) in the physical memory) are used if contiguous buffers can't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) allocated. To support all SCSI adapters (including those not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) supporting scatter/gather), buffer allocation is using the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) three kinds of chunks:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 1. The initial segment that is used for all SCSI adapters including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)    those not supporting scatter/gather. The size of this buffer will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)    (PAGE_SIZE << ST_FIRST_ORDER) bytes if the system can give a chunk of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)    this size (and it is not larger than the buffer size specified by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)    ST_BUFFER_BLOCKS). If this size is not available, the driver halves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)    the size and tries again until the size of one page. The default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)    settings in st_options.h make the driver to try to allocate all of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)    buffer as one chunk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 2. The scatter/gather segments to fill the specified buffer size are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)    allocated so that as many segments as possible are used but the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)    of segments does not exceed ST_FIRST_SG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 3. The remaining segments between ST_MAX_SG (or the module parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)    max_sg_segs) and the number of segments used in phases 1 and 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)    are used to extend the buffer at run-time if this is necessary. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)    number of scatter/gather segments allowed for the SCSI adapter is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)    exceeded if it is smaller than the maximum number of scatter/gather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)    segments specified. If the maximum number allowed for the SCSI adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)    is smaller than the number of segments used in phases 1 and 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)    extending the buffer will always fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) EOM Behaviour When Writing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) When the end of medium early warning is encountered, the current write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) is finished and the number of bytes is returned. The next write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) returns -1 and errno is set to ENOSPC. To enable writing a trailer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) the next write is allowed to proceed and, if successful, the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) bytes is returned. After this, -1 and the number of bytes are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) alternately returned until the physical end of medium (or some other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) error) is encountered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) Module Parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) The buffer size, write threshold, and the maximum number of allocated buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) are configurable when the driver is loaded as a module. The keywords are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) ========================== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) buffer_kbs=xxx             the buffer size for fixed block mode is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 			   to xxx kilobytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) write_threshold_kbs=xxx    the write threshold in kilobytes set to xxx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) max_sg_segs=xxx		   the maximum number of scatter/gather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 			   segments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) try_direct_io=x		   try direct transfer between user buffer and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 			   tape drive if this is non-zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) ========================== ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) Note that if the buffer size is changed but the write threshold is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) set, the write threshold is set to the new buffer size - 2 kB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) Boot Time Configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) If the driver is compiled into the kernel, the same parameters can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) also set using, e.g., the LILO command line. The preferred syntax is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) to use the same keyword used when loading as module but prepended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) with 'st.'. For instance, to set the maximum number of scatter/gather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) segments, the parameter 'st.max_sg_segs=xx' should be used (xx is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) number of scatter/gather segments).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) For compatibility, the old syntax from early 2.5 and 2.4 kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) versions is supported. The same keywords can be used as when loading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) the driver as module. If several parameters are set, the keyword-value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) pairs are separated with a comma (no spaces allowed). A colon can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) used instead of the equal mark. The definition is prepended by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) string st=. Here is an example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	st=buffer_kbs:64,write_threshold_kbs:60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) The following syntax used by the old kernel versions is also supported::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)            st=aa[,bb[,dd]]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) where:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)   - aa is the buffer size for fixed block mode in 1024 byte units
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)   - bb is the write threshold in 1024 byte units
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)   - dd is the maximum number of scatter/gather segments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) IOCTLs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) The tape is positioned and the drive parameters are set with ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) defined in mtio.h The tape control program 'mt' uses these ioctls. Try
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) to find an mt that supports all of the Linux SCSI tape ioctls and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) opens the device for writing if the tape contents will be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) (look for a package mt-st* from the Linux ftp sites; the GNU mt does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) not open for writing for, e.g., erase).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) The supported ioctls are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) The following use the structure mtop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) MTFSF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	Space forward over count filemarks. Tape positioned after filemark.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) MTFSFM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	As above but tape positioned before filemark.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) MTBSF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	Space backward over count filemarks. Tape positioned before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)         filemark.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) MTBSFM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	As above but ape positioned after filemark.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) MTFSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	Space forward over count records.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) MTBSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	Space backward over count records.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) MTFSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	Space forward over count setmarks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) MTBSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	Space backward over count setmarks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) MTWEOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	Write count filemarks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) MTWEOFI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	Write count filemarks with immediate bit set (i.e., does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	wait until data is on tape)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) MTWSM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	Write count setmarks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) MTREW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	Rewind tape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) MTOFFL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	Set device off line (often rewind plus eject).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) MTNOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	Do nothing except flush the buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) MTRETEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	Re-tension tape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) MTEOM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	Space to end of recorded data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) MTERASE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	Erase tape. If the argument is zero, the short erase command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	is used. The long erase command is used with all other values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	of the argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) MTSEEK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	Seek to tape block count. Uses Tandberg-compatible seek (QFA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)         for SCSI-1 drives and SCSI-2 seek for SCSI-2 drives. The file and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	block numbers in the status are not valid after a seek.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) MTSETBLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	Set the drive block size. Setting to zero sets the drive into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)         variable block mode (if applicable).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) MTSETDENSITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	Sets the drive density code to arg. See drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)         documentation for available codes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) MTLOCK and MTUNLOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	Explicitly lock/unlock the tape drive door.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) MTLOAD and MTUNLOAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	Explicitly load and unload the tape. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	command argument x is between MT_ST_HPLOADER_OFFSET + 1 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	MT_ST_HPLOADER_OFFSET + 6, the number x is used sent to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	drive with the command and it selects the tape slot to use of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	HP C1553A changer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) MTCOMPRESSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	Sets compressing or uncompressing drive mode using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	SCSI mode page 15. Note that some drives other methods for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	control of compression. Some drives (like the Exabytes) use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	density codes for compression control. Some drives use another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	mode page but this page has not been implemented in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	driver. Some drives without compression capability will accept
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	any compression mode without error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) MTSETPART
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	Moves the tape to the partition given by the argument at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	next tape operation. The block at which the tape is positioned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	is the block where the tape was previously positioned in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	new active partition unless the next tape operation is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	MTSEEK. In this case the tape is moved directly to the block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	specified by MTSEEK. MTSETPART is inactive unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	MT_ST_CAN_PARTITIONS set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) MTMKPART
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	Formats the tape with one partition (argument zero) or two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	partitions (argument non-zero). If the argument is positive,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	it specifies the size of partition 1 in megabytes. For DDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	drives and several early drives this is the physically first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	partition of the tape. If the argument is negative, its absolute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	value specifies the size of partition 0 in megabytes. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	the physically first partition of many later drives, like the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	LTO drives from LTO-5 upwards. The drive has to support partitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	with size specified by the initiator. Inactive unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	MT_ST_CAN_PARTITIONS set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) MTSETDRVBUFFER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	Is used for several purposes. The command is obtained from count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)         with mask MT_SET_OPTIONS, the low order bits are used as argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	This command is only allowed for the superuser (root). The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	subcommands are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	* 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)            The drive buffer option is set to the argument. Zero means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)            no buffering.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)         * MT_ST_BOOLEANS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)            Sets the buffering options. The bits are the new states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)            (enabled/disabled) the following options (in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	   parenthesis is specified whether the option is global or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	   can be specified differently for each mode):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	     MT_ST_BUFFER_WRITES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		write buffering (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	     MT_ST_ASYNC_WRITES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		asynchronous writes (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)              MT_ST_READ_AHEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		read ahead (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)              MT_ST_TWO_FM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		writing of two filemarks (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	     MT_ST_FAST_EOM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		using the SCSI spacing to EOD (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	     MT_ST_AUTO_LOCK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		automatic locking of the drive door (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)              MT_ST_DEF_WRITES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		the defaults are meant only for writes (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	     MT_ST_CAN_BSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		backspacing over more than one records can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		be used for repositioning the tape (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	     MT_ST_NO_BLKLIMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		the driver does not ask the block limits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		from the drive (block size can be changed only to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		variable) (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	     MT_ST_CAN_PARTITIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		enables support for partitioned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		tapes (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	     MT_ST_SCSI2LOGICAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		the logical block number is used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		the MTSEEK and MTIOCPOS for SCSI-2 drives instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		the device dependent address. It is recommended to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		this flag unless there are tapes using the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		dependent (from the old times) (global)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	     MT_ST_SYSV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		sets the SYSV semantics (mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	     MT_ST_NOWAIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		enables immediate mode (i.e., don't wait for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	        the command to finish) for some commands (e.g., rewind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	     MT_ST_NOWAIT_EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		enables immediate filemark mode (i.e. when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	        writing a filemark, don't wait for it to complete). Please
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		see the BASICS note about MTWEOFI with respect to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		possible dangers of writing immediate filemarks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	     MT_ST_SILI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		enables setting the SILI bit in SCSI commands when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 		reading in variable block mode to enhance performance when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		reading blocks shorter than the byte count; set this only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 		if you are sure that the drive supports SILI and the HBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 		correctly returns transfer residuals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	     MT_ST_DEBUGGING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 		debugging (global; debugging must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		compiled into the driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	* MT_ST_SETBOOLEANS, MT_ST_CLEARBOOLEANS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	   Sets or clears the option bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)         * MT_ST_WRITE_THRESHOLD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)            Sets the write threshold for this device to kilobytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)            specified by the lowest bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	* MT_ST_DEF_BLKSIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	   Defines the default block size set automatically. Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	   0xffffff means that the default is not used any more.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	* MT_ST_DEF_DENSITY, MT_ST_DEF_DRVBUFFER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	   Used to set or clear the density (8 bits), and drive buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	   state (3 bits). If the value is MT_ST_CLEAR_DEFAULT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	   (0xfffff) the default will not be used any more. Otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	   the lowermost bits of the value contain the new value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	   the parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	* MT_ST_DEF_COMPRESSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	   The compression default will not be used if the value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	   the lowermost byte is 0xff. Otherwise the lowermost bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	   contains the new default. If the bits 8-15 are set to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	   non-zero number, and this number is not 0xff, the number is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	   used as the compression algorithm. The value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	   MT_ST_CLEAR_DEFAULT can be used to clear the compression
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	   default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	* MT_ST_SET_TIMEOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	   Set the normal timeout in seconds for this device. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	   default is 900 seconds (15 minutes). The timeout should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	   long enough for the retries done by the device while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	   reading/writing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	* MT_ST_SET_LONG_TIMEOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	   Set the long timeout that is used for operations that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	   known to take a long time. The default is 14000 seconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	   (3.9 hours). For erase this value is further multiplied by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	   eight.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	* MT_ST_SET_CLN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	   Set the cleaning request interpretation parameters using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	   the lowest 24 bits of the argument. The driver can set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	   generic status bit GMT_CLN if a cleaning request bit pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	   is found from the extended sense data. Many drives set one or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	   more bits in the extended sense data when the drive needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	   cleaning. The bits are device-dependent. The driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	   given the number of the sense data byte (the lowest eight
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	   bits of the argument; must be >= 18 (values 1 - 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	   reserved) and <= the maximum requested sense data sixe),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	   a mask to select the relevant bits (the bits 9-16), and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	   bit pattern (bits 17-23). If the bit pattern is zero, one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	   or more bits under the mask indicate cleaning request. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	   the pattern is non-zero, the pattern must match the masked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	   sense data byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	   (The cleaning bit is set if the additional sense code and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	   qualifier 00h 17h are seen regardless of the setting of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	   MT_ST_SET_CLN.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) The following ioctl uses the structure mtpos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) MTIOCPOS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	Reads the current position from the drive. Uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)         Tandberg-compatible QFA for SCSI-1 drives and the SCSI-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)         command for the SCSI-2 drives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) The following ioctl uses the structure mtget to return the status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) MTIOCGET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	Returns some status information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)         The file number and block number within file are returned. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)         block is -1 when it can't be determined (e.g., after MTBSF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)         The drive type is either MTISSCSI1 or MTISSCSI2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)         The number of recovered errors since the previous status call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)         is stored in the lower word of the field mt_erreg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)         The current block size and the density code are stored in the field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)         mt_dsreg (shifts for the subfields are MT_ST_BLKSIZE_SHIFT and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)         MT_ST_DENSITY_SHIFT).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	The GMT_xxx status bits reflect the drive status. GMT_DR_OPEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	is set if there is no tape in the drive. GMT_EOD means either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	end of recorded data or end of tape. GMT_EOT means end of tape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) Miscellaneous Compile Options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) The recovered write errors are considered fatal if ST_RECOVERED_WRITE_FATAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) is defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) The maximum number of tape devices is determined by the define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) ST_MAX_TAPES. If more tapes are detected at driver initialization, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) maximum is adjusted accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) Immediate return from tape positioning SCSI commands can be enabled by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) defining ST_NOWAIT. If this is defined, the user should take care that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) the next tape operation is not started before the previous one has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) finished. The drives and SCSI adapters should handle this condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) gracefully, but some drive/adapter combinations are known to hang the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) SCSI bus in this case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) The MTEOM command is by default implemented as spacing over 32767
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) filemarks. With this method the file number in the status is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) correct. The user can request using direct spacing to EOD by setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) ST_FAST_EOM 1 (or using the MT_ST_OPTIONS ioctl). In this case the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) number will be invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) When using read ahead or buffered writes the position within the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) may not be correct after the file is closed (correct position may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) require backspacing over more than one record). The correct position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) within file can be obtained if ST_IN_FILE_POS is defined at compile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) time or the MT_ST_CAN_BSR bit is set for the drive with an ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) (The driver always backs over a filemark crossed by read ahead if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) user does not request data that far.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) Debugging Hints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) Debugging code is now compiled in by default but debugging is turned off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) with the kernel module parameter debug_flag defaulting to 0.  Debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) can still be switched on and off with an ioctl.  To enable debug at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) module load time add debug_flag=1 to the module load options, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) debugging output is not voluminous. Debugging can also be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) and disabled by writing a '0' (disable) or '1' (enable) to the sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) file /sys/bus/scsi/drivers/st/debug_flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) If the tape seems to hang, I would be very interested to hear where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) the driver is waiting. With the command 'ps -l' you can see the state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) of the process using the tape. If the state is D, the process is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) waiting for something. The field WCHAN tells where the driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) waiting. If you have the current System.map in the correct place (in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) /boot for the procps I use) or have updated /etc/psdatabase (for kmem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) ps), ps writes the function name in the WCHAN field. If not, you have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) to look up the function from System.map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) Note also that the timeouts are very long compared to most other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) drivers. This means that the Linux driver may appear hung although the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) real reason is that the tape firmware has got confused.