From c652be54ae5f31f13eb03acfa533b9228843a7c0 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 4 Mar 2010 16:06:53 -0800 Subject: [PATCH] HAMMER VFS - Ensure sufficient free memory is available before large allocation * The HAMMER rebalancing code can be a heavy user of kernel memory when collecting B-Tree nodes to rebalance. Call the new vm_wait_nominal() function before allocating said memory in an attempt to avoid VM/VFS deadlocks when memory is low. Reported-by: Francois Tigeot --- sys/vfs/hammer/hammer.h | 1 + sys/vfs/hammer/hammer_rebalance.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index cc30895523..1662b81d6d 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -58,6 +58,7 @@ #include #include #include +#include #include #include diff --git a/sys/vfs/hammer/hammer_rebalance.c b/sys/vfs/hammer/hammer_rebalance.c index 6250eb5f6a..1b8de5c37e 100644 --- a/sys/vfs/hammer/hammer_rebalance.c +++ b/sys/vfs/hammer/hammer_rebalance.c @@ -113,6 +113,12 @@ retry: while (error == 0) { /* + * Rebalancing can be hard on the memory allocator, make + * sure there is enough free memory before doing it. + */ + vm_wait_nominal(); + + /* * We only care about internal nodes visited for the last * time on the way up... that is, a trailing scan of the * internal node after all of its children have been recursed -- 2.11.4.GIT