]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/disk.9
This commit was generated by cvs2svn to compensate for changes in r171169,
[FreeBSD/FreeBSD.git] / share / man / man9 / disk.9
1 .\"
2 .\" Copyright (c) 2003 Robert N. M. Watson
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice(s), this list of conditions and the following disclaimer as
10 .\"    the first lines of this file unmodified other than the possible
11 .\"    addition of one or more copyright notices.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice(s), this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 .\" DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd February 18, 2004
31 .Dt DISK 9
32 .Os
33 .Sh NAME
34 .Nm disk
35 .Nd kernel disk storage API
36 .Sh SYNOPSIS
37 .In geom/geom_disk.h
38 .Ft struct disk *
39 .Fn disk_alloc void
40 .Ft void
41 .Fn disk_create "struct disk *disk" "int version"
42 .Ft void
43 .Fn disk_destroy "struct disk *disk"
44 .Sh DESCRIPTION
45 The disk storage API permits kernel device drivers providing access to
46 disk-like storage devices to advertise the device to other kernel
47 components, including
48 .Xr GEOM 4
49 and
50 .Xr devfs 5 .
51 .Pp
52 Each disk device is described by a
53 .Vt "struct disk"
54 structure, which contains a variety of parameters for the disk device,
55 function pointers for various methods that may be performed on the device,
56 as well as private data storage for the device driver.
57 In addition, some fields are reserved for use by GEOM in managing access
58 to the device and its statistics.
59 .Pp
60 GEOM has the ownership of
61 .Vt "struct disk" ,
62 and drivers must allocate storage for it with the
63 .Fn disk_alloc
64 function,
65 fill in the fields and call
66 .Fn disk_create
67 when the device is ready to service requests.
68 After calling
69 .Fn disk_destroy ,
70 the device driver is not allowed to access the contents of
71 .Vt "struct disk"
72 anymore.
73 .Pp
74 The
75 .Fn disk_create
76 function
77 takes a second parameter,
78 .Fa version ,
79 which must always be passed
80 .Dv DISK_VERSION .
81 If GEOM detects that the driver is compiled against an unsupported version,
82 it will ignore the device and print a warning on the console.
83 .Ss Descriptive Fields
84 The following fields identify the disk device described by the structure
85 instance, and must be filled in prior to submitting the structure to
86 .Fn disk_create
87 and may not be subsequently changed:
88 .Bl -tag -width indent
89 .It Vt u_int Va d_flags
90 Optional flags indicating to the storage framework what optional features
91 or descriptions the storage device driver supports.
92 Currently supported flags are
93 .Dv DISKFLAG_NEEDSGIANT
94 (maintained by device driver),
95 .Dv DISKFLAG_OPEN
96 (maintained by storage framework),
97 .Dv DISKFLAG_CANDELETE
98 (maintained by device driver),
99 and
100 .Dv DISKFLAG_CANFLUSHCACHE
101 (maintained by device driver).
102 .It Vt "const char *" Va d_name
103 Holds the name of the storage device class, e.g.,
104 .Dq Li ahd .
105 This value typically uniquely identifies a particular driver device,
106 and must not conflict with devices serviced by other device drivers.
107 .It Vt u_int Va d_unit
108 Holds the instance of the storage device class, e.g.,
109 .Dq Li 4 .
110 This namespace is managed by the device driver, and assignment of unit
111 numbers might be a property of probe order, or in some cases topology.
112 Together, the
113 .Va d_name
114 and
115 .Va d_unit
116 values will uniquely identify a disk storage device.
117 .El
118 .Ss Disk Device Methods
119 The following fields identify various disk device methods, if implemented:
120 .Bl -tag -width indent
121 .It Vt "disk_open_t *" Va d_open
122 Optional: invoked when the disk device is opened.
123 If no method is provided, open will always succeed.
124 .It Vt "disk_close_t *" Va d_close
125 Optional: invoked when the disk device is closed.
126 Although an error code may be returned, the call should always terminate
127 any state setup by the corresponding open method call.
128 .It Vt "disk_strategy_t *" Va d_strategy
129 Mandatory: invoked when a new
130 .Vt "struct bio"
131 is to be initiated on the disk device.
132 .It Vt "disk_ioctl_t *" Va d_ioctl
133 Optional: invoked when an I/O control operation is initiated on the disk device.
134 Please note that for security reasons these operations should not
135 be able to affect other devices than the one on which they are performed.
136 .It Vt "dumper_t *" Va d_dump
137 Optional: if configured with
138 .Xr dumpon 8 ,
139 this function is invoked from a very restricted system state after a
140 kernel panic to record a copy of the system RAM to the disk.
141 .El
142 .Ss Mandatory Media Properties
143 The following fields identify the size and granularity of the disk device.
144 These fields must stay stable from return of the drivers open method until
145 the close method is called, but it is perfectly legal to modify them in
146 the open method before returning.
147 .Bl -tag -width indent
148 .It Vt u_int Va d_sectorsize
149 The sector size of the disk device in bytes.
150 .It Vt off_t Va d_mediasize
151 The size of the disk device in bytes.
152 .It Vt u_int Va d_maxsize
153 The maximum supported size in bytes of an I/O request.
154 Requests larger than this size will be chopped up by GEOM.
155 .El
156 .Ss Optional Media Properties
157 These optional fields can provide extra information about the disk
158 device.
159 Do not initialize these fields if the field/concept does not apply.
160 These fields must stay stable from return of the drivers open method until
161 the close method is called, but it is perfectly legal to modify them in
162 the open method before returning.
163 .Bl -tag -width indent
164 .It Vt u_int Va d_fwsectors , Vt u_int Va d_fwheads
165 The number of sectors and heads advertised on the disk device by the
166 firmware or BIOS.
167 These values are almost universally bogus, but on some architectures
168 necessary for the correct calculation of disk partitioning.
169 .It Vt u_int Va d_stripeoffset , Vt u_int Va d_stripesize
170 These two fields can be used to describe the width and location of
171 natural performance boundaries for most disk technologies.
172 Please see
173 .Pa src/sys/geom/notes
174 for details.
175 .It Vt char Va d_ident[DISK_IDENT_SIZE]
176 This field can and should be used to store disk's serial number.
177 .El
178 .Ss Driver Private Data
179 This field may be used by the device driver to store a pointer to
180 private data to implement the disk service.
181 .Bl -tag -width indent
182 .It Vt "void *" Va d_drv1
183 Private data pointer.
184 Typically used to store a pointer to the drivers
185 .Vt softc
186 structure for this disk device.
187 .El
188 .Sh SEE ALSO
189 .Xr GEOM 4 ,
190 .Xr devfs 5
191 .Sh AUTHORS
192 This manual page was written by
193 .An Robert Watson .