Assert that runningbufspace does not underflow.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Konstantin Belousov 2013-07-13 19:36:18 +00:00
parent da4ca6c8ab
commit 982d771242

View File

@ -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