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