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