xref: /freebsd/lib/libgeom/libgeom.3 (revision f9218d3d4fd34f082473b3a021c6d4d109fb47cf)
1.\" Copyright (c) 2003 Poul-Henning Kamp
2.\" 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.\" 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
14.\"    permission.
15.\"
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
26.\" SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
30.Dd February 8, 2003
31.Dt LIBGEOM 3
32.Os
33.Sh NAME
34.Nm geom_stats_open ,
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
42.Nd userland API library for kernel GEOM subsystem
43.Sh LIBRARY
44.Lb libgeom
45.Sh SYNOPSIS
46.In libgeom.h
47.Ss "Statistics Functions"
48.Ft void
49.Fn geom_stats_close void
50.Ft int
51.Fn geom_stats_open void
52.Ft void
53.Fn geom_stats_resync void
54.Ft "void *"
55.Fn geom_stats_snapshot_get void
56.Ft void
57.Fn geom_stats_snapshot_free "void *arg"
58.Ft void
59.Fn geom_stats_snapshot_timestamp "void *arg" "struct timespec *tp"
60.Ft void
61.Fn geom_stats_snapshot_reset "void *arg"
62.Ft "struct g_stat *"
63.Fn geom_stats_snapshot_next "void *arg"
64.Sh DESCRIPTION
65The
66.Nm geom
67library contains the official and publicized API for
68interacting with the GEOM subsystem in the kernel.
69.Ss "Statistics Functions"
70GEOM collects statistics data for all consumers and providers, but does
71not perform any normalization or presentation on the raw data, this is
72left as an excercize for user-land presentation utilities.
73.Pp
74The
75.Fn geom_stats_open
76and
77.Fn geom_stats_close
78functions open and close the necessary pathways to access the raw
79statistics information in the kernel.
80These functions are likely to
81open one or more files and cache the file descriptors locally.
82.Fn geom_stats_open
83returns zero on success, and sets
84.Va errno
85if not.
86.Pp
87The
88.Fn geom_stats_resync
89function will check if more statistics collection points have been
90added in the kernel since
91.Fn geom_stats_open
92or the previous call to
93.Fn geom_stats_resync .
94.Pp
95The
96.Fn geom_stats_snapshot_get
97function
98will acquire a snapshot of the raw data from the kernel, and while a
99reasonable effort is made to make this snapshot as atomic and consistent
100as possible, no guarantee is given that it will actually be so.
101The snapshot must be freed again using the
102.Fn geom_stats_snapshot_free
103function.
104.Fn geom_stats_snapshot_get
105returns
106.Dv NULL
107on failure.
108.Pp
109The
110.Fn geom_stats_snapshot_timestamp
111function
112provides access to the timestamp acquired in the snapshot.
113.Pp
114The
115.Fn geom_stats_snapshot_reset
116and
117.Fn geom_stats_snapshot_next
118functions
119provide an iterator over the statistics slots in the snapshot.
120The
121.Fn geom_stats_snapshot_reset
122function
123forces the internal pointer in the snapshot back to before the first item.
124The
125.Fn geom_stats_snapshot_next
126function
127returns the next item, and
128.Dv NULL
129if there are no more items in the snapshot.
130.Sh AUTHORS
131.An Poul-Henning Kamp Aq phk@FreeBSD.org
132.Sh HISTORY
133The
134.Nm geom
135library appeared in
136.Fx 5.1 .
137