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);
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to