From owner-svn-src-head@freebsd.org Sat Oct 17 13:04:51 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF28D4377DE; Sat, 17 Oct 2020 13:04:51 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CD3C70pdwz4771; Sat, 17 Oct 2020 13:04:51 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B3BD21CB7; Sat, 17 Oct 2020 13:04:46 +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 09HD4kOv023690; Sat, 17 Oct 2020 13:04:46 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09HD4kBo023689; Sat, 17 Oct 2020 13:04:46 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202010171304.09HD4kBo023689@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 17 Oct 2020 13:04:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366792 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 366792 X-SVN-Commit-Repository: base 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.33 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: Sat, 17 Oct 2020 13:04:51 -0000 Author: mjg Date: Sat Oct 17 13:04:46 2020 New Revision: 366792 URL: https://svnweb.freebsd.org/changeset/base/366792 Log: cache: factor negative lookup out of cache_fplookup_next Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Sat Oct 17 13:04:25 2020 (r366791) +++ head/sys/kern/vfs_cache.c Sat Oct 17 13:04:46 2020 (r366792) @@ -3815,16 +3815,53 @@ cache_fplookup_dotdot(struct cache_fpl *fpl) return (0); } +static int __noinline +cache_fplookup_neg(struct cache_fpl *fpl, struct namecache *ncp, uint32_t hash) +{ + struct negstate *ns; + struct vnode *dvp; + u_char nc_flag; + bool neg_hot; + + dvp = fpl->dvp; + nc_flag = atomic_load_char(&ncp->nc_flag); + MPASS((nc_flag & NCF_NEGATIVE) != 0); + /* + * If they want to create an entry we need to replace this one. + */ + if (__predict_false(fpl->cnp->cn_nameiop != LOOKUP)) { + /* + * TODO + * This should call something similar to + * cache_fplookup_final_modifying. + */ + return (cache_fpl_partial(fpl)); + } + ns = NCP2NEGSTATE(ncp); + neg_hot = ((ns->neg_flag & NEG_HOT) != 0); + if (__predict_false(!cache_ncp_canuse(ncp))) { + return (cache_fpl_partial(fpl)); + } + if (__predict_false((nc_flag & NCF_WHITE) != 0)) { + return (cache_fpl_partial(fpl)); + } + if (!neg_hot) { + return (cache_fplookup_negative_promote(fpl, ncp, hash)); + } + SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, ncp->nc_name); + counter_u64_add(numneghits, 1); + cache_fpl_smr_exit(fpl); + return (cache_fpl_handled(fpl, ENOENT)); +} + static int cache_fplookup_next(struct cache_fpl *fpl) { struct componentname *cnp; struct namecache *ncp; - struct negstate *ns; struct vnode *dvp, *tvp; u_char nc_flag; uint32_t hash; - bool neg_hot; cnp = fpl->cnp; dvp = fpl->dvp; @@ -3853,28 +3890,7 @@ cache_fplookup_next(struct cache_fpl *fpl) tvp = atomic_load_ptr(&ncp->nc_vp); nc_flag = atomic_load_char(&ncp->nc_flag); if ((nc_flag & NCF_NEGATIVE) != 0) { - /* - * If they want to create an entry we need to replace this one. - */ - if (__predict_false(fpl->cnp->cn_nameiop != LOOKUP)) { - return (cache_fpl_partial(fpl)); - } - ns = NCP2NEGSTATE(ncp); - neg_hot = ((ns->neg_flag & NEG_HOT) != 0); - if (__predict_false(!cache_ncp_canuse(ncp))) { - return (cache_fpl_partial(fpl)); - } - if (__predict_false((nc_flag & NCF_WHITE) != 0)) { - return (cache_fpl_partial(fpl)); - } - if (!neg_hot) { - return (cache_fplookup_negative_promote(fpl, ncp, hash)); - } - SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, - ncp->nc_name); - counter_u64_add(numneghits, 1); - cache_fpl_smr_exit(fpl); - return (cache_fpl_handled(fpl, ENOENT)); + return (cache_fplookup_neg(fpl, ncp, hash)); } if (__predict_false(!cache_ncp_canuse(ncp))) {