xref: /freebsd/lib/libgeom/libgeom.3 (revision 7660b554bc59a07be0431c17e0e33815818baa69)
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.
82The
83.Fn geom_stats_open
84function returns zero on success, and sets
85.Va errno
86if not.
87.Pp
88The
89.Fn geom_stats_resync
90function will check if more statistics collection points have been
91added in the kernel since
92.Fn geom_stats_open
93or the previous call to
94.Fn geom_stats_resync .
95.Pp
96The
97.Fn geom_stats_snapshot_get
98function
99will acquire a snapshot of the raw data from the kernel, and while a
100reasonable effort is made to make this snapshot as atomic and consistent
101as possible, no guarantee is given that it will actually be so.
102The snapshot must be freed again using the
103.Fn geom_stats_snapshot_free
104function.
105The
106.Fn geom_stats_snapshot_get
107function returns
108.Dv NULL
109on failure.
110.Pp
111The
112.Fn geom_stats_snapshot_timestamp
113function
114provides access to the timestamp acquired in the snapshot.
115.Pp
116The
117.Fn geom_stats_snapshot_reset
118and
119.Fn geom_stats_snapshot_next
120functions
121provide an iterator over the statistics slots in the snapshot.
122The
123.Fn geom_stats_snapshot_reset
124function
125forces the internal pointer in the snapshot back to before the first item.
126The
127.Fn geom_stats_snapshot_next
128function
129returns the next item, and
130.Dv NULL
131if there are no more items in the snapshot.
132.Sh AUTHORS
133.An Poul-Henning Kamp Aq phk@FreeBSD.org
134.Sh HISTORY
135The
136.Nm geom
137library appeared in
138.Fx 5.1 .
139