xref: /freebsd/sys/fs/nullfs/null_vnops.c (revision 4a0f765fbf09711e612e86fce8bb09ec43f482d9)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * John Heidemann of the UCLA Ficus project.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by the University of
19  *	California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	@(#)null_vnops.c	8.6 (Berkeley) 5/27/95
37  *
38  * Ancestors:
39  *	@(#)lofs_vnops.c	1.2 (Berkeley) 6/18/92
40  *	$Id: null_vnops.c,v 1.15 1997/02/12 18:06:08 mpp Exp $
41  *	...and...
42  *	@(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
43  *
44  * $Id$
45  */
46 
47 /*
48  * Null Layer
49  *
50  * (See mount_null(8) for more information.)
51  *
52  * The null layer duplicates a portion of the file system
53  * name space under a new name.  In this respect, it is
54  * similar to the loopback file system.  It differs from
55  * the loopback fs in two respects:  it is implemented using
56  * a stackable layers techniques, and it's "null-node"s stack above
57  * all lower-layer vnodes, not just over directory vnodes.
58  *
59  * The null layer has two purposes.  First, it serves as a demonstration
60  * of layering by proving a layer which does nothing.  (It actually
61  * does everything the loopback file system does, which is slightly
62  * more than nothing.)  Second, the null layer can serve as a prototype
63  * layer.  Since it provides all necessary layer framework,
64  * new file system layers can be created very easily be starting
65  * with a null layer.
66  *
67  * The remainder of this man page examines the null layer as a basis
68  * for constructing new layers.
69  *
70  *
71  * INSTANTIATING NEW NULL LAYERS
72  *
73  * New null layers are created with mount_null(8).
74  * Mount_null(8) takes two arguments, the pathname
75  * of the lower vfs (target-pn) and the pathname where the null
76  * layer will appear in the namespace (alias-pn).  After
77  * the null layer is put into place, the contents
78  * of target-pn subtree will be aliased under alias-pn.
79  *
80  *
81  * OPERATION OF A NULL LAYER
82  *
83  * The null layer is the minimum file system layer,
84  * simply bypassing all possible operations to the lower layer
85  * for processing there.  The majority of its activity centers
86  * on the bypass routine, though which nearly all vnode operations
87  * pass.
88  *
89  * The bypass routine accepts arbitrary vnode operations for
90  * handling by the lower layer.  It begins by examing vnode
91  * operation arguments and replacing any null-nodes by their
92  * lower-layer equivlants.  It then invokes the operation
93  * on the lower layer.  Finally, it replaces the null-nodes
94  * in the arguments and, if a vnode is return by the operation,
95  * stacks a null-node on top of the returned vnode.
96  *
97  * Although bypass handles most operations, vop_getattr, vop_lock,
98  * vop_unlock, vop_inactive, vop_reclaim, and vop_print are not
99  * bypassed. Vop_getattr must change the fsid being returned.
100  * Vop_lock and vop_unlock must handle any locking for the
101  * current vnode as well as pass the lock request down.
102  * Vop_inactive and vop_reclaim are not bypassed so that
103  * they can handle freeing null-layer specific data. Vop_print
104  * is not bypassed to avoid excessive debugging information.
105  * Also, certain vnode operations change the locking state within
106  * the operation (create, mknod, remove, link, rename, mkdir, rmdir,
107  * and symlink). Ideally these operations should not change the
108  * lock state, but should be changed to let the caller of the
109  * function unlock them. Otherwise all intermediate vnode layers
110  * (such as union, umapfs, etc) must catch these functions to do
111  * the necessary locking at their layer.
112  *
113  *
114  * INSTANTIATING VNODE STACKS
115  *
116  * Mounting associates the null layer with a lower layer,
117  * effect stacking two VFSes.  Vnode stacks are instead
118  * created on demand as files are accessed.
119  *
120  * The initial mount creates a single vnode stack for the
121  * root of the new null layer.  All other vnode stacks
122  * are created as a result of vnode operations on
123  * this or other null vnode stacks.
124  *
125  * New vnode stacks come into existance as a result of
126  * an operation which returns a vnode.
127  * The bypass routine stacks a null-node above the new
128  * vnode before returning it to the caller.
129  *
130  * For example, imagine mounting a null layer with
131  * "mount_null /usr/include /dev/layer/null".
132  * Changing directory to /dev/layer/null will assign
133  * the root null-node (which was created when the null layer was mounted).
134  * Now consider opening "sys".  A vop_lookup would be
135  * done on the root null-node.  This operation would bypass through
136  * to the lower layer which would return a vnode representing
137  * the UFS "sys".  Null_bypass then builds a null-node
138  * aliasing the UFS "sys" and returns this to the caller.
139  * Later operations on the null-node "sys" will repeat this
140  * process when constructing other vnode stacks.
141  *
142  *
143  * CREATING OTHER FILE SYSTEM LAYERS
144  *
145  * One of the easiest ways to construct new file system layers is to make
146  * a copy of the null layer, rename all files and variables, and
147  * then begin modifing the copy.  Sed can be used to easily rename
148  * all variables.
149  *
150  * The umap layer is an example of a layer descended from the
151  * null layer.
152  *
153  *
154  * INVOKING OPERATIONS ON LOWER LAYERS
155  *
156  * There are two techniques to invoke operations on a lower layer
157  * when the operation cannot be completely bypassed.  Each method
158  * is appropriate in different situations.  In both cases,
159  * it is the responsibility of the aliasing layer to make
160  * the operation arguments "correct" for the lower layer
161  * by mapping an vnode arguments to the lower layer.
162  *
163  * The first approach is to call the aliasing layer's bypass routine.
164  * This method is most suitable when you wish to invoke the operation
165  * currently being hanldled on the lower layer.  It has the advantage
166  * that the bypass routine already must do argument mapping.
167  * An example of this is null_getattrs in the null layer.
168  *
169  * A second approach is to directly invoked vnode operations on
170  * the lower layer with the VOP_OPERATIONNAME interface.
171  * The advantage of this method is that it is easy to invoke
172  * arbitrary operations on the lower layer.  The disadvantage
173  * is that vnodes arguments must be manualy mapped.
174  *
175  */
176 
177 #include <sys/param.h>
178 #include <sys/systm.h>
179 #include <sys/kernel.h>
180 #include <sys/sysctl.h>
181 #include <sys/proc.h>
182 #include <sys/time.h>
183 #include <sys/types.h>
184 #include <sys/vnode.h>
185 #include <sys/mount.h>
186 #include <sys/namei.h>
187 #include <sys/malloc.h>
188 #include <sys/buf.h>
189 #include <miscfs/nullfs/null.h>
190 
191 static int null_bug_bypass = 0;   /* for debugging: enables bypass printf'ing */
192 SYSCTL_INT(_debug, OID_AUTO, nullfs_bug_bypass, CTLFLAG_RW,
193 	&null_bug_bypass, 0, "");
194 
195 static int	null_access __P((struct vop_access_args *ap));
196 int		null_bypass __P((struct vop_generic_args *ap));
197 static int	null_bwrite __P((struct vop_bwrite_args *ap));
198 static int	null_getattr __P((struct vop_getattr_args *ap));
199 static int	null_inactive __P((struct vop_inactive_args *ap));
200 static int	null_lock __P((struct vop_lock_args *ap));
201 static int	null_lookup __P((struct vop_lookup_args *ap));
202 static int	null_print __P((struct vop_print_args *ap));
203 static int	null_reclaim __P((struct vop_reclaim_args *ap));
204 static int	null_setattr __P((struct vop_setattr_args *ap));
205 static int	null_strategy __P((struct vop_strategy_args *ap));
206 static int	null_unlock __P((struct vop_unlock_args *ap));
207 
208 /*
209  * This is the 10-Apr-92 bypass routine.
210  *    This version has been optimized for speed, throwing away some
211  * safety checks.  It should still always work, but it's not as
212  * robust to programmer errors.
213  *    Define SAFETY to include some error checking code.
214  *
215  * In general, we map all vnodes going down and unmap them on the way back.
216  * As an exception to this, vnodes can be marked "unmapped" by setting
217  * the Nth bit in operation's vdesc_flags.
218  *
219  * Also, some BSD vnode operations have the side effect of vrele'ing
220  * their arguments.  With stacking, the reference counts are held
221  * by the upper node, not the lower one, so we must handle these
222  * side-effects here.  This is not of concern in Sun-derived systems
223  * since there are no such side-effects.
224  *
225  * This makes the following assumptions:
226  * - only one returned vpp
227  * - no INOUT vpp's (Sun's vop_open has one of these)
228  * - the vnode operation vector of the first vnode should be used
229  *   to determine what implementation of the op should be invoked
230  * - all mapped vnodes are of our vnode-type (NEEDSWORK:
231  *   problems on rmdir'ing mount points and renaming?)
232  */
233 int
234 null_bypass(ap)
235 	struct vop_generic_args /* {
236 		struct vnodeop_desc *a_desc;
237 		<other random data follows, presumably>
238 	} */ *ap;
239 {
240 	register struct vnode **this_vp_p;
241 	int error;
242 	struct vnode *old_vps[VDESC_MAX_VPS];
243 	struct vnode **vps_p[VDESC_MAX_VPS];
244 	struct vnode ***vppp;
245 	struct vnodeop_desc *descp = ap->a_desc;
246 	int reles, i;
247 
248 	if (null_bug_bypass)
249 		printf ("null_bypass: %s\n", descp->vdesc_name);
250 
251 #ifdef SAFETY
252 	/*
253 	 * We require at least one vp.
254 	 */
255 	if (descp->vdesc_vp_offsets == NULL ||
256 	    descp->vdesc_vp_offsets[0] == VDESC_NO_OFFSET)
257 		panic ("null_bypass: no vp's in map.");
258 #endif
259 
260 	/*
261 	 * Map the vnodes going in.
262 	 * Later, we'll invoke the operation based on
263 	 * the first mapped vnode's operation vector.
264 	 */
265 	reles = descp->vdesc_flags;
266 	for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
267 		if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
268 			break;   /* bail out at end of list */
269 		vps_p[i] = this_vp_p =
270 			VOPARG_OFFSETTO(struct vnode**,descp->vdesc_vp_offsets[i],ap);
271 		/*
272 		 * We're not guaranteed that any but the first vnode
273 		 * are of our type.  Check for and don't map any
274 		 * that aren't.  (We must always map first vp or vclean fails.)
275 		 */
276 		if (i && (*this_vp_p == NULL ||
277 		    (*this_vp_p)->v_op != null_vnodeop_p)) {
278 			old_vps[i] = NULL;
279 		} else {
280 			old_vps[i] = *this_vp_p;
281 			*(vps_p[i]) = NULLVPTOLOWERVP(*this_vp_p);
282 			/*
283 			 * XXX - Several operations have the side effect
284 			 * of vrele'ing their vp's.  We must account for
285 			 * that.  (This should go away in the future.)
286 			 */
287 			if (reles & 1)
288 				VREF(*this_vp_p);
289 		}
290 
291 	}
292 
293 	/*
294 	 * Call the operation on the lower layer
295 	 * with the modified argument structure.
296 	 */
297 	error = VCALL(*(vps_p[0]), descp->vdesc_offset, ap);
298 
299 	/*
300 	 * Maintain the illusion of call-by-value
301 	 * by restoring vnodes in the argument structure
302 	 * to their original value.
303 	 */
304 	reles = descp->vdesc_flags;
305 	for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
306 		if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
307 			break;   /* bail out at end of list */
308 		if (old_vps[i]) {
309 			*(vps_p[i]) = old_vps[i];
310 			if (reles & 1)
311 				vrele(*(vps_p[i]));
312 		}
313 	}
314 
315 	/*
316 	 * Map the possible out-going vpp
317 	 * (Assumes that the lower layer always returns
318 	 * a VREF'ed vpp unless it gets an error.)
319 	 */
320 	if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET &&
321 	    !(descp->vdesc_flags & VDESC_NOMAP_VPP) &&
322 	    !error) {
323 		/*
324 		 * XXX - even though some ops have vpp returned vp's,
325 		 * several ops actually vrele this before returning.
326 		 * We must avoid these ops.
327 		 * (This should go away when these ops are regularized.)
328 		 */
329 		if (descp->vdesc_flags & VDESC_VPP_WILLRELE)
330 			goto out;
331 		vppp = VOPARG_OFFSETTO(struct vnode***,
332 				 descp->vdesc_vpp_offset,ap);
333 		error = null_node_create(old_vps[0]->v_mount, **vppp, *vppp);
334 	}
335 
336  out:
337 	return (error);
338 }
339 
340 /*
341  * We have to carry on the locking protocol on the null layer vnodes
342  * as we progress through the tree. We also have to enforce read-only
343  * if this layer is mounted read-only.
344  */
345 static int
346 null_lookup(ap)
347 	struct vop_lookup_args /* {
348 		struct vnode * a_dvp;
349 		struct vnode ** a_vpp;
350 		struct componentname * a_cnp;
351 	} */ *ap;
352 {
353 	struct componentname *cnp = ap->a_cnp;
354 	struct proc *p = cnp->cn_proc;
355 	int flags = cnp->cn_flags;
356 	struct vop_lock_args lockargs;
357 	struct vop_unlock_args unlockargs;
358 	struct vnode *dvp, *vp;
359 	int error;
360 
361 	if ((flags & ISLASTCN) && (ap->a_dvp->v_mount->mnt_flag & MNT_RDONLY) &&
362 	    (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
363 		return (EROFS);
364 	error = null_bypass((struct vop_generic_args *)ap);
365 	if (error == EJUSTRETURN && (flags & ISLASTCN) &&
366 	    (ap->a_dvp->v_mount->mnt_flag & MNT_RDONLY) &&
367 	    (cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME))
368 		error = EROFS;
369 	/*
370 	 * We must do the same locking and unlocking at this layer as
371 	 * is done in the layers below us. We could figure this out
372 	 * based on the error return and the LASTCN, LOCKPARENT, and
373 	 * LOCKLEAF flags. However, it is more expidient to just find
374 	 * out the state of the lower level vnodes and set ours to the
375 	 * same state.
376 	 */
377 	dvp = ap->a_dvp;
378 	vp = *ap->a_vpp;
379 	if (dvp == vp)
380 		return (error);
381 	if (!VOP_ISLOCKED(dvp)) {
382 		unlockargs.a_vp = dvp;
383 		unlockargs.a_flags = 0;
384 		unlockargs.a_p = p;
385 		vop_nounlock(&unlockargs);
386 	}
387 	if (vp != NULL && VOP_ISLOCKED(vp)) {
388 		lockargs.a_vp = vp;
389 		lockargs.a_flags = LK_SHARED;
390 		lockargs.a_p = p;
391 		vop_nolock(&lockargs);
392 	}
393 	return (error);
394 }
395 
396 /*
397  * Setattr call. Disallow write attempts if the layer is mounted read-only.
398  */
399 int
400 null_setattr(ap)
401 	struct vop_setattr_args /* {
402 		struct vnodeop_desc *a_desc;
403 		struct vnode *a_vp;
404 		struct vattr *a_vap;
405 		struct ucred *a_cred;
406 		struct proc *a_p;
407 	} */ *ap;
408 {
409 	struct vnode *vp = ap->a_vp;
410 	struct vattr *vap = ap->a_vap;
411 
412   	if ((vap->va_flags != VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
413 	    vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
414 	    vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) &&
415 	    (vp->v_mount->mnt_flag & MNT_RDONLY))
416 		return (EROFS);
417 	if (vap->va_size != VNOVAL) {
418  		switch (vp->v_type) {
419  		case VDIR:
420  			return (EISDIR);
421  		case VCHR:
422  		case VBLK:
423  		case VSOCK:
424  		case VFIFO:
425 			return (0);
426 		case VREG:
427 		case VLNK:
428  		default:
429 			/*
430 			 * Disallow write attempts if the filesystem is
431 			 * mounted read-only.
432 			 */
433 			if (vp->v_mount->mnt_flag & MNT_RDONLY)
434 				return (EROFS);
435 		}
436 	}
437 	return (null_bypass((struct vop_generic_args *)ap));
438 }
439 
440 /*
441  *  We handle getattr only to change the fsid.
442  */
443 static int
444 null_getattr(ap)
445 	struct vop_getattr_args /* {
446 		struct vnode *a_vp;
447 		struct vattr *a_vap;
448 		struct ucred *a_cred;
449 		struct proc *a_p;
450 	} */ *ap;
451 {
452 	int error;
453 
454 	if (error = null_bypass((struct vop_generic_args *)ap))
455 		return (error);
456 	/* Requires that arguments be restored. */
457 	ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
458 	return (0);
459 }
460 
461 static int
462 null_access(ap)
463 	struct vop_access_args /* {
464 		struct vnode *a_vp;
465 		int  a_mode;
466 		struct ucred *a_cred;
467 		struct proc *a_p;
468 	} */ *ap;
469 {
470 	struct vnode *vp = ap->a_vp;
471 	mode_t mode = ap->a_mode;
472 
473 	/*
474 	 * Disallow write attempts on read-only layers;
475 	 * unless the file is a socket, fifo, or a block or
476 	 * character device resident on the file system.
477 	 */
478 	if (mode & VWRITE) {
479 		switch (vp->v_type) {
480 		case VDIR:
481 		case VLNK:
482 		case VREG:
483 			if (vp->v_mount->mnt_flag & MNT_RDONLY)
484 				return (EROFS);
485 			break;
486 		}
487 	}
488 	return (null_bypass((struct vop_generic_args *)ap));
489 }
490 
491 /*
492  * We need to process our own vnode lock and then clear the
493  * interlock flag as it applies only to our vnode, not the
494  * vnodes below us on the stack.
495  */
496 static int
497 null_lock(ap)
498 	struct vop_lock_args /* {
499 		struct vnode *a_vp;
500 		int a_flags;
501 		struct proc *a_p;
502 	} */ *ap;
503 {
504 
505 	vop_nolock(ap);
506 	if ((ap->a_flags & LK_TYPE_MASK) == LK_DRAIN)
507 		return (0);
508 	ap->a_flags &= ~LK_INTERLOCK;
509 	return (null_bypass((struct vop_generic_args *)ap));
510 }
511 
512 /*
513  * We need to process our own vnode unlock and then clear the
514  * interlock flag as it applies only to our vnode, not the
515  * vnodes below us on the stack.
516  */
517 static int
518 null_unlock(ap)
519 	struct vop_unlock_args /* {
520 		struct vnode *a_vp;
521 		int a_flags;
522 		struct proc *a_p;
523 	} */ *ap;
524 {
525 	struct vnode *vp = ap->a_vp;
526 
527 	vop_nounlock(ap);
528 	ap->a_flags &= ~LK_INTERLOCK;
529 	return (null_bypass((struct vop_generic_args *)ap));
530 }
531 
532 static int
533 null_inactive(ap)
534 	struct vop_inactive_args /* {
535 		struct vnode *a_vp;
536 		struct proc *a_p;
537 	} */ *ap;
538 {
539 	/*
540 	 * Do nothing (and _don't_ bypass).
541 	 * Wait to vrele lowervp until reclaim,
542 	 * so that until then our null_node is in the
543 	 * cache and reusable.
544 	 *
545 	 * NEEDSWORK: Someday, consider inactive'ing
546 	 * the lowervp and then trying to reactivate it
547 	 * with capabilities (v_id)
548 	 * like they do in the name lookup cache code.
549 	 * That's too much work for now.
550 	 */
551 	VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
552 	return (0);
553 }
554 
555 static int
556 null_reclaim(ap)
557 	struct vop_reclaim_args /* {
558 		struct vnode *a_vp;
559 		struct proc *a_p;
560 	} */ *ap;
561 {
562 	struct vnode *vp = ap->a_vp;
563 	struct null_node *xp = VTONULL(vp);
564 	struct vnode *lowervp = xp->null_lowervp;
565 
566 	/*
567 	 * Note: in vop_reclaim, vp->v_op == dead_vnodeop_p,
568 	 * so we can't call VOPs on ourself.
569 	 */
570 	/* After this assignment, this node will not be re-used. */
571 	xp->null_lowervp = NULL;
572 	LIST_REMOVE(xp, null_hash);
573 	FREE(vp->v_data, M_TEMP);
574 	vp->v_data = NULL;
575 	vrele (lowervp);
576 	return (0);
577 }
578 
579 static int
580 null_print(ap)
581 	struct vop_print_args /* {
582 		struct vnode *a_vp;
583 	} */ *ap;
584 {
585 	register struct vnode *vp = ap->a_vp;
586 	printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp, NULLVPTOLOWERVP(vp));
587 	return (0);
588 }
589 
590 /*
591  * XXX - vop_strategy must be hand coded because it has no
592  * vnode in its arguments.
593  * This goes away with a merged VM/buffer cache.
594  */
595 static int
596 null_strategy(ap)
597 	struct vop_strategy_args /* {
598 		struct buf *a_bp;
599 	} */ *ap;
600 {
601 	struct buf *bp = ap->a_bp;
602 	int error;
603 	struct vnode *savedvp;
604 
605 	savedvp = bp->b_vp;
606 	bp->b_vp = NULLVPTOLOWERVP(bp->b_vp);
607 
608 	error = VOP_STRATEGY(bp);
609 
610 	bp->b_vp = savedvp;
611 
612 	return (error);
613 }
614 
615 /*
616  * XXX - like vop_strategy, vop_bwrite must be hand coded because it has no
617  * vnode in its arguments.
618  * This goes away with a merged VM/buffer cache.
619  */
620 static int
621 null_bwrite(ap)
622 	struct vop_bwrite_args /* {
623 		struct buf *a_bp;
624 	} */ *ap;
625 {
626 	struct buf *bp = ap->a_bp;
627 	int error;
628 	struct vnode *savedvp;
629 
630 	savedvp = bp->b_vp;
631 	bp->b_vp = NULLVPTOLOWERVP(bp->b_vp);
632 
633 	error = VOP_BWRITE(bp);
634 
635 	bp->b_vp = savedvp;
636 
637 	return (error);
638 }
639 
640 /*
641  * Global vfs data structures
642  */
643 vop_t **null_vnodeop_p;
644 static struct vnodeopv_entry_desc null_vnodeop_entries[] = {
645 	{ &vop_default_desc, (vop_t *)null_bypass },
646 
647 	{ &vop_lookup_desc, (vop_t *)null_lookup },
648 	{ &vop_setattr_desc, (vop_t *)null_setattr },
649 	{ &vop_getattr_desc, (vop_t *)null_getattr },
650 	{ &vop_access_desc, (vop_t *)null_access },
651 	{ &vop_lock_desc, (vop_t *)null_lock },
652 	{ &vop_unlock_desc, (vop_t *)null_unlock },
653 	{ &vop_inactive_desc, (vop_t *)null_inactive },
654 	{ &vop_reclaim_desc, (vop_t *)null_reclaim },
655 	{ &vop_print_desc, (vop_t *)null_print },
656 
657 	{ &vop_strategy_desc, (vop_t *)null_strategy },
658 	{ &vop_bwrite_desc, (vop_t *)null_bwrite },
659 
660 	{ NULL, NULL }
661 };
662 static struct vnodeopv_desc null_vnodeop_opv_desc =
663 	{ &null_vnodeop_p, null_vnodeop_entries };
664 
665 VNODEOP_SET(null_vnodeop_opv_desc);
666