summaryrefslogtreecommitdiffstats
path: root/sys/sys/buf.h
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2008-03-01 19:47:50 +0000
committerattilio <attilio@FreeBSD.org>2008-03-01 19:47:50 +0000
commit0d873341312bfcbee292129a09cf72ab59e3ef38 (patch)
treeaae2aca960881cff832f160d3cf4e0a5dcfa5d55 /sys/sys/buf.h
parent354de8687f8df06279d4389e7437123d99d5ddb9 (diff)
downloadFreeBSD-src-0d873341312bfcbee292129a09cf72ab59e3ef38.zip
FreeBSD-src-0d873341312bfcbee292129a09cf72ab59e3ef38.tar.gz
- Handle buffer lock waiters count directly in the buffer cache instead
than rely on the lockmgr support [1]: * bump the waiters only if the interlock is held * let brelvp() return the waiters count * rely on brelvp() instead than BUF_LOCKWAITERS() in order to check for the waiters number - Remove a namespace pollution introduced recently with lockmgr.h including lock.h by including lock.h directly in the consumers and making it mandatory for using lockmgr. - Modify flags accepted by lockinit(): * introduce LK_NOPROFILE which disables lock profiling for the specified lockmgr * introduce LK_QUIET which disables ktr tracing for the specified lockmgr [2] * disallow LK_SLEEPFAIL and LK_NOWAIT to be passed there so that it can only be used on a per-instance basis - Remove BUF_LOCKWAITERS() and lockwaiters() as they are no longer used This patch breaks KPI so __FreBSD_version will be bumped and manpages updated by further commits. Additively, 'struct buf' changes results in a disturbed ABI also. [2] Really, currently there is no ktr tracing in the lockmgr, but it will be added soon. [1] Submitted by: kib Tested by: pho, Andrea Barberio <insomniac at slackware dot it>
Diffstat (limited to 'sys/sys/buf.h')
-rw-r--r--sys/sys/buf.h49
1 files changed, 33 insertions, 16 deletions
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 4682ae6..5cb5656 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -139,6 +139,7 @@ struct buf {
void *b_fsprivate2;
void *b_fsprivate3;
int b_pin_count;
+ int b_waiters; /* (V) waiters counter */
};
#define b_object b_bufobj->bo_object
@@ -266,15 +267,41 @@ extern const char *buf_wmesg; /* Default buffer lock message */
*
* Get a lock sleeping non-interruptably until it becomes available.
*/
-#define BUF_LOCK(bp, locktype, interlock) \
- (lockmgr(&(bp)->b_lock, (locktype), (interlock)))
+static __inline int
+BUF_LOCK(struct buf *bp, int locktype, struct mtx *interlock);
+static __inline int
+BUF_LOCK(struct buf *bp, int locktype, struct mtx *interlock)
+{
+ int res;
+
+ if (locktype & LK_INTERLOCK)
+ bp->b_waiters++;
+ res = lockmgr(&bp->b_lock, locktype, interlock);
+ if (locktype & LK_INTERLOCK)
+ bp->b_waiters--;
+ return (res);
+}
/*
* Get a lock sleeping with specified interruptably and timeout.
*/
-#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \
- (lockmgr_args(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \
- (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo)))
+static __inline int
+BUF_TIMELOCK(struct buf *bp, int locktype, struct mtx *interlock,
+ const char *wmesg, int catch, int timo);
+static __inline int
+BUF_TIMELOCK(struct buf *bp, int locktype, struct mtx *interlock,
+ const char *wmesg, int catch, int timo)
+{
+ int res;
+
+ if (locktype & LK_INTERLOCK)
+ bp->b_waiters++;
+ res = lockmgr_args(&bp->b_lock, locktype | LK_TIMELOCK, interlock,
+ wmesg, (PRIBIO + 4) | catch, timo);
+ if (locktype & LK_INTERLOCK)
+ bp->b_waiters--;
+ return (res);
+}
/*
* Release a lock. Only the acquiring process may free the lock unless
@@ -351,16 +378,6 @@ BUF_KERNPROC(struct buf *bp)
}
#endif
-/*
- * Find out the number of waiters on a lock.
- */
-static __inline int BUF_LOCKWAITERS(struct buf *);
-static __inline int
-BUF_LOCKWAITERS(struct buf *bp)
-{
- return (lockwaiters(&bp->b_lock));
-}
-
#endif /* _KERNEL */
struct buf_queue_head {
@@ -516,7 +533,7 @@ void vfs_unbusy_pages(struct buf *);
int vmapbuf(struct buf *);
void vunmapbuf(struct buf *);
void relpbuf(struct buf *, int *);
-void brelvp(struct buf *);
+int brelvp(struct buf *);
void bgetvp(struct vnode *, struct buf *);
void pbgetbo(struct bufobj *bo, struct buf *bp);
void pbgetvp(struct vnode *, struct buf *);
OpenPOWER on IntegriCloud