git: 1a03846b4050 - stable/14 - vfs cache: Simplify cache_enter_time() a bit
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Jun 2025 19:54:01 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1a03846b405093048324ea2783a19d88a469d5e6 commit 1a03846b405093048324ea2783a19d88a469d5e6 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-05-02 21:35:18 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-06-01 19:53:29 +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 (cherry picked from commit 01435e28211220f985c66569f60939e440f0887f) --- 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 284e23f3d1e8..a61a684e396e 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2540,28 +2540,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) {