From d638e093d606088b4e716baabff1a3b9b17d45df Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Sat, 19 Jan 2008 17:36:23 +0000 Subject: - Introduce the function lockmgr_recursed() which returns true if the lockmgr lkp, when held in exclusive mode, is recursed - Introduce the function BUF_RECURSED() which does the same for bufobj locks based on the top of lockmgr_recursed() - Introduce the function BUF_ISLOCKED() which works like the counterpart VOP_ISLOCKED(9), showing the state of lockmgr linked with the bufobj BUF_RECURSED() and BUF_ISLOCKED() entirely replace the usage of bogus BUF_REFCNT() in a more explicative and SMP-compliant way. This allows us to axe out BUF_REFCNT() and leaving the function lockcount() totally unused in our stock kernel. Further commits will axe lockcount() as well as part of lockmgr() cleanup. KPI results, obviously, broken so further commits will update manpages and freebsd version. Tested by: kris (on UFS and NFS) --- sys/gnu/fs/xfs/FreeBSD/xfs_buf.c | 6 +++--- sys/gnu/fs/xfs/FreeBSD/xfs_buf.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'sys/gnu') diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c index 30aafc4626e0f..65030df8bba77 100644 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c +++ b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c @@ -86,7 +86,7 @@ xfs_buf_get_empty(size_t size, xfs_buftarg_t *target) bp->b_bufsize = size; bp->b_bcount = size; - KASSERT(BUF_REFCNT(bp) == 1, + KASSERT(BUF_ISLOCKED(bp), ("xfs_buf_get_empty: bp %p not locked",bp)); xfs_buf_set_target(bp, target); @@ -103,7 +103,7 @@ xfs_buf_get_noaddr(size_t len, xfs_buftarg_t *target) bp = geteblk(len); if (bp != NULL) { - KASSERT(BUF_REFCNT(bp) == 1, + KASSERT(BUF_ISLOCKED(bp), ("xfs_buf_get_empty: bp %p not locked",bp)); xfs_buf_set_target(bp, target); @@ -163,7 +163,7 @@ XFS_bwrite(xfs_buf_t *bp) if ((bp->b_flags & B_ASYNC) == 0) { error = bufwait(bp); #if 0 - if (BUF_REFCNT(bp) > 1) + if (BUF_LOCKRECURSED(bp)) BUF_UNLOCK(bp); else brelse(bp); diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h index c27a14c261ff3..34e579d5b74bd 100644 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h +++ b/sys/gnu/fs/xfs/FreeBSD/xfs_buf.h @@ -160,7 +160,6 @@ xfs_buf_get_error(struct buf *bp) #define XFS_BUF_HOLD(x) ((void)0) #define XFS_BUF_UNHOLD(x) ((void)0) -#define XFS_BUF_ISHOLD(x) BUF_REFCNT(x) #define XFS_BUF_READ(x) ((x)->b_iocmd = BIO_READ) #define XFS_BUF_UNREAD(x) ((x)->b_iocmd = 0) @@ -234,7 +233,7 @@ xfs_buf_offset(xfs_buf_t *bp, size_t offset) #define XFS_BUF_SET_VTYPE(bp, type) #define XFS_BUF_SET_REF(bp, ref) -#define XFS_BUF_VALUSEMA(bp) (BUF_REFCNT(bp)? 0 : 1) +#define XFS_BUF_VALUSEMA(bp) (BUF_ISLOCKED(bp) ? 0 : 1) #define XFS_BUF_CPSEMA(bp) \ (BUF_LOCK(bp, LK_EXCLUSIVE|LK_CANRECURSE | LK_SLEEPFAIL, NULL) == 0) -- cgit v1.3