root is mounted read-only by default; replace bflush with vflushbuf
[unix-history] / usr / src / sys / ufs / lfs / lfs_inode.c
index 386aa3f..6b29201 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)lfs_inode.c 7.17 (Berkeley) %G%
+ *     @(#)lfs_inode.c 7.22 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -46,6 +46,8 @@ union ihead {
        struct inode *ih_chain[2];
 } ihead[INOHSZ];
 
        struct inode *ih_chain[2];
 } ihead[INOHSZ];
 
+int prtactive; /* 1 => print out reclaim of active vnodes */
+
 /*
  * Initialize hash links for inodes.
  */
 /*
  * Initialize hash links for inodes.
  */
@@ -54,8 +56,10 @@ ufs_init()
        register int i;
        register union ihead *ih = ihead;
 
        register int i;
        register union ihead *ih = ihead;
 
+#ifndef lint
        if (VN_MAXPRIVATE < sizeof(struct inode))
                panic("ihinit: too small");
        if (VN_MAXPRIVATE < sizeof(struct inode))
                panic("ihinit: too small");
+#endif /* not lint */
        for (i = INOHSZ; --i >= 0; ih++) {
                ih->ih_head[0] = ih;
                ih->ih_head[1] = ih;
        for (i = INOHSZ; --i >= 0; ih++) {
                ih->ih_head[0] = ih;
                ih->ih_head[1] = ih;
@@ -117,7 +121,6 @@ loop:
        ip->i_devvp = 0;
        ip->i_lastr = 0;
        ip->i_mode = 0;
        ip->i_devvp = 0;
        ip->i_lastr = 0;
        ip->i_mode = 0;
-       ip->i_flags = 0;
 #ifdef QUOTA
        ip->i_dquot = NODQUOT;
 #endif
 #ifdef QUOTA
        ip->i_dquot = NODQUOT;
 #endif
@@ -154,9 +157,8 @@ loop:
        vp = ITOV(ip);
        vp->v_type = IFTOVT(ip->i_mode);
        if (vp->v_type == VCHR || vp->v_type == VBLK) {
        vp = ITOV(ip);
        vp->v_type = IFTOVT(ip->i_mode);
        if (vp->v_type == VCHR || vp->v_type == VBLK) {
-               vp->v_rdev = ip->i_rdev;
                vp->v_op = &spec_inodeops;
                vp->v_op = &spec_inodeops;
-               if (nvp = checkalias(vp, mntp)) {
+               if (nvp = checkalias(vp, ip->i_rdev, mntp)) {
                        /*
                         * Reinitialize aliased inode.
                         */
                        /*
                         * Reinitialize aliased inode.
                         */
@@ -164,7 +166,7 @@ loop:
                        iq = VTOI(vp);
                        iq->i_vnode = vp;
                        iq->i_lastr = 0;
                        iq = VTOI(vp);
                        iq->i_vnode = vp;
                        iq->i_lastr = 0;
-                       iq->i_flags = 0;
+                       iq->i_flag = 0;
                        ILOCK(iq);
                        iq->i_din = ip->i_din;
                        iq->i_dev = dev;
                        ILOCK(iq);
                        iq->i_din = ip->i_din;
                        iq->i_dev = dev;
@@ -228,7 +230,7 @@ ufs_inactive(vp)
        register struct inode *ip = VTOI(vp);
        int mode, error = 0;
 
        register struct inode *ip = VTOI(vp);
        int mode, error = 0;
 
-       if (vp->v_count != 0)
+       if (prtactive && vp->v_count != 0)
                printf("ufs_inactive: pushing active ino %d dev 0x%x\n",
                        ip->i_number, ip->i_dev);
        /*
                printf("ufs_inactive: pushing active ino %d dev 0x%x\n",
                        ip->i_number, ip->i_dev);
        /*
@@ -270,9 +272,9 @@ ufs_inactive(vp)
 ufs_reclaim(vp)
        register struct vnode *vp;
 {
 ufs_reclaim(vp)
        register struct vnode *vp;
 {
-       register struct inode *iq, *ip = VTOI(vp);
+       register struct inode *ip = VTOI(vp);
 
 
-       if (vp->v_count != 0)
+       if (prtactive && vp->v_count != 0)
                printf("ufs_reclaim: pushing active ino %d dev 0x%x\n",
                        ip->i_number, ip->i_dev);
        /*
                printf("ufs_reclaim: pushing active ino %d dev 0x%x\n",
                        ip->i_number, ip->i_dev);
        /*
@@ -431,7 +433,7 @@ itrunc(oip, length)
        for (i = NDADDR - 1; i > lastblock; i--)
                oip->i_db[i] = 0;
        oip->i_flag |= ICHG|IUPD;
        for (i = NDADDR - 1; i > lastblock; i--)
                oip->i_db[i] = 0;
        oip->i_flag |= ICHG|IUPD;
-       allerror = syncip(oip);
+       allerror = syncip(oip, MNT_WAIT);
 
        /*
         * Indirect blocks first.
 
        /*
         * Indirect blocks first.
@@ -618,54 +620,6 @@ indirtrunc(ip, bn, lastbn, level, countp)
        return (allerror);
 }
 
        return (allerror);
 }
 
-/*
- * Remove any inodes in the inode cache belonging to dev.
- *
- * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err).
- */
-int busyprt = 0;       /* patch to print out busy inodes */
-
-#ifdef QUOTA
-iflush(mp, iq)
-       struct mount *mp;
-       struct inode *iq;
-#else
-iflush(mp)
-       struct mount *mp;
-#endif
-{
-       register struct vnode *vp, *nvp;
-       register struct inode *ip;
-       int busy = 0;
-
-       for (vp = mp->m_mounth; vp; vp = nvp) {
-               nvp = vp->v_mountf;
-               ip = VTOI(vp);
-#ifdef QUOTA
-               if (ip == iq)
-                       continue;
-#endif
-               if (vp->v_count) {
-                       busy++;
-                       if (!busyprt)
-                               continue;
-                       printf("%s %d on dev 0x%x count %d type %d\n",
-                           "iflush: busy inode ", ip->i_number, ip->i_dev,
-                           vp->v_count, vp->v_type);
-                       continue;
-               }
-               /*
-                * With v_count == 0, all we need to do is clear out the
-                * vnode data structures and we are done.
-                */
-               vgone(vp);
-       }
-       if (busy)
-               return (EBUSY);
-       return (0);
-}
-
 /*
  * Lock an inode. If its already locked, set the WANT bit and sleep.
  */
 /*
  * Lock an inode. If its already locked, set the WANT bit and sleep.
  */