layer_subr.c revision 1.3.2.2 1 1.3.2.2 thorpej /* $NetBSD: layer_subr.c,v 1.3.2.2 1999/08/02 22:27:34 thorpej Exp $ */
2 1.3.2.2 thorpej
3 1.3.2.2 thorpej /*
4 1.3.2.2 thorpej * Copyright (c) 1999 National Aeronautics & Space Administration
5 1.3.2.2 thorpej * All rights reserved.
6 1.3.2.2 thorpej *
7 1.3.2.2 thorpej * This software was written by William Studenmund of the
8 1.3.2.2 thorpej * Numerical Aerospace Similation Facility, NASA Ames Research Center.
9 1.3.2.2 thorpej *
10 1.3.2.2 thorpej * Redistribution and use in source and binary forms, with or without
11 1.3.2.2 thorpej * modification, are permitted provided that the following conditions
12 1.3.2.2 thorpej * are met:
13 1.3.2.2 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.3.2.2 thorpej * notice, this list of conditions and the following disclaimer.
15 1.3.2.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.2.2 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.3.2.2 thorpej * documentation and/or other materials provided with the distribution.
18 1.3.2.2 thorpej * 3. Neither the the name of the National Aeronautics & Space Administration
19 1.3.2.2 thorpej * nor the names of its contributors may be used to endorse or promote
20 1.3.2.2 thorpej * products derived from this software without specific prior written
21 1.3.2.2 thorpej * permission.
22 1.3.2.2 thorpej *
23 1.3.2.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NATIONAL AERONAUTICS & SPACE ADMINISTRATION
24 1.3.2.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 1.3.2.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 1.3.2.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ADMINISTRATION OR CONTRIB-
27 1.3.2.2 thorpej * UTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28 1.3.2.2 thorpej * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 1.3.2.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 1.3.2.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 1.3.2.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 1.3.2.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 1.3.2.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
34 1.3.2.2 thorpej */
35 1.3.2.2 thorpej /*
36 1.3.2.2 thorpej * Copyright (c) 1992, 1993
37 1.3.2.2 thorpej * The Regents of the University of California. All rights reserved.
38 1.3.2.2 thorpej *
39 1.3.2.2 thorpej * This code is derived from software donated to Berkeley by
40 1.3.2.2 thorpej * Jan-Simon Pendry.
41 1.3.2.2 thorpej *
42 1.3.2.2 thorpej * Redistribution and use in source and binary forms, with or without
43 1.3.2.2 thorpej * modification, are permitted provided that the following conditions
44 1.3.2.2 thorpej * are met:
45 1.3.2.2 thorpej * 1. Redistributions of source code must retain the above copyright
46 1.3.2.2 thorpej * notice, this list of conditions and the following disclaimer.
47 1.3.2.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
48 1.3.2.2 thorpej * notice, this list of conditions and the following disclaimer in the
49 1.3.2.2 thorpej * documentation and/or other materials provided with the distribution.
50 1.3.2.2 thorpej * 3. All advertising materials mentioning features or use of this software
51 1.3.2.2 thorpej * must display the following acknowledgement:
52 1.3.2.2 thorpej * This product includes software developed by the University of
53 1.3.2.2 thorpej * California, Berkeley and its contributors.
54 1.3.2.2 thorpej * 4. Neither the name of the University nor the names of its contributors
55 1.3.2.2 thorpej * may be used to endorse or promote products derived from this software
56 1.3.2.2 thorpej * without specific prior written permission.
57 1.3.2.2 thorpej *
58 1.3.2.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.3.2.2 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.3.2.2 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.3.2.2 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.3.2.2 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.3.2.2 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.3.2.2 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.3.2.2 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.3.2.2 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.3.2.2 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.3.2.2 thorpej * SUCH DAMAGE.
69 1.3.2.2 thorpej *
70 1.3.2.2 thorpej * from: Id: lofs_subr.c,v 1.11 1992/05/30 10:05:43 jsp Exp
71 1.3.2.2 thorpej * @(#)null_subr.c 8.7 (Berkeley) 5/14/95
72 1.3.2.2 thorpej */
73 1.3.2.2 thorpej
74 1.3.2.2 thorpej #include <sys/param.h>
75 1.3.2.2 thorpej #include <sys/systm.h>
76 1.3.2.2 thorpej #include <sys/proc.h>
77 1.3.2.2 thorpej #include <sys/time.h>
78 1.3.2.2 thorpej #include <sys/types.h>
79 1.3.2.2 thorpej #include <sys/vnode.h>
80 1.3.2.2 thorpej #include <sys/mount.h>
81 1.3.2.2 thorpej #include <sys/namei.h>
82 1.3.2.2 thorpej #include <sys/malloc.h>
83 1.3.2.2 thorpej #include <miscfs/specfs/specdev.h>
84 1.3.2.2 thorpej #include <miscfs/genfs/layer.h>
85 1.3.2.2 thorpej #include <miscfs/genfs/layer_extern.h>
86 1.3.2.2 thorpej
87 1.3.2.2 thorpej #define NLAYERNODECACHE 16
88 1.3.2.2 thorpej
89 1.3.2.2 thorpej /*
90 1.3.2.2 thorpej * layer cache:
91 1.3.2.2 thorpej * Each cache entry holds a reference to the lower vnode
92 1.3.2.2 thorpej * along with a pointer to the alias vnode. When an
93 1.3.2.2 thorpej * entry is added the lower vnode is VREF'd. When the
94 1.3.2.2 thorpej * alias is removed the lower vnode is vrele'd.
95 1.3.2.2 thorpej */
96 1.3.2.2 thorpej
97 1.3.2.2 thorpej /*
98 1.3.2.2 thorpej * Initialise cache headers
99 1.3.2.2 thorpej */
100 1.3.2.2 thorpej void
101 1.3.2.2 thorpej layerfs_init()
102 1.3.2.2 thorpej {
103 1.3.2.2 thorpej
104 1.3.2.2 thorpej #ifdef LAYERFS_DIAGNOSTIC
105 1.3.2.2 thorpej printf("layerfs_init\n"); /* printed during system boot */
106 1.3.2.2 thorpej #endif
107 1.3.2.2 thorpej }
108 1.3.2.2 thorpej
109 1.3.2.2 thorpej /*
110 1.3.2.2 thorpej * Return a locked, VREF'ed alias for lower vnode if already exists, else 0.
111 1.3.2.2 thorpej */
112 1.3.2.2 thorpej struct vnode *
113 1.3.2.2 thorpej layer_node_find(mp, lowervp)
114 1.3.2.2 thorpej struct mount *mp;
115 1.3.2.2 thorpej struct vnode *lowervp;
116 1.3.2.2 thorpej {
117 1.3.2.2 thorpej struct layer_mount *lmp = MOUNTTOLAYERMOUNT(mp);
118 1.3.2.2 thorpej struct layer_node_hashhead *hd;
119 1.3.2.2 thorpej struct layer_node *a;
120 1.3.2.2 thorpej struct vnode *vp;
121 1.3.2.2 thorpej
122 1.3.2.2 thorpej /*
123 1.3.2.2 thorpej * Find hash base, and then search the (two-way) linked
124 1.3.2.2 thorpej * list looking for a layer_node structure which is referencing
125 1.3.2.2 thorpej * the lower vnode. If found, the increment the layer_node
126 1.3.2.2 thorpej * reference count (but NOT the lower vnode's VREF counter)
127 1.3.2.2 thorpej * and return the vnode locked.
128 1.3.2.2 thorpej */
129 1.3.2.2 thorpej hd = LAYER_NHASH(lmp, lowervp);
130 1.3.2.2 thorpej loop:
131 1.3.2.2 thorpej simple_lock(&lmp->layerm_hashlock);
132 1.3.2.2 thorpej for (a = hd->lh_first; a != 0; a = a->layer_hash.le_next) {
133 1.3.2.2 thorpej if (a->layer_lowervp == lowervp && LAYERTOV(a)->v_mount == mp) {
134 1.3.2.2 thorpej vp = LAYERTOV(a);
135 1.3.2.2 thorpej simple_unlock(&lmp->layerm_hashlock);
136 1.3.2.2 thorpej /*
137 1.3.2.2 thorpej * We must be careful here as the fact the lower
138 1.3.2.2 thorpej * vnode is locked will imply vp is locked unless
139 1.3.2.2 thorpej * someone has decided to start vclean'ing either
140 1.3.2.2 thorpej * vp or lowervp.
141 1.3.2.2 thorpej *
142 1.3.2.2 thorpej * So we try for an exclusive, recursive lock
143 1.3.2.2 thorpej * on the upper vnode. If it fails, vcleaning
144 1.3.2.2 thorpej * is in progress (so when we try again, we'll
145 1.3.2.2 thorpej * fail). If it succeeds, we now have double
146 1.3.2.2 thorpej * locked the bottom node. So we do an explicit
147 1.3.2.2 thorpej * VOP_UNLOCK on it to keep the counts right. Note
148 1.3.2.2 thorpej * that we will end up with the upper node and
149 1.3.2.2 thorpej * the lower node locked once.
150 1.3.2.2 thorpej */
151 1.3.2.2 thorpej if (vget(vp, LK_EXCLUSIVE | LK_CANRECURSE)) {
152 1.3.2.2 thorpej printf ("layer_node_find: vget failed.\n");
153 1.3.2.2 thorpej goto loop;
154 1.3.2.2 thorpej };
155 1.3.2.2 thorpej VOP_UNLOCK(lowervp, 0);
156 1.3.2.2 thorpej return (vp);
157 1.3.2.2 thorpej }
158 1.3.2.2 thorpej }
159 1.3.2.2 thorpej
160 1.3.2.2 thorpej simple_unlock(&lmp->layerm_hashlock);
161 1.3.2.2 thorpej return NULL;
162 1.3.2.2 thorpej }
163 1.3.2.2 thorpej
164 1.3.2.2 thorpej
165 1.3.2.2 thorpej /*
166 1.3.2.2 thorpej * Make a new layer_node node.
167 1.3.2.2 thorpej * Vp is the alias vnode, lowervp is the lower vnode.
168 1.3.2.2 thorpej * Maintain a reference to lowervp.
169 1.3.2.2 thorpej */
170 1.3.2.2 thorpej int
171 1.3.2.2 thorpej layer_node_alloc(mp, lowervp, vpp)
172 1.3.2.2 thorpej struct mount *mp;
173 1.3.2.2 thorpej struct vnode *lowervp;
174 1.3.2.2 thorpej struct vnode **vpp;
175 1.3.2.2 thorpej {
176 1.3.2.2 thorpej struct layer_mount *lmp = MOUNTTOLAYERMOUNT(mp);
177 1.3.2.2 thorpej struct layer_node_hashhead *hd;
178 1.3.2.2 thorpej struct layer_node *xp;
179 1.3.2.2 thorpej struct vnode *vp, *nvp;
180 1.3.2.2 thorpej int error;
181 1.3.2.2 thorpej extern int (**dead_vnodeop_p) __P((void *));
182 1.3.2.2 thorpej
183 1.3.2.2 thorpej if ((error = getnewvnode(lmp->layerm_tag, mp, lmp->layerm_vnodeop_p,
184 1.3.2.2 thorpej &vp)) != 0)
185 1.3.2.2 thorpej return (error);
186 1.3.2.2 thorpej vp->v_type = lowervp->v_type;
187 1.3.2.2 thorpej vp->v_flag |= VLAYER;
188 1.3.2.2 thorpej
189 1.3.2.2 thorpej MALLOC(xp, struct layer_node *, lmp->layerm_size, M_TEMP, M_WAITOK);
190 1.3.2.2 thorpej if (vp->v_type == VBLK || vp->v_type == VCHR) {
191 1.3.2.2 thorpej MALLOC(vp->v_specinfo, struct specinfo *,
192 1.3.2.2 thorpej sizeof(struct specinfo), M_VNODE, M_WAITOK);
193 1.3.2.2 thorpej vp->v_rdev = lowervp->v_rdev;
194 1.3.2.2 thorpej }
195 1.3.2.2 thorpej
196 1.3.2.2 thorpej vp->v_data = xp;
197 1.3.2.2 thorpej xp->layer_vnode = vp;
198 1.3.2.2 thorpej xp->layer_lowervp = lowervp;
199 1.3.2.2 thorpej xp->layer_flags = 0;
200 1.3.2.2 thorpej /*
201 1.3.2.2 thorpej * Before we insert our new node onto the hash chains,
202 1.3.2.2 thorpej * check to see if someone else has beaten us to it.
203 1.3.2.2 thorpej * (We could have slept in MALLOC.)
204 1.3.2.2 thorpej */
205 1.3.2.2 thorpej if ((nvp = layer_node_find(mp, lowervp)) != NULL) {
206 1.3.2.2 thorpej *vpp = nvp;
207 1.3.2.2 thorpej
208 1.3.2.2 thorpej /* free the substructures we've allocated. */
209 1.3.2.2 thorpej FREE(xp, M_TEMP);
210 1.3.2.2 thorpej if (vp->v_type == VBLK || vp->v_type == VCHR)
211 1.3.2.2 thorpej FREE(vp->v_specinfo, M_VNODE);
212 1.3.2.2 thorpej
213 1.3.2.2 thorpej vp->v_type = VBAD; /* node is discarded */
214 1.3.2.2 thorpej vp->v_op = dead_vnodeop_p; /* so ops will still work */
215 1.3.2.2 thorpej vrele(vp); /* get rid of it. */
216 1.3.2.2 thorpej return (0);
217 1.3.2.2 thorpej }
218 1.3.2.2 thorpej
219 1.3.2.2 thorpej simple_lock(&lmp->layerm_hashlock);
220 1.3.2.2 thorpej
221 1.3.2.2 thorpej /*
222 1.3.2.2 thorpej * Now lock the new node. We rely on the fact that we were passed
223 1.3.2.2 thorpej * a locked vnode. If the lower node is exporting a struct lock
224 1.3.2.2 thorpej * (v_vnlock != NULL) then we just set the upper v_vnlock to the
225 1.3.2.2 thorpej * lower one, and both are now locked. If the lower node is exporting
226 1.3.2.2 thorpej * NULL, then we copy that up and manually lock the upper node.
227 1.3.2.2 thorpej *
228 1.3.2.2 thorpej * LAYERFS_UPPERLOCK already has the test, so we use it after copying
229 1.3.2.2 thorpej * up the v_vnlock from below.
230 1.3.2.2 thorpej */
231 1.3.2.2 thorpej
232 1.3.2.2 thorpej vp->v_vnlock = lowervp->v_vnlock;
233 1.3.2.2 thorpej LAYERFS_UPPERLOCK(vp, LK_EXCLUSIVE, error);
234 1.3.2.2 thorpej
235 1.3.2.2 thorpej if (error) {
236 1.3.2.2 thorpej /*
237 1.3.2.2 thorpej * How did we get a locking error? The node just came off
238 1.3.2.2 thorpej * of the free list, and we're the only routine which
239 1.3.2.2 thorpej * knows it's there...
240 1.3.2.2 thorpej */
241 1.3.2.2 thorpej vp->v_vnlock = &vp->v_lock;
242 1.3.2.2 thorpej *vpp = NULL;
243 1.3.2.2 thorpej
244 1.3.2.2 thorpej /* free the substructures we've allocated. */
245 1.3.2.2 thorpej FREE(xp, M_TEMP);
246 1.3.2.2 thorpej if (vp->v_type == VBLK || vp->v_type == VCHR)
247 1.3.2.2 thorpej FREE(vp->v_specinfo, M_VNODE);
248 1.3.2.2 thorpej
249 1.3.2.2 thorpej vp->v_type = VBAD; /* node is discarded */
250 1.3.2.2 thorpej vp->v_op = dead_vnodeop_p; /* so ops will still work */
251 1.3.2.2 thorpej vrele(vp); /* get rid of it. */
252 1.3.2.2 thorpej return (error);
253 1.3.2.2 thorpej }
254 1.3.2.2 thorpej /*
255 1.3.2.2 thorpej * NetBSD used to do an inlined checkalias here. We do not, as
256 1.3.2.2 thorpej * we never flag device nodes as being aliased. The lowervp
257 1.3.2.2 thorpej * node will, when appropriate, be flaged as an alias.
258 1.3.2.2 thorpej */
259 1.3.2.2 thorpej
260 1.3.2.2 thorpej *vpp = vp;
261 1.3.2.2 thorpej VREF(lowervp); /* Take into account reference held in layer_node */
262 1.3.2.2 thorpej hd = LAYER_NHASH(lmp, lowervp);
263 1.3.2.2 thorpej LIST_INSERT_HEAD(hd, xp, layer_hash);
264 1.3.2.2 thorpej simple_unlock(&lmp->layerm_hashlock);
265 1.3.2.2 thorpej return (0);
266 1.3.2.2 thorpej }
267 1.3.2.2 thorpej
268 1.3.2.2 thorpej
269 1.3.2.2 thorpej /*
270 1.3.2.2 thorpej * Try to find an existing layer_node vnode refering
271 1.3.2.2 thorpej * to it, otherwise make a new layer_node vnode which
272 1.3.2.2 thorpej * contains a reference to the lower vnode.
273 1.3.2.2 thorpej *
274 1.3.2.2 thorpej * >>> we assume that the lower node is already locked upon entry, so we
275 1.3.2.2 thorpej * propagate the lock state to upper node <<
276 1.3.2.2 thorpej */
277 1.3.2.2 thorpej int
278 1.3.2.2 thorpej layer_node_create(mp, lowervp, newvpp)
279 1.3.2.2 thorpej struct mount *mp;
280 1.3.2.2 thorpej struct vnode *lowervp;
281 1.3.2.2 thorpej struct vnode **newvpp;
282 1.3.2.2 thorpej {
283 1.3.2.2 thorpej struct vnode *aliasvp;
284 1.3.2.2 thorpej struct layer_mount *lmp = MOUNTTOLAYERMOUNT(mp);
285 1.3.2.2 thorpej
286 1.3.2.2 thorpej if ((aliasvp = layer_node_find(mp, lowervp)) != NULL) {
287 1.3.2.2 thorpej /*
288 1.3.2.2 thorpej * layer_node_find has taken another reference
289 1.3.2.2 thorpej * to the alias vnode and moved the lock holding to
290 1.3.2.2 thorpej * aliasvp
291 1.3.2.2 thorpej */
292 1.3.2.2 thorpej #ifdef LAYERFS_DIAGNOSTIC
293 1.3.2.2 thorpej vprint("layer_node_create: exists", aliasvp);
294 1.3.2.2 thorpej #endif
295 1.3.2.2 thorpej } else {
296 1.3.2.2 thorpej int error;
297 1.3.2.2 thorpej
298 1.3.2.2 thorpej /*
299 1.3.2.2 thorpej * Get new vnode.
300 1.3.2.2 thorpej */
301 1.3.2.2 thorpej #ifdef LAYERFS_DIAGNOSTIC
302 1.3.2.2 thorpej printf("layer_node_create: create new alias vnode\n");
303 1.3.2.2 thorpej #endif
304 1.3.2.2 thorpej
305 1.3.2.2 thorpej /*
306 1.3.2.2 thorpej * Make new vnode reference the layer_node.
307 1.3.2.2 thorpej */
308 1.3.2.2 thorpej if ((error = (lmp->layerm_alloc)(mp, lowervp, &aliasvp)) != 0)
309 1.3.2.2 thorpej return error;
310 1.3.2.2 thorpej
311 1.3.2.2 thorpej /*
312 1.3.2.2 thorpej * aliasvp is already VREF'd by getnewvnode()
313 1.3.2.2 thorpej */
314 1.3.2.2 thorpej }
315 1.3.2.2 thorpej
316 1.3.2.2 thorpej /*
317 1.3.2.2 thorpej * Now that we have VREF'd the upper vnode, release the reference
318 1.3.2.2 thorpej * to the lower node. The existance of the layer_node retains one
319 1.3.2.2 thorpej * reference to the lower node.
320 1.3.2.2 thorpej */
321 1.3.2.2 thorpej vrele(lowervp);
322 1.3.2.2 thorpej
323 1.3.2.2 thorpej #ifdef DIAGNOSTIC
324 1.3.2.2 thorpej if (lowervp->v_usecount < 1) {
325 1.3.2.2 thorpej /* Should never happen... */
326 1.3.2.2 thorpej vprint("layer_node_create: alias", aliasvp);
327 1.3.2.2 thorpej vprint("layer_node_create: lower", lowervp);
328 1.3.2.2 thorpej panic("layer_node_create: lower has 0 usecount.");
329 1.3.2.2 thorpej };
330 1.3.2.2 thorpej #endif
331 1.3.2.2 thorpej
332 1.3.2.2 thorpej #ifdef LAYERFS_DIAGNOSTIC
333 1.3.2.2 thorpej vprint("layer_node_create: alias", aliasvp);
334 1.3.2.2 thorpej #endif
335 1.3.2.2 thorpej *newvpp = aliasvp;
336 1.3.2.2 thorpej return (0);
337 1.3.2.2 thorpej }
338 1.3.2.2 thorpej
339 1.3.2.2 thorpej struct vnode *
340 1.3.2.2 thorpej layer_checkvp(vp, fil, lno)
341 1.3.2.2 thorpej struct vnode *vp;
342 1.3.2.2 thorpej char *fil;
343 1.3.2.2 thorpej int lno;
344 1.3.2.2 thorpej {
345 1.3.2.2 thorpej struct layer_node *a = VTOLAYER(vp);
346 1.3.2.2 thorpej #ifdef notyet
347 1.3.2.2 thorpej /*
348 1.3.2.2 thorpej * Can't do this check because vop_reclaim runs
349 1.3.2.2 thorpej * with a funny vop vector.
350 1.3.2.2 thorpej *
351 1.3.2.2 thorpej * WRS - no it doesnt...
352 1.3.2.2 thorpej */
353 1.3.2.2 thorpej if (vp->v_op != layer_vnodeop_p) {
354 1.3.2.2 thorpej printf ("layer_checkvp: on non-layer-node\n");
355 1.3.2.2 thorpej #ifdef notyet
356 1.3.2.2 thorpej while (layer_checkvp_barrier) /*WAIT*/ ;
357 1.3.2.2 thorpej #endif
358 1.3.2.2 thorpej panic("layer_checkvp");
359 1.3.2.2 thorpej };
360 1.3.2.2 thorpej #endif
361 1.3.2.2 thorpej if (a->layer_lowervp == NULL) {
362 1.3.2.2 thorpej /* Should never happen */
363 1.3.2.2 thorpej int i; u_long *p;
364 1.3.2.2 thorpej printf("vp = %p, ZERO ptr\n", vp);
365 1.3.2.2 thorpej for (p = (u_long *) a, i = 0; i < 8; i++)
366 1.3.2.2 thorpej printf(" %lx", p[i]);
367 1.3.2.2 thorpej printf("\n");
368 1.3.2.2 thorpej /* wait for debugger */
369 1.3.2.2 thorpej panic("layer_checkvp");
370 1.3.2.2 thorpej }
371 1.3.2.2 thorpej if (a->layer_lowervp->v_usecount < 1) {
372 1.3.2.2 thorpej int i; u_long *p;
373 1.3.2.2 thorpej printf("vp = %p, unref'ed lowervp\n", vp);
374 1.3.2.2 thorpej for (p = (u_long *) a, i = 0; i < 8; i++)
375 1.3.2.2 thorpej printf(" %lx", p[i]);
376 1.3.2.2 thorpej printf("\n");
377 1.3.2.2 thorpej /* wait for debugger */
378 1.3.2.2 thorpej panic ("layer with unref'ed lowervp");
379 1.3.2.2 thorpej };
380 1.3.2.2 thorpej #ifdef notnow
381 1.3.2.2 thorpej printf("layer %p/%d -> %p/%d [%s, %d]\n",
382 1.3.2.2 thorpej LAYERTOV(a), LAYERTOV(a)->v_usecount,
383 1.3.2.2 thorpej a->layer_lowervp, a->layer_lowervp->v_usecount,
384 1.3.2.2 thorpej fil, lno);
385 1.3.2.2 thorpej #endif
386 1.3.2.2 thorpej return a->layer_lowervp;
387 1.3.2.2 thorpej }
388