From owner-svn-src-head@freebsd.org Thu Jan 21 01:09:40 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8399A89A50; Thu, 21 Jan 2016 01:09:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88FB61A57; Thu, 21 Jan 2016 01:09:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0L19dCq099058; Thu, 21 Jan 2016 01:09:39 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0L19d2E099057; Thu, 21 Jan 2016 01:09:39 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201601210109.u0L19d2E099057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 21 Jan 2016 01:09:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294478 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2016 01:09:41 -0000 Author: mjg Date: Thu Jan 21 01:09:39 2016 New Revision: 294478 URL: https://svnweb.freebsd.org/changeset/base/294478 Log: cache: minor changes 1. vhold and zap immediately instead of postponing few lines later 2. increment numneg after new entry is added No functional changes. No objections: kib Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Thu Jan 21 01:07:05 2016 (r294477) +++ head/sys/kern/vfs_cache.c Thu Jan 21 01:09:39 2016 (r294478) @@ -723,8 +723,6 @@ cache_enter_time(struct vnode *dvp, stru struct nchashhead *ncpp; uint32_t hash; int flag; - int hold; - int zap; int len; CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr); @@ -782,9 +780,6 @@ cache_enter_time(struct vnode *dvp, stru } } - hold = 0; - zap = 0; - /* * Calculate the hash key and setup as much of the new * namecache entry as possible before acquiring the lock. @@ -855,24 +850,22 @@ cache_enter_time(struct vnode *dvp, stru } numcache++; - if (vp == NULL) { - numneg++; - if (cnp->cn_flags & ISWHITEOUT) - ncp->nc_flag |= NCF_WHITE; - } else if (vp->v_type == VDIR) { - if (flag != NCF_ISDOTDOT) { - /* - * For this case, the cache entry maps both the - * directory name in it and the name ".." for the - * directory's parent. - */ - if ((n2 = vp->v_cache_dd) != NULL && - (n2->nc_flag & NCF_ISDOTDOT) != 0) - cache_zap(n2); - vp->v_cache_dd = ncp; + if (vp != NULL) { + if (vp->v_type == VDIR) { + if (flag != NCF_ISDOTDOT) { + /* + * For this case, the cache entry maps both the + * directory name in it and the name ".." for the + * directory's parent. + */ + if ((n2 = vp->v_cache_dd) != NULL && + (n2->nc_flag & NCF_ISDOTDOT) != 0) + cache_zap(n2); + vp->v_cache_dd = ncp; + } + } else { + vp->v_cache_dd = NULL; } - } else { - vp->v_cache_dd = NULL; } /* @@ -882,7 +875,7 @@ cache_enter_time(struct vnode *dvp, stru LIST_INSERT_HEAD(ncpp, ncp, nc_hash); if (flag != NCF_ISDOTDOT) { if (LIST_EMPTY(&dvp->v_cache_src)) { - hold = 1; + vhold(dvp); numcachehv++; } LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src); @@ -898,7 +891,10 @@ cache_enter_time(struct vnode *dvp, stru SDT_PROBE3(vfs, namecache, enter, done, dvp, nc_get_name(ncp), vp); } else { + if (cnp->cn_flags & ISWHITEOUT) + ncp->nc_flag |= NCF_WHITE; TAILQ_INSERT_TAIL(&ncneg, ncp, nc_dst); + numneg++; SDT_PROBE2(vfs, namecache, enter_negative, done, dvp, nc_get_name(ncp)); } @@ -906,12 +902,8 @@ cache_enter_time(struct vnode *dvp, stru ncp = TAILQ_FIRST(&ncneg); KASSERT(ncp->nc_vp == NULL, ("ncp %p vp %p on ncneg", ncp, ncp->nc_vp)); - zap = 1; - } - if (hold) - vhold(dvp); - if (zap) cache_zap(ncp); + } CACHE_WUNLOCK(); }