Author: kib
Date: Thu Jan 19 14:49:55 2017
New Revision: 312410
URL: https://svnweb.freebsd.org/changeset/base/312410

Log:
  Rework some tmpfs lock assertions.
  
  Remove TMPFS_ASSERT_ELOCKED().  Its claims are already stated by other
  asserts nearby and by VFS guarantees.
  Change TMPFS_ASSERT_LOCKED() and one inlined place to use
  ASSERT_VOP_(E)LOCKED() instead of hand-rolled imprecise asserts.
  
  Tested by:    pho (as part of the larger patch)
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==============================================================================
--- head/sys/fs/tmpfs/tmpfs.h   Thu Jan 19 14:27:37 2017        (r312409)
+++ head/sys/fs/tmpfs/tmpfs.h   Thu Jan 19 14:49:55 2017        (r312410)
@@ -309,19 +309,10 @@ LIST_HEAD(tmpfs_node_list, tmpfs_node);
 #define TMPFS_ASSERT_LOCKED(node) do {                                 \
                MPASS(node != NULL);                                    \
                MPASS(node->tn_vnode != NULL);                          \
-               if (!VOP_ISLOCKED(node->tn_vnode) &&                    \
-                   !mtx_owned(TMPFS_NODE_MTX(node)))                   \
-                       panic("tmpfs: node is not locked: %p", node);   \
-       } while (0)
-#define TMPFS_ASSERT_ELOCKED(node) do {                                        
\
-               MPASS((node) != NULL);                                  \
-               MPASS((node)->tn_vnode != NULL);                        \
-               mtx_assert(TMPFS_NODE_MTX(node), MA_OWNED);             \
-               ASSERT_VOP_LOCKED((node)->tn_vnode, "tmpfs");           \
+               ASSERT_VOP_LOCKED(node->tn_vnode, "tmpfs assert");      \
        } while (0)
 #else
 #define TMPFS_ASSERT_LOCKED(node) (void)0
-#define TMPFS_ASSERT_ELOCKED(node) (void)0
 #endif
 
 #define TMPFS_VNODE_ALLOCATING 1

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_subr.c      Thu Jan 19 14:27:37 2017        
(r312409)
+++ head/sys/fs/tmpfs/tmpfs_subr.c      Thu Jan 19 14:49:55 2017        
(r312410)
@@ -669,7 +669,7 @@ tmpfs_alloc_file(struct vnode *dvp, stru
        struct tmpfs_node *node;
        struct tmpfs_node *parent;
 
-       MPASS(VOP_ISLOCKED(dvp));
+       ASSERT_VOP_ELOCKED(dvp, "tmpfs_alloc_file");
        MPASS(cnp->cn_flags & HASBUF);
 
        tmp = VFS_TO_TMPFS(dvp->v_mount);

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c     Thu Jan 19 14:27:37 2017        
(r312409)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c     Thu Jan 19 14:49:55 2017        
(r312410)
@@ -1111,7 +1111,6 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
 
        /* No vnode should be allocated for this entry from this point */
        TMPFS_NODE_LOCK(node);
-       TMPFS_ASSERT_ELOCKED(node);
        node->tn_links--;
        node->tn_dir.tn_parent = NULL;
        node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED |
@@ -1120,7 +1119,6 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
        TMPFS_NODE_UNLOCK(node);
 
        TMPFS_NODE_LOCK(dnode);
-       TMPFS_ASSERT_ELOCKED(dnode);
        dnode->tn_links--;
        dnode->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED |
            TMPFS_NODE_MODIFIED;
@@ -1274,7 +1272,6 @@ tmpfs_reclaim(struct vop_reclaim_args *v
        cache_purge(vp);
 
        TMPFS_NODE_LOCK(node);
-       TMPFS_ASSERT_ELOCKED(node);
        tmpfs_free_vp(vp);
 
        /* If the node referenced by this vnode was deleted by the user,
_______________________________________________
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