null_vnops.c revision 1.3 1 1.3 mycroft /* $NetBSD: null_vnops.c,v 1.3 1994/07/20 07:37:25 mycroft Exp $ */
2 1.2 cgd
3 1.1 mycroft /*
4 1.1 mycroft * Copyright (c) 1992, 1993
5 1.1 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 mycroft *
7 1.1 mycroft * This code is derived from software contributed to Berkeley by
8 1.1 mycroft * John Heidemann of the UCLA Ficus project.
9 1.1 mycroft *
10 1.1 mycroft * Redistribution and use in source and binary forms, with or without
11 1.1 mycroft * modification, are permitted provided that the following conditions
12 1.1 mycroft * are met:
13 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
14 1.1 mycroft * notice, this list of conditions and the following disclaimer.
15 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
17 1.1 mycroft * documentation and/or other materials provided with the distribution.
18 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
19 1.1 mycroft * must display the following acknowledgement:
20 1.1 mycroft * This product includes software developed by the University of
21 1.1 mycroft * California, Berkeley and its contributors.
22 1.1 mycroft * 4. Neither the name of the University nor the names of its contributors
23 1.1 mycroft * may be used to endorse or promote products derived from this software
24 1.1 mycroft * without specific prior written permission.
25 1.1 mycroft *
26 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 mycroft * SUCH DAMAGE.
37 1.1 mycroft *
38 1.2 cgd * @(#)null_vnops.c 8.1 (Berkeley) 6/10/93
39 1.1 mycroft *
40 1.1 mycroft * Ancestors:
41 1.1 mycroft * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92
42 1.1 mycroft * Id: lofs_vnops.c,v 1.11 1992/05/30 10:05:43 jsp Exp
43 1.1 mycroft * ...and...
44 1.1 mycroft * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
45 1.1 mycroft */
46 1.1 mycroft
47 1.1 mycroft /*
48 1.1 mycroft * Null Layer
49 1.1 mycroft *
50 1.1 mycroft * (See mount_null(8) for more information.)
51 1.1 mycroft *
52 1.1 mycroft * The null layer duplicates a portion of the file system
53 1.1 mycroft * name space under a new name. In this respect, it is
54 1.1 mycroft * similar to the loopback file system. It differs from
55 1.1 mycroft * the loopback fs in two respects: it is implemented using
56 1.1 mycroft * a stackable layers techniques, and it's "null-node"s stack above
57 1.1 mycroft * all lower-layer vnodes, not just over directory vnodes.
58 1.1 mycroft *
59 1.1 mycroft * The null layer has two purposes. First, it serves as a demonstration
60 1.1 mycroft * of layering by proving a layer which does nothing. (It actually
61 1.1 mycroft * does everything the loopback file system does, which is slightly
62 1.1 mycroft * more than nothing.) Second, the null layer can serve as a prototype
63 1.1 mycroft * layer. Since it provides all necessary layer framework,
64 1.1 mycroft * new file system layers can be created very easily be starting
65 1.1 mycroft * with a null layer.
66 1.1 mycroft *
67 1.1 mycroft * The remainder of this man page examines the null layer as a basis
68 1.1 mycroft * for constructing new layers.
69 1.1 mycroft *
70 1.1 mycroft *
71 1.1 mycroft * INSTANTIATING NEW NULL LAYERS
72 1.1 mycroft *
73 1.1 mycroft * New null layers are created with mount_null(8).
74 1.1 mycroft * Mount_null(8) takes two arguments, the pathname
75 1.1 mycroft * of the lower vfs (target-pn) and the pathname where the null
76 1.1 mycroft * layer will appear in the namespace (alias-pn). After
77 1.1 mycroft * the null layer is put into place, the contents
78 1.1 mycroft * of target-pn subtree will be aliased under alias-pn.
79 1.1 mycroft *
80 1.1 mycroft *
81 1.1 mycroft * OPERATION OF A NULL LAYER
82 1.1 mycroft *
83 1.1 mycroft * The null layer is the minimum file system layer,
84 1.1 mycroft * simply bypassing all possible operations to the lower layer
85 1.1 mycroft * for processing there. The majority of its activity centers
86 1.1 mycroft * on the bypass routine, though which nearly all vnode operations
87 1.1 mycroft * pass.
88 1.1 mycroft *
89 1.1 mycroft * The bypass routine accepts arbitrary vnode operations for
90 1.1 mycroft * handling by the lower layer. It begins by examing vnode
91 1.1 mycroft * operation arguments and replacing any null-nodes by their
92 1.1 mycroft * lower-layer equivlants. It then invokes the operation
93 1.1 mycroft * on the lower layer. Finally, it replaces the null-nodes
94 1.1 mycroft * in the arguments and, if a vnode is return by the operation,
95 1.1 mycroft * stacks a null-node on top of the returned vnode.
96 1.1 mycroft *
97 1.1 mycroft * Although bypass handles most operations,
98 1.1 mycroft * vop_getattr, _inactive, _reclaim, and _print are not bypassed.
99 1.1 mycroft * Vop_getattr must change the fsid being returned.
100 1.1 mycroft * Vop_inactive and vop_reclaim are not bypassed so that
101 1.1 mycroft * they can handle freeing null-layer specific data.
102 1.1 mycroft * Vop_print is not bypassed to avoid excessive debugging
103 1.1 mycroft * information.
104 1.1 mycroft *
105 1.1 mycroft *
106 1.1 mycroft * INSTANTIATING VNODE STACKS
107 1.1 mycroft *
108 1.1 mycroft * Mounting associates the null layer with a lower layer,
109 1.1 mycroft * effect stacking two VFSes. Vnode stacks are instead
110 1.1 mycroft * created on demand as files are accessed.
111 1.1 mycroft *
112 1.1 mycroft * The initial mount creates a single vnode stack for the
113 1.1 mycroft * root of the new null layer. All other vnode stacks
114 1.1 mycroft * are created as a result of vnode operations on
115 1.1 mycroft * this or other null vnode stacks.
116 1.1 mycroft *
117 1.1 mycroft * New vnode stacks come into existance as a result of
118 1.1 mycroft * an operation which returns a vnode.
119 1.1 mycroft * The bypass routine stacks a null-node above the new
120 1.1 mycroft * vnode before returning it to the caller.
121 1.1 mycroft *
122 1.1 mycroft * For example, imagine mounting a null layer with
123 1.1 mycroft * "mount_null /usr/include /dev/layer/null".
124 1.1 mycroft * Changing directory to /dev/layer/null will assign
125 1.1 mycroft * the root null-node (which was created when the null layer was mounted).
126 1.1 mycroft * Now consider opening "sys". A vop_lookup would be
127 1.1 mycroft * done on the root null-node. This operation would bypass through
128 1.1 mycroft * to the lower layer which would return a vnode representing
129 1.1 mycroft * the UFS "sys". Null_bypass then builds a null-node
130 1.1 mycroft * aliasing the UFS "sys" and returns this to the caller.
131 1.1 mycroft * Later operations on the null-node "sys" will repeat this
132 1.1 mycroft * process when constructing other vnode stacks.
133 1.1 mycroft *
134 1.1 mycroft *
135 1.1 mycroft * CREATING OTHER FILE SYSTEM LAYERS
136 1.1 mycroft *
137 1.1 mycroft * One of the easiest ways to construct new file system layers is to make
138 1.1 mycroft * a copy of the null layer, rename all files and variables, and
139 1.1 mycroft * then begin modifing the copy. Sed can be used to easily rename
140 1.1 mycroft * all variables.
141 1.1 mycroft *
142 1.1 mycroft * The umap layer is an example of a layer descended from the
143 1.1 mycroft * null layer.
144 1.1 mycroft *
145 1.1 mycroft *
146 1.1 mycroft * INVOKING OPERATIONS ON LOWER LAYERS
147 1.1 mycroft *
148 1.1 mycroft * There are two techniques to invoke operations on a lower layer
149 1.1 mycroft * when the operation cannot be completely bypassed. Each method
150 1.1 mycroft * is appropriate in different situations. In both cases,
151 1.1 mycroft * it is the responsibility of the aliasing layer to make
152 1.1 mycroft * the operation arguments "correct" for the lower layer
153 1.1 mycroft * by mapping an vnode arguments to the lower layer.
154 1.1 mycroft *
155 1.1 mycroft * The first approach is to call the aliasing layer's bypass routine.
156 1.1 mycroft * This method is most suitable when you wish to invoke the operation
157 1.1 mycroft * currently being hanldled on the lower layer. It has the advantage
158 1.1 mycroft * that the bypass routine already must do argument mapping.
159 1.1 mycroft * An example of this is null_getattrs in the null layer.
160 1.1 mycroft *
161 1.1 mycroft * A second approach is to directly invoked vnode operations on
162 1.1 mycroft * the lower layer with the VOP_OPERATIONNAME interface.
163 1.1 mycroft * The advantage of this method is that it is easy to invoke
164 1.1 mycroft * arbitrary operations on the lower layer. The disadvantage
165 1.1 mycroft * is that vnodes arguments must be manualy mapped.
166 1.1 mycroft *
167 1.1 mycroft */
168 1.1 mycroft
169 1.1 mycroft #include <sys/param.h>
170 1.1 mycroft #include <sys/systm.h>
171 1.1 mycroft #include <sys/proc.h>
172 1.1 mycroft #include <sys/time.h>
173 1.1 mycroft #include <sys/types.h>
174 1.1 mycroft #include <sys/vnode.h>
175 1.1 mycroft #include <sys/mount.h>
176 1.1 mycroft #include <sys/namei.h>
177 1.1 mycroft #include <sys/malloc.h>
178 1.1 mycroft #include <sys/buf.h>
179 1.1 mycroft #include <miscfs/nullfs/null.h>
180 1.1 mycroft
181 1.1 mycroft
182 1.1 mycroft int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
183 1.1 mycroft
184 1.1 mycroft /*
185 1.1 mycroft * This is the 10-Apr-92 bypass routine.
186 1.1 mycroft * This version has been optimized for speed, throwing away some
187 1.1 mycroft * safety checks. It should still always work, but it's not as
188 1.1 mycroft * robust to programmer errors.
189 1.1 mycroft * Define SAFETY to include some error checking code.
190 1.1 mycroft *
191 1.1 mycroft * In general, we map all vnodes going down and unmap them on the way back.
192 1.1 mycroft * As an exception to this, vnodes can be marked "unmapped" by setting
193 1.1 mycroft * the Nth bit in operation's vdesc_flags.
194 1.1 mycroft *
195 1.1 mycroft * Also, some BSD vnode operations have the side effect of vrele'ing
196 1.1 mycroft * their arguments. With stacking, the reference counts are held
197 1.1 mycroft * by the upper node, not the lower one, so we must handle these
198 1.1 mycroft * side-effects here. This is not of concern in Sun-derived systems
199 1.1 mycroft * since there are no such side-effects.
200 1.1 mycroft *
201 1.1 mycroft * This makes the following assumptions:
202 1.1 mycroft * - only one returned vpp
203 1.1 mycroft * - no INOUT vpp's (Sun's vop_open has one of these)
204 1.1 mycroft * - the vnode operation vector of the first vnode should be used
205 1.1 mycroft * to determine what implementation of the op should be invoked
206 1.1 mycroft * - all mapped vnodes are of our vnode-type (NEEDSWORK:
207 1.1 mycroft * problems on rmdir'ing mount points and renaming?)
208 1.1 mycroft */
209 1.1 mycroft int
210 1.1 mycroft null_bypass(ap)
211 1.1 mycroft struct vop_generic_args /* {
212 1.1 mycroft struct vnodeop_desc *a_desc;
213 1.1 mycroft <other random data follows, presumably>
214 1.1 mycroft } */ *ap;
215 1.1 mycroft {
216 1.1 mycroft extern int (**null_vnodeop_p)(); /* not extern, really "forward" */
217 1.1 mycroft register struct vnode **this_vp_p;
218 1.1 mycroft int error;
219 1.1 mycroft struct vnode *old_vps[VDESC_MAX_VPS];
220 1.1 mycroft struct vnode **vps_p[VDESC_MAX_VPS];
221 1.1 mycroft struct vnode ***vppp;
222 1.1 mycroft struct vnodeop_desc *descp = ap->a_desc;
223 1.1 mycroft int reles, i;
224 1.1 mycroft
225 1.1 mycroft if (null_bug_bypass)
226 1.1 mycroft printf ("null_bypass: %s\n", descp->vdesc_name);
227 1.1 mycroft
228 1.1 mycroft #ifdef SAFETY
229 1.1 mycroft /*
230 1.1 mycroft * We require at least one vp.
231 1.1 mycroft */
232 1.1 mycroft if (descp->vdesc_vp_offsets == NULL ||
233 1.1 mycroft descp->vdesc_vp_offsets[0] == VDESC_NO_OFFSET)
234 1.1 mycroft panic ("null_bypass: no vp's in map.\n");
235 1.1 mycroft #endif
236 1.1 mycroft
237 1.1 mycroft /*
238 1.1 mycroft * Map the vnodes going in.
239 1.1 mycroft * Later, we'll invoke the operation based on
240 1.1 mycroft * the first mapped vnode's operation vector.
241 1.1 mycroft */
242 1.1 mycroft reles = descp->vdesc_flags;
243 1.1 mycroft for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
244 1.1 mycroft if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
245 1.1 mycroft break; /* bail out at end of list */
246 1.1 mycroft vps_p[i] = this_vp_p =
247 1.1 mycroft VOPARG_OFFSETTO(struct vnode**,descp->vdesc_vp_offsets[i],ap);
248 1.1 mycroft /*
249 1.1 mycroft * We're not guaranteed that any but the first vnode
250 1.1 mycroft * are of our type. Check for and don't map any
251 1.1 mycroft * that aren't. (We must always map first vp or vclean fails.)
252 1.1 mycroft */
253 1.3 mycroft if (i && (*this_vp_p == NULLVP ||
254 1.3 mycroft (*this_vp_p)->v_op != null_vnodeop_p)) {
255 1.3 mycroft old_vps[i] = NULLVP;
256 1.1 mycroft } else {
257 1.1 mycroft old_vps[i] = *this_vp_p;
258 1.1 mycroft *(vps_p[i]) = NULLVPTOLOWERVP(*this_vp_p);
259 1.1 mycroft /*
260 1.1 mycroft * XXX - Several operations have the side effect
261 1.1 mycroft * of vrele'ing their vp's. We must account for
262 1.1 mycroft * that. (This should go away in the future.)
263 1.1 mycroft */
264 1.1 mycroft if (reles & 1)
265 1.1 mycroft VREF(*this_vp_p);
266 1.1 mycroft }
267 1.1 mycroft
268 1.1 mycroft }
269 1.1 mycroft
270 1.1 mycroft /*
271 1.1 mycroft * Call the operation on the lower layer
272 1.1 mycroft * with the modified argument structure.
273 1.1 mycroft */
274 1.1 mycroft error = VCALL(*(vps_p[0]), descp->vdesc_offset, ap);
275 1.1 mycroft
276 1.1 mycroft /*
277 1.1 mycroft * Maintain the illusion of call-by-value
278 1.1 mycroft * by restoring vnodes in the argument structure
279 1.1 mycroft * to their original value.
280 1.1 mycroft */
281 1.1 mycroft reles = descp->vdesc_flags;
282 1.1 mycroft for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
283 1.1 mycroft if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
284 1.1 mycroft break; /* bail out at end of list */
285 1.3 mycroft if (old_vps[i] != NULLVP) {
286 1.1 mycroft *(vps_p[i]) = old_vps[i];
287 1.1 mycroft if (reles & 1)
288 1.1 mycroft vrele(*(vps_p[i]));
289 1.1 mycroft }
290 1.1 mycroft }
291 1.1 mycroft
292 1.1 mycroft /*
293 1.1 mycroft * Map the possible out-going vpp
294 1.1 mycroft * (Assumes that the lower layer always returns
295 1.1 mycroft * a VREF'ed vpp unless it gets an error.)
296 1.1 mycroft */
297 1.1 mycroft if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET &&
298 1.1 mycroft !(descp->vdesc_flags & VDESC_NOMAP_VPP) &&
299 1.1 mycroft !error) {
300 1.1 mycroft /*
301 1.1 mycroft * XXX - even though some ops have vpp returned vp's,
302 1.1 mycroft * several ops actually vrele this before returning.
303 1.1 mycroft * We must avoid these ops.
304 1.1 mycroft * (This should go away when these ops are regularized.)
305 1.1 mycroft */
306 1.1 mycroft if (descp->vdesc_flags & VDESC_VPP_WILLRELE)
307 1.1 mycroft goto out;
308 1.1 mycroft vppp = VOPARG_OFFSETTO(struct vnode***,
309 1.1 mycroft descp->vdesc_vpp_offset,ap);
310 1.1 mycroft error = null_node_create(old_vps[0]->v_mount, **vppp, *vppp);
311 1.1 mycroft }
312 1.1 mycroft
313 1.1 mycroft out:
314 1.1 mycroft return (error);
315 1.1 mycroft }
316 1.1 mycroft
317 1.1 mycroft
318 1.1 mycroft /*
319 1.1 mycroft * We handle getattr only to change the fsid.
320 1.1 mycroft */
321 1.1 mycroft int
322 1.1 mycroft null_getattr(ap)
323 1.1 mycroft struct vop_getattr_args /* {
324 1.1 mycroft struct vnode *a_vp;
325 1.1 mycroft struct vattr *a_vap;
326 1.1 mycroft struct ucred *a_cred;
327 1.1 mycroft struct proc *a_p;
328 1.1 mycroft } */ *ap;
329 1.1 mycroft {
330 1.1 mycroft int error;
331 1.1 mycroft if (error = null_bypass(ap))
332 1.1 mycroft return (error);
333 1.1 mycroft /* Requires that arguments be restored. */
334 1.1 mycroft ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
335 1.1 mycroft return (0);
336 1.1 mycroft }
337 1.1 mycroft
338 1.1 mycroft
339 1.1 mycroft int
340 1.1 mycroft null_inactive(ap)
341 1.1 mycroft struct vop_inactive_args /* {
342 1.1 mycroft struct vnode *a_vp;
343 1.1 mycroft } */ *ap;
344 1.1 mycroft {
345 1.1 mycroft /*
346 1.1 mycroft * Do nothing (and _don't_ bypass).
347 1.1 mycroft * Wait to vrele lowervp until reclaim,
348 1.1 mycroft * so that until then our null_node is in the
349 1.1 mycroft * cache and reusable.
350 1.1 mycroft *
351 1.1 mycroft * NEEDSWORK: Someday, consider inactive'ing
352 1.1 mycroft * the lowervp and then trying to reactivate it
353 1.1 mycroft * with capabilities (v_id)
354 1.1 mycroft * like they do in the name lookup cache code.
355 1.1 mycroft * That's too much work for now.
356 1.1 mycroft */
357 1.1 mycroft return (0);
358 1.1 mycroft }
359 1.1 mycroft
360 1.1 mycroft int
361 1.1 mycroft null_reclaim(ap)
362 1.1 mycroft struct vop_reclaim_args /* {
363 1.1 mycroft struct vnode *a_vp;
364 1.1 mycroft } */ *ap;
365 1.1 mycroft {
366 1.1 mycroft struct vnode *vp = ap->a_vp;
367 1.1 mycroft struct null_node *xp = VTONULL(vp);
368 1.1 mycroft struct vnode *lowervp = xp->null_lowervp;
369 1.1 mycroft
370 1.1 mycroft /*
371 1.1 mycroft * Note: in vop_reclaim, vp->v_op == dead_vnodeop_p,
372 1.1 mycroft * so we can't call VOPs on ourself.
373 1.1 mycroft */
374 1.1 mycroft /* After this assignment, this node will not be re-used. */
375 1.1 mycroft xp->null_lowervp = NULL;
376 1.1 mycroft remque(xp);
377 1.1 mycroft FREE(vp->v_data, M_TEMP);
378 1.1 mycroft vp->v_data = NULL;
379 1.1 mycroft vrele (lowervp);
380 1.1 mycroft return (0);
381 1.1 mycroft }
382 1.1 mycroft
383 1.1 mycroft
384 1.1 mycroft int
385 1.1 mycroft null_print(ap)
386 1.1 mycroft struct vop_print_args /* {
387 1.1 mycroft struct vnode *a_vp;
388 1.1 mycroft } */ *ap;
389 1.1 mycroft {
390 1.1 mycroft register struct vnode *vp = ap->a_vp;
391 1.1 mycroft printf ("\ttag VT_NULLFS, vp=%x, lowervp=%x\n", vp, NULLVPTOLOWERVP(vp));
392 1.1 mycroft return (0);
393 1.1 mycroft }
394 1.1 mycroft
395 1.1 mycroft
396 1.1 mycroft /*
397 1.1 mycroft * XXX - vop_strategy must be hand coded because it has no
398 1.1 mycroft * vnode in its arguments.
399 1.1 mycroft * This goes away with a merged VM/buffer cache.
400 1.1 mycroft */
401 1.1 mycroft int
402 1.1 mycroft null_strategy(ap)
403 1.1 mycroft struct vop_strategy_args /* {
404 1.1 mycroft struct buf *a_bp;
405 1.1 mycroft } */ *ap;
406 1.1 mycroft {
407 1.1 mycroft struct buf *bp = ap->a_bp;
408 1.1 mycroft int error;
409 1.1 mycroft struct vnode *savedvp;
410 1.1 mycroft
411 1.1 mycroft savedvp = bp->b_vp;
412 1.1 mycroft bp->b_vp = NULLVPTOLOWERVP(bp->b_vp);
413 1.1 mycroft
414 1.1 mycroft error = VOP_STRATEGY(bp);
415 1.1 mycroft
416 1.1 mycroft bp->b_vp = savedvp;
417 1.1 mycroft
418 1.1 mycroft return (error);
419 1.1 mycroft }
420 1.1 mycroft
421 1.1 mycroft
422 1.1 mycroft /*
423 1.1 mycroft * XXX - like vop_strategy, vop_bwrite must be hand coded because it has no
424 1.1 mycroft * vnode in its arguments.
425 1.1 mycroft * This goes away with a merged VM/buffer cache.
426 1.1 mycroft */
427 1.1 mycroft int
428 1.1 mycroft null_bwrite(ap)
429 1.1 mycroft struct vop_bwrite_args /* {
430 1.1 mycroft struct buf *a_bp;
431 1.1 mycroft } */ *ap;
432 1.1 mycroft {
433 1.1 mycroft struct buf *bp = ap->a_bp;
434 1.1 mycroft int error;
435 1.1 mycroft struct vnode *savedvp;
436 1.1 mycroft
437 1.1 mycroft savedvp = bp->b_vp;
438 1.1 mycroft bp->b_vp = NULLVPTOLOWERVP(bp->b_vp);
439 1.1 mycroft
440 1.1 mycroft error = VOP_BWRITE(bp);
441 1.1 mycroft
442 1.1 mycroft bp->b_vp = savedvp;
443 1.1 mycroft
444 1.1 mycroft return (error);
445 1.1 mycroft }
446 1.1 mycroft
447 1.1 mycroft /*
448 1.1 mycroft * Global vfs data structures
449 1.1 mycroft */
450 1.1 mycroft int (**null_vnodeop_p)();
451 1.1 mycroft struct vnodeopv_entry_desc null_vnodeop_entries[] = {
452 1.1 mycroft { &vop_default_desc, null_bypass },
453 1.1 mycroft
454 1.1 mycroft { &vop_getattr_desc, null_getattr },
455 1.1 mycroft { &vop_inactive_desc, null_inactive },
456 1.1 mycroft { &vop_reclaim_desc, null_reclaim },
457 1.1 mycroft { &vop_print_desc, null_print },
458 1.1 mycroft
459 1.1 mycroft { &vop_strategy_desc, null_strategy },
460 1.1 mycroft { &vop_bwrite_desc, null_bwrite },
461 1.1 mycroft
462 1.1 mycroft { (struct vnodeop_desc*)NULL, (int(*)())NULL }
463 1.1 mycroft };
464 1.1 mycroft struct vnodeopv_desc null_vnodeop_opv_desc =
465 1.1 mycroft { &null_vnodeop_p, null_vnodeop_entries };
466