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) \
#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
#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)
{
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)
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;
} 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);
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)
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;
} 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);
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;
char *s;
const int tmpsiz = 256;
int len;
- int ver;
+ int *ver_p = (unsigned int *)(&filp->private_data);
int idx;
int num;
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);
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 {
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;
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);