From 0f86ed9f8be0666bb49252daa24b2db6aa174199 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Mon, 20 Aug 2018 15:28:16 +0200 Subject: Fix physical memory detection on NetBSD NetBSD has two sysctl for physical memory detection: hw.physmem and hw.physmem64. Only the later is 64-bit proof, and it has been available for years. That fix is important because it cause recent glusterfs to refuse mounting fileystems when there is too much RAM, with an error loading the quick-read xlator [quick-read.c:838:check_cache_size_ok] 0-gfs-quick-read: Cache size 134217728 is greater than the max size of 0 Change-Id: I957a1ff1d7018fe2f9d47384a28708e6cbdf710a Signed-off-by: Emmanuel Dreyfus Fixes: bz#1619475 --- libglusterfs/src/common-utils.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 9dd030aa6c4..06636a1fa85 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -2877,13 +2877,23 @@ get_mem_size () memsize = page_size * num_pages; #endif -#if defined GF_BSD_HOST_OS || defined GF_DARWIN_HOST_OS +#if defined GF_DARWIN_HOST_OS size_t len = sizeof(memsize); int name [] = { CTL_HW, HW_PHYSMEM }; sysctl (name, 2, &memsize, &len, NULL, 0); #endif + +#if defined __NetBSD__ + + size_t len = sizeof(memsize); + int name64 [] = { CTL_HW, HW_PHYSMEM64 }; + + sysctl (name64, 2, &memsize, &len, NULL, 0); + if (memsize == -1) + sysctl (name64, 2, &memsize, &len, NULL, 0); +#endif return memsize; } -- cgit