Date: Fri, 1 Jan 2021 00:11:52 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 1365b5f86f63 - main - cache: fold NCF_WHITE check into the rest Message-ID: <202101010011.1010Bq95005755@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=1365b5f86f631ab6b30fd5f71685e39aa8887474 commit 1365b5f86f631ab6b30fd5f71685e39aa8887474 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2020-12-28 11:24:48 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-01-01 00:10:43 +0000 cache: fold NCF_WHITE check into the rest Tested by: pho --- sys/kern/vfs_cache.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 40cd174e1022..4b8940b7511c 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -263,6 +263,18 @@ cache_ncp_invalidate(struct namecache *ncp) __predict_true((_nc_flag & (NCF_INVALID | NCF_WIP)) == 0); \ }) +/* + * Like the above but also checks NCF_WHITE. + */ +#define cache_fpl_neg_ncp_canuse(ncp) ({ \ + struct namecache *_ncp = (ncp); \ + u_char _nc_flag; \ + \ + atomic_thread_fence_acq(); \ + _nc_flag = atomic_load_char(&_ncp->nc_flag); \ + __predict_true((_nc_flag & (NCF_INVALID | NCF_WIP | NCF_WHITE)) == 0); \ +}) + /* * Name caching works as follows: * @@ -4505,11 +4517,7 @@ cache_fplookup_neg(struct cache_fpl *fpl, struct namecache *ncp, uint32_t hash) return (cache_fplookup_modifying(fpl)); } neg_promote = cache_neg_hit_prep(ncp); - if (!cache_ncp_canuse(ncp)) { - cache_neg_hit_abort(ncp); - return (cache_fpl_partial(fpl)); - } - if (__predict_false((nc_flag & NCF_WHITE) != 0)) { + if (!cache_fpl_neg_ncp_canuse(ncp)) { cache_neg_hit_abort(ncp); return (cache_fpl_partial(fpl)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101010011.1010Bq95005755>