From f043c4c79ceeda55239cae3d41752cf4c324d039 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 30 Jun 2008 03:57:41 +0000 Subject: [PATCH] Fix a low-memory deadlock in the VM system which can occur on systems with small amounts of system memory. The pageout daemon uses LK_TIMELOCK to avoid deadlocking on a vnode so it can continue operation. This only works if lk_timo is non-zero, but all filesystems initialize their vnodes with a timeout of zero so the feature is defeated. Adjust allocvnode() to guarantee that lk_timo is never zero. --- sys/kern/vfs_lock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lock.c b/sys/kern/vfs_lock.c index 32d3531aee..79d5d100a6 100644 --- a/sys/kern/vfs_lock.c +++ b/sys/kern/vfs_lock.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/vfs_lock.c,v 1.29 2008/06/19 23:27:35 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_lock.c,v 1.30 2008/06/30 03:57:41 dillon Exp $ */ /* @@ -618,6 +618,14 @@ allocvnode(int lktimeout, int lkflags) vp->v_socket = 0; vp->v_opencount = 0; vp->v_writecount = 0; /* XXX */ + + /* + * lktimeout only applies when LK_TIMELOCK is used, and only + * the pageout daemon uses it. The timeout may not be zero + * or the pageout daemon can deadlock in low-VM situations. + */ + if (lktimeout == 0) + lktimeout = hz / 10; lockreinit(&vp->v_lock, "vnode", lktimeout, lkflags); KKASSERT(TAILQ_FIRST(&vp->v_namecache) == NULL); /* exclusive lock still held */ -- 2.41.0