Deleted Added
sdiff udiff text old ( 17605 ) new ( 17761 )
full compact
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.13 (Berkeley) 4/18/94
39 * $Id: vfs_subr.c,v 1.57 1996/07/30 18:00:25 bde Exp $
40 */
41
42/*
43 * External virtual filesystem routines
44 */
45#include "opt_ddb.h"
46
47#include <sys/param.h>

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

60#include <sys/malloc.h>
61#include <sys/domain.h>
62#include <sys/mbuf.h>
63
64#include <vm/vm.h>
65#include <vm/vm_param.h>
66#include <vm/vm_object.h>
67#include <vm/vm_extern.h>
68#include <sys/sysctl.h>
69
70#include <miscfs/specfs/specdev.h>
71
72#ifdef DDB
73extern void printlockedvnodes __P((void));
74#endif
75extern void vclean __P((struct vnode *vp, int flags));

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

472 vm_object_t object;
473
474 if (flags & V_SAVE) {
475 if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)))
476 return (error);
477 if (vp->v_dirtyblkhd.lh_first != NULL)
478 panic("vinvalbuf: dirty bufs");
479 }
480 for (;;) {
481 if ((blist = vp->v_cleanblkhd.lh_first) && (flags & V_SAVEMETA))
482 while (blist && blist->b_lblkno < 0)
483 blist = blist->b_vnbufs.le_next;
484 if (!blist && (blist = vp->v_dirtyblkhd.lh_first) &&
485 (flags & V_SAVEMETA))
486 while (blist && blist->b_lblkno < 0)
487 blist = blist->b_vnbufs.le_next;
488 if (!blist)
489 break;
490
491 for (bp = blist; bp; bp = nbp) {
492 nbp = bp->b_vnbufs.le_next;
493 if ((flags & V_SAVEMETA) && bp->b_lblkno < 0)
494 continue;
495 s = splbio();
496 if (bp->b_flags & B_BUSY) {
497 bp->b_flags |= B_WANTED;
498 error = tsleep((caddr_t) bp,
499 slpflag | (PRIBIO + 1), "vinvalbuf",
500 slptimeo);
501 splx(s);
502 if (error)
503 return (error);
504 break;
505 }
506 bremfree(bp);
507 bp->b_flags |= B_BUSY;
508 splx(s);
509 /*
510 * XXX Since there are no node locks for NFS, I
511 * believe there is a slight chance that a delayed
512 * write will occur while sleeping just above, so
513 * check for it.
514 */
515 if ((bp->b_flags & B_DELWRI) && (flags & V_SAVE)) {
516 (void) VOP_BWRITE(bp);
517 break;
518 }
519 bp->b_flags |= (B_INVAL|B_NOCACHE|B_RELBUF);
520 brelse(bp);
521 }
522 }
523
524 s = splbio();
525 while (vp->v_numoutput > 0) {
526 vp->v_flag |= VBWAIT;
527 tsleep(&vp->v_numoutput, PVM, "vnvlbv", 0);
528 }
529 splx(s);
530

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

633 * Used to assign file specific control information
634 * (indirect blocks) to the vnode to which they belong.
635 */
636void
637reassignbuf(bp, newvp)
638 register struct buf *bp;
639 register struct vnode *newvp;
640{
641 register struct buflists *listheadp;
642 int s;
643
644 if (newvp == NULL) {
645 printf("reassignbuf: NULL");
646 return;
647 }
648
649 s = splbio();

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

665 } else {
666 while (tbp->b_vnbufs.le_next &&
667 (tbp->b_vnbufs.le_next->b_lblkno < bp->b_lblkno)) {
668 tbp = tbp->b_vnbufs.le_next;
669 }
670 LIST_INSERT_AFTER(tbp, bp, b_vnbufs);
671 }
672 } else {
673 listheadp = &newvp->v_cleanblkhd;
674 bufinsvn(bp, listheadp);
675 }
676 splx(s);
677}
678
679#ifndef DEVFS_ROOT
680/*
681 * Create a vnode for a block device.
682 * Used for root filesystem, argdev, and swap areas.

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

740 if (vp->v_usecount == 0) {
741 vgone(vp);
742 goto loop;
743 }
744 if (vget(vp, 1))
745 goto loop;
746 break;
747 }
748 if (vp == NULL || vp->v_tag != VT_NON) {
749 MALLOC(nvp->v_specinfo, struct specinfo *,
750 sizeof(struct specinfo), M_VNODE, M_WAITOK);
751 nvp->v_rdev = nvp_rdev;
752 nvp->v_hashchain = vpp;
753 nvp->v_specnext = *vpp;
754 nvp->v_specflags = 0;
755 *vpp = nvp;

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

799 (void) tsleep((caddr_t) vp, PINOD, "vget", 0);
800 return (1);
801 }
802 if (vp->v_usecount == 0) {
803 TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
804 freevnodes--;
805 }
806 vp->v_usecount++;
807 if (lockflag)
808 VOP_LOCK(vp);
809 return (0);
810}
811
812/*
813 * Vnode reference, just increment the count
814 */
815void
816vref(vp)
817 struct vnode *vp;
818{
819
820 if (vp->v_usecount <= 0)
821 panic("vref used where vget required");
822 vp->v_usecount++;
823}
824
825/*
826 * vput(), just unlock and vrele()
827 */
828void
829vput(vp)
830 register struct vnode *vp;
831{
832
833 VOP_UNLOCK(vp);
834 vrele(vp);
835}
836
837/*
838 * Vnode release.
839 * If count drops to zero, call inactive routine and return to freelist.
840 */
841void
842vrele(vp)
843 register struct vnode *vp;
844{
845
846#ifdef DIAGNOSTIC
847 if (vp == NULL)
848 panic("vrele: null vp");
849#endif
850 vp->v_usecount--;
851 if (vp->v_usecount > 0)
852 return;
853 if (vp->v_usecount < 0 /* || vp->v_writecount < 0 */ ) {
854#ifdef DIAGNOSTIC
855 vprint("vrele: negative ref count", vp);
856#endif
857 panic("vrele: negative reference cnt");
858 }
859 if (vp->v_flag & VAGE) {
860 TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
861 vp->v_flag &= ~VAGE;

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

939 continue;
940 /*
941 * If WRITECLOSE is set, only flush out regular file vnodes
942 * open for writing.
943 */
944 if ((flags & WRITECLOSE) &&
945 (vp->v_writecount == 0 || vp->v_type != VREG))
946 continue;
947 /*
948 * With v_usecount == 0, all we need to do is clear out the
949 * vnode data structures and we are done.
950 */
951 if (vp->v_usecount == 0) {
952 vgone(vp);
953 continue;
954 }

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

1541 for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
1542
1543 if (vp->v_mount != mp)
1544 goto loop;
1545 nvp = vp->v_mntvnodes.le_next;
1546 if (VOP_ISLOCKED(vp) && (flags != MNT_WAIT))
1547 continue;
1548 if (vp->v_object &&
1549 (((vm_object_t) vp->v_object)->flags & OBJ_MIGHTBEDIRTY)) {
1550 vm_object_page_clean(vp->v_object, 0, 0, TRUE, TRUE);
1551 }
1552 }
1553}