From 1ce32b2e9e7c5debe9ca25a3e89f3dec991dd246 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 1 Dec 2011 17:12:12 -0800 Subject: [PATCH] HAMMER VFS - Attempt to fix a low-memory deadlock * Avoid trying to allocate a new buffer cache buffer when memory is low from inside the blockmap allocation path (where the global blockmap lock is held). Reported-by: tuxillo --- sys/vfs/hammer/hammer_blockmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/vfs/hammer/hammer_blockmap.c b/sys/vfs/hammer/hammer_blockmap.c index f97909f8fe..7bb656b406 100644 --- a/sys/vfs/hammer/hammer_blockmap.c +++ b/sys/vfs/hammer/hammer_blockmap.c @@ -601,9 +601,13 @@ again: * * If we are reserving a whole buffer (or more), the caller will * probably use a direct read, so do nothing. + * + * If we do not have a whole lot of system memory we really can't + * afford to block while holding the blkmap_lock! */ if (bytes < HAMMER_BUFSIZE && (next_offset & HAMMER_BUFMASK) == 0) { - hammer_bnew(hmp, next_offset, errorp, &buffer3); + if (!vm_page_count_min(HAMMER_BUFSIZE / PAGE_SIZE)) + hammer_bnew(hmp, next_offset, errorp, &buffer3); } /* -- 2.41.0