From b6f8b968c23aec5369c008801a56e489183a2792 Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 4 Apr 2005 11:43:44 +0000 Subject: - 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(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 7cb1ac4..dfa5a68 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); -- cgit v1.1