Date: Thu, 2 Jul 2020 12:54:50 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362888 - head/sys/kern Message-ID: <202007021254.062Cso12086778@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Thu Jul 2 12:54:50 2020 New Revision: 362888 URL: https://svnweb.freebsd.org/changeset/base/362888 Log: cache: fix misplaced fence in cache_ncp_invalidate The intent was to mark the entry as invalid before cache_zap starts messing with it. While here add some comments. Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Thu Jul 2 10:44:45 2020 (r362887) +++ head/sys/kern/vfs_cache.c Thu Jul 2 12:54:50 2020 (r362888) @@ -147,22 +147,33 @@ struct namecache_ts { #define NCF_HOTNEGATIVE 0x40 #define NCF_INVALID 0x80 -static bool -cache_ncp_invalid(struct namecache *ncp) -{ - - atomic_thread_fence_acq(); - return ((ncp->nc_flag & NCF_INVALID) != 0); -} - +/* + * Mark an entry as invalid. + * + * This is called before it starts getting deconstructed. + */ static void cache_ncp_invalidate(struct namecache *ncp) { - atomic_thread_fence_rel(); KASSERT((ncp->nc_flag & NCF_INVALID) == 0, ("%s: entry %p already invalid", __func__, ncp)); ncp->nc_flag |= NCF_INVALID; + atomic_thread_fence_rel(); +} + +/* + * Verify validity of an entry. + * + * All places which elide locks are supposed to call this after they are + * done with reading from an entry. + */ +static bool +cache_ncp_invalid(struct namecache *ncp) +{ + + atomic_thread_fence_acq(); + return ((ncp->nc_flag & NCF_INVALID) != 0); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007021254.062Cso12086778>