summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2015-05-07 20:36:24 +0200
committerVijay Bellur <vbellur@redhat.com>2015-05-07 11:52:10 -0700
commit6f8f47b6cbfbe96bc1324d836ed4baeab112a2f2 (patch)
treea860418d0d69ed131ab57daede7a6cf198882240
parentcfe56c96ff435f916a7017f3252717cf0df151d9 (diff)
Restore build on non Linux systems
This change broke the build on NetBSD, FreeBSD, and MacOS X: http://review.gluster.org/10526/ We restore the build with two fixes: - Use POSIX-compliant sysconf(_SC_NPROCESSORS_ONLN) to get the number of processors, instead of Linux specific get_nprocs(). That let us remove Linux-specific #include <sys/sysinfo.h> - Only define MAX() if it is not already defined. NetBSD defines it in <sys/param.h> which is already included Backport of: I62341c670598670e47ea2f69ab94864f96588b18 BUG: 1212676 Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Change-Id: I0f098153e76954bb85b5dca3f054a069e31dd94c Reviewed-on: http://review.gluster.org/10653 Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c5
-rw-r--r--xlators/cluster/dht/src/dht-shared.c6
2 files changed, 7 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index d229dd69000..33f6099c6d1 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -19,7 +19,6 @@
#include <signal.h>
#include <fnmatch.h>
#include <signal.h>
-#include <sys/sysinfo.h>
#define GF_DISK_SECTOR_SIZE 512
#define DHT_REBALANCE_PID 4242 /* Change it if required */
@@ -28,7 +27,9 @@
#define MAX_MIGRATE_QUEUE_COUNT 500
#define MIN_MIGRATE_QUEUE_COUNT 200
+#ifndef MAX
#define MAX(a, b) (((a) > (b))?(a):(b))
+#endif
#define GF_CRAWL_INDEX_MOVE(idx, sv_cnt) { \
idx++; \
@@ -2641,7 +2642,7 @@ gf_defrag_start_crawl (void *data)
INIT_LIST_HEAD (&(defrag->queue[0].list));
- thread_spawn_count = MAX ((get_nprocs() - 4), 4);
+ thread_spawn_count = MAX ((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4);
gf_log (this->name, GF_LOG_DEBUG, "thread_spawn_count: %d",
thread_spawn_count);
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index 22c843a5c77..ffabc820d70 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -15,12 +15,13 @@
#endif
/* TODO: add NS locking */
-#include <sys/sysinfo.h>
#include "statedump.h"
#include "dht-common.h"
#include "dht-messages.h"
+#ifndef MAX
#define MAX(a, b) (((a) > (b))?(a):(b))
+#endif
#define GF_DECIDE_DEFRAG_THROTTLE_COUNT(throttle_count, conf) { \
\
@@ -29,7 +30,8 @@
if (!strcasecmp (conf->dthrottle, "lazy")) \
conf->defrag->recon_thread_count = 1; \
\
- throttle_count = MAX ((get_nprocs() - 4), 4); \
+ throttle_count = \
+ MAX ((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); \
\
if (!strcasecmp (conf->dthrottle, "normal")) \
conf->defrag->recon_thread_count = \