Lines Matching refs:the
1 This file contains brief information about the SCSI tape driver.
12 one of the following three methods:
14 1. Each user can specify the tape parameters he/she wants to use
17 in a multiuser environment the next user finds the tape parameters in
18 state the previous user left them.
21 parameters, like block size and density using the MTSETDRVBUFFER ioctl.
23 new tape is loaded into the drive or if writing begins at the
24 beginning of the tape. The second method is applicable if the tape
25 drive performs auto-detection of the tape format well (like some
27 continued using existing format, and the default format is used if
28 the tape is rewritten from the beginning (or a new tape is written
29 for the first time). The first method is applicable if the drive
31 "sensible" mode for the device. An example is a DAT drive that is
35 The user can override the parameters defined by the system
36 manager. The changes persist until the defaults again come into
39 3. By default, up to four modes can be defined and selected using the minor
41 ST_NBR_MODE_BITS in st.h. Mode 0 corresponds to the defaults discussed
42 above. Additional modes are dormant until they are defined by the
44 the configuration of mode 0 is used to provide a starting point for
45 definition of the new mode.
47 Using the modes allows the system manager to give the users choices
48 over some of the buffering parameters not directly accessible to the
50 between formats in multi-tape operations (the explicitly overridden
54 for the same set of parameters.
59 program can be made that fetches the inquiry data sent by the device,
60 scans its database, and sets up the modes using the ioctls. Another
61 alternative is to make a small script that uses mt to set the defaults
62 tailored to the system.
65 limits). Both the auto-rewind (minor equals device number) and
68 In variable block mode, the byte count in write() determines the size
69 of the physical block on tape. When reading, the drive reads the next
70 tape block and returns to the user the data if the read() byte count
71 is at least the block size. Otherwise, error ENOMEM is returned.
73 In fixed block mode, the data transfer between the drive and the
74 driver is in multiples of the block size. The write() byte count must
75 be a multiple of the block size. This is not required when reading but
78 Support is provided for changing the tape partition and partitioning
79 of the tape with one or two partitions. By default support for
81 with the ioctl MTSETDRVBUFFER.
83 By default the driver writes one filemark when the device is closed after
84 writing and the last operation has been a write. Two filemarks can be
88 Writing filemarks without the immediate bit set in the SCSI command block acts
89 as a synchronization point, i.e., all remaining data form the drive buffers is
90 written to tape before the command returns. This makes sure that write errors
93 write the filemarks without flushing the drive buffer. Writing filemark at
94 close() is always flushing the drive buffers. However, if the previous
96 the program wants to close/open the tape device between files and wants to
102 The compile options are defined in the file linux/drivers/scsi/st_options.h.
104 4. If the open option O_NONBLOCK is used, open succeeds even if the
105 drive is not ready. If O_NONBLOCK is not used, the driver waits for
106 the drive to become ready. If this does not happen in ST_BLOCK_SECONDS
107 seconds, open fails with the errno value EIO. With O_NONBLOCK the
109 tape in the drive (commands trying to write something return error if
118 The minor numbers consist of the following bit fields:
122 The non-rewind bit is always bit 7 (the uppermost bit in the lowermost
123 byte). The bits defining the mode are below the non-rewind bit. The
124 remaining bits define the tape device number. This numbering is
125 backward compatible with the numbering used when the minor number was
131 The driver creates the directory /sys/class/scsi_tape and populates it with
132 directories corresponding to the existing tape devices. There are autorewind
134 is the tape number and y a character corresponding to the mode (none, l, m,
135 a). For example, the directories for the first tape device are (assuming four
138 Each directory contains the entries: default_blksize default_compression
140 if the mode is defined and zero if not defined. The files 'default_*' contain
141 the defaults set by the user. The value -1 means the default is not set. The
142 file 'dev' contains the device numbers corresponding to this device. The links
143 'device' and 'driver' point to the SCSI device and driver entries.
145 Each directory also contains the entry 'options' which shows the currently
146 enabled driver and mode options. The value in the file is a bit mask where the
147 bit definitions are the same as those used with MTSETDRVBUFFER in setting the
150 A link named 'tape' is made from the SCSI device directory to the class
151 directory corresponding to the mode 0 auto-rewind device (e.g., st0).
156 The st driver maintains statistics for tape drives inside the sysfs filesystem.
157 The following method can be used to locate the statistics that are
160 1. Use opendir(3) on the directory /sys/class/scsi_tape
161 2. Use readdir(3) to read the directory contents
162 3. Use regcomp(3)/regexec(3) to match directory entries to the extended
164 4. Access the statistics from the /sys/class/scsi_tape/<match>/stats
166 that matched the extended regular expression)
168 The reason for using this approach is that all the character devices
169 pointing to the same tape drive use the same statistics. That means
170 that st0 would have the same statistics as nst0.
172 The directory contains the following statistics files:
179 3. other_cnt - The number of I/Os issued to the tape drive other than read or
180 write commands. The time taken to complete these commands uses the
182 4. read_byte_cnt - The number of bytes read from the tape drive.
183 5. read_cnt - The number of read requests issued to the tape drive.
186 7. write_byte_cnt - The number of bytes written to the tape drive.
187 8. write_cnt - The number of write requests issued to the tape drive.
191 the residual amount to be non-zero. This should mean that a program
192 is issuing a read larger thean the block size on tape. For write
195 Note: The in_flight value is incremented when an I/O starts the I/O
196 itself is not added to the statistics until it completes.
198 The total of read_cnt, write_cnt, and other_cnt may not total to the same
199 value as iodone_cnt at the device level. The tape statistics only count
200 I/O issued via the st module.
202 When read the statistics may not be temporally consistent while I/O is in
204 when reading them back via sysfs they may be in the process of being
210 issued by the st driver. Tape statistics do not take into account any
211 I/O performed via the sg device.
215 The user can choose between these two behaviours of the tape driver by
216 defining the value of the symbol ST_SYSV. The semantics differ when a
217 file being read is closed. The BSD semantics leaves the tape where it
218 currently is whereas the SYS V semantics moves the tape past the next
219 filemark unless the filemark has just been crossed.
228 direct i/o is not possible for the whole transfer, the driver buffer
231 - one or more pages are at addresses not reachable by the HBA
232 - the number of pages in the transfer exceeds the number of
233 scatter/gather segments permitted by the HBA
237 The size of the driver buffers is always at least one tape block. In fixed
238 block mode, the minimum buffer size is defined (in 1024 byte units) by
240 several blocks and using one SCSI read or write to transfer all of the
244 size). Because of this the actual buffer size may be larger than the
247 NOTE that if direct i/o is used, the small writes are not buffered. This may
253 Asynchronous writing. Writing the buffer contents to the tape is
254 started and the write call returns immediately. The status is checked
255 at the next tape operation. Asynchronous writes are not done with
259 problems in multivolume operations if there is not enough space on the
260 tape after the early-warning mark to flush the driver buffer.
262 Read ahead for fixed block mode (ST_READ_AHEAD). Filling the buffer is
263 attempted even if the user does not want to get all of the data at
268 in the physical memory) are used if contiguous buffers can't be
270 supporting scatter/gather), buffer allocation is using the following
274 (PAGE_SIZE << ST_FIRST_ORDER) bytes if the system can give a chunk of
275 this size (and it is not larger than the buffer size specified by
276 ST_BUFFER_BLOCKS). If this size is not available, the driver halves
277 the size and tries again until the size of one page. The default
278 settings in st_options.h make the driver to try to allocate all of the
280 2. The scatter/gather segments to fill the specified buffer size are
281 allocated so that as many segments as possible are used but the number
283 3. The remaining segments between ST_MAX_SG (or the module parameter
284 max_sg_segs) and the number of segments used in phases 1 and 2
285 are used to extend the buffer at run-time if this is necessary. The
286 number of scatter/gather segments allowed for the SCSI adapter is not
287 exceeded if it is smaller than the maximum number of scatter/gather
288 segments specified. If the maximum number allowed for the SCSI adapter
289 is smaller than the number of segments used in phases 1 and 2,
290 extending the buffer will always fail.
295 When the end of medium early warning is encountered, the current write
296 is finished and the number of bytes is returned. The next write
298 the next write is allowed to proceed and, if successful, the number of
299 bytes is returned. After this, -1 and the number of bytes are
300 alternately returned until the physical end of medium (or some other
306 The buffer size, write threshold, and the maximum number of allocated buffers
307 are configurable when the driver is loaded as a module. The keywords are:
309 buffer_kbs=xxx the buffer size for fixed block mode is set
311 write_threshold_kbs=xxx the write threshold in kilobytes set to xxx
312 max_sg_segs=xxx the maximum number of scatter/gather
317 Note that if the buffer size is changed but the write threshold is not
318 set, the write threshold is set to the new buffer size - 2 kB.
323 If the driver is compiled into the kernel, the same parameters can be
324 also set using, e.g., the LILO command line. The preferred syntax is
325 to use the same keyword used when loading as module but prepended
326 with 'st.'. For instance, to set the maximum number of scatter/gather
327 segments, the parameter 'st.max_sg_segs=xx' should be used (xx is the
330 For compatibility, the old syntax from early 2.5 and 2.4 kernel
332 the driver as module. If several parameters are set, the keyword-value
334 used instead of the equal mark. The definition is prepended by the
339 The following syntax used by the old kernel versions is also supported:
344 aa is the buffer size for fixed block mode in 1024 byte units
345 bb is the write threshold in 1024 byte units
346 dd is the maximum number of scatter/gather segments
351 The tape is positioned and the drive parameters are set with ioctls
353 to find an mt that supports all of the Linux SCSI tape ioctls and
354 opens the device for writing if the tape contents will be modified
355 (look for a package mt-st* from the Linux ftp sites; the GNU mt does
360 The following use the structure mtop:
377 MTNOP Do nothing except flush the buffers.
380 MTERASE Erase tape. If the argument is zero, the short erase command
382 of the argument.
385 block numbers in the status are not valid after a seek.
386 MTSETBLK Set the drive block size. Setting to zero sets the drive into
388 MTSETDENSITY Sets the drive density code to arg. See drive
390 MTLOCK and MTUNLOCK Explicitly lock/unlock the tape drive door.
391 MTLOAD and MTUNLOAD Explicitly load and unload the tape. If the
393 MT_ST_HPLOADER_OFFSET + 6, the number x is used sent to the
394 drive with the command and it selects the tape slot to use of
396 MTCOMPRESSION Sets compressing or uncompressing drive mode using the
398 control of compression. Some drives (like the Exabytes) use
400 mode page but this page has not been implemented in the
403 MTSETPART Moves the tape to the partition given by the argument at the
404 next tape operation. The block at which the tape is positioned
405 is the block where the tape was previously positioned in the
406 new active partition unless the next tape operation is
407 MTSEEK. In this case the tape is moved directly to the block
410 MTMKPART Formats the tape with one partition (argument zero) or two
411 partitions (the argument gives in megabytes the size of
412 partition 1 that is physically the first partition of the
414 by the initiator. Inactive unless MT_ST_CAN_PARTITIONS set.
417 with mask MT_SET_OPTIONS, the low order bits are used as argument.
418 This command is only allowed for the superuser (root). The
421 The drive buffer option is set to the argument. Zero means
424 Sets the buffering options. The bits are the new states
425 (enabled/disabled) the following options (in the
426 parenthesis is specified whether the option is global or
432 MT_ST_FAST_EOM using the SCSI spacing to EOD (global)
433 MT_ST_AUTO_LOCK automatic locking of the drive door (global)
434 MT_ST_DEF_WRITES the defaults are meant only for writes (mode)
436 be used for repositioning the tape (global)
437 MT_ST_NO_BLKLIMS the driver does not ask the block limits
438 from the drive (block size can be changed only to
442 MT_ST_SCSI2LOGICAL the logical block number is used in
443 the MTSEEK and MTIOCPOS for SCSI-2 drives instead of
444 the device dependent address. It is recommended to set
445 this flag unless there are tapes using the device
446 dependent (from the old times) (global)
447 MT_ST_SYSV sets the SYSV semantics (mode)
449 the command to finish) for some commands (e.g., rewind)
452 see the BASICS note about MTWEOFI with respect to the
454 MT_ST_SILI enables setting the SILI bit in SCSI commands when
456 reading blocks shorter than the byte count; set this only
457 if you are sure that the drive supports SILI and the HBA
460 compiled into the driver)
463 Sets or clears the option bits.
465 Sets the write threshold for this device to kilobytes
466 specified by the lowest bits.
468 Defines the default block size set automatically. Value
469 0xffffff means that the default is not used any more.
472 Used to set or clear the density (8 bits), and drive buffer
473 state (3 bits). If the value is MT_ST_CLEAR_DEFAULT
474 (0xfffff) the default will not be used any more. Otherwise
475 the lowermost bits of the value contain the new value of
476 the parameter.
478 The compression default will not be used if the value of
479 the lowermost byte is 0xff. Otherwise the lowermost bit
480 contains the new default. If the bits 8-15 are set to a
481 non-zero number, and this number is not 0xff, the number is
482 used as the compression algorithm. The value
483 MT_ST_CLEAR_DEFAULT can be used to clear the compression
486 Set the normal timeout in seconds for this device. The
488 long enough for the retries done by the device while
491 Set the long timeout that is used for operations that are
496 Set the cleaning request interpretation parameters using
497 the lowest 24 bits of the argument. The driver can set the
499 is found from the extended sense data. Many drives set one or
500 more bits in the extended sense data when the drive needs
502 given the number of the sense data byte (the lowest eight
503 bits of the argument; must be >= 18 (values 1 - 17
504 reserved) and <= the maximum requested sense data sixe),
505 a mask to select the relevant bits (the bits 9-16), and the
506 bit pattern (bits 17-23). If the bit pattern is zero, one
507 or more bits under the mask indicate cleaning request. If
508 the pattern is non-zero, the pattern must match the masked
511 (The cleaning bit is set if the additional sense code and
512 qualifier 00h 17h are seen regardless of the setting of
515 The following ioctl uses the structure mtpos:
516 MTIOCPOS Reads the current position from the drive. Uses
517 Tandberg-compatible QFA for SCSI-1 drives and the SCSI-2
518 command for the SCSI-2 drives.
520 The following ioctl uses the structure mtget to return the status:
525 The number of recovered errors since the previous status call
526 is stored in the lower word of the field mt_erreg.
527 The current block size and the density code are stored in the field
528 mt_dsreg (shifts for the subfields are MT_ST_BLKSIZE_SHIFT and
530 The GMT_xxx status bits reflect the drive status. GMT_DR_OPEN
531 is set if there is no tape in the drive. GMT_EOD means either
540 The maximum number of tape devices is determined by the define
541 ST_MAX_TAPES. If more tapes are detected at driver initialization, the
545 defining ST_NOWAIT. If this is defined, the user should take care that
546 the next tape operation is not started before the previous one has
548 gracefully, but some drive/adapter combinations are known to hang the
552 filemarks. With this method the file number in the status is
554 ST_FAST_EOM 1 (or using the MT_ST_OPTIONS ioctl). In this case the file
557 When using read ahead or buffered writes the position within the file
558 may not be correct after the file is closed (correct position may
561 time or the MT_ST_CAN_BSR bit is set for the drive with an ioctl.
562 (The driver always backs over a filemark crossed by read ahead if the
569 with the kernel module parameter debug_flag defaulting to 0. Debugging
571 module load time add debug_flag=1 to the module load options, the
573 and disabled by writing a '0' (disable) or '1' (enable) to the sysfs
576 If the tape seems to hang, I would be very interested to hear where
577 the driver is waiting. With the command 'ps -l' you can see the state
578 of the process using the tape. If the state is D, the process is
579 waiting for something. The field WCHAN tells where the driver is
580 waiting. If you have the current System.map in the correct place (in
581 /boot for the procps I use) or have updated /etc/psdatabase (for kmem
582 ps), ps writes the function name in the WCHAN field. If not, you have
583 to look up the function from System.map.
585 Note also that the timeouts are very long compared to most other
586 drivers. This means that the Linux driver may appear hung although the
587 real reason is that the tape firmware has got confused.