Whamcloud - gitweb
b=21532 various build fixes for rhel4 and sles9
authorBrian J. Murrell <brian@sun.com>
Thu, 17 Dec 2009 13:58:11 +0000 (08:58 -0500)
committerjohann <johann@granier.local>
Thu, 17 Dec 2009 15:28:33 +0000 (16:28 +0100)
various build fixes for rhel4 and sles9 including:
- configure checks for and backports of:
  * atomic_inc_not_zero
  * atomic_cmpxchg
- don't include linux/pagevec.h in llite/lloop.c as it causes some duplicate
  definitions when it's later included by another source file
- use LPU64 portability formats

lnet/klnds/qswlnd/qswlnd_cb.c
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/llite/lloop.c
lustre/utils/ll_decode_filter_fid.c

index a018dc9..109e236 100644 (file)
@@ -44,7 +44,7 @@ kqswnal_unmap_tx (kqswnal_tx_t *ktx)
 
         if (ktx->ktx_nmappedpages == 0)
                 return;
-        
+
         CDEBUG(D_NET, "%p unloading %d frags starting at %d\n",
                ktx, ktx->ktx_nfrag, ktx->ktx_firsttmpfrag);
 
@@ -57,7 +57,7 @@ kqswnal_unmap_tx (kqswnal_tx_t *ktx)
 }
 
 int
-kqswnal_map_tx_kiov (kqswnal_tx_t *ktx, int offset, int nob, 
+kqswnal_map_tx_kiov (kqswnal_tx_t *ktx, int offset, int nob,
                      unsigned int niov, lnet_kiov_t *kiov)
 {
         int       nfrags    = ktx->ktx_nfrag;
index f925966..d01d8e0 100644 (file)
@@ -1685,6 +1685,38 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+AC_DEFUN([LC_ATOMIC_CMPXCHG],
+[AC_MSG_CHECKING([if kernel has atomic_cmpxchg])
+LB_LINUX_TRY_COMPILE([
+        #include <asm/atomic.h>
+],[
+        #ifndef atomic_cmpxchg
+        #error missing atomic_cmpxchg
+        #endif
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_ATOMIC_CMPXCHG, 1, [kernel has atomic_cmpxchg])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_ATOMIC_INC_NOT_ZERO],
+[AC_MSG_CHECKING([if kernel has atomic_inc_not_zero])
+LB_LINUX_TRY_COMPILE([
+        #include <asm/atomic.h>
+],[
+        #ifndef atomic_inc_not_zero
+        #error missing atomic_inc_not_zero
+        #endif
+],[
+        AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_ATOMIC_INC_NOT_ZERO, 1, [kernel has atomic_inc_not_zero])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
 #
 # LC_PROG_LINUX
 #
@@ -1748,6 +1780,8 @@ AC_DEFUN([LC_PROG_LINUX],
 
           # 2.6.15
           LC_INODE_I_MUTEX
+          LC_ATOMIC_CMPXCHG
+          LC_ATOMIC_INC_NOT_ZERO
 
           # 2.6.16
           LC_SECURITY_PLUG  # for SLES10 SP2
index 9ffd18a..78ca298 100644 (file)
@@ -626,5 +626,33 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
 #else
 #define ll_update_time(file) inode_update_time(file->f_mapping->host, 1)
 #endif
+
+/* Needed for sles9 */
+#ifndef HAVE_ATOMIC_CMPXCHG
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+#endif
+
+/* Needed for rhel4 and sles9 */
+#ifndef HAVE_ATOMIC_INC_NOT_ZERO
+/**
+ * atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns non-zero if @v was not @u, and zero otherwise.
+ */
+#define atomic_add_unless(v, a, u)                             \
+({                                                             \
+       int c, old;                                             \
+       c = atomic_read(v);                                     \
+       while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+               c = old;                                        \
+       c != (u);                                               \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+#endif /* !atomic_inc_not_zero */
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
index 1aad475..7de218e 100644 (file)
 #include <linux/highmem.h>
 #include <linux/gfp.h>
 #include <linux/swap.h>
-#include <linux/pagevec.h>
 
 #include <asm/uaccess.h>
 
index e5441bf..533521a 100644 (file)
@@ -49,6 +49,7 @@
 #include <sys/types.h>
 #include <sys/xattr.h>
 #include <lustre/lustre_user.h>
+#include <liblustre.h>
 
 int main(int argc, char *argv[])
 {
@@ -74,7 +75,7 @@ int main(int argc, char *argv[])
                                        "(%d bytes), recompile?\n",
                                        argv[i], size);
                } else {
-                       printf("%s: objid=%llu group=%llu inode=%llu generation=%u stripe=%u\n",
+                       printf("%s: objid="LPU64" group="LPU64" inode="LPU64" generation=%u stripe=%u\n",
                                argv[i], ff->ff_objid, ff->ff_group,
                                ff->ff_fid.id, ff->ff_fid.generation,
                                ff->ff_fid.f_type);