From 9d00a4a781eb15e7fa43415462c01f82087ded69 Mon Sep 17 00:00:00 2001 From: mckusick Date: Mon, 14 Oct 2002 19:54:39 +0000 Subject: [PATCH] When scanning the freelist looking for candidate vnodes to recycle, be sure to exit the loop with vp == NULL if no candidates are found. Formerly, this bug would cause the last vnode inspected to be used, even if it was not available. The result was a panic "vn_finished_write: neg cnt". Sponsored by: DARPA & NAI Labs. --- sys/kern/vfs_subr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 579f08d99a30..101dffdbb16f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -925,11 +925,10 @@ getnewvnode(tag, mp, vops, vpp) mtx_unlock(&vnode_free_list_mtx); error = vcanrecycle(vp, &vnmp); mtx_lock(&vnode_free_list_mtx); - if (error != 0) - TAILQ_INSERT_TAIL(&vnode_free_list, vp, - v_freelist); - else + if (error == 0) break; + TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); + vp = NULL; } } if (vp) {