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: e17e01bd0e4a - main - cache: refactor dot handling Message-ID: <202101010011.1010BqJX005806@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=e17e01bd0e4a528fff69bff8faf7045d4d619aae commit e17e01bd0e4a528fff69bff8faf7045d4d619aae Author: Mateusz Guzik <mjguzik@gmail.com> AuthorDate: 2020-12-28 07:46:02 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-01-01 00:10:43 +0000 cache: refactor dot handling Tested by: pho --- sys/kern/vfs_cache.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index d5e5e6e3d018..22a5b54b2805 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -3746,6 +3746,7 @@ _Static_assert((CACHE_FPL_SUPPORTED_CN_FLAGS & CACHE_FPL_INTERNAL_CN_FLAGS) == 0 "supported and internal flags overlap"); static bool cache_fplookup_is_mp(struct cache_fpl *fpl); +static int cache_fplookup_cross_mount(struct cache_fpl *fpl); static bool cache_fpl_islastcn(struct nameidata *ndp) @@ -4392,6 +4393,7 @@ cache_fplookup_noentry(struct cache_fpl *fpl) static int __noinline cache_fplookup_dot(struct cache_fpl *fpl) { + int error; MPASS(!seqc_in_modify(fpl->dvp_seqc)); /* @@ -4401,6 +4403,12 @@ cache_fplookup_dot(struct cache_fpl *fpl) */ fpl->tvp = fpl->dvp; fpl->tvp_seqc = fpl->dvp_seqc; + if (cache_fplookup_is_mp(fpl)) { + error = cache_fplookup_cross_mount(fpl); + if (__predict_false(error != 0)) { + return (error); + } + } counter_u64_add(dothits, 1); SDT_PROBE3(vfs, namecache, lookup, hit, fpl->dvp, ".", fpl->dvp); @@ -4421,6 +4429,8 @@ cache_fplookup_dotdot(struct cache_fpl *fpl) cnp = fpl->cnp; dvp = fpl->dvp; + MPASS(cache_fpl_isdotdot(cnp)); + /* * XXX this is racy the same way regular lookup is */ @@ -4520,14 +4530,22 @@ cache_fplookup_next(struct cache_fpl *fpl) struct vnode *dvp, *tvp; u_char nc_flag; uint32_t hash; + int error; cnp = fpl->cnp; dvp = fpl->dvp; - if (__predict_false(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.')) { - return (cache_fplookup_dot(fpl)); + if (__predict_false(cnp->cn_nameptr[0] == '.')) { + if (cnp->cn_namelen == 1) { + return (cache_fplookup_dot(fpl)); + } + if (cnp->cn_namelen == 2 && cnp->cn_nameptr[1] == '.') { + return (cache_fplookup_dotdot(fpl)); + } } + MPASS(!cache_fpl_isdotdot(cnp)); + hash = cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp); CK_SLIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) { @@ -4560,6 +4578,13 @@ cache_fplookup_next(struct cache_fpl *fpl) return (cache_fpl_partial(fpl)); } + if (cache_fplookup_is_mp(fpl)) { + error = cache_fplookup_cross_mount(fpl); + if (__predict_false(error != 0)) { + return (error); + } + } + counter_u64_add(numposhits, 1); SDT_PROBE3(vfs, namecache, lookup, hit, dvp, ncp->nc_name, tvp); return (0); @@ -4973,25 +4998,9 @@ cache_fplookup_impl(struct vnode *dvp, struct cache_fpl *fpl) break; } - if (__predict_false(cache_fpl_isdotdot(cnp))) { - error = cache_fplookup_dotdot(fpl); - if (__predict_false(cache_fpl_terminated(fpl))) { - break; - } - } else { - error = cache_fplookup_next(fpl); - if (__predict_false(cache_fpl_terminated(fpl))) { - break; - } - - VNPASS(!seqc_in_modify(fpl->tvp_seqc), fpl->tvp); - - if (cache_fplookup_is_mp(fpl)) { - error = cache_fplookup_cross_mount(fpl); - if (__predict_false(error != 0)) { - break; - } - } + error = cache_fplookup_next(fpl); + if (__predict_false(cache_fpl_terminated(fpl))) { + break; } VNPASS(!seqc_in_modify(fpl->tvp_seqc), fpl->tvp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101010011.1010BqJX005806>