nfs + zfs hangs on RELENG_9

Andriy Gapon avg at FreeBSD.org
Fri Oct 5 12:24:16 UTC 2012


on 04/10/2012 19:14 Andriy Gapon said the following:
> BTW, one thing to note here is that the lowmem hook was invoked because of KVA
> space shortage, not because of page shortage.
> 
> From practical point of view this may mean that having sufficient KVA size may
> help to not run into this deadlock.
> 
> From programming point of view I am tempted to let arc_lowmem block only if
> curproc == pageproc.  That should both handle the case where blocking is most
> needed and should prevent the deadlock described above.

A possible patch:

--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -3720,8 +3720,16 @@ arc_lowmem(void *arg __unused, int howto __unused)
 	mutex_enter(&arc_reclaim_thr_lock);
 	needfree = 1;
 	cv_signal(&arc_reclaim_thr_cv);
-	while (needfree)
-		msleep(&needfree, &arc_reclaim_thr_lock, 0, "zfs:lowmem", 0);
+
+	/*
+	 * It is unsafe to block here in arbitrary threads, because we can come
+	 * here from ARC itself and may hold ARC locks and thus risk a deadlock
+	 * with ARC reclaim thread.
+	 */
+	if (curproc == pageproc) {
+		while (needfree)
+			msleep(&needfree, &arc_reclaim_thr_lock, 0, "zfs:lowmem", 0);
+	}
 	mutex_exit(&arc_reclaim_thr_lock);
 	mutex_exit(&arc_lowmem_lock);
 }

-- 
Andriy Gapon


More information about the freebsd-fs mailing list