null_vnops.c (172644) | null_vnops.c (175294) |
---|---|
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 --- 22 unchanged lines hidden (view full) --- 31 * 32 * @(#)null_vnops.c 8.6 (Berkeley) 5/27/95 33 * 34 * Ancestors: 35 * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92 36 * ...and... 37 * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project 38 * | 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 --- 22 unchanged lines hidden (view full) --- 31 * 32 * @(#)null_vnops.c 8.6 (Berkeley) 5/27/95 33 * 34 * Ancestors: 35 * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92 36 * ...and... 37 * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project 38 * |
39 * $FreeBSD: head/sys/fs/nullfs/null_vnops.c 172644 2007-10-14 13:57:11Z daichi $ | 39 * $FreeBSD: head/sys/fs/nullfs/null_vnops.c 175294 2008-01-13 14:44:15Z attilio $ |
40 */ 41 42/* 43 * Null Layer 44 * 45 * (See mount_nullfs(8) for more information.) 46 * 47 * The null layer duplicates a portion of the filesystem --- 243 unchanged lines hidden (view full) --- 291 reles = descp->vdesc_flags; 292 for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) { 293 if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET) 294 break; /* bail out at end of list */ 295 if (old_vps[i]) { 296 *(vps_p[i]) = old_vps[i]; 297#if 0 298 if (reles & VDESC_VP0_WILLUNLOCK) | 40 */ 41 42/* 43 * Null Layer 44 * 45 * (See mount_nullfs(8) for more information.) 46 * 47 * The null layer duplicates a portion of the filesystem --- 243 unchanged lines hidden (view full) --- 291 reles = descp->vdesc_flags; 292 for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) { 293 if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET) 294 break; /* bail out at end of list */ 295 if (old_vps[i]) { 296 *(vps_p[i]) = old_vps[i]; 297#if 0 298 if (reles & VDESC_VP0_WILLUNLOCK) |
299 VOP_UNLOCK(*(vps_p[i]), 0, curthread); | 299 VOP_UNLOCK(*(vps_p[i]), 0); |
300#endif 301 if (reles & VDESC_VP0_WILLRELE) 302 vrele(*(vps_p[i])); 303 } 304 } 305 306 /* 307 * Map the possible out-going vpp --- 200 unchanged lines hidden (view full) --- 508 * interlock flag as it applies only to our vnode, not the 509 * vnodes below us on the stack. 510 */ 511static int 512null_lock(struct vop_lock1_args *ap) 513{ 514 struct vnode *vp = ap->a_vp; 515 int flags = ap->a_flags; | 300#endif 301 if (reles & VDESC_VP0_WILLRELE) 302 vrele(*(vps_p[i])); 303 } 304 } 305 306 /* 307 * Map the possible out-going vpp --- 200 unchanged lines hidden (view full) --- 508 * interlock flag as it applies only to our vnode, not the 509 * vnodes below us on the stack. 510 */ 511static int 512null_lock(struct vop_lock1_args *ap) 513{ 514 struct vnode *vp = ap->a_vp; 515 int flags = ap->a_flags; |
516 struct thread *td = ap->a_td; | |
517 struct null_node *nn; 518 struct vnode *lvp; 519 int error; 520 521 522 if ((flags & LK_INTERLOCK) == 0) { 523 VI_LOCK(vp); 524 ap->a_flags = flags |= LK_INTERLOCK; --- 14 unchanged lines hidden (view full) --- 539 * the lowervp's vop_lock routine. When we vgone we will 540 * drop our last ref to the lowervp, which would allow it 541 * to be reclaimed. The lowervp could then be recycled, 542 * in which case it is not legal to be sleeping in it's VOP. 543 * We prevent it from being recycled by holding the vnode 544 * here. 545 */ 546 vholdl(lvp); | 516 struct null_node *nn; 517 struct vnode *lvp; 518 int error; 519 520 521 if ((flags & LK_INTERLOCK) == 0) { 522 VI_LOCK(vp); 523 ap->a_flags = flags |= LK_INTERLOCK; --- 14 unchanged lines hidden (view full) --- 538 * the lowervp's vop_lock routine. When we vgone we will 539 * drop our last ref to the lowervp, which would allow it 540 * to be reclaimed. The lowervp could then be recycled, 541 * in which case it is not legal to be sleeping in it's VOP. 542 * We prevent it from being recycled by holding the vnode 543 * here. 544 */ 545 vholdl(lvp); |
547 error = VOP_LOCK(lvp, flags, td); | 546 error = VOP_LOCK(lvp, flags); |
548 549 /* 550 * We might have slept to get the lock and someone might have 551 * clean our vnode already, switching vnode lock from one in 552 * lowervp to v_lock in our own vnode structure. Handle this 553 * case by reacquiring correct lock in requested mode. 554 */ 555 if (VTONULL(vp) == NULL && error == 0) { --- 5 unchanged lines hidden (view full) --- 561 case LK_UPGRADE: 562 case LK_EXCLUSIVE: 563 ap->a_flags |= LK_EXCLUSIVE; 564 break; 565 default: 566 panic("Unsupported lock request %d\n", 567 ap->a_flags); 568 } | 547 548 /* 549 * We might have slept to get the lock and someone might have 550 * clean our vnode already, switching vnode lock from one in 551 * lowervp to v_lock in our own vnode structure. Handle this 552 * case by reacquiring correct lock in requested mode. 553 */ 554 if (VTONULL(vp) == NULL && error == 0) { --- 5 unchanged lines hidden (view full) --- 560 case LK_UPGRADE: 561 case LK_EXCLUSIVE: 562 ap->a_flags |= LK_EXCLUSIVE; 563 break; 564 default: 565 panic("Unsupported lock request %d\n", 566 ap->a_flags); 567 } |
569 VOP_UNLOCK(lvp, 0, td); | 568 VOP_UNLOCK(lvp, 0); |
570 error = vop_stdlock(ap); 571 } 572 vdrop(lvp); 573 } else 574 error = vop_stdlock(ap); 575 576 return (error); 577} --- 4 unchanged lines hidden (view full) --- 582 * vnodes below us on the stack. 583 */ 584static int 585null_unlock(struct vop_unlock_args *ap) 586{ 587 struct vnode *vp = ap->a_vp; 588 int flags = ap->a_flags; 589 int mtxlkflag = 0; | 569 error = vop_stdlock(ap); 570 } 571 vdrop(lvp); 572 } else 573 error = vop_stdlock(ap); 574 575 return (error); 576} --- 4 unchanged lines hidden (view full) --- 581 * vnodes below us on the stack. 582 */ 583static int 584null_unlock(struct vop_unlock_args *ap) 585{ 586 struct vnode *vp = ap->a_vp; 587 int flags = ap->a_flags; 588 int mtxlkflag = 0; |
590 struct thread *td = ap->a_td; | |
591 struct null_node *nn; 592 struct vnode *lvp; 593 int error; 594 595 if ((flags & LK_INTERLOCK) != 0) 596 mtxlkflag = 1; 597 else if (mtx_owned(VI_MTX(vp)) == 0) { 598 VI_LOCK(vp); 599 mtxlkflag = 2; 600 } 601 nn = VTONULL(vp); 602 if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) { 603 VI_LOCK_FLAGS(lvp, MTX_DUPOK); 604 flags |= LK_INTERLOCK; 605 vholdl(lvp); 606 VI_UNLOCK(vp); | 589 struct null_node *nn; 590 struct vnode *lvp; 591 int error; 592 593 if ((flags & LK_INTERLOCK) != 0) 594 mtxlkflag = 1; 595 else if (mtx_owned(VI_MTX(vp)) == 0) { 596 VI_LOCK(vp); 597 mtxlkflag = 2; 598 } 599 nn = VTONULL(vp); 600 if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) { 601 VI_LOCK_FLAGS(lvp, MTX_DUPOK); 602 flags |= LK_INTERLOCK; 603 vholdl(lvp); 604 VI_UNLOCK(vp); |
607 error = VOP_UNLOCK(lvp, flags, td); | 605 error = VOP_UNLOCK(lvp, flags); |
608 vdrop(lvp); 609 if (mtxlkflag == 0) 610 VI_LOCK(vp); 611 } else { 612 if (mtxlkflag == 2) 613 VI_UNLOCK(vp); 614 error = vop_stdunlock(ap); 615 } --- 138 unchanged lines hidden --- | 606 vdrop(lvp); 607 if (mtxlkflag == 0) 608 VI_LOCK(vp); 609 } else { 610 if (mtxlkflag == 2) 611 VI_UNLOCK(vp); 612 error = vop_stdunlock(ap); 613 } --- 138 unchanged lines hidden --- |