From e3d9be7c5561af9d08075c7e78503944c4d30e60 Mon Sep 17 00:00:00 2001 From: Rahul Deshmukh Date: Fri, 21 May 2010 11:50:30 +0530 Subject: [PATCH] b=21951 2.6.32-fc13 patchless client support for HEAD b=21951 2.6.32-fc13 patchless client support for HEAD i=sheng.yang i=sebastien.buisson Improvement changes for proc_handler, head port --- libcfs/include/libcfs/linux/portals_compat25.h | 13 ++++ lnet/autoconf/lustre-lnet.m4 | 26 +++++++ lnet/lnet/router_proc.c | 102 ++++++++++++++++--------- lustre/autoconf/lustre-core.m4 | 6 +- 4 files changed, 109 insertions(+), 38 deletions(-) diff --git a/libcfs/include/libcfs/linux/portals_compat25.h b/libcfs/include/libcfs/linux/portals_compat25.h index e816908..da9eecb 100644 --- a/libcfs/include/libcfs/linux/portals_compat25.h +++ b/libcfs/include/libcfs/linux/portals_compat25.h @@ -148,6 +148,18 @@ typedef unsigned long cfs_cpumask_t; #define __cfs_fls __fls #endif +#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); @@ -158,6 +170,7 @@ typedef unsigned long cfs_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 /* helper for sysctl handlers */ diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 44c7a23..dc77f7d 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -915,6 +915,30 @@ AC_DEFUN([LN_CONFIG_USERSPACE], [ ]) +# 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 +],[ + 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 # @@ -934,6 +958,8 @@ LN_CONFIG_O2IB LN_CONFIG_RALND LN_CONFIG_PTLLND LN_CONFIG_MX +# 2.6.32 +LN_5ARGS_SYSCTL_PROC_HANDLER ]) # diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index c053f4c..837c2a7 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -51,6 +51,41 @@ 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) { @@ -113,10 +148,14 @@ int LL_PROC_PROTO(proc_lnet_routes) char *s; const int tmpsiz = 256; int len; - int *ver_p = (unsigned int *)(&filp->private_data); + int ver; + int num; DECLARE_LL_PROC_PPOS_DECL; + num = LNET_PHASH_NUM_GET(*ppos); + ver = LNET_VERSION_GET(*ppos); + LASSERT (!write); if (*lenp == 0) @@ -138,18 +177,19 @@ int LL_PROC_PROTO(proc_lnet_routes) LASSERT (tmpstr + tmpsiz - s > 0); LNET_LOCK(); - *ver_p = (unsigned int)the_lnet.ln_remote_nets_version; + ver = (unsigned int)the_lnet.ln_remote_nets_version; LNET_UNLOCK(); + *ppos = LNET_PHASH_POS_MAKE(ver, 0, num); } else { cfs_list_t *n; cfs_list_t *r; lnet_route_t *route = NULL; lnet_remotenet_t *rnet = NULL; - int skip = *ppos - 1; + int skip = num - 1; LNET_LOCK(); - if (*ver_p != (unsigned int)the_lnet.ln_remote_nets_version) { + if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_remote_nets_version)) { LNET_UNLOCK(); LIBCFS_FREE(tmpstr, tmpsiz); return -ESTALE; @@ -200,8 +240,10 @@ int LL_PROC_PROTO(proc_lnet_routes) } else if (len > 0) { /* wrote something */ if (cfs_copy_to_user(buffer, tmpstr, len)) rc = -EFAULT; - else - *ppos += 1; + else { + num += 1; + *ppos = LNET_PHASH_POS_MAKE(ver, 0, num); + } } LIBCFS_FREE(tmpstr, tmpsiz); @@ -219,10 +261,14 @@ int LL_PROC_PROTO(proc_lnet_routers) char *s; const int tmpsiz = 256; int len; - int *ver_p = (unsigned int *)(&filp->private_data); + int ver; + int num; DECLARE_LL_PROC_PPOS_DECL; + num = LNET_PHASH_NUM_GET(*ppos); + ver = LNET_VERSION_GET(*ppos); + LASSERT (!write); if (*lenp == 0) @@ -242,16 +288,17 @@ int LL_PROC_PROTO(proc_lnet_routers) LASSERT (tmpstr + tmpsiz - s > 0); LNET_LOCK(); - *ver_p = (unsigned int)the_lnet.ln_routers_version; + ver = (unsigned int)the_lnet.ln_routers_version; LNET_UNLOCK(); + *ppos = LNET_PHASH_POS_MAKE(ver, 0, num); } else { cfs_list_t *r; lnet_peer_t *peer = NULL; - int skip = *ppos - 1; + int skip = num - 1; LNET_LOCK(); - if (*ver_p != (unsigned int)the_lnet.ln_routers_version) { + if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_routers_version)) { LNET_UNLOCK(); LIBCFS_FREE(tmpstr, tmpsiz); return -ESTALE; @@ -314,8 +361,10 @@ int LL_PROC_PROTO(proc_lnet_routers) } else if (len > 0) { /* wrote something */ if (cfs_copy_to_user(buffer, tmpstr, len)) rc = -EFAULT; - else - *ppos += 1; + else { + num += 1; + *ppos = LNET_PHASH_POS_MAKE(ver, 0, num); + } } LIBCFS_FREE(tmpstr, tmpsiz); @@ -326,23 +375,6 @@ 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; @@ -350,7 +382,7 @@ int LL_PROC_PROTO(proc_lnet_peers) char *s; const int tmpsiz = 256; int len; - int *ver_p = (unsigned int *)(&filp->private_data); + int ver; int idx; int num; @@ -358,8 +390,9 @@ 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 ((1 << LNET_PHASH_BITS) > LNET_PEER_HASHSIZE); + CLASSERT ((1ULL << LNET_PHASH_BITS) > LNET_PEER_HASHSIZE); LASSERT (!write); @@ -380,8 +413,9 @@ int LL_PROC_PROTO(proc_lnet_peers) LASSERT (tmpstr + tmpsiz - s > 0); LNET_LOCK(); - *ver_p = (unsigned int)the_lnet.ln_peertable_version; + ver = (unsigned int)the_lnet.ln_peertable_version; LNET_UNLOCK(); + *ppos = LNET_PHASH_POS_MAKE(ver, idx, num); num++; } else { @@ -391,7 +425,7 @@ int LL_PROC_PROTO(proc_lnet_peers) LNET_LOCK(); - if (*ver_p != (unsigned int)the_lnet.ln_peertable_version) { + if (ver != LNET_VERSION_VALID_MASK(the_lnet.ln_peertable_version)) { LNET_UNLOCK(); LIBCFS_FREE(tmpstr, tmpsiz); return -ESTALE; @@ -467,7 +501,7 @@ int LL_PROC_PROTO(proc_lnet_peers) if (cfs_copy_to_user(buffer, tmpstr, len)) rc = -EFAULT; else - *ppos = LNET_PHASH_POS_MAKE(idx, num); + *ppos = LNET_PHASH_POS_MAKE(ver, idx, num); } LIBCFS_FREE(tmpstr, tmpsiz); diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f1468b6..c1b447e 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -421,9 +421,7 @@ AC_DEFUN([LC_POSIX_ACL_XATTR_H], [LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[ AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled]) LB_LINUX_TRY_COMPILE([ - #ifdef CONFIG_FS_POSIX_ACL - # include - #endif + #include #include ],[],[ AC_MSG_RESULT([yes]) @@ -434,7 +432,7 @@ AC_DEFUN([LC_POSIX_ACL_XATTR_H], ]) $1 ],[ -AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) ]) ]) -- 1.8.3.1