xref: /freebsd/share/man/man9/g_provider.9 (revision 1a720cbec513210fa2e85c3882741ef2f6dc5f35)
1f827ccb9SPawel Jakub Dawidek.\"
2f827ccb9SPawel Jakub Dawidek.\" Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3f827ccb9SPawel Jakub Dawidek.\" All rights reserved.
4f827ccb9SPawel Jakub Dawidek.\"
5f827ccb9SPawel Jakub Dawidek.\" Redistribution and use in source and binary forms, with or without
6f827ccb9SPawel Jakub Dawidek.\" modification, are permitted provided that the following conditions
7f827ccb9SPawel Jakub Dawidek.\" are met:
8f827ccb9SPawel Jakub Dawidek.\" 1. Redistributions of source code must retain the above copyright
9f827ccb9SPawel Jakub Dawidek.\"    notice, this list of conditions and the following disclaimer.
10f827ccb9SPawel Jakub Dawidek.\" 2. Redistributions in binary form must reproduce the above copyright
11f827ccb9SPawel Jakub Dawidek.\"    notice, this list of conditions and the following disclaimer in the
12f827ccb9SPawel Jakub Dawidek.\"    documentation and/or other materials provided with the distribution.
13f827ccb9SPawel Jakub Dawidek.\"
14f827ccb9SPawel Jakub Dawidek.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
15f827ccb9SPawel Jakub Dawidek.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16f827ccb9SPawel Jakub Dawidek.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17f827ccb9SPawel Jakub Dawidek.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
18f827ccb9SPawel Jakub Dawidek.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19f827ccb9SPawel Jakub Dawidek.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20f827ccb9SPawel Jakub Dawidek.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21f827ccb9SPawel Jakub Dawidek.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22f827ccb9SPawel Jakub Dawidek.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23f827ccb9SPawel Jakub Dawidek.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24f827ccb9SPawel Jakub Dawidek.\"
25f827ccb9SPawel Jakub Dawidek.Dd January 16, 2004
266f39ea88SRuslan Ermilov.Dt G_PROVIDER 9
27f827ccb9SPawel Jakub Dawidek.Os
28f827ccb9SPawel Jakub Dawidek.Sh NAME
29f827ccb9SPawel Jakub Dawidek.Nm g_new_providerf ,
30f827ccb9SPawel Jakub Dawidek.Nm g_destroy_provider ,
31f827ccb9SPawel Jakub Dawidek.Nm g_error_provider
32f827ccb9SPawel Jakub Dawidek.Nd "GEOM providers management"
33f827ccb9SPawel Jakub Dawidek.Sh SYNOPSIS
34f827ccb9SPawel Jakub Dawidek.In geom/geom.h
35f827ccb9SPawel Jakub Dawidek.Ft "struct g_provider *"
36f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf "struct g_geom *gp" "const char *fmt" ...
37f827ccb9SPawel Jakub Dawidek.Ft void
38f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider "struct g_provider *pp"
39f827ccb9SPawel Jakub Dawidek.Ft void
40f827ccb9SPawel Jakub Dawidek.Fn g_error_provider "struct g_provider *pp" "int error"
41f827ccb9SPawel Jakub Dawidek.Sh DESCRIPTION
42eaad868dSLukas ErtlA GEOM provider is the front gate at which a geom offers service.
43f827ccb9SPawel Jakub DawidekA provider is
446f39ea88SRuslan Ermilov.Dq a disk-like thing which appears in Pa /dev
456f39ea88SRuslan Ermilov\[en] a logical disk in other words.
46f827ccb9SPawel Jakub DawidekAll providers have three main properties: name, sectorsize and size.
47f827ccb9SPawel Jakub Dawidek.Pp
48f827ccb9SPawel Jakub DawidekThe
49f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf
50eaad868dSLukas Ertlfunction creates a new provider on given geom
51f827ccb9SPawel Jakub Dawidek.Fa gp .
526f39ea88SRuslan ErmilovThe name of the provider, which will appear as device in
53*1a720cbeSAlexander Ziaee.Xr devfs 4 ,
546f39ea88SRuslan Ermilovis created
556f39ea88SRuslan Ermilovin a
566f39ea88SRuslan Ermilov.Xr printf 3 Ns
576f39ea88SRuslan Ermilov-like way from the rest of
58f827ccb9SPawel Jakub Dawidekthe arguments.
59eaad868dSLukas ErtlAfter creation, the caller has to set the provider's
60f827ccb9SPawel Jakub Dawidek.Va mediasize
61f827ccb9SPawel Jakub Dawidekand
62eaad868dSLukas Ertl.Va sectorsize ,
63eaad868dSLukas Ertlas well as other desired initializations, and then call
64eaad868dSLukas Ertl.Fn g_error_provider
65eaad868dSLukas Ertlto reset the provider's error, which is initially set to
66eaad868dSLukas Ertl.Er ENXIO .
67f827ccb9SPawel Jakub Dawidek.Pp
68f827ccb9SPawel Jakub DawidekThe
69f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider
70f827ccb9SPawel Jakub Dawidekfunction destroys the given provider, cancels all related pending events and
71eaad868dSLukas Ertlremoves the corresponding devfs entry.
72f827ccb9SPawel Jakub Dawidek.Pp
73f827ccb9SPawel Jakub DawidekThe
74f827ccb9SPawel Jakub Dawidek.Fn g_error_provider
75eaad868dSLukas Ertlfunction is used to set the provider's error value.
76eaad868dSLukas ErtlIf set to a nonzero, all I/O requests will be denied,
77eaad868dSLukas Ertlas well as increasing its access count will not be possible (error
78f827ccb9SPawel Jakub Dawidek.Fa error
79f827ccb9SPawel Jakub Dawidekwill be returned).
80f827ccb9SPawel Jakub Dawidek.Sh RESTRICTIONS/CONDITIONS
81f827ccb9SPawel Jakub Dawidek.Fn g_new_provider :
82f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent
83f827ccb9SPawel Jakub Dawidek.It
84f827ccb9SPawel Jakub DawidekThe provider name should be unique, but this is not enforced by GEOM.
85f827ccb9SPawel Jakub DawidekIf the name is not unique, one will end up with two (or more) files
86eaad868dSLukas Ertlwith the same name, which is a programmer error.
87f827ccb9SPawel Jakub Dawidek.It
88eaad868dSLukas ErtlThe geom
89eaad868dSLukas Ertl.Fa gp
90eaad868dSLukas Ertlhas to have a
91f827ccb9SPawel Jakub Dawidek.Fa start
92eaad868dSLukas Ertlmethod defined.
93f827ccb9SPawel Jakub Dawidek.It
94f827ccb9SPawel Jakub DawidekThe topology lock has to be held.
95f827ccb9SPawel Jakub Dawidek.El
96f827ccb9SPawel Jakub Dawidek.Pp
97f827ccb9SPawel Jakub Dawidek.Fn g_destroy_provider :
98f827ccb9SPawel Jakub Dawidek.Bl -item -offset indent
99f827ccb9SPawel Jakub Dawidek.It
100eaad868dSLukas ErtlThe provider must not have consumers attached.
101f827ccb9SPawel Jakub Dawidek.It
102f827ccb9SPawel Jakub DawidekThe access count has to be 0.
103f827ccb9SPawel Jakub Dawidek.It
104f827ccb9SPawel Jakub DawidekThe topology lock has to be held.
105f827ccb9SPawel Jakub Dawidek.El
106f827ccb9SPawel Jakub Dawidek.Sh RETURN VALUES
107eaad868dSLukas ErtlThe
108f827ccb9SPawel Jakub Dawidek.Fn g_new_providerf
109eaad868dSLukas Ertlfunction returns a pointer to the newly created provider.
110f827ccb9SPawel Jakub Dawidek.Sh EXAMPLES
111f827ccb9SPawel Jakub DawidekCreate an example provider, set its parameters and make it usable.
112f827ccb9SPawel Jakub Dawidek.Bd -literal -offset indent
113f827ccb9SPawel Jakub Dawidekstruct g_provider *
114f827ccb9SPawel Jakub Dawidekcreate_example_provider(struct g_geom *gp)
115f827ccb9SPawel Jakub Dawidek{
116f827ccb9SPawel Jakub Dawidek	struct g_provider *pp;
117f827ccb9SPawel Jakub Dawidek
118f827ccb9SPawel Jakub Dawidek	g_topology_lock();
119f827ccb9SPawel Jakub Dawidek	pp = g_new_providerf(gp, "example_provider");
120030f6f35SPawel Jakub Dawidek	g_topology_unlock();
121f827ccb9SPawel Jakub Dawidek	pp->mediasize = 65536;
122f827ccb9SPawel Jakub Dawidek	pp->sectorsize = 512;
123f827ccb9SPawel Jakub Dawidek	g_error_provider(pp, 0);
124f827ccb9SPawel Jakub Dawidek
125f827ccb9SPawel Jakub Dawidek	return (pp);
126f827ccb9SPawel Jakub Dawidek}
127f827ccb9SPawel Jakub Dawidek.Ed
128f827ccb9SPawel Jakub Dawidek.Sh SEE ALSO
129f827ccb9SPawel Jakub Dawidek.Xr geom 4 ,
1301c85060aSRuslan Ermilov.Xr DECLARE_GEOM_CLASS 9 ,
1318217df6dSPawel Jakub Dawidek.Xr g_access 9 ,
132f827ccb9SPawel Jakub Dawidek.Xr g_attach 9 ,
133f827ccb9SPawel Jakub Dawidek.Xr g_bio 9 ,
134f827ccb9SPawel Jakub Dawidek.Xr g_consumer 9 ,
135f827ccb9SPawel Jakub Dawidek.Xr g_data 9 ,
136f827ccb9SPawel Jakub Dawidek.Xr g_event 9 ,
137f827ccb9SPawel Jakub Dawidek.Xr g_geom 9 ,
138f827ccb9SPawel Jakub Dawidek.Xr g_provider_by_name 9 ,
139f827ccb9SPawel Jakub Dawidek.Xr g_wither_geom 9
140f827ccb9SPawel Jakub Dawidek.Sh AUTHORS
141f827ccb9SPawel Jakub Dawidek.An -nosplit
142f827ccb9SPawel Jakub DawidekThis manual page was written by
1438a7314fcSBaptiste Daroussin.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org .
144