2 .\" Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
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.
14 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .Nm g_destroy_consumer
33 .Nd "GEOM consumers management"
36 .Ft "struct g_consumer *"
37 .Fn g_new_consumer "struct g_geom *gp"
39 .Fn g_destroy_consumer "struct g_consumer *cp"
41 A GEOM consumer is the backdoor through which a geom connects to
42 another GEOM provider and through which I/O requests are sent.
46 function creates a new consumer on geom
48 Before using the new consumer, it has to be attached to a provider with
54 .Fn g_destroy_consumer
55 function destroys the given consumer and cancels all related pending events.
56 This function is the last stage of killing an unwanted consumer.
57 .Sh RESTRICTIONS/CONDITIONS
59 .Bl -item -offset indent
67 The topology lock has to be held.
70 .Fn g_destroy_consumer :
71 .Bl -item -offset indent
73 The consumer must not be attached to a provider.
75 The access count has to be 0.
77 The topology lock has to be held.
83 returns a pointer to the newly created consumer.
85 Create consumer, attach it to given provider, gain read access and clean up.
86 .Bd -literal -offset indent
88 some_function(struct g_geom *mygeom, struct g_provider *pp)
90 struct g_consumer *cp;
94 /* Create new consumer on 'mygeom' geom. */
95 cp = g_new_consumer(mygeom);
96 /* Attach newly created consumer to given provider. */
97 if (g_attach(cp, pp) != 0) {
98 g_destroy_consumer(cp);
101 /* Open provider for reading through our consumer. */
102 if (g_access(cp, 1, 0, 0) != 0) {
104 g_destroy_consumer(cp);
110 * Read data from provider.
114 /* Disconnect from provider (release access count). */
115 g_access(cp, -1, 0, 0);
116 /* Detach from provider. */
118 /* Destroy consumer. */
119 g_destroy_consumer(cp);
124 .Xr DECLARE_GEOM_CLASS 9 ,
132 .Xr g_provider_by_name 9 ,
136 This manual page was written by
137 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .