aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/tmpfs/tmpfs.h
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-10-11 07:03:56 +0000
committerXin LI <delphij@FreeBSD.org>2009-10-11 07:03:56 +0000
commit82cf92d4836ca0dbdeec98d8a294119594608cd3 (patch)
treeb60e455bba502c70843ad5fe0cb6ec8aa2645d57 /sys/fs/tmpfs/tmpfs.h
parent0b4b0b0feea2734cdf46d8542dee3cc4a56fa52b (diff)
downloadsrc-82cf92d4836ca0dbdeec98d8a294119594608cd3.tar.gz
src-82cf92d4836ca0dbdeec98d8a294119594608cd3.zip
Add locking around access to parent node, and bail out when the parent
node is already freed rather than panicking the system. PR: kern/122038 Submitted by: gk Tested by: pho MFC after: 1 week
Notes
Notes: svn path=/head/; revision=197953
Diffstat (limited to 'sys/fs/tmpfs/tmpfs.h')
-rw-r--r--sys/fs/tmpfs/tmpfs.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h
index ffd705fe026d..1edbc415106b 100644
--- a/sys/fs/tmpfs/tmpfs.h
+++ b/sys/fs/tmpfs/tmpfs.h
@@ -303,10 +303,30 @@ LIST_HEAD(tmpfs_node_list, tmpfs_node);
#define TMPFS_NODE_LOCK(node) mtx_lock(&(node)->tn_interlock)
#define TMPFS_NODE_UNLOCK(node) mtx_unlock(&(node)->tn_interlock)
-#define TMPFS_NODE_MTX(node) (&(node)->tn_interlock)
+#define TMPFS_NODE_MTX(node) (&(node)->tn_interlock)
+
+#ifdef INVARIANTS
+#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"); \
+ } while (0)
+#else
+#define TMPFS_ASSERT_LOCKED(node) (void)0
+#define TMPFS_ASSERT_ELOCKED(node) (void)0
+#endif
#define TMPFS_VNODE_ALLOCATING 1
#define TMPFS_VNODE_WANT 2
+#define TMPFS_VNODE_DOOMED 4
/* --------------------------------------------------------------------- */
/*