Whamcloud - gitweb
Revert "b=21951 proc_handler() just want 5 parameters since 2.6.32."
authorJohann Lombardi <johann@sun.com>
Fri, 21 May 2010 20:44:48 +0000 (22:44 +0200)
committerJohann Lombardi <johann@sun.com>
Fri, 21 May 2010 20:44:48 +0000 (22:44 +0200)
This reverts commit ef8c9a1b79d63dc9c609d577ec8e2449384edaa1.

This breaks build on oel5/i686.

lnet/autoconf/lustre-lnet.m4
lnet/include/libcfs/linux/portals_compat25.h
lnet/lnet/router_proc.c

index 855baf3..6011fb6 100644 (file)
@@ -1510,30 +1510,6 @@ LB_LINUX_TRY_COMPILE([
 EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-# See if sysctl proc_handler wants only 5 arguments (since 2.6.32)
-AC_DEFUN([LN_5ARGS_SYSCTL_PROC_HANDLER],
-[AC_MSG_CHECKING([if sysctl proc_handler wants 5 args])
-LB_LINUX_TRY_COMPILE([
-       #include <linux/sysctl.h>
-],[
-        struct ctl_table *table = NULL;
-       int write = 1;
-       void __user *buffer = NULL;
-       size_t *lenp = NULL;
-       loff_t *ppos = NULL;
-
-       proc_handler *proc_handler;
-       proc_handler(table, write, buffer, lenp, ppos);
-
-],[
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(HAVE_5ARGS_SYSCTL_PROC_HANDLER, 1,
-                  [sysctl proc_handler wants 5 args])
-],[
-        AC_MSG_RESULT(no)
-])
-])
-
 #
 # LN_PROG_LINUX
 #
@@ -1591,8 +1567,6 @@ LN_HAVE_LINUX_CRED_H
 LN_STRUCT_CRED_IN_TASK
 # 2.6.30
 LN_FUNC_UNSHARE_FS_STRUCT
-# 2.6.32
-LN_5ARGS_SYSCTL_PROC_HANDLER
 ])
 
 #
index 37798cd..2ad4d1a 100644 (file)
@@ -145,18 +145,6 @@ typedef unsigned long cpumask_t;
              void __user *buffer, size_t *lenp)
 #define DECLARE_LL_PROC_PPOS_DECL  loff_t *ppos = &filp->f_pos
 #else
-#ifdef HAVE_5ARGS_SYSCTL_PROC_HANDLER
-#define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
-        proc_dointvec(table, write, buffer, lenp, ppos);
-
-#define ll_proc_dolongvec(table, write, filp, buffer, lenp, ppos)        \
-        proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
-#define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
-        proc_dostring(table, write, buffer, lenp, ppos);
-#define LL_PROC_PROTO(name)                                             \
-        name(cfs_sysctl_table_t *table, int write,                      \
-             void __user *buffer, size_t *lenp, loff_t *ppos)
-#else
 #define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
         proc_dointvec(table, write, filp, buffer, lenp, ppos);
 #define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
@@ -164,7 +152,6 @@ typedef unsigned long cpumask_t;
 #define LL_PROC_PROTO(name)                                             \
         name(cfs_sysctl_table_t *table, int write, struct file *filp,   \
              void __user *buffer, size_t *lenp, loff_t *ppos)
-#endif
 #define DECLARE_LL_PROC_PPOS_DECL
 #endif
 
