delete VERBOSE #ifdef's
[unix-history] / usr / src / sys / ufs / lfs / lfs_alloc.c
index 8fe840f..09c0a5d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_alloc.c 7.45 (Berkeley) %G%
+ *     @(#)lfs_alloc.c 7.51 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -29,8 +29,13 @@ extern u_long nextgennumber;
 /* Allocate a new inode. */
 /* ARGSUSED */
 int
 /* Allocate a new inode. */
 /* ARGSUSED */
 int
-lfs_valloc (ap)
-       struct vop_valloc_args *ap;
+lfs_valloc(ap)
+       struct vop_valloc_args /* {
+               struct vnode *a_pvp;
+               int a_mode;
+               struct ucred *a_cred;
+               struct vnode **a_vpp;
+       } */ *ap;
 {
        struct lfs *fs;
        struct buf *bp;
 {
        struct lfs *fs;
        struct buf *bp;
@@ -42,9 +47,6 @@ lfs_valloc (ap)
        u_long i, max;
        int error;
 
        u_long i, max;
        int error;
 
-#ifdef VERBOSE
-       printf("lfs_valloc\n");
-#endif
        /* Get the head of the freelist. */
        fs = VTOI(ap->a_pvp)->i_lfs;
        new_ino = fs->lfs_free;
        /* Get the head of the freelist. */
        fs = VTOI(ap->a_pvp)->i_lfs;
        new_ino = fs->lfs_free;
@@ -67,7 +69,6 @@ lfs_valloc (ap)
                vp = fs->lfs_ivnode;
                ip = VTOI(vp);
                blkno = lblkno(fs, ip->i_size);
                vp = fs->lfs_ivnode;
                ip = VTOI(vp);
                blkno = lblkno(fs, ip->i_size);
-printf("Extending ifile: blkno = %d\n", blkno);
                bp = getblk(vp, blkno, fs->lfs_bsize);
                if (!bp) {
                        uprintf("\n%s: no inodes left\n", fs->lfs_fsmnt);
                bp = getblk(vp, blkno, fs->lfs_bsize);
                if (!bp) {
                        uprintf("\n%s: no inodes left\n", fs->lfs_fsmnt);
@@ -77,10 +78,8 @@ printf("Extending ifile: blkno = %d\n", blkno);
                }
                i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) *
                    fs->lfs_ifpb;
                }
                i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) *
                    fs->lfs_ifpb;
-printf("Extending ifile: first inum = %d\n", i);
                fs->lfs_free = i;
                max = i + fs->lfs_ifpb;
                fs->lfs_free = i;
                max = i + fs->lfs_ifpb;
-printf("Extending ifile: max inum = %d\n", max);
                for (ifp = (struct ifile *)bp->b_un.b_words; i < max; ++ifp) {
                        ifp->if_version = 1;
                        ifp->if_daddr = LFS_UNUSED_DADDR;
                for (ifp = (struct ifile *)bp->b_un.b_words; i < max; ++ifp) {
                        ifp->if_version = 1;
                        ifp->if_daddr = LFS_UNUSED_DADDR;
@@ -89,9 +88,9 @@ printf("Extending ifile: max inum = %d\n", max);
                ifp--;
                ifp->if_nextfree = LFS_UNUSED_INUM;
 
                ifp--;
                ifp->if_nextfree = LFS_UNUSED_INUM;
 
-               ++ip->i_blocks;                 /* XXX This may not be right. */
+               ip->i_blocks += btodb(fs->lfs_bsize);
+               fs->lfs_bfree -= btodb(fs->lfs_bsize);
                ip->i_size += fs->lfs_bsize;
                ip->i_size += fs->lfs_bsize;
-printf("Extending ifile: blocks = %d size = %d\n", ip->i_blocks, ip->i_size);
                vnode_pager_setsize(vp, (u_long)ip->i_size);
                vnode_pager_uncache(vp);
                LFS_UBWRITE(bp);
                vnode_pager_setsize(vp, (u_long)ip->i_size);
                vnode_pager_uncache(vp);
                LFS_UBWRITE(bp);
@@ -101,6 +100,7 @@ printf("Extending ifile: blocks = %d size = %d\n", ip->i_blocks, ip->i_size);
        if (error = lfs_vcreate(ap->a_pvp->v_mount, new_ino, &vp))
                return (error);
        *ap->a_vpp = vp;
        if (error = lfs_vcreate(ap->a_pvp->v_mount, new_ino, &vp))
                return (error);
        *ap->a_vpp = vp;
+       vp->v_flag |= VDIROP;
        ip = VTOI(vp);
        VREF(ip->i_devvp);
 
        ip = VTOI(vp);
        VREF(ip->i_devvp);
 
@@ -133,9 +133,6 @@ lfs_vcreate(mp, ino, vpp)
        struct ufsmount *ump;
        int error, i;
 
        struct ufsmount *ump;
        int error, i;
 
-#ifdef VERBOSE
-       printf("lfs_vcreate: ino %d\n", ino);
-#endif
        /* Create the vnode. */
        if (error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) {
                *vpp = NULL;
        /* Create the vnode. */
        if (error = getnewvnode(VT_LFS, mp, lfs_vnodeop_p, vpp)) {
                *vpp = NULL;
@@ -162,14 +159,19 @@ lfs_vcreate(mp, ino, vpp)
        ip->i_diroff = 0;
        ip->i_mode = 0;
        ip->i_size = 0;
        ip->i_diroff = 0;
        ip->i_mode = 0;
        ip->i_size = 0;
+       ip->i_blocks = 0;
        return (0);
 }
 
 /* Free an inode. */
 /* ARGUSED */
 int
        return (0);
 }
 
 /* Free an inode. */
 /* ARGUSED */
 int
-lfs_vfree (ap)
-       struct vop_vfree_args *ap;
+lfs_vfree(ap)
+       struct vop_vfree_args /* {
+               struct vnode *a_pvp;
+               ino_t a_ino;
+               int a_mode;
+       } */ *ap;
 {
        SEGUSE *sup;
        struct buf *bp;
 {
        SEGUSE *sup;
        struct buf *bp;
@@ -179,11 +181,8 @@ lfs_vfree (ap)
        daddr_t old_iaddr;
        ino_t ino;
 
        daddr_t old_iaddr;
        ino_t ino;
 
-       ip = VTOI(ap->a_pvp);
-#ifdef VERBOSE
-       printf("lfs_vfree: free %d\n", ip->i_number);
-#endif
        /* Get the inode number and file system. */
        /* Get the inode number and file system. */
+       ip = VTOI(ap->a_pvp);
        fs = ip->i_lfs;
        ino = ip->i_number;
 
        fs = ip->i_lfs;
        ino = ip->i_number;
 
@@ -215,5 +214,3 @@ lfs_vfree (ap)
        --fs->lfs_nfiles;
        return (0);
 }
        --fs->lfs_nfiles;
        return (0);
 }
-
-