diff options
author | jasone <jasone@FreeBSD.org> | 2000-10-04 01:29:17 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-10-04 01:29:17 +0000 |
commit | 4e290e67b7310d906f113850fddfdf1017a9d15b (patch) | |
tree | bae3e99c848c6e38aee34a7cf61ffa9ca55b0095 /sys/sys/buf.h | |
parent | bea51a4aa1bf67a183bd1d4a6227fa891345af60 (diff) | |
download | FreeBSD-src-4e290e67b7310d906f113850fddfdf1017a9d15b.zip FreeBSD-src-4e290e67b7310d906f113850fddfdf1017a9d15b.tar.gz |
Convert lockmgr locks from using simple locks to using mutexes.
Add lockdestroy() and appropriate invocations, which corresponds to
lockinit() and must be called to clean up after a lockmgr lock is no
longer needed.
Diffstat (limited to 'sys/sys/buf.h')
-rw-r--r-- | sys/sys/buf.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/sys/buf.h b/sys/sys/buf.h index d469a04..94ae4c1 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -229,10 +229,12 @@ struct buf { /* * Buffer locking */ -extern struct simplelock buftimelock; /* Interlock on setting prio and timo */ +extern struct mtx buftimelock; /* Interlock on setting prio and timo */ extern char *buf_wmesg; /* Default buffer lock message */ #define BUF_WMESG "bufwait" #include <sys/proc.h> /* XXX for curproc */ +#include <machine/mutex.h> + /* * Initialize a lock. */ @@ -249,7 +251,7 @@ BUF_LOCK(struct buf *bp, int locktype) int s, ret; s = splbio(); - simple_lock(&buftimelock); + mtx_enter(&buftimelock, MTX_DEF); locktype |= LK_INTERLOCK; bp->b_lock.lk_wmesg = buf_wmesg; bp->b_lock.lk_prio = PRIBIO + 4; @@ -268,7 +270,7 @@ BUF_TIMELOCK(struct buf *bp, int locktype, char *wmesg, int catch, int timo) int s, ret; s = splbio(); - simple_lock(&buftimelock); + mtx_enter(&buftimelock, MTX_DEF); locktype |= LK_INTERLOCK; bp->b_lock.lk_wmesg = wmesg; bp->b_lock.lk_prio = (PRIBIO + 4) | catch; @@ -296,8 +298,12 @@ BUF_UNLOCK(struct buf *bp) * Free a buffer lock. */ #define BUF_LOCKFREE(bp) \ +do { \ if (BUF_REFCNT(bp) > 0) \ - panic("free locked buf") + panic("free locked buf"); \ + lockdestroy(&(bp)->b_lock); \ +} while (0) + /* * When initiating asynchronous I/O, change ownership of the lock to the * kernel. Once done, the lock may legally released by biodone. The @@ -423,6 +429,7 @@ buf_deallocate(struct buf *bp) { if (bioops.io_deallocate) (*bioops.io_deallocate)(bp); + BUF_LOCKFREE(bp); } static __inline void |