From a5db4bf4757cbd3f56c7d823bb005b6f71c011ce Mon Sep 17 00:00:00 2001 From: John Dyson Date: Tue, 26 Aug 1997 04:36:27 +0000 Subject: [PATCH] Back out some incorrect changes that was worse than the original bug. --- sys/fs/msdosfs/msdosfs_denode.c | 4 +--- sys/kern/vfs_bio.c | 10 ++++----- sys/kern/vfs_export.c | 37 ++++++++++++++------------------- sys/kern/vfs_subr.c | 37 ++++++++++++++------------------- sys/msdosfs/msdosfs_denode.c | 4 +--- sys/ufs/ufs/ufs_inode.c | 4 ++-- sys/ufs/ufs/ufs_vnops.c | 10 +-------- 7 files changed, 42 insertions(+), 64 deletions(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 597326590cbc..ef57cef250da 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -750,9 +750,7 @@ out: printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount, dep->de_Name[0]); #endif - if (dep->de_Name[0] == SLOT_DELETED) - vp->v_flag |= VAGE; - + vrecycle(vp, (struct simplelock *)0, p); return error; } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 5d726eb633f0..fc991ad9d00c 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -18,7 +18,7 @@ * 5. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: vfs_bio.c,v 1.122 1997/08/09 10:13:12 dyson Exp $ + * $Id: vfs_bio.c,v 1.123 1997/08/21 01:35:37 dyson Exp $ */ /* @@ -2196,7 +2196,7 @@ tryagain: bp->b_pages[index] = p; PAGE_WAKEUP(p); } - bp->b_npages = index; + bp->b_npages = to >> PAGE_SHIFT; } void @@ -2204,11 +2204,11 @@ vm_hold_free_pages(struct buf * bp, vm_offset_t from, vm_offset_t to) { vm_offset_t pg; vm_page_t p; - int index, newnpages; + int index; from = round_page(from); to = round_page(to); - newnpages = index = (from - trunc_page(bp->b_data)) >> PAGE_SHIFT; + index = (from - trunc_page(bp->b_data)) >> PAGE_SHIFT; for (pg = from; pg < to; pg += PAGE_SIZE, index++) { p = bp->b_pages[index]; @@ -2225,7 +2225,7 @@ vm_hold_free_pages(struct buf * bp, vm_offset_t from, vm_offset_t to) vm_page_free(p); } } - bp->b_npages = newnpages; + bp->b_npages = from >> PAGE_SHIFT; } diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 5d6605480565..5d01d8e38f2e 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.92 1997/08/21 20:33:39 bde Exp $ + * $Id: vfs_subr.c,v 1.93 1997/08/22 03:56:29 dyson Exp $ */ /* @@ -63,8 +63,6 @@ #include #include -#include - #include #include #include @@ -1089,11 +1087,11 @@ vputrele(vp, put) panic("vputrele: null vp"); #endif simple_lock(&vp->v_interlock); + vp->v_usecount--; - if ((vp->v_usecount == 2) && + if ((vp->v_usecount == 1) && vp->v_object && (vp->v_object->flags & OBJ_VFS_REF)) { - vp->v_usecount--; vp->v_object->flags &= ~OBJ_VFS_REF; if (put) { VOP_UNLOCK(vp, LK_INTERLOCK, p); @@ -1104,8 +1102,7 @@ vputrele(vp, put) return; } - if (vp->v_usecount > 1) { - vp->v_usecount--; + if (vp->v_usecount > 0) { if (put) { VOP_UNLOCK(vp, LK_INTERLOCK, p); } else { @@ -1114,12 +1111,23 @@ vputrele(vp, put) return; } - if (vp->v_usecount < 1) { + if (vp->v_usecount < 0) { #ifdef DIAGNOSTIC vprint("vputrele: negative ref count", vp); #endif panic("vputrele: negative ref cnt"); } + simple_lock(&vnode_free_list_slock); + if (vp->v_flag & VAGE) { + vp->v_flag &= ~VAGE; + if(vp->v_tag != VT_TFS) + TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); + } else { + if(vp->v_tag != VT_TFS) + TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); + } + freevnodes++; + simple_unlock(&vnode_free_list_slock); /* * If we are doing a vput, the node is already locked, and we must @@ -1132,19 +1140,6 @@ vputrele(vp, put) } else if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) == 0) { VOP_INACTIVE(vp, p); } - - vp->v_usecount--; - simple_lock(&vnode_free_list_slock); - if (vp->v_flag & VAGE) { - vp->v_flag &= ~VAGE; - if(vp->v_tag != VT_TFS) - TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); - } else { - if(vp->v_tag != VT_TFS) - TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); - } - freevnodes++; - simple_unlock(&vnode_free_list_slock); } /* diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5d6605480565..5d01d8e38f2e 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.92 1997/08/21 20:33:39 bde Exp $ + * $Id: vfs_subr.c,v 1.93 1997/08/22 03:56:29 dyson Exp $ */ /* @@ -63,8 +63,6 @@ #include #include -#include - #include #include #include @@ -1089,11 +1087,11 @@ vputrele(vp, put) panic("vputrele: null vp"); #endif simple_lock(&vp->v_interlock); + vp->v_usecount--; - if ((vp->v_usecount == 2) && + if ((vp->v_usecount == 1) && vp->v_object && (vp->v_object->flags & OBJ_VFS_REF)) { - vp->v_usecount--; vp->v_object->flags &= ~OBJ_VFS_REF; if (put) { VOP_UNLOCK(vp, LK_INTERLOCK, p); @@ -1104,8 +1102,7 @@ vputrele(vp, put) return; } - if (vp->v_usecount > 1) { - vp->v_usecount--; + if (vp->v_usecount > 0) { if (put) { VOP_UNLOCK(vp, LK_INTERLOCK, p); } else { @@ -1114,12 +1111,23 @@ vputrele(vp, put) return; } - if (vp->v_usecount < 1) { + if (vp->v_usecount < 0) { #ifdef DIAGNOSTIC vprint("vputrele: negative ref count", vp); #endif panic("vputrele: negative ref cnt"); } + simple_lock(&vnode_free_list_slock); + if (vp->v_flag & VAGE) { + vp->v_flag &= ~VAGE; + if(vp->v_tag != VT_TFS) + TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); + } else { + if(vp->v_tag != VT_TFS) + TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); + } + freevnodes++; + simple_unlock(&vnode_free_list_slock); /* * If we are doing a vput, the node is already locked, and we must @@ -1132,19 +1140,6 @@ vputrele(vp, put) } else if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) == 0) { VOP_INACTIVE(vp, p); } - - vp->v_usecount--; - simple_lock(&vnode_free_list_slock); - if (vp->v_flag & VAGE) { - vp->v_flag &= ~VAGE; - if(vp->v_tag != VT_TFS) - TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); - } else { - if(vp->v_tag != VT_TFS) - TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); - } - freevnodes++; - simple_unlock(&vnode_free_list_slock); } /* diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c index 597326590cbc..ef57cef250da 100644 --- a/sys/msdosfs/msdosfs_denode.c +++ b/sys/msdosfs/msdosfs_denode.c @@ -750,9 +750,7 @@ out: printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount, dep->de_Name[0]); #endif - if (dep->de_Name[0] == SLOT_DELETED) - vp->v_flag |= VAGE; - + vrecycle(vp, (struct simplelock *)0, p); return error; } diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 29b5dff59ec9..c3166ade957e 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_inode.c 8.9 (Berkeley) 5/14/95 - * $Id: ufs_inode.c,v 1.12 1997/03/22 06:53:44 bde Exp $ + * $Id: ufs_inode.c,v 1.13 1997/08/22 03:56:35 dyson Exp $ */ #include "opt_quota.h" @@ -104,7 +104,7 @@ out: * so that it can be reused immediately. */ if (ip->i_mode == 0) - vp->v_flag |= VAGE; + vrecycle(vp, (struct simplelock *)0, p); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 3f9d72c32867..fc60e857f6e4 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95 - * $Id: ufs_vnops.c,v 1.53 1997/08/21 01:42:47 dyson Exp $ + * $Id: ufs_vnops.c,v 1.54 1997/08/22 15:37:23 dyson Exp $ */ #include "opt_quota.h" @@ -692,14 +692,6 @@ ufs_remove(ap) ip->i_flag |= IN_CHANGE; } out: -#if 0 - if ((ip->i_nlink == 0) && - ((vp->v_object == NULL) && (vp->v_usecount == 1)) || - (vp->v_usecount <= 2)) { - VOP_TRUNCATE(vp, (off_t)0, 0, NOCRED, NULL); - } -#endif - if (dvp == vp) vrele(vp); else