aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/mount.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2019-08-23 21:05:37 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2019-08-23 21:05:37 +0000
commit25c8d940ab5b46b2fb7072a711f275e4fcabd684 (patch)
tree79545191cc861c0d7954ce42c2f76d7b431d5840 /sys/sys/mount.h
parentf93670b7b9f6f4a9457fd306411d04a8052d2522 (diff)
downloadsrc-25c8d940ab5b46b2fb7072a711f275e4fcabd684.tar.gz
src-25c8d940ab5b46b2fb7072a711f275e4fcabd684.zip
vfs: assert the lock held in MNT_REF/MNT_REL
Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=351438
Diffstat (limited to 'sys/sys/mount.h')
-rw-r--r--sys/sys/mount.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index 2b7f988b7639..50f0663537c5 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -265,8 +265,12 @@ void __mnt_vnode_markerfree_active(struct vnode **mvp, struct mount *);
#define MNT_ITRYLOCK(mp) mtx_trylock(&(mp)->mnt_mtx)
#define MNT_IUNLOCK(mp) mtx_unlock(&(mp)->mnt_mtx)
#define MNT_MTX(mp) (&(mp)->mnt_mtx)
-#define MNT_REF(mp) (mp)->mnt_ref++
+#define MNT_REF(mp) do { \
+ mtx_assert(MNT_MTX(mp), MA_OWNED); \
+ (mp)->mnt_ref++; \
+} while (0)
#define MNT_REL(mp) do { \
+ mtx_assert(MNT_MTX(mp), MA_OWNED); \
KASSERT((mp)->mnt_ref > 0, ("negative mnt_ref")); \
(mp)->mnt_ref--; \
if ((mp)->mnt_ref == 0) \