MFC: Set flag in needsbuffer while still holding bqlock to avoid lost wakeup.

This commit is contained in:
tegge 2006-01-21 20:41:42 +00:00
parent 83bc9841ac
commit 637c08fadb

View File

@ -1864,7 +1864,6 @@ getnewbuf(int slpflag, int slptimeo, int size, int maxsize)
int flags; int flags;
char *waitmsg; char *waitmsg;
mtx_unlock(&bqlock);
if (defrag) { if (defrag) {
flags = VFS_BIO_NEED_BUFSPACE; flags = VFS_BIO_NEED_BUFSPACE;
waitmsg = "nbufkv"; waitmsg = "nbufkv";
@ -1875,11 +1874,14 @@ getnewbuf(int slpflag, int slptimeo, int size, int maxsize)
waitmsg = "newbuf"; waitmsg = "newbuf";
flags = VFS_BIO_NEED_ANY; flags = VFS_BIO_NEED_ANY;
} }
mtx_lock(&nblock);
needsbuffer |= flags;
mtx_unlock(&nblock);
mtx_unlock(&bqlock);
bd_speedup(); /* heeeelp */ bd_speedup(); /* heeeelp */
mtx_lock(&nblock); mtx_lock(&nblock);
needsbuffer |= flags;
while (needsbuffer & flags) { while (needsbuffer & flags) {
if (msleep(&needsbuffer, &nblock, if (msleep(&needsbuffer, &nblock,
(PRIBIO + 4) | slpflag, waitmsg, slptimeo)) { (PRIBIO + 4) | slpflag, waitmsg, slptimeo)) {