HAMMER VFS - Fix another low memory deadlock issue
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 23 Mar 2010 23:27:50 +0000 (16:27 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 23 Mar 2010 23:27:50 +0000 (16:27 -0700)
* Unlock the cursor around calls to vm_wait_nominal() to avoid deadlocking
  while holding shared node locks.

* Add vm_test_nominal() which returns TRUE if vm_wait_nominal() would
  block.

Reported-by: Francois Tigeot <ftigeot@wolfpond.org>
sys/vfs/hammer/hammer_rebalance.c
sys/vm/vm_extern.h
sys/vm/vm_page.c

index 5390aa2..e232617 100644 (file)
@@ -119,7 +119,11 @@ retry:
                 * Rebalancing can be hard on the memory allocator, make
                 * sure there is enough free memory before doing it.
                 */
-               vm_wait_nominal();
+               if (vm_test_nominal()) {
+                       hammer_unlock_cursor(&cursor);
+                       vm_wait_nominal();
+                       hammer_lock_cursor(&cursor);
+               }
 
                /*
                 * We only care about internal nodes visited for the last
index 49fa4b9..eb5e914 100644 (file)
@@ -96,6 +96,7 @@ int vm_fault_wire (vm_map_t, vm_map_entry_t, boolean_t);
 void vm_fork (struct proc *, struct proc *, int);
 void vm_fault_ratecheck(void);
 void vm_waitproc (struct proc *);
+int vm_test_nominal (void);
 void vm_wait_nominal (void);
 void vm_init_limits(struct proc *);
 
index 2a20a23..6b57cc3 100644 (file)
@@ -846,6 +846,17 @@ vm_wait_nominal(void)
 }
 
 /*
+ * Test if vm_wait_nominal() would block.
+ */
+int
+vm_test_nominal(void)
+{
+       if (vm_page_count_min(0))
+               return(1);
+       return(0);
+}
+
+/*
  * Block until free pages are available for allocation, called in various
  * places before memory allocations.
  */