From ef8ce5ba98c8a16f18c5c3778bc22217442bcba1 Mon Sep 17 00:00:00 2001
From: Milind Changire <mchangir@redhat.com>
Date: Tue, 20 Sep 2016 13:35:16 +0530
Subject: [PATCH 84/86] build: linux/oom.h fix for RHEL-5
linux/oom.h is not available on RHEL-5.
Add check for linux/oom.h in configure.ac
Wrap code in #ifdef HAVE_LINUX_OOM_H
Label: DOWNSTREAM ONLY
Change-Id: I70f4a68aa05d51f449e0185ef61fd56d8bddbddc
Signed-off-by: Milind Changire <mchangir@redhat.com>
---
configure.ac | 2 ++
glusterfsd/src/glusterfsd.c | 10 ++++++++++
glusterfsd/src/glusterfsd.h | 2 ++
libglusterfs/src/glusterfs.h | 2 ++
4 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index e77ca9e..2c25be6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -476,6 +476,8 @@ AC_SUBST(ZLIB_LIBS)
AC_CHECK_HEADERS([linux/falloc.h])
+AC_CHECK_HEADERS([linux/oom.h], AC_DEFINE(HAVE_LINUX_OOM_H, 1, [have linux/oom.h]))
+
dnl Mac OS X does not have spinlocks
AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
if test "x${have_spinlock}" = "xyes"; then
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index e726cc5..45eca8d 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -33,8 +33,10 @@
#include <pwd.h>
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
#include <linux/oom.h>
#endif
+#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
@@ -209,10 +211,12 @@ static struct argp_option gf_options[] = {
"Set fuse module's congestion threshold to N "
"[default: 48]"},
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
{"oom-score-adj", ARGP_OOM_SCORE_ADJ_KEY, "INTEGER", 0,
"Set oom_score_adj value for process"
"[default: 0]"},
#endif
+#endif
{"client-pid", ARGP_CLIENT_PID_KEY, "PID", OPTION_HIDDEN,
"client will authenticate itself with process id PID to server"},
{"no-root-squash", ARGP_FUSE_NO_ROOT_SQUASH_KEY, "BOOL",
@@ -1129,6 +1133,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
case ARGP_OOM_SCORE_ADJ_KEY:
k = 0;
@@ -1143,6 +1148,7 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
#endif
+#endif
case ARGP_FUSE_MOUNTOPTS_KEY:
cmd_args->fuse_mountopts = gf_strdup (arg);
@@ -2208,6 +2214,7 @@ out:
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
static int
set_oom_score_adj (glusterfs_ctx_t *ctx)
{
@@ -2242,6 +2249,7 @@ out:
return ret;
}
#endif
+#endif
int
@@ -2417,10 +2425,12 @@ main (int argc, char *argv[])
goto out;
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
ret = set_oom_score_adj (ctx);
if (ret)
goto out;
#endif
+#endif
ctx->env = syncenv_new (0, 0, 0);
if (!ctx->env) {
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index e442bed..62aae2a 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -94,8 +94,10 @@ enum argp_option_keys {
ARGP_RESOLVE_GIDS_KEY = 174,
ARGP_CAPABILITY_KEY = 175,
#ifdef GF_LINUX_HOST_OS
+#ifdef HAVE_LINUX_OOM_H
ARGP_OOM_SCORE_ADJ_KEY = 176,
#endif
+#endif
};
struct _gfd_vol_top_priv_t {
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 0cee2ba..af59c73 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -345,7 +345,9 @@ struct _cmd_args {
int acl;
int selinux;
int capability;
+#ifdef HAVE_LINUX_OOM_H
char *oom_score_adj;
+#endif
int enable_ino32;
int worm;
int mac_compat;
--
1.7.1