From 92b8231d4fc5c9de27c4e69bee4917401174a0a7 Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Mon, 4 Apr 2005 11:43:44 +0000 Subject: [PATCH] - Instead of waiting forever to get a vnode in getnewvnode() wait for one to become available for one second and then return ENFILE. We can run out of vnodes, and there must be a hard limit because without one we can quickly run out of KVA on x86. Presently the system can deadlock if there are maxvnodes directories in the namecache. The original 4.x BSD behavior was to return ENFILE if we reached the max, but 4.x BSD did not have the vnlru proc so it was less profitable to wait. --- sys/kern/vfs_subr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 7cb1ac4a2070..dfa5a689c1eb 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -815,13 +815,15 @@ getnewvnode(tag, mp, vops, vpp) /* * Wait for available vnodes. */ - while (numvnodes > desiredvnodes) { + if (numvnodes > desiredvnodes) { if (vnlruproc_sig == 0) { vnlruproc_sig = 1; /* avoid unnecessary wakeups */ wakeup(vnlruproc); } msleep(&vnlruproc_sig, &vnode_free_list_mtx, PVFS, "vlruwk", hz); + if (numvnodes > desiredvnodes) + return (ENFILE); } numvnodes++; mtx_unlock(&vnode_free_list_mtx);