Deleted Added
full compact
geom_slice.c (93326) geom_slice.c (93776)
1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the

--- 18 unchanged lines hidden (view full) ---

27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
1/*-
2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the

--- 18 unchanged lines hidden (view full) ---

27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/geom/geom_slice.c 93326 2002-03-28 10:09:24Z phk $
35 * $FreeBSD: head/sys/geom/geom_slice.c 93776 2002-04-04 09:54:13Z phk $
36 */
37
38
39#include <sys/param.h>
40#ifndef _KERNEL
41#include <stdio.h>
42#include <unistd.h>
43#include <stdlib.h>

--- 11 unchanged lines hidden (view full) ---

55#include <sys/mutex.h>
56#endif
57#include <sys/errno.h>
58#include <sys/sbuf.h>
59#include <geom/geom.h>
60#include <geom/geom_slice.h>
61#include <machine/stdarg.h>
62
36 */
37
38
39#include <sys/param.h>
40#ifndef _KERNEL
41#include <stdio.h>
42#include <unistd.h>
43#include <stdlib.h>

--- 11 unchanged lines hidden (view full) ---

55#include <sys/mutex.h>
56#endif
57#include <sys/errno.h>
58#include <sys/sbuf.h>
59#include <geom/geom.h>
60#include <geom/geom_slice.h>
61#include <machine/stdarg.h>
62
63static g_orphan_t g_slice_orphan;
64static g_access_t g_slice_access;
65static g_start_t g_slice_start;
66
63struct g_slicer *
64g_slice_init(unsigned nslice, unsigned scsize)
65{
66 struct g_slicer *gsp;
67
68 gsp = g_malloc(sizeof *gsp, M_WAITOK | M_ZERO);
69 gsp->softc = g_malloc(scsize, M_WAITOK | M_ZERO);
70 gsp->slices = g_malloc(nslice * sizeof(struct g_slice), M_WAITOK | M_ZERO);
71 gsp->nslice = nslice;
72 return (gsp);
73}
74
67struct g_slicer *
68g_slice_init(unsigned nslice, unsigned scsize)
69{
70 struct g_slicer *gsp;
71
72 gsp = g_malloc(sizeof *gsp, M_WAITOK | M_ZERO);
73 gsp->softc = g_malloc(scsize, M_WAITOK | M_ZERO);
74 gsp->slices = g_malloc(nslice * sizeof(struct g_slice), M_WAITOK | M_ZERO);
75 gsp->nslice = nslice;
76 return (gsp);
77}
78
75int
79static int
76g_slice_access(struct g_provider *pp, int dr, int dw, int de)
77{
78 int error, i;
79 struct g_geom *gp;
80 struct g_consumer *cp;
81 struct g_provider *pp2;
82 struct g_slicer *gsp;
83 struct g_slice *gsl, *gsl2;

--- 25 unchanged lines hidden (view full) ---

109 de++;
110 /* ... and let go of it on last close */
111 if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
112 de--;
113 error = g_access_rel(cp, dr, dw, de);
114 return (error);
115}
116
80g_slice_access(struct g_provider *pp, int dr, int dw, int de)
81{
82 int error, i;
83 struct g_geom *gp;
84 struct g_consumer *cp;
85 struct g_provider *pp2;
86 struct g_slicer *gsp;
87 struct g_slice *gsl, *gsl2;

--- 25 unchanged lines hidden (view full) ---

113 de++;
114 /* ... and let go of it on last close */
115 if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
116 de--;
117 error = g_access_rel(cp, dr, dw, de);
118 return (error);
119}
120
117void
121static void
118g_slice_start(struct bio *bp)
119{
120 struct bio *bp2;
121 struct g_provider *pp;
122 struct g_geom *gp;
123 struct g_consumer *cp;
124 struct g_slicer *gsp;
125 struct g_slice *gsl;

--- 95 unchanged lines hidden (view full) ---

221 void **vp;
222 int error;
223
224 g_topology_assert();
225 vp = (void **)extrap;
226 gp = g_new_geomf(mp, "%s", pp->name);
227 gsp = g_slice_init(slices, extra);
228 gsp->start = start;
122g_slice_start(struct bio *bp)
123{
124 struct bio *bp2;
125 struct g_provider *pp;
126 struct g_geom *gp;
127 struct g_consumer *cp;
128 struct g_slicer *gsp;
129 struct g_slice *gsl;

--- 95 unchanged lines hidden (view full) ---

225 void **vp;
226 int error;
227
228 g_topology_assert();
229 vp = (void **)extrap;
230 gp = g_new_geomf(mp, "%s", pp->name);
231 gsp = g_slice_init(slices, extra);
232 gsp->start = start;
233 gp->access = g_slice_access;
234 gp->orphan = g_slice_orphan;
229 gp->softc = gsp;
230 gp->start = g_slice_start;
231 gp->spoiled = g_std_spoiled;
232 gp->dumpconf = g_slice_dumpconf;
233 cp = g_new_consumer(gp);
234 g_attach(cp, pp);
235 error = g_access_rel(cp, 1, 0, 0);
236 if (error) {

--- 4 unchanged lines hidden (view full) ---

241 g_destroy_geom(gp);
242 return (NULL);
243 }
244 *vp = gsp->softc;
245 *cpp = cp;
246 return (gp);
247}
248
235 gp->softc = gsp;
236 gp->start = g_slice_start;
237 gp->spoiled = g_std_spoiled;
238 gp->dumpconf = g_slice_dumpconf;
239 cp = g_new_consumer(gp);
240 g_attach(cp, pp);
241 error = g_access_rel(cp, 1, 0, 0);
242 if (error) {

--- 4 unchanged lines hidden (view full) ---

247 g_destroy_geom(gp);
248 return (NULL);
249 }
250 *vp = gsp->softc;
251 *cpp = cp;
252 return (gp);
253}
254
249void
255static void
250g_slice_orphan(struct g_consumer *cp)
251{
252 struct g_geom *gp;
253 struct g_provider *pp;
254 int error;
255
256 g_trace(G_T_TOPOLOGY, "g_slice_orphan(%p/%s)", cp, cp->provider->name);
257 g_topology_assert();

--- 12 unchanged lines hidden ---
256g_slice_orphan(struct g_consumer *cp)
257{
258 struct g_geom *gp;
259 struct g_provider *pp;
260 int error;
261
262 g_trace(G_T_TOPOLOGY, "g_slice_orphan(%p/%s)", cp, cp->provider->name);
263 g_topology_assert();

--- 12 unchanged lines hidden ---