Cleanup remaining tsleep priority issues.
[dragonfly.git] / share / man / man4 / sa.4
1 .\" Copyright (c) 1996
2 .\"     Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\"
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/share/man/man4/sa.4,v 1.22.2.7 2001/08/17 13:08:39 ru Exp $
27 .\" $DragonFly: src/share/man/man4/sa.4,v 1.2 2003/06/17 04:36:59 dillon Exp $
28 .\"
29 .Dd June 6, 1999
30 .Dt SA 4
31 .Os
32 .Sh NAME
33 .Nm sa
34 .Nd SCSI Sequential Access device driver
35 .Sh SYNOPSIS
36 .Cd device sa
37 .Cd device sa1 at scbus0 target 4 unit 0
38 .Sh DESCRIPTION
39 The
40 .Nm
41 driver provides support for all
42 .Tn SCSI
43 devices of the sequential access class that are attached to the system
44 through a supported
45 .Tn SCSI
46 Host Adapter.
47 The sequential access class includes tape and other linear access devices.
48 .Pp
49 A
50 .Tn SCSI
51 Host
52 adapter must also be separately configured into the system
53 before a
54 .Tn SCSI
55 sequential access device can be configured.
56 .Sh MOUNT SESSIONS
57 The
58 .Nm
59 driver is based around the concept of a
60 .Dq Em mount session ,
61 which is defined as the period between the time that a tape is
62 mounted, and the time when it is unmounted.  Any parameters set during
63 a mount session remain in effect for the remainder of the session or
64 until replaced.
65 The tape can be unmounted, bringing the session to a
66 close in several ways.  These include:
67 .Bl -enum
68 .It
69 Closing a `rewind device',
70 referred to as sub-mode 00 below.
71 An example is
72 .Pa /dev/sa0 .
73 .It
74 Using the MTOFFL
75 .Xr ioctl 2
76 command, reachable through the
77 .Sq Cm offline
78 command of
79 .Xr mt 1 .
80 .El
81 .Pp
82 It should be noted that tape devices are exclusive open devices, except in
83 the case where a control mode device is opened.
84 In the latter case, exclusive
85 access is only sought when needed (e.g., to set parameters).
86 .Sh SUB-MODES
87 Bits 0 and 1 of the minor number are interpreted as
88 .Sq sub-modes .
89 The sub-modes differ in the action taken when the device is closed:
90 .Bl -tag -width XXXX
91 .It 00
92 A close will rewind the device; if the tape has been
93 written, then a file mark will be written before the rewind is requested.
94 The device is unmounted.
95 .It 01
96 A close will leave the tape mounted.
97 If the tape was written to, a file mark will be written.
98 No other head positioning takes place.
99 Any further reads or writes will occur directly after the
100 last read, or the written file mark.
101 .It 10
102 A close will rewind the device.
103 If the tape has been
104 written, then a file mark will be written before the rewind is requested.
105 On completion of the rewind an unload command will be issued.
106 The device is unmounted.
107 .El
108 .Sh BLOCKING MODES
109 .Tn SCSI
110 tapes may run in either
111 .Sq Em variable
112 or
113 .Sq Em fixed
114 block-size modes.  Most
115 .Tn QIC Ns -type
116 devices run in fixed block-size mode, where most nine-track tapes and
117 many new cartridge formats allow variable block-size.  The difference
118 between the two is as follows:
119 .Bl -inset
120 .It Variable block-size:
121 Each write made to the device results in a single logical record
122 written to the tape.  One can never read or write
123 .Em part
124 of a record from tape (though you may request a larger block and read
125 a smaller record); nor can one read multiple blocks.  Data from a
126 single write is therefore read by a single read.
127 The block size used
128 may be any value supported by the device, the
129 .Tn SCSI
130 adapter and the system (usually between 1 byte and 64 Kbytes,
131 sometimes more).
132 .Pp
133 When reading a variable record/block from the tape, the head is
134 logically considered to be immediately after the last item read,
135 and before the next item after that.
136 If the next item is a file mark,
137 but it was never read, then the next
138 process to read will immediately hit the file mark and receive an end-of-file notification.
139 .It Fixed block-size:
140 Data written by the user is passed to the tape as a succession of
141 fixed size blocks.  It may be contiguous in memory, but it is
142 considered to be a series of independent blocks.
143 One may never write
144 an amount of data that is not an exact multiple of the blocksize.  One
145 may read and write the same data as a different set of records, In
146 other words, blocks that were written together may be read separately,
147 and vice-versa.
148 .Pp
149 If one requests more blocks than remain in the file, the drive will
150 encounter the file mark.  Because there is some data to return (unless
151 there were no records before the file mark), the read will succeed,
152 returning that data, The next read will return immediately with a value
153 of 0.  (As above, if the file mark is never read, it remains for the next
154 process to read if in no-rewind mode.)
155 .El
156 .Sh FILE MARK HANDLING
157 The handling of file marks on write is automatic.
158 If the user has
159 written to the tape, and has not done a read since the last write,
160 then a file mark will be written to the tape when the device is
161 closed.  If a rewind is requested after a write, then the driver
162 assumes that the last file on the tape has been written, and ensures
163 that there are two file marks written to the tape.  The exception to
164 this is that there seems to be a standard (which we follow, but don't
165 understand why) that certain types of tape do not actually write two
166 file marks to tape, but when read, report a `phantom' file mark when the
167 last file is read.  These devices include the QIC family of devices.
168 (It might be that this set of devices is the same set as that of fixed
169 block devices.  This has not been determined yet, and they are treated
170 as separate behaviors by the driver at this time.)
171 .Sh IOCTLS
172 The
173 .Nm
174 driver supports all of the ioctls of
175 .Xr mtio 4 .
176 .Sh FILES
177 .Bl -tag -width /dev/[n][e]sa[0-9] -compact
178 .It Pa /dev/[n][e]sa[0-9]
179 general form:
180 .It Pa /dev/sa0
181 Rewind on close
182 .It Pa /dev/nsa0
183 No rewind on close
184 .It Pa /dev/esa0
185 Eject on close (if capable)
186 .It Pa /dev/sa0.ctl
187 Control mode device (to examine state while another program is
188 accessing the device, e.g.).
189 .El
190 .Sh BUGS
191 This driver lacks many of the hacks required to deal with older devices.
192 Many older
193 .Tn SCSI-1
194 devices may not work properly with this driver yet.
195 .Pp
196 Additionally, certain
197 tapes (QIC tapes mostly) that were written under
198 .Fx
199 2.X
200 aren't automatically read correctly with this driver: you may need to
201 explicitly set variable block mode or set to the blocksize that works best
202 for your device in order to read tapes written under
203 .Fx
204 2.X.
205 .Pp
206 Fine grained density and compression mode support that is bound to specific
207 device names needs to be added.
208 .Pp
209 Support for fast indexing by use of partitions is missing.
210 .Sh DIAGNOSTICS
211 None.
212 .Sh SEE ALSO
213 .Xr mt 1 ,
214 .Xr scsi 4
215 .Sh HISTORY
216 The
217 .Nm
218 driver was written for the
219 .Tn CAM
220 .Tn SCSI
221 subsystem by Justin T. Gibbs and Kenneth Merry.
222 Many ideas were gleaned from the
223 .Nm st
224 device driver written and ported from
225 .Tn Mach
226 2.5
227 by
228 .An Julian Elischer .
229 .Pp
230 The current owner of record is
231 .An Matthew Jacob
232 who has suffered too many
233 years of breaking tape drivers.