1 .\" Copyright (c) 2003 Poul-Henning Kamp
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. The names of the authors may not be used to endorse or promote
13 .\" products derived from this software without specific prior written
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER 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
35 .Nm geom_stats_close ,
36 .Nm geom_stats_resync ,
37 .Nm geom_stats_snapshot_get ,
38 .Nm geom_stats_snapshot_free ,
39 .Nm geom_stats_snapshot_timestamp ,
40 .Nm geom_stats_snapshot_reset ,
41 .Nm geom_stats_snapshot_next ,
48 .Nd userland API library for kernel GEOM subsystem
53 .Ss "Statistics Functions"
55 .Fn geom_stats_close void
57 .Fn geom_stats_open void
59 .Fn geom_stats_resync void
61 .Fn geom_stats_snapshot_get void
63 .Fn geom_stats_snapshot_free "void *arg"
65 .Fn geom_stats_snapshot_timestamp "void *arg" "struct timespec *tp"
67 .Fn geom_stats_snapshot_reset "void *arg"
68 .Ft "struct devstat *"
69 .Fn geom_stats_snapshot_next "void *arg"
70 .Ss "Control Functions"
71 .Ft "struct gctl_req *"
72 .Fn gctl_get_handle "void"
74 .Fn gctl_ro_param "struct gctl_req *req" "const char *name" "int len" "const void *value"
76 .Fn gctl_rw_param "struct gctl_req *req" "const char *name" "int len" "void *value"
78 .Fn gctl_issue "struct gctl_req *req"
80 .Fn gctl_free "struct gctl_req *req"
82 .Fn gctl_dump "struct gctl_req *req" "FILE *f"
86 library contains the official and publicized API for
87 interacting with the GEOM subsystem in the kernel.
88 .Ss "Statistics Functions"
89 GEOM collects statistics data for all consumers and providers, but does
90 not perform any normalization or presentation on the raw data, this is
91 left as an excercize for user-land presentation utilities.
97 functions open and close the necessary pathways to access the raw
98 statistics information in the kernel.
99 These functions are likely to
100 open one or more files and cache the file descriptors locally.
103 function returns zero on success, and sets
108 .Fn geom_stats_resync
109 function will check if more statistics collection points have been
110 added in the kernel since
112 or the previous call to
113 .Fn geom_stats_resync .
116 .Fn geom_stats_snapshot_get
118 will acquire a snapshot of the raw data from the kernel, and while a
119 reasonable effort is made to make this snapshot as atomic and consistent
120 as possible, no guarantee is given that it will actually be so.
121 The snapshot must be freed again using the
122 .Fn geom_stats_snapshot_free
125 .Fn geom_stats_snapshot_get
131 .Fn geom_stats_snapshot_timestamp
133 provides access to the timestamp acquired in the snapshot.
136 .Fn geom_stats_snapshot_reset
138 .Fn geom_stats_snapshot_next
140 provide an iterator over the statistics slots in the snapshot.
142 .Fn geom_stats_snapshot_reset
144 forces the internal pointer in the snapshot back to before the first item.
146 .Fn geom_stats_snapshot_next
148 returns the next item, and
150 if there are no more items in the snapshot.
151 .Ss "Control Functions"
154 functions are used to send requests to GEOM classes.
156 class to actually be able to receive these requests, it must have defined a
160 .Vt "struct gctl_req *" ,
162 .Fn gctl_get_handle ,
163 can hold any number of parameters, which must be added to it with
165 (for read-only parameters) or
167 (for read/write parameters).
175 which is used to identify the parameter, and a
177 which contains, in the read-only case, the data to be passed to the
178 GEOM class, or, in the read/write case, a pointer to preallocated memory
179 that the GEOM class should fill with the desired data.
182 is negative, it is assumed that
186 string and the actual length is taken from the string length of
188 otherwise it must hold the size of
193 containing the string
195 is mandatory for each request, and the
198 must hold the name of the GEOM class where the request should be sent to.
200 Also mandatory for each request is a parameter with a
204 and the corresponding
206 needs to hold the command string that the GEOM class should react upon.
208 Once all desired parameters are filled in, the request must be sent to
209 the GEOM subsystem with
213 on success, or a string containing the error message
216 After the request is finished, the allocated memory should be released with
222 can be used to format the contents of
224 to the open file handle pointed to by
226 for debugging purposes.
228 Error handling for the control functions is postponed until the call
233 on success, or an error message corresponding to the
234 first error which happened.
236 Create a request that is to be sent to the CCD class, and tell
237 it to destroy a specific geom:
238 .Bd -literal -offset indent
239 H = gctl_get_handle();
240 gctl_ro_param(H, "verb", -1, "destroy geom");
241 gctl_ro_param(H, "class", -1, "CCD");
242 sprintf(buf, "ccd%d", ccd);
243 gctl_ro_param(H, "geom", -1, buf);
244 errstr = gctl_issue(H);
246 err(1, "could not destroy ccd: %s", errstr);
250 .Pa http://ezine.daemonnews.org/200308/blueprints.html
257 .An Poul-Henning Kamp Aq phk@FreeBSD.org
258 .An Lukas Ertl Aq le@FreeBSD.org