vfs_export.c (34577) | vfs_export.c (34611) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 |
39 * $Id: vfs_subr.c,v 1.139 1998/03/14 02:55:01 tegge Exp $ | 39 * $Id: vfs_subr.c,v 1.140 1998/03/14 19:50:36 dyson Exp $ |
40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45#include "opt_ddb.h" 46#include "opt_devfs.h" 47 --- 60 unchanged lines hidden (view full) --- 108 109static u_long wantfreevnodes = 25; 110SYSCTL_INT(_debug, OID_AUTO, wantfreevnodes, CTLFLAG_RW, &wantfreevnodes, 0, ""); 111static u_long freevnodes = 0; 112SYSCTL_INT(_debug, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, ""); 113 114int vfs_ioopt = 0; 115#ifdef REALLYBADBUG | 40 */ 41 42/* 43 * External virtual filesystem routines 44 */ 45#include "opt_ddb.h" 46#include "opt_devfs.h" 47 --- 60 unchanged lines hidden (view full) --- 108 109static u_long wantfreevnodes = 25; 110SYSCTL_INT(_debug, OID_AUTO, wantfreevnodes, CTLFLAG_RW, &wantfreevnodes, 0, ""); 111static u_long freevnodes = 0; 112SYSCTL_INT(_debug, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, ""); 113 114int vfs_ioopt = 0; 115#ifdef REALLYBADBUG |
116#ifdef ENABLE_VFS_IOOPT |
|
116SYSCTL_INT(_vfs, OID_AUTO, ioopt, CTLFLAG_RW, &vfs_ioopt, 0, ""); 117#endif | 117SYSCTL_INT(_vfs, OID_AUTO, ioopt, CTLFLAG_RW, &vfs_ioopt, 0, ""); 118#endif |
119#endif |
|
118 119struct mntlist mountlist; /* mounted filesystem list */ 120struct simplelock mountlist_slock; 121static struct simplelock mntid_slock; 122struct simplelock mntvnode_slock; 123static struct simplelock vnode_free_list_slock; 124static struct simplelock spechash_slock; 125struct nfs_public nfs_pub; /* publicly exported FS */ --- 500 unchanged lines hidden (view full) --- 626 VOP_BWRITE(bp); 627 } 628 } else { 629 (void) VOP_BWRITE(bp); 630 } 631 break; 632 } 633 bp->b_flags |= (B_INVAL|B_NOCACHE|B_RELBUF); | 120 121struct mntlist mountlist; /* mounted filesystem list */ 122struct simplelock mountlist_slock; 123static struct simplelock mntid_slock; 124struct simplelock mntvnode_slock; 125static struct simplelock vnode_free_list_slock; 126static struct simplelock spechash_slock; 127struct nfs_public nfs_pub; /* publicly exported FS */ --- 500 unchanged lines hidden (view full) --- 628 VOP_BWRITE(bp); 629 } 630 } else { 631 (void) VOP_BWRITE(bp); 632 } 633 break; 634 } 635 bp->b_flags |= (B_INVAL|B_NOCACHE|B_RELBUF); |
636 bp->b_flags &= ~B_ASYNC; |
|
634 brelse(bp); 635 } 636 } 637 638 while (vp->v_numoutput > 0) { 639 vp->v_flag |= VBWAIT; 640 tsleep(&vp->v_numoutput, PVM, "vnvlbv", 0); 641 } --- 17 unchanged lines hidden (view full) --- 659 660 if (!(flags & V_SAVEMETA) && 661 (vp->v_dirtyblkhd.lh_first || vp->v_cleanblkhd.lh_first)) 662 panic("vinvalbuf: flush failed"); 663 return (0); 664} 665 666/* | 637 brelse(bp); 638 } 639 } 640 641 while (vp->v_numoutput > 0) { 642 vp->v_flag |= VBWAIT; 643 tsleep(&vp->v_numoutput, PVM, "vnvlbv", 0); 644 } --- 17 unchanged lines hidden (view full) --- 662 663 if (!(flags & V_SAVEMETA) && 664 (vp->v_dirtyblkhd.lh_first || vp->v_cleanblkhd.lh_first)) 665 panic("vinvalbuf: flush failed"); 666 return (0); 667} 668 669/* |
670 * Truncate a file's buffer and pages to a specified length. This 671 * is in lieu of the old vinvalbuf mechanism, which performed unneeded 672 * sync activity. 673 */ 674int 675vtruncbuf(vp, cred, p, length, blksize) 676 register struct vnode *vp; 677 struct ucred *cred; 678 struct proc *p; 679 off_t length; 680 int blksize; 681{ 682 register struct buf *bp; 683 struct buf *nbp, *blist; 684 int s, error, anyfreed; 685 vm_object_t object; 686 int trunclbn; 687 688 /* 689 * Round up to the *next* lbn. 690 */ 691 trunclbn = ((length + blksize - 1) / blksize) * blksize; 692 693 s = splbio(); 694restart: 695 anyfreed = 1; 696 for (;anyfreed;) { 697 anyfreed = 0; 698 for ( bp = LIST_FIRST(&vp->v_cleanblkhd); bp; bp = nbp) { 699 700 nbp = LIST_NEXT(bp, b_vnbufs); 701 702 if (bp->b_lblkno >= trunclbn) { 703 if (bp->b_flags & B_BUSY) { 704 bp->b_flags |= B_WANTED; 705 tsleep((caddr_t) bp, PRIBIO, "vtrb1", 0); 706 nbp = bp; 707 } else { 708 bremfree(bp); 709 bp->b_flags |= (B_BUSY|B_INVAL|B_NOCACHE|B_RELBUF); 710 bp->b_flags &= ~B_ASYNC; 711 brelse(bp); 712 anyfreed = 1; 713 } 714 if (nbp && 715 ((LIST_NEXT(nbp, b_vnbufs) == NOLIST) || (nbp->b_vp != vp) || 716 (nbp->b_flags & B_DELWRI))) { 717 goto restart; 718 } 719 } 720 } 721 722 for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { 723 724 nbp = LIST_NEXT(bp, b_vnbufs); 725 726 if (bp->b_lblkno >= trunclbn) { 727 if (bp->b_flags & B_BUSY) { 728 bp->b_flags |= B_WANTED; 729 tsleep((caddr_t) bp, PRIBIO, "vtrb2", 0); 730 nbp = bp; 731 } else { 732 bremfree(bp); 733 bp->b_flags |= (B_BUSY|B_INVAL|B_NOCACHE|B_RELBUF); 734 bp->b_flags &= ~B_ASYNC; 735 brelse(bp); 736 anyfreed = 1; 737 } 738 if (nbp && 739 ((LIST_NEXT(nbp, b_vnbufs) == NOLIST) || (nbp->b_vp != vp) || 740 (nbp->b_flags & B_DELWRI) == 0)) { 741 goto restart; 742 } 743 } 744 } 745 } 746 splx(s); 747 748 vnode_pager_setsize(vp, length); 749 750 return (0); 751} 752 753/* |
|
667 * Associate a buffer with a vnode. 668 */ 669void 670bgetvp(vp, bp) 671 register struct vnode *vp; 672 register struct buf *bp; 673{ 674 int s; --- 2004 unchanged lines hidden --- | 754 * Associate a buffer with a vnode. 755 */ 756void 757bgetvp(vp, bp) 758 register struct vnode *vp; 759 register struct buf *bp; 760{ 761 int s; --- 2004 unchanged lines hidden --- |