HAMMER VFS - frontload kmalloc()'s when rebalancing
* The rebalancing code must allocate upwards of 16MB of memory to hold
copies of B-Tree nodes (~64*64*4K). This is enough to blow out the
emergency memory reserve used by the pageout daemon and deadlock the
system in low memory situations.
* Refactor the allocations. Allocate all the memory up-front so no
major allocations occur while nodes in the B-Tree are held locked.
* There are probably other cases where this may become a problem. With
UFS it wasn't an issue because flushing a file was fairly unsophisticated.
But with HAMMER certain aspects of the flush require B-Tree lookups and
can't be dumbed down to a simple raw disk write.
The rebalancing code was the most aggregious abuser of kernel memory
though and that should now be fixed.
Reported-by: Francois Tigeot <ftigeot@wolfpond.org>