Deleted Added
full compact
null_vnops.c (12595) null_vnops.c (12769)
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

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

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.1 (Berkeley) 6/10/93
37 *
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

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

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.1 (Berkeley) 6/10/93
37 *
38 * $Id: null_vnops.c,v 1.9 1995/11/09 08:14:51 bde Exp $
38 * $Id: null_vnops.c,v 1.10 1995/12/03 14:54:24 bde Exp $
39 */
40
41/*
42 * Null Layer
43 *
44 * (See mount_null(8) for more information.)
45 *
46 * The null layer duplicates a portion of the file system

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

158 * arbitrary operations on the lower layer. The disadvantage
159 * is that vnodes arguments must be manualy mapped.
160 *
161 */
162
163#include <sys/param.h>
164#include <sys/systm.h>
165#include <sys/kernel.h>
39 */
40
41/*
42 * Null Layer
43 *
44 * (See mount_null(8) for more information.)
45 *
46 * The null layer duplicates a portion of the file system

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

158 * arbitrary operations on the lower layer. The disadvantage
159 * is that vnodes arguments must be manualy mapped.
160 *
161 */
162
163#include <sys/param.h>
164#include <sys/systm.h>
165#include <sys/kernel.h>
166#include <sys/sysctl.h>
166#include <sys/proc.h>
167#include <sys/time.h>
168#include <sys/types.h>
169#include <sys/vnode.h>
170#include <sys/mount.h>
171#include <sys/namei.h>
172#include <sys/malloc.h>
173#include <sys/buf.h>
174#include <miscfs/nullfs/null.h>
175
167#include <sys/proc.h>
168#include <sys/time.h>
169#include <sys/types.h>
170#include <sys/vnode.h>
171#include <sys/mount.h>
172#include <sys/namei.h>
173#include <sys/malloc.h>
174#include <sys/buf.h>
175#include <miscfs/nullfs/null.h>
176
176int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
177static int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
178SYSCTL_INT(_debug, OID_AUTO, nullfs_bug_bypass, CTLFLAG_RW,
179 &null_bug_bypass, 0, "");
177
180
178extern int null_bypass __P((struct vop_generic_args *ap));
179extern int null_bwrite __P((struct vop_bwrite_args *ap));
180extern int null_getattr __P((struct vop_getattr_args *ap));
181extern int null_inactive __P((struct vop_inactive_args *ap));
182extern int null_print __P((struct vop_print_args *ap));
183extern int null_reclaim __P((struct vop_reclaim_args *ap));
184extern int null_strategy __P((struct vop_strategy_args *ap));
181static int null_bypass __P((struct vop_generic_args *ap));
182static int null_bwrite __P((struct vop_bwrite_args *ap));
183static int null_getattr __P((struct vop_getattr_args *ap));
184static int null_inactive __P((struct vop_inactive_args *ap));
185static int null_print __P((struct vop_print_args *ap));
186static int null_reclaim __P((struct vop_reclaim_args *ap));
187static int null_strategy __P((struct vop_strategy_args *ap));
185
186/*
187 * This is the 10-Apr-92 bypass routine.
188 * This version has been optimized for speed, throwing away some
189 * safety checks. It should still always work, but it's not as
190 * robust to programmer errors.
191 * Define SAFETY to include some error checking code.
192 *

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

203 * This makes the following assumptions:
204 * - only one returned vpp
205 * - no INOUT vpp's (Sun's vop_open has one of these)
206 * - the vnode operation vector of the first vnode should be used
207 * to determine what implementation of the op should be invoked
208 * - all mapped vnodes are of our vnode-type (NEEDSWORK:
209 * problems on rmdir'ing mount points and renaming?)
210 */
188
189/*
190 * This is the 10-Apr-92 bypass routine.
191 * This version has been optimized for speed, throwing away some
192 * safety checks. It should still always work, but it's not as
193 * robust to programmer errors.
194 * Define SAFETY to include some error checking code.
195 *

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

206 * This makes the following assumptions:
207 * - only one returned vpp
208 * - no INOUT vpp's (Sun's vop_open has one of these)
209 * - the vnode operation vector of the first vnode should be used
210 * to determine what implementation of the op should be invoked
211 * - all mapped vnodes are of our vnode-type (NEEDSWORK:
212 * problems on rmdir'ing mount points and renaming?)
213 */
211int
214static int
212null_bypass(ap)
213 struct vop_generic_args /* {
214 struct vnodeop_desc *a_desc;
215 <other random data follows, presumably>
216 } */ *ap;
217{
218 register struct vnode **this_vp_p;
219 int error;

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

313 out:
314 return (error);
315}
316
317
318/*
319 * We handle getattr only to change the fsid.
320 */
215null_bypass(ap)
216 struct vop_generic_args /* {
217 struct vnodeop_desc *a_desc;
218 <other random data follows, presumably>
219 } */ *ap;
220{
221 register struct vnode **this_vp_p;
222 int error;

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

316 out:
317 return (error);
318}
319
320
321/*
322 * We handle getattr only to change the fsid.
323 */
321int
324static int
322null_getattr(ap)
323 struct vop_getattr_args /* {
324 struct vnode *a_vp;
325 struct vattr *a_vap;
326 struct ucred *a_cred;
327 struct proc *a_p;
328 } */ *ap;
329{
330 int error;
331 error = null_bypass(ap);
332 if (error)
333 return (error);
334 /* Requires that arguments be restored. */
335 ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
336 return (0);
337}
338
339
325null_getattr(ap)
326 struct vop_getattr_args /* {
327 struct vnode *a_vp;
328 struct vattr *a_vap;
329 struct ucred *a_cred;
330 struct proc *a_p;
331 } */ *ap;
332{
333 int error;
334 error = null_bypass(ap);
335 if (error)
336 return (error);
337 /* Requires that arguments be restored. */
338 ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
339 return (0);
340}
341
342
340int
343static int
341null_inactive(ap)
342 struct vop_inactive_args /* {
343 struct vnode *a_vp;
344 } */ *ap;
345{
346 /*
347 * Do nothing (and _don't_ bypass).
348 * Wait to vrele lowervp until reclaim,

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

353 * the lowervp and then trying to reactivate it
354 * with capabilities (v_id)
355 * like they do in the name lookup cache code.
356 * That's too much work for now.
357 */
358 return (0);
359}
360
344null_inactive(ap)
345 struct vop_inactive_args /* {
346 struct vnode *a_vp;
347 } */ *ap;
348{
349 /*
350 * Do nothing (and _don't_ bypass).
351 * Wait to vrele lowervp until reclaim,

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

356 * the lowervp and then trying to reactivate it
357 * with capabilities (v_id)
358 * like they do in the name lookup cache code.
359 * That's too much work for now.
360 */
361 return (0);
362}
363
361int
364static int
362null_reclaim(ap)
363 struct vop_reclaim_args /* {
364 struct vnode *a_vp;
365 } */ *ap;
366{
367 struct vnode *vp = ap->a_vp;
368 struct null_node *xp = VTONULL(vp);
369 struct vnode *lowervp = xp->null_lowervp;

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

377 remque(xp);
378 FREE(vp->v_data, M_TEMP);
379 vp->v_data = NULL;
380 vrele (lowervp);
381 return (0);
382}
383
384
365null_reclaim(ap)
366 struct vop_reclaim_args /* {
367 struct vnode *a_vp;
368 } */ *ap;
369{
370 struct vnode *vp = ap->a_vp;
371 struct null_node *xp = VTONULL(vp);
372 struct vnode *lowervp = xp->null_lowervp;

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

380 remque(xp);
381 FREE(vp->v_data, M_TEMP);
382 vp->v_data = NULL;
383 vrele (lowervp);
384 return (0);
385}
386
387
385int
388static int
386null_print(ap)
387 struct vop_print_args /* {
388 struct vnode *a_vp;
389 } */ *ap;
390{
391 register struct vnode *vp = ap->a_vp;
392 printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp, NULLVPTOLOWERVP(vp));
393 return (0);
394}
395
396
397/*
398 * XXX - vop_strategy must be hand coded because it has no
399 * vnode in its arguments.
400 * This goes away with a merged VM/buffer cache.
401 */
389null_print(ap)
390 struct vop_print_args /* {
391 struct vnode *a_vp;
392 } */ *ap;
393{
394 register struct vnode *vp = ap->a_vp;
395 printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp, NULLVPTOLOWERVP(vp));
396 return (0);
397}
398
399
400/*
401 * XXX - vop_strategy must be hand coded because it has no
402 * vnode in its arguments.
403 * This goes away with a merged VM/buffer cache.
404 */
402int
405static int
403null_strategy(ap)
404 struct vop_strategy_args /* {
405 struct buf *a_bp;
406 } */ *ap;
407{
408 struct buf *bp = ap->a_bp;
409 int error;
410 struct vnode *savedvp;

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

420}
421
422
423/*
424 * XXX - like vop_strategy, vop_bwrite must be hand coded because it has no
425 * vnode in its arguments.
426 * This goes away with a merged VM/buffer cache.
427 */
406null_strategy(ap)
407 struct vop_strategy_args /* {
408 struct buf *a_bp;
409 } */ *ap;
410{
411 struct buf *bp = ap->a_bp;
412 int error;
413 struct vnode *savedvp;

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

423}
424
425
426/*
427 * XXX - like vop_strategy, vop_bwrite must be hand coded because it has no
428 * vnode in its arguments.
429 * This goes away with a merged VM/buffer cache.
430 */
428int
431static int
429null_bwrite(ap)
430 struct vop_bwrite_args /* {
431 struct buf *a_bp;
432 } */ *ap;
433{
434 struct buf *bp = ap->a_bp;
435 int error;
436 struct vnode *savedvp;

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

444
445 return (error);
446}
447
448/*
449 * Global vfs data structures
450 */
451vop_t **null_vnodeop_p;
432null_bwrite(ap)
433 struct vop_bwrite_args /* {
434 struct buf *a_bp;
435 } */ *ap;
436{
437 struct buf *bp = ap->a_bp;
438 int error;
439 struct vnode *savedvp;

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

447
448 return (error);
449}
450
451/*
452 * Global vfs data structures
453 */
454vop_t **null_vnodeop_p;
452struct vnodeopv_entry_desc null_vnodeop_entries[] = {
455static struct vnodeopv_entry_desc null_vnodeop_entries[] = {
453 { &vop_default_desc, (vop_t *)null_bypass },
454
455 { &vop_getattr_desc, (vop_t *)null_getattr },
456 { &vop_inactive_desc, (vop_t *)null_inactive },
457 { &vop_reclaim_desc, (vop_t *)null_reclaim },
458 { &vop_print_desc, (vop_t *)null_print },
459
460 { &vop_strategy_desc, (vop_t *)null_strategy },
461 { &vop_bwrite_desc, (vop_t *)null_bwrite },
462
463 { NULL, NULL }
464};
456 { &vop_default_desc, (vop_t *)null_bypass },
457
458 { &vop_getattr_desc, (vop_t *)null_getattr },
459 { &vop_inactive_desc, (vop_t *)null_inactive },
460 { &vop_reclaim_desc, (vop_t *)null_reclaim },
461 { &vop_print_desc, (vop_t *)null_print },
462
463 { &vop_strategy_desc, (vop_t *)null_strategy },
464 { &vop_bwrite_desc, (vop_t *)null_bwrite },
465
466 { NULL, NULL }
467};
465struct vnodeopv_desc null_vnodeop_opv_desc =
468static struct vnodeopv_desc null_vnodeop_opv_desc =
466 { &null_vnodeop_p, null_vnodeop_entries };
467
468VNODEOP_SET(null_vnodeop_opv_desc);
469 { &null_vnodeop_p, null_vnodeop_entries };
470
471VNODEOP_SET(null_vnodeop_opv_desc);