index ab60f55..f04f7ba 100644 (file)
@@ -51,40 +51,6 @@ enum {
 #define PSDEV_LNET_NIS     CTL_UNNUMBERED
 #endif
 
-/*
- * NB: we don't use the highest bit of *ppos because it's signed;
- *     next 9 bits is used to stash idx (assuming that
- *     LNET_PEER_HASHSIZE < 512)
- */
-#define LNET_LOFFT_BITS        (sizeof(loff_t) * 8)
-#define LNET_VERSION_BITS      MAX(((MIN(LNET_LOFFT_BITS, 64)) / 4), 8)
-#define LNET_PHASH_IDX_BITS    9
-#define LNET_PHASH_NUM_BITS    (LNET_LOFFT_BITS - 1 -\
-                                LNET_VERSION_BITS - LNET_PHASH_IDX_BITS)
-#define LNET_PHASH_BITS        (LNET_PHASH_IDX_BITS + LNET_PHASH_NUM_BITS)
-
-#define LNET_VERSION_BITMASK   ((1ULL << LNET_VERSION_BITS) - 1)
-#define LNET_PHASH_IDX_BITMASK ((1ULL << LNET_PHASH_IDX_BITS) - 1)
-#define LNET_PHASH_NUM_BITMASK ((1ULL << LNET_PHASH_NUM_BITS) - 1)
-
-#define LNET_VERSION_MASK      (LNET_VERSION_BITMASK << LNET_PHASH_BITS)
-#define LNET_PHASH_IDX_MASK    (LNET_PHASH_IDX_BITMASK << LNET_PHASH_NUM_BITS)
-#define LNET_PHASH_NUM_MASK    (LNET_PHASH_NUM_BITMASK)
-
-#define LNET_VERSION_GET(pos)   (int)(((pos) & LNET_VERSION_MASK) >> \
-                                     LNET_PHASH_BITS)
-#define LNET_PHASH_IDX_GET(pos) (int)(((pos) & LNET_PHASH_IDX_MASK) >> \
-                                      LNET_PHASH_NUM_BITS)
-#define LNET_PHASH_NUM_GET(pos) (int)((pos) & LNET_PHASH_NUM_MASK)
-#define LNET_VERSION_VALID_MASK(ver) \
-                                ((unsigned int)((ver) & LNET_VERSION_BITMASK))
-#define LNET_PHASH_POS_MAKE(ver, idx, num)                                     \
-                                (((((loff_t)(ver)) & LNET_VERSION_BITMASK) <<  \
-                                   LNET_PHASH_BITS) |                          \
-                                 ((((loff_t)(idx)) & LNET_PHASH_IDX_BITMASK) <<\
-                                   LNET_PHASH_NUM_BITS) |                      \
-                                 ((num) & LNET_PHASH_NUM_BITMASK))
-
 static int __proc_lnet_stats(void *data, int write,
                              loff_t pos, void *buffer, int nob)
 {
@@ -147,14 +113,10 @@ int LL_PROC_PROTO(proc_lnet_routes)
         char      *s;
         const int  tmpsiz = 256;
         int        len;
-        int        ver;
-        int        num;
+        int       *ver_p  = (unsigned int *)(&filp->private_data);
 
         DECLARE_LL_PROC_PPOS_DECL;
 
-        num = LNET_PHASH_NUM_GET(*ppos);
-        ver = LNET_VERSION_GET(*ppos);
-
         LASSERT (!write);
 
         if (*lenp == 0)
@@ -176,19 +138,18 @@ int LL_PROC_PROTO(proc_lnet_routes)
                 LASSERT (tmpstr + tmpsiz - s > 0);
 
                 LNET_LOCK();
-                ver = (unsigned int)the_lnet.ln_remote_nets_version;
+                *ver_p = (unsigned int)the_lnet.ln_remote_nets_version;
                 LNET_UNLOCK();
-                *ppos = LNET_PHASH_POS_MAKE(ver, 0, num);
         } else {
                 struct list_head  *n;
                 struct list_head  *r;
                 lnet_route_t      *route = NULL;
                 lnet_remotenet_t  *rnet  = NULL;
-                int                skip  = num - 1;
+                int                skip  = *ppos - 1;
 
                 LNET_LOCK();
 
-                if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_remote_nets_version)) {
+                if (*ver_p != (unsigned int)the_lnet.ln_remote_nets_version) {
                         LNET_UNLOCK();
                         LIBCFS_FREE(tmpstr, tmpsiz);
                         return -ESTALE;
@@ -238,10 +199,8 @@ int LL_PROC_PROTO(proc_lnet_routes)
         } else if (len > 0) { /* wrote something */
                 if (copy_to_user(buffer, tmpstr, len))
                         rc = -EFAULT;
-                else {
-                        num += 1;
-                        *ppos = LNET_PHASH_POS_MAKE(ver, 0, num);
-                }
+                else
+                        *ppos += 1;
         }
 
         LIBCFS_FREE(tmpstr, tmpsiz);
@@ -259,14 +218,10 @@ int LL_PROC_PROTO(proc_lnet_routers)
         char      *s;
         const int  tmpsiz = 256;
         int        len;
-        int        ver;
-        int        num;
+        int       *ver_p = (unsigned int *)(&filp->private_data);
 
         DECLARE_LL_PROC_PPOS_DECL;
 
-        num = LNET_PHASH_NUM_GET(*ppos);
-        ver = LNET_VERSION_GET(*ppos);
-
         LASSERT (!write);
 
         if (*lenp == 0)
@@ -286,17 +241,16 @@ int LL_PROC_PROTO(proc_lnet_routers)
                 LASSERT (tmpstr + tmpsiz - s > 0);
 
                 LNET_LOCK();
-                ver = (unsigned int)the_lnet.ln_routers_version;
+                *ver_p = (unsigned int)the_lnet.ln_routers_version;
                 LNET_UNLOCK();
-                *ppos = LNET_PHASH_POS_MAKE(ver, 0, num);
         } else {
                 struct list_head  *r;
                 lnet_peer_t       *peer = NULL;
-                int                skip = num - 1;
+                int                skip = *ppos - 1;
 
                 LNET_LOCK();
 
-                if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_routers_version)) {
+                if (*ver_p != (unsigned int)the_lnet.ln_routers_version) {
                         LNET_UNLOCK();
                         LIBCFS_FREE(tmpstr, tmpsiz);
                         return -ESTALE;
@@ -359,10 +313,8 @@ int LL_PROC_PROTO(proc_lnet_routers)
         } else if (len > 0) { /* wrote something */
                 if (copy_to_user(buffer, tmpstr, len))
                         rc = -EFAULT;
-                else {
-                        num += 1;
-                        *ppos = LNET_PHASH_POS_MAKE(ver, 0, num);
-                }
+                else
+                        *ppos += 1;
         }
 
         LIBCFS_FREE(tmpstr, tmpsiz);
@@ -373,6 +325,23 @@ int LL_PROC_PROTO(proc_lnet_routers)
         return rc;
 }
 
+/*
+ * NB: we don't use the highest bit of *ppos because it's signed;
+ *     next 9 bits is used to stash idx (assuming that
+ *     LNET_PEER_HASHSIZE < 512)
+ */
+#define LNET_LOFFT_BITS (sizeof(loff_t) * 8)
+#define LNET_PHASH_BITS 9
+#define LNET_PHASH_IDX_MASK (((1ULL << LNET_PHASH_BITS) - 1) <<               \
+                             (LNET_LOFFT_BITS - LNET_PHASH_BITS - 1))
+#define LNET_PHASH_NUM_MASK ((1ULL <<                                         \
+                              (LNET_LOFFT_BITS - LNET_PHASH_BITS -1)) - 1)
+#define LNET_PHASH_IDX_GET(pos) (int)(((pos) & LNET_PHASH_IDX_MASK) >>  \
+                                      (LNET_LOFFT_BITS - LNET_PHASH_BITS -1))
+#define LNET_PHASH_NUM_GET(pos) (int)((pos) & LNET_PHASH_NUM_MASK)
+#define LNET_PHASH_POS_MAKE(idx, num) ((((loff_t)idx) << (LNET_LOFFT_BITS -   \
+                                                  LNET_PHASH_BITS -1)) | (num))
+
 int LL_PROC_PROTO(proc_lnet_peers)
 {
         int        rc = 0;
@@ -380,7 +349,7 @@ int LL_PROC_PROTO(proc_lnet_peers)
         char      *s;
         const int  tmpsiz      = 256;
         int        len;
-        int        ver;
+        int       *ver_p       = (unsigned int *)(&filp->private_data);
         int        idx;
         int        num;
 
@@ -388,9 +357,8 @@ int LL_PROC_PROTO(proc_lnet_peers)
 
         idx = LNET_PHASH_IDX_GET(*ppos);
         num = LNET_PHASH_NUM_GET(*ppos);
-        ver = LNET_VERSION_GET(*ppos);
 
-        CLASSERT ((1UL << LNET_PHASH_BITS) > LNET_PEER_HASHSIZE);
+        CLASSERT ((1 << LNET_PHASH_BITS) > LNET_PEER_HASHSIZE);
 
         LASSERT (!write);
 
@@ -411,9 +379,8 @@ int LL_PROC_PROTO(proc_lnet_peers)
                 LASSERT (tmpstr + tmpsiz - s > 0);
 
                 LNET_LOCK();
-                ver = (unsigned int)the_lnet.ln_peertable_version;
+                *ver_p  = (unsigned int)the_lnet.ln_peertable_version;
                 LNET_UNLOCK();
-                *ppos = LNET_PHASH_POS_MAKE(ver, idx, num);
 
                 num++;
         } else {
@@ -423,7 +390,7 @@ int LL_PROC_PROTO(proc_lnet_peers)
 
                 LNET_LOCK();
 
-                if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_peertable_version)) {
+                if (*ver_p != (unsigned int)the_lnet.ln_peertable_version) {
                         LNET_UNLOCK();
                         LIBCFS_FREE(tmpstr, tmpsiz);
                         return -ESTALE;
@@ -499,7 +466,7 @@ int LL_PROC_PROTO(proc_lnet_peers)
                 if (copy_to_user(buffer, tmpstr, len))
                         rc = -EFAULT;
                 else
-                        *ppos = LNET_PHASH_POS_MAKE(ver, idx, num);
+                        *ppos = LNET_PHASH_POS_MAKE(idx, num);
         }
 
         LIBCFS_FREE(tmpstr, tmpsiz);