Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/vfs_vnode.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/vfs_vnode.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.14 retrieving revision 1.14.2.3 diff -u -p -r1.14 -r1.14.2.3 --- src/sys/kern/vfs_vnode.c 2011/10/07 09:35:06 1.14 +++ src/sys/kern/vfs_vnode.c 2012/10/30 17:22:39 1.14.2.3 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.14.2.3 2012/10/30 17:22:39 yamt Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -78,11 +78,15 @@ * - Allocation, via getnewvnode(9) and/or vnalloc(9). * - Reclamation of inactive vnode, via vget(9). * + * Recycle from a free list, via getnewvnode(9) -> getcleanvnode(9) + * was another, traditional way. Currently, only the draining thread + * recycles the vnodes. This behaviour might be revisited. + * * The life-cycle ends when the last reference is dropped, usually * in VOP_REMOVE(9). In such case, VOP_INACTIVE(9) is called to inform * the file system that vnode is inactive. Via this call, file system - * indicates whether vnode should be recycled (usually, count of links - * is checked i.e. whether file was removed). + * indicates whether vnode can be recycled (usually, it checks its own + * references, e.g. count of links, whether the file was removed). * * Depending on indication, vnode can be put into a free list (cache), * or cleaned via vclean(9), which calls VOP_RECLAIM(9) to disassociate @@ -120,7 +124,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.14 2011/10/07 09:35:06 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.14.2.3 2012/10/30 17:22:39 yamt Exp $"); #include #include @@ -147,18 +151,23 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, u_int numvnodes __cacheline_aligned; static pool_cache_t vnode_cache __read_mostly; -static kmutex_t vnode_free_list_lock __cacheline_aligned; +/* + * There are two free lists: one is for vnodes which have no buffer/page + * references and one for those which do (i.e. v_holdcnt is non-zero). + * Vnode recycling mechanism first attempts to look into the former list. + */ +static kmutex_t vnode_free_list_lock __cacheline_aligned; static vnodelst_t vnode_free_list __cacheline_aligned; static vnodelst_t vnode_hold_list __cacheline_aligned; -static vnodelst_t vrele_list __cacheline_aligned; +static kcondvar_t vdrain_cv __cacheline_aligned; +static vnodelst_t vrele_list __cacheline_aligned; static kmutex_t vrele_lock __cacheline_aligned; static kcondvar_t vrele_cv __cacheline_aligned; static lwp_t * vrele_lwp __cacheline_aligned; static int vrele_pending __cacheline_aligned; static int vrele_gen __cacheline_aligned; -static kcondvar_t vdrain_cv __cacheline_aligned; static int cleanvnode(void); static void vdrain_thread(void *); @@ -329,7 +338,7 @@ try_nextlist: KASSERT(vp->v_data == NULL); KASSERT(vp->v_uobj.uo_npages == 0); - KASSERT(TAILQ_EMPTY(&vp->v_uobj.memq)); + KASSERT(radix_tree_empty_tree_p(&vp->v_uobj.uo_pages)); KASSERT(vp->v_numoutput == 0); KASSERT((vp->v_iflag & VI_ONWORKLST) == 0); @@ -386,7 +395,7 @@ getnewvnode(enum vtagtype tag, struct mo uobj = &vp->v_uobj; KASSERT(uobj->pgops == &uvm_vnodeops); KASSERT(uobj->uo_npages == 0); - KASSERT(TAILQ_FIRST(&uobj->memq) == NULL); + KASSERT(radix_tree_empty_tree_p(&vp->v_uobj.uo_pages)); vp->v_size = vp->v_writesize = VSIZENOTSET; /* Share the vnode_t::v_interlock, if requested. */ @@ -637,6 +646,13 @@ vrelel(vnode_t *vp, int flags) KASSERT((vp->v_iflag & VI_XLOCK) == 0); +#ifdef DIAGNOSTIC + if ((vp->v_type == VBLK || vp->v_type == VCHR) && + vp->v_specnode != NULL && vp->v_specnode->sn_opencnt != 0) { + vprint("vrelel: missing VOP_CLOSE()", vp); + } +#endif + /* * If not clean, deactivate the vnode, but preserve * our reference across the call to VOP_INACTIVE(). @@ -706,13 +722,6 @@ retry: return; } -#ifdef DIAGNOSTIC - if ((vp->v_type == VBLK || vp->v_type == VCHR) && - vp->v_specnode != NULL && vp->v_specnode->sn_opencnt != 0) { - vprint("vrelel: missing VOP_CLOSE()", vp); - } -#endif - /* * The vnode can gain another reference while being * deactivated. If VOP_INACTIVE() indicates that