xref: /freebsd/share/man/man4/da.4 (revision 4cf49a43559ed9fdad601bdcccd2c55963008675)
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$
27.\"
28.Dd October 15, 1998
29.Dt DA 4
30.Os FreeBSD
31.Sh NAME
32.Nm da
33.Nd SCSI Direct Access Device Driver
34.Sh SYNOPSIS
35.Cd device da0
36.Cd device da1 at scbus0 target 4 unit 0
37.Sh DESCRIPTION
38The
39.Nm da
40driver provides support for all
41.Tn SCSI
42devices of the direct access class that are attached to the system
43through a supported
44.Tn SCSI
45Host Adapter.
46The direct access class includes disk, magneto-optical,
47and solid-state devices.
48.Pp
49A
50.Tn SCSI
51Host
52adapter must also be separately configured into the system
53before a
54.Tn SCSI
55direct access device can be configured.
56.Sh PARTITIONING
57The
58.Nm
59driver allows the disk to have two levels of partitioning.
60One layer, called the
61.Dq slice layer ,
62is used to separate the
63.Tn FreeBSD
64areas of the disk from areas used by other operating systems.
65The second layer is the native
66.Bx 4.4
67partitioning scheme,
68.Xr disklabel 5 ,
69which is used to subdivide the
70.Tn FreeBSD
71slices into areas for individual filesystems and swap spaces.
72For more information, see
73.Xr fdisk 8
74and
75.Xr disklabel 8 ,
76respectively.
77.Pp
78If an uninitialized disk is opened, the slice table will be
79initialized with a fictitious
80.Tn FreeBSD
81slice spanning the entire disk.  Similarly, if an uninitialized
82(or
83.No non- Ns Tn FreeBSD )
84slice is opened, its disklabel will be initialized with parameters returned
85by the drive and a single
86.Sq Li c
87partition encompassing the entire slice.
88.Sh CACHE EFFECTS
89Many direct access devices are equipped with read and/or write caches.
90Parameters affecting the device's cache are stored in mode page 8,
91the caching control page.  Mode pages can be examined and modified
92via the
93.Xr camcontrol 8
94utility.
95
96The read cache is used to store data from device-initiated read ahead
97operations as well as frequently used data.  The read cache is transparent
98to the user and can be enabled without any adverse effect.  Most devices
99with a read cache come from the factory with it enabled.  The read cache
100can be disabled by setting the
101.Tn RCD
102(Read Cache Disable) bit in the caching control mode page.
103
104The write cache can greatly decrease the latency of write operations
105and allows the device to reorganize writes to increase efficiency and
106performance.  This performance gain comes at a price.  Should the device
107lose power while its cache contains uncommitted write operations, these
108writes will be lost.  The effect of a loss of write transactions on
109a file system is non-deterministic and can cause corruption.  Most
110devices age write transactions to limit vulnerability to a few transactions
111recently reported as complete, but it is none-the-less recommended that
112systems with write cache enabled devices reside on an Uninterruptible
113Power Supply (UPS).  The
114.Nm da
115device driver ensures that the cache and media are synchronized upon
116final close of the device or an unexpected shutdown (panic) event.  This
117ensures that it is safe to disconnect power once the operating system
118has reported that it has halted.  The write cache can be enabled by
119setting the
120.Tn WCE
121(Write Cache Enable) bit in the caching control mode page.
122.Sh TAGGED QUEUING
123The
124.Nm da
125device driver will take full advantage of the SCSI feature known as tagged
126queuing.  Tagged queuing allows the device to process multiple transactions
127concurrently, often re-ordering them to reduce the number and length of
128seeks.  To ensure that transactions to distant portions of the media,
129which may be deferred indefinitely by servicing requests nearer the current
130head position, are completed in a timely fashion, an ordered tagged
131transaction is sent every 15 seconds during continuous device operation.
132.Sh BAD BLOCK RECOVERY
133Direct Access devices have the capability of mapping out portions of
134defective media.  Media recovery parameters are located in mode page 1,
135the Read-Write Error Recovery mode page.  The most important media
136remapping features are 'Auto Write Reallocation' and 'Auto Read
137Reallocation' which can be enabled via the AWRE and ARRE bits,
138respectively, of the Read-Write Error Recovery page.
139Many devices do not ship from the factory with these feature enabled.
140Mode pages can be examined and modifie
141via the
142.Xr camcontrol 8
143utility.
144.Sh KERNEL CONFIGURATION
145It is only necessary to explicitly configure one
146.Nm da
147device; data structures are dynamically allocated as disks are found
148on the
149.Tn SCSI
150bus.
151.Sh IOCTLS
152The following
153.Xr ioctl 2
154calls apply to
155.Tn SCSI
156disks as well as to other disks.  They are defined in the header file
157.Aq Pa sys/disklabel.h .
158.Pp
159.Bl -tag -width DIOCSDINFO
160.It Dv DIOCSBAD
161Usually used to set up a bad-block mapping system on the disk.
162.Tn SCSI
163drives incorporate their own bad-block mapping so this command is not
164implemented.
165.It Dv DIOCGDINFO
166Read, from the kernel, the in-core copy of the disklabel for the
167drive. This may be a fictitious disklabel if the drive has never
168been initialized, in which case it will contain information read
169from the
170.Tn SCSI
171inquiry commands.
172.It Dv DIOCSDINFO
173Give the driver a new disklabel to use. The driver
174.Em will not
175write the new
176disklabel to the disk.
177.It Dv DIOCWLABEL
178Enable or disable the driver's software
179write protect of the disklabel on the disk.
180.It Dv DIOCWDINFO
181Give the driver a new disklabel to use. The driver
182.Em will
183write the new disklabel to the disk.
184.El
185.Sh NOTES
186If a device becomes invalidated (media is removed, device becomes unresponsive)
187the disklabel and information held within the kernel about the device will
188be invalidated.  To avoid corruption of a newly inserted piece of media or
189a replacement device, all accesses to the device will be discarded until
190the last file descriptor referencing the old device is closed.  During this
191period, all new open attempts will be rejected.
192.Sh FILES
193.Bl -tag -width /dev/rsdXXXXX -compact
194.It Pa /dev/rda Ns Ar u
195raw mode
196.Tn SCSI
197disk unit
198.Ar u ,
199accessed as an unpartitioned device
200.Sm off
201.It Pa /dev/da Ar u Pa s Ar n
202.Sm on
203block mode
204.Tn SCSI
205disk unit
206.Ar u ,
207slice
208.Ar n ,
209accessed as an unpartitioned device
210.Sm off
211.It Pa /dev/rda Ar u Pa s Ar n
212.Sm on
213raw mode
214.Tn SCSI
215disk unit
216.Ar u ,
217slice
218.ar n ,
219accessed as an unpartitioned device
220.It Pa /dev/da Ns Ar u Ns Ar p
221block mode
222.Tn SCSI
223disk unit
224.Ar u ,
225first
226.Tn FreeBSD
227slice, partition
228.Ar p
229.It Pa /dev/rda Ns Ar u Ns Ar p
230raw mode
231.Tn SCSI
232disk unit
233.Ar u ,
234first
235.Tn FreeBSD
236slice, partition
237.Ar p
238.Sm off
239.It Xo
240.Pa /dev/da
241.Ar u
242.Pa s
243.Ar n
244.Ar p
245.Xc
246.Sm on
247block mode
248.Tn SCSI
249disk unit
250.Ar u ,
251.No Ar n Ns th
252slice, partition
253.Ar p
254.Sm off
255.It Xo
256.Pa /dev/rda
257.Ar u
258.Pa s
259.Ar n
260.Ar p
261.Xc
262raw mode
263.Tn SCSI
264disk unit
265.Ar u ,
266.No Ar n Ns th
267slice, partition
268.Ar p
269.El
270.Sh DIAGNOSTICS
271None.
272.Sh SEE ALSO
273.Xr wd 4 ,
274.Xr disklabel 5 ,
275.Xr disklabel 8 ,
276.Xr fdisk 8
277.Sh HISTORY
278The
279.Nm
280driver was written for the
281.Tn CAM
282.Tn SCSI
283subsystem by Justin T. Gibbs.
284Many ideas were gleaned from the
285.Nm sd
286device driver written and ported from
287.Tn Mach
2882.5
289by Julian Elischer.  Support for slices was written by Bruce Evans.
290