* Fix a small timing window in an update of a counter.
* This bug is not known to have been hit by anyone, due to default
settings for asynchronous I/O.
void bpdone (struct buf *, int);
void biodone (struct bio *);
void biodone_sync (struct bio *);
+void pbuf_adjcount(int *pfreecnt, int n);
void cluster_append(struct bio *, struct buf *);
int cluster_readx (struct vnode *, off_t, off_t, int,
* Update nsw parameters from swap_async_max sysctl values.
* Do not let the sysop crash the machine with bogus numbers.
*/
-
if (swap_async_max != nsw_wcount_async_max) {
int n;
lwkt_gettoken(&vm_token);
n -= nsw_wcount_async_max;
if (nsw_wcount_async + n >= 0) {
- nsw_wcount_async += n;
nsw_wcount_async_max += n;
- wakeup(&nsw_wcount_async);
+ pbuf_adjcount(&nsw_wcount_async, n);
}
lwkt_reltoken(&vm_token);
}
if (wake_freecnt)
wakeup(pfreecnt);
}
+
+void
+pbuf_adjcount(int *pfreecnt, int n)
+{
+ if (n) {
+ spin_lock(&bswspin);
+ *pfreecnt += n;
+ spin_unlock(&bswspin);
+ wakeup(pfreecnt);
+ }
+}