From 302c7aaab96575e021f27466af3c2be070971122 Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Sat, 6 Jul 2002 05:21:12 +0000 Subject: [PATCH] - Add vop_strategy_pre to validate VOP_STRATEGY locking. - Disable original vop_strategy lock specification. - Switch to the new vop_strategy_pre for lock validation. VOP_STRATEGY requires only that the buf is locked UNLESS the block numbers need to be translated. There may be other reasons, but as long as the underlying layer uses a VOP to perform the operations they will be caught later. --- sys/kern/vfs_subr.c | 16 ++++++++++++++++ sys/sys/vnode.h | 1 + 2 files changed, 17 insertions(+) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index fb7ba43c21f7..882fc391d557 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -253,6 +253,22 @@ vop_rename_pre(void *ap) ASSERT_VOP_LOCKED(a->a_tdvp, "vop_rename: tdvp not locked.\n"); } +void +vop_strategy_pre(void *ap) +{ + struct vop_strategy_args *a = ap; + int status; + + status = lockstatus(&a->a_bp->b_lock, curthread); + + if (status != LK_SHARED && status != LK_EXCLUSIVE) { + if (vfs_badlock_print) + printf("VOP_STRATEGY: bp is not locked but should be.\n"); + if (vfs_badlock_panic) + Debugger("Lock violation.\n"); + } +} + #endif /* DEBUG_VFS_LOCKS */ void diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 4e315d70fa6c..71e9236390c9 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -524,6 +524,7 @@ do { \ } while (0) void vop_rename_pre(void *a); +void vop_strategy_pre(void *a); #else