Subject: VOP locking issue
To: None <tech-kern@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 11/12/2006 22:33:38
Hi,
a Xen user reported the following panic:
> panic: lockmgr: pid 17, not exclusive lock holder 497 unlocking
> stopped in pid 17.1 (xenwatch) at    netbsd: cpu_Debugger+0x4   popl
> %
> ebp
> db>   bt
> cpu_Debugger+0x4
> panic+0x155
> lockmgr+0xb2b
> genfs_unlock+0x28
> VOP_UNLOCK+0x28
> xbdback_backend_changed+0x179
> xenwatch_thread+0x94

This maps to this code in xbdback_xenbus.c (with error handling removed for
better reading)
	err = bdevvp(xbdi->xbdi_dev, &xbdi->xbdi_vp);
        err  = VOP_OPEN(xbdi->xbdi_vp, FREAD, NOCRED, 0);
	VOP_UNLOCK(xbdi->xbdi_vp, 0); 

I suspect the block device opened here was also open in userland 
(by the qemu-dm process). It's also possible that it was mounted.
Does anyone have an idea if this is the problem, and if it can be avoided ?

I can change xbdback to not open the device if it's an ioemu one (linux
doesn't seem to care), but this leaves the issue open for real Xen
devices.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--