git: 01435e282112 - main - vfs cache: Simplify cache_enter_time() a bit
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 May 2025 00:04:50 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=01435e28211220f985c66569f60939e440f0887f commit 01435e28211220f985c66569f60939e440f0887f Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-05-02 21:35:18 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-05-03 00:04:32 +0000 vfs cache: Simplify cache_enter_time() a bit The condition `flag == NFC_ISDOTDOT && vp != NULL && vp->v_type != VDIR` is never true at this point in the function. This is asserted slightly earlier. So, remove some dead code and simplify control flow. N.B. we set v_cache_dd for all vnode types, not just VDIR. This seems to be intentional, see commit ce575cd0e2f9069. For regular files it appears to effectively represent the most recently entered cache entry for the vnode. No functional change intended. Reviewed by: olce, kib MFC after: 2 weeks Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50107 --- sys/kern/vfs_cache.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 86e5c65ba3da..c949363de003 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2628,28 +2628,20 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, ("wrong vnode type %p", vp)); atomic_thread_fence_rel(); atomic_store_ptr(&dvp->v_cache_dd, ncp); - } - - if (vp != NULL) { - 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 ((ndd = vp->v_cache_dd) != NULL) { - if ((ndd->nc_flag & NCF_ISDOTDOT) != 0) - cache_zap_locked(ndd); - else - ndd = NULL; - } - atomic_thread_fence_rel(); - atomic_store_ptr(&vp->v_cache_dd, ncp); - } else if (vp->v_type != VDIR) { - if (vp->v_cache_dd != NULL) { - atomic_store_ptr(&vp->v_cache_dd, NULL); - } + } else if (vp != NULL) { + /* + * For this case, the cache entry maps both the + * directory name in it and the name ".." for the + * directory's parent. + */ + if ((ndd = vp->v_cache_dd) != NULL) { + if ((ndd->nc_flag & NCF_ISDOTDOT) != 0) + cache_zap_locked(ndd); + else + ndd = NULL; } + atomic_thread_fence_rel(); + atomic_store_ptr(&vp->v_cache_dd, ncp); } if (flag != NCF_ISDOTDOT) {