From cbf04bd9c1b7afe2cb170aca104d173904684d84 Mon Sep 17 00:00:00 2001 From: kib Date: Sat, 13 Jul 2013 19:36:18 +0000 Subject: Assert that runningbufspace does not underflow. Sponsored by: The FreeBSD Foundation --- sys/kern/vfs_bio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/kern/vfs_bio.c') diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index a25c934..205e9b3 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -474,10 +474,12 @@ runningbufwakeup(struct buf *bp) { long space, bspace; - if (bp->b_runningbufspace == 0) - return; - space = atomic_fetchadd_long(&runningbufspace, -bp->b_runningbufspace); bspace = bp->b_runningbufspace; + if (bspace == 0) + return; + space = atomic_fetchadd_long(&runningbufspace, -bspace); + KASSERT(space >= bspace, ("runningbufspace underflow %ld %ld", + space, bspace)); bp->b_runningbufspace = 0; /* * Only acquire the lock and wakeup on the transition from exceeding -- cgit v1.1