From 1a6f2f0467a985a3146ce2aa4b80a0738a1a0f3a Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Fri, 18 Apr 2008 09:45:38 +0000
Subject: [PATCH] Fix warnings with compile liblustre at sles10/rhel5 which
 have __u64 as usingied long long type. b=15517 i=johan i=deen

---
 lustre/ChangeLog                   |  5 +++++
 lustre/autoconf/lustre-core.m4     | 22 ++++++++++++++++++++
 lustre/include/linux/lustre_user.h | 32 ------------------------------
 lustre/liblustre/tests/sanity.c    |  7 +------
 lustre/llite/dir.c                 |  5 ++++-
 5 files changed, 32 insertions(+), 39 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index fa2b8e9c90..30cd78dfa8 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -18,6 +18,11 @@ tbd  Sun Microsystems, Inc.
        * RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
         removed cwd "./" (refer to Bugzilla 14399).
 
+Severity   : minor
+Bugzilla   : 15517
+Description: Fix warnings with compile liblustre at sles10/rhel5 which have
+             __u64 as usingied long long type.
+
 Severity   : minor
 Bugzilla   : 15210
 Frequency  : rare, on shutdown
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 51ba04a690..ff695410ed 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1077,6 +1077,27 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# RHEL5 PageChecked and SetPageChecked defined
+AC_DEFUN([LC_PAGE_CHECKED],
+[AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/page-flags.h>
+],[
+        #ifndef PageChecked
+        #error PageChecked not defined in kernel
+        #endif
+        #ifndef SetPageChecked
+        #error SetPageChecked not defined in kernel
+        #endif
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_PAGE_CHECKED, 1,
+                  [does kernel have PageChecked and SetPageChecked])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
 AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
 [mm/truncate.c],[
@@ -1306,6 +1327,7 @@ AC_DEFUN([LC_PROG_LINUX],
 
           #2.6.18 + RHEL5 (fc6)
           LC_PG_FS_MISC
+          LC_PAGE_CHECKED
 
           # 2.6.19
           LC_INODE_BLKSIZE
diff --git a/lustre/include/linux/lustre_user.h b/lustre/include/linux/lustre_user.h
index 4778993299..1b7fb8aee2 100644
--- a/lustre/include/linux/lustre_user.h
+++ b/lustre/include/linux/lustre_user.h
@@ -56,36 +56,4 @@ typedef struct stat64   lstat_t;
 #define HAVE_LOV_USER_MDS_DATA
 #endif
 
-#ifndef LPU64
-/* this is a bit chunky */
-#if defined(__KERNEL__)
- #define _LWORDSIZE BITS_PER_LONG
-#else
- #define _LWORDSIZE __WORDSIZE
-#endif
-/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
-#if (defined(__x86_64__) && (defined(__KERNEL__) || defined(CRAY_XT3)))
-# define LPU64 "%Lu"
-# define LPD64 "%Ld"
-# define LPX64 "%#Lx"
-# define LPSZ  "%lu"
-# define LPSSZ "%ld"
-#elif (_LWORDSIZE == 32)
-# define LPU64 "%Lu"
-# define LPD64 "%Ld"
-# define LPX64 "%#Lx"
-# define LPSZ  "%u"
-# define LPSSZ "%d"
-#elif (_LWORDSIZE == 64)
-# define LPU64 "%lu"
-# define LPD64 "%ld"
-# define LPX64 "%#lx"
-# define LPSZ  "%lu"
-# define LPSSZ "%ld"
-#endif
-
-#undef _LWORDSIZE
-
-#endif /* !LPU64 */
-
 #endif /* _LUSTRE_USER_H */
diff --git a/lustre/liblustre/tests/sanity.c b/lustre/liblustre/tests/sanity.c
index b07906d877..27f7211d43 100644
--- a/lustre/liblustre/tests/sanity.c
+++ b/lustre/liblustre/tests/sanity.c
@@ -32,22 +32,17 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/queue.h>
 #include <signal.h>
 #include <errno.h>
 #include <dirent.h>
 #include <sys/uio.h>
 #include <sys/time.h>
 #include <time.h>
-#include <sys/ioctl.h>
 
+#include <liblustre.h>
 #include "test_common.h"
-#include <ioctl.h>
 #include <lustre/liblustreapi.h>
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE getpagesize()
-#endif
 #define _npages (2048)
 
 void *buf_alloc;
diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c
index 813351d78e..c05255d8c5 100644
--- a/lustre/llite/dir.c
+++ b/lustre/llite/dir.c
@@ -73,10 +73,13 @@ static inline unsigned ll_dir_rec_len(unsigned name_len)
         return (name_len + 8 + LL_DIR_PAD - 1) & ~(LL_DIR_PAD - 1);
 }
 
-
+#ifndef HAVE_PAGE_CHECKED
 #ifdef HAVE_PG_FS_MISC
 #define PageChecked(page)        test_bit(PG_fs_misc, &(page)->flags)
 #define SetPageChecked(page)     set_bit(PG_fs_misc, &(page)->flags)
+#else
+#error PageChecked or PageFsMisc not defined in kernel
+#endif
 #endif
 
 /* returns the page unlocked, but with a reference */
-- 
GitLab