X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Fmodule.c;h=e8080f323c422a6093ec9bdc35c5a306b4ec372d;hb=beb733c0f27c28d699700a5aabec41bf573712f8;hp=a3c3ea29c47026a0152d085a25fdf9f911aaddf7;hpb=72057a3af19ee02d9a686bd7e7d074917e381310;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index a3c3ea2..e8080f3 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -463,6 +463,55 @@ proc_cpt_table(struct ctl_table *table, int write, void __user *buffer, __proc_cpt_table); } +static int __proc_cpt_distance(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + char *buf = NULL; + int len = 4096; + int rc = 0; + + if (write) + return -EPERM; + + LASSERT(cfs_cpt_table != NULL); + + while (1) { + LIBCFS_ALLOC(buf, len); + if (buf == NULL) + return -ENOMEM; + + rc = cfs_cpt_distance_print(cfs_cpt_table, buf, len); + if (rc >= 0) + break; + + if (rc == -EFBIG) { + LIBCFS_FREE(buf, len); + len <<= 1; + continue; + } + goto out; + } + + if (pos >= rc) { + rc = 0; + goto out; + } + + rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL); + out: + if (buf != NULL) + LIBCFS_FREE(buf, len); + return rc; +} + +static int +proc_cpt_distance(struct ctl_table *table, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + return lprocfs_call_handler(table->data, write, ppos, buffer, lenp, + __proc_cpt_distance); +} + static struct ctl_table lnet_table[] = { /* * NB No .strategy entries have been provided since sysctl(8) prefers @@ -538,11 +587,10 @@ static struct ctl_table lnet_table[] = { }, { INIT_CTL_NAME - .procname = "upcall", - .data = lnet_upcall, - .maxlen = sizeof(lnet_upcall), - .mode = 0644, - .proc_handler = &proc_dostring, + .procname = "cpu_partition_distance", + .maxlen = 128, + .mode = 0444, + .proc_handler = &proc_cpt_distance, }, { INIT_CTL_NAME