2 * Documentation/ABI/stable/orangefs-sysfs:
4 * What: /sys/fs/orangefs/perf_counter_reset
6 * Contact: Mike Marshall <hubcap@omnibond.com>
8 * echo a 0 or a 1 into perf_counter_reset to
9 * reset all the counters in
10 * /sys/fs/orangefs/perf_counters
11 * except ones with PINT_PERF_PRESERVE set.
14 * What: /sys/fs/orangefs/perf_counters/...
16 * Contact: Mike Marshall <hubcap@omnibond.com>
18 * Counters and settings for various caches.
22 * What: /sys/fs/orangefs/perf_time_interval_secs
24 * Contact: Mike Marshall <hubcap@omnibond.com>
26 * Length of perf counter intervals in
30 * What: /sys/fs/orangefs/perf_history_size
32 * Contact: Mike Marshall <hubcap@omnibond.com>
34 * The perf_counters cache statistics have N, or
35 * perf_history_size, samples. The default is
38 * Every perf_time_interval_secs the (first)
41 * If N is greater than one, the "current" set
42 * of samples is reset, and the samples from the
43 * other N-1 intervals remain available.
46 * What: /sys/fs/orangefs/op_timeout_secs
48 * Contact: Mike Marshall <hubcap@omnibond.com>
50 * Service operation timeout in seconds.
53 * What: /sys/fs/orangefs/slot_timeout_secs
55 * Contact: Mike Marshall <hubcap@omnibond.com>
57 * "Slot" timeout in seconds. A "slot"
58 * is an indexed buffer in the shared
59 * memory segment used for communication
60 * between the kernel module and userspace.
61 * Slots are requested and waited for,
62 * the wait times out after slot_timeout_secs.
64 * What: /sys/fs/orangefs/dcache_timeout_msecs
66 * Contact: Martin Brandenburg <martin@omnibond.com>
68 * Time lookup is valid in milliseconds.
70 * What: /sys/fs/orangefs/getattr_timeout_msecs
72 * Contact: Martin Brandenburg <martin@omnibond.com>
74 * Time getattr is valid in milliseconds.
76 * What: /sys/fs/orangefs/readahead_count
78 * Contact: Martin Brandenburg <martin@omnibond.com>
80 * Readahead cache buffer count.
82 * What: /sys/fs/orangefs/readahead_size
84 * Contact: Martin Brandenburg <martin@omnibond.com>
86 * Readahead cache buffer size.
88 * What: /sys/fs/orangefs/readahead_count_size
90 * Contact: Martin Brandenburg <martin@omnibond.com>
92 * Readahead cache buffer count and size.
94 * What: /sys/fs/orangefs/acache/...
96 * Contact: Martin Brandenburg <martin@omnibond.com>
98 * Attribute cache configurable settings.
101 * What: /sys/fs/orangefs/ncache/...
103 * Contact: Mike Marshall <hubcap@omnibond.com>
105 * Name cache configurable settings.
108 * What: /sys/fs/orangefs/capcache/...
110 * Contact: Mike Marshall <hubcap@omnibond.com>
112 * Capability cache configurable settings.
115 * What: /sys/fs/orangefs/ccache/...
117 * Contact: Mike Marshall <hubcap@omnibond.com>
119 * Credential cache configurable settings.
123 #include <linux/fs.h>
124 #include <linux/kobject.h>
125 #include <linux/string.h>
126 #include <linux/sysfs.h>
127 #include <linux/module.h>
128 #include <linux/init.h>
130 #include "protocol.h"
131 #include "orangefs-kernel.h"
132 #include "orangefs-sysfs.h"
134 #define ORANGEFS_KOBJ_ID "orangefs"
135 #define ACACHE_KOBJ_ID "acache"
136 #define CAPCACHE_KOBJ_ID "capcache"
137 #define CCACHE_KOBJ_ID "ccache"
138 #define NCACHE_KOBJ_ID "ncache"
139 #define PC_KOBJ_ID "pc"
140 #define STATS_KOBJ_ID "stats"
142 struct orangefs_attribute {
143 struct attribute attr;
144 ssize_t (*show)(struct orangefs_attribute *attr,
146 ssize_t (*store)(struct orangefs_attribute *attr,
151 static ssize_t orangefs_attr_show(struct kobject *kobj,
152 struct attribute *attr,
155 struct orangefs_attribute *attribute;
158 attribute = container_of(attr, struct orangefs_attribute, attr);
160 if (!attribute->show) {
165 rc = attribute->show(attribute, buf);
171 static ssize_t orangefs_attr_store(struct kobject *kobj,
172 struct attribute *attr,
176 struct orangefs_attribute *attribute;
179 gossip_debug(GOSSIP_SYSFS_DEBUG,
180 "orangefs_attr_store: start\n");
182 attribute = container_of(attr, struct orangefs_attribute, attr);
184 if (!attribute->store) {
189 rc = attribute->store(attribute, buf, len);
195 static const struct sysfs_ops orangefs_sysfs_ops = {
196 .show = orangefs_attr_show,
197 .store = orangefs_attr_store,
200 static const struct sysfs_ops acache_orangefs_sysfs_ops = {
201 .show = orangefs_attr_show,
202 .store = orangefs_attr_store,
205 static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
206 .show = orangefs_attr_show,
207 .store = orangefs_attr_store,
210 static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
211 .show = orangefs_attr_show,
212 .store = orangefs_attr_store,
215 static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
216 .show = orangefs_attr_show,
217 .store = orangefs_attr_store,
220 static const struct sysfs_ops pc_orangefs_sysfs_ops = {
221 .show = orangefs_attr_show,
224 static const struct sysfs_ops stats_orangefs_sysfs_ops = {
225 .show = orangefs_attr_show,
228 static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr)
231 struct orangefs_attribute *orangefs_attr = attr;
233 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id);
235 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
236 if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) {
242 } else if (!strcmp(orangefs_attr->attr.name,
243 "slot_timeout_secs")) {
249 } else if (!strcmp(orangefs_attr->attr.name,
250 "dcache_timeout_msecs")) {
254 dcache_timeout_msecs);
256 } else if (!strcmp(orangefs_attr->attr.name,
257 "getattr_timeout_msecs")) {
261 getattr_timeout_msecs);
267 } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) {
268 if (!strcmp(orangefs_attr->attr.name, "reads")) {
272 g_orangefs_stats.reads);
274 } else if (!strcmp(orangefs_attr->attr.name, "writes")) {
278 g_orangefs_stats.writes);
290 static ssize_t int_orangefs_show(struct orangefs_attribute *attr,
295 gossip_debug(GOSSIP_SYSFS_DEBUG,
296 "int_orangefs_show:start attr->attr.name:%s:\n",
299 rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr);
304 static ssize_t int_stats_show(struct orangefs_attribute *attr,
309 gossip_debug(GOSSIP_SYSFS_DEBUG,
310 "int_stats_show:start attr->attr.name:%s:\n",
313 rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr);
318 static ssize_t int_store(struct orangefs_attribute *attr,
324 gossip_debug(GOSSIP_SYSFS_DEBUG,
325 "int_store: start attr->attr.name:%s: buf:%s:\n",
326 attr->attr.name, buf);
328 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
329 rc = kstrtoint(buf, 0, &op_timeout_secs);
331 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
332 rc = kstrtoint(buf, 0, &slot_timeout_secs);
334 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
335 rc = kstrtoint(buf, 0, &dcache_timeout_msecs);
337 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
338 rc = kstrtoint(buf, 0, &getattr_timeout_msecs);
354 * obtain attribute values from userspace with a service operation.
356 static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr)
358 struct orangefs_kernel_op_s *new_op = NULL;
360 char *ser_op_type = NULL;
361 struct orangefs_attribute *orangefs_attr = attr;
364 gossip_debug(GOSSIP_SYSFS_DEBUG,
365 "sysfs_service_op_show: id:%s:\n",
368 if (strcmp(kobj_id, PC_KOBJ_ID))
369 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
371 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
373 new_op = op_alloc(op_alloc_type);
377 /* Can't do a service_operation if the client is not running... */
378 rc = is_daemon_in_service();
380 pr_info("%s: Client not running :%d:\n",
382 is_daemon_in_service());
386 if (strcmp(kobj_id, PC_KOBJ_ID))
387 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
389 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
390 if (!strcmp(orangefs_attr->attr.name, "perf_history_size"))
391 new_op->upcall.req.param.op =
392 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
393 else if (!strcmp(orangefs_attr->attr.name,
394 "perf_time_interval_secs"))
395 new_op->upcall.req.param.op =
396 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
397 else if (!strcmp(orangefs_attr->attr.name,
398 "perf_counter_reset"))
399 new_op->upcall.req.param.op =
400 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
402 else if (!strcmp(orangefs_attr->attr.name,
404 new_op->upcall.req.param.op =
405 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
407 else if (!strcmp(orangefs_attr->attr.name,
409 new_op->upcall.req.param.op =
410 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
412 else if (!strcmp(orangefs_attr->attr.name,
413 "readahead_count_size"))
414 new_op->upcall.req.param.op =
415 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
416 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
417 if (!strcmp(orangefs_attr->attr.name, "timeout_msecs"))
418 new_op->upcall.req.param.op =
419 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
421 if (!strcmp(orangefs_attr->attr.name, "hard_limit"))
422 new_op->upcall.req.param.op =
423 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
425 if (!strcmp(orangefs_attr->attr.name, "soft_limit"))
426 new_op->upcall.req.param.op =
427 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
429 if (!strcmp(orangefs_attr->attr.name, "reclaim_percentage"))
430 new_op->upcall.req.param.op =
431 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
433 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
434 if (!strcmp(orangefs_attr->attr.name, "timeout_secs"))
435 new_op->upcall.req.param.op =
436 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
438 if (!strcmp(orangefs_attr->attr.name, "hard_limit"))
439 new_op->upcall.req.param.op =
440 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
442 if (!strcmp(orangefs_attr->attr.name, "soft_limit"))
443 new_op->upcall.req.param.op =
444 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
446 if (!strcmp(orangefs_attr->attr.name, "reclaim_percentage"))
447 new_op->upcall.req.param.op =
448 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
450 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
451 if (!strcmp(orangefs_attr->attr.name, "timeout_secs"))
452 new_op->upcall.req.param.op =
453 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
455 if (!strcmp(orangefs_attr->attr.name, "hard_limit"))
456 new_op->upcall.req.param.op =
457 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
459 if (!strcmp(orangefs_attr->attr.name, "soft_limit"))
460 new_op->upcall.req.param.op =
461 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
463 if (!strcmp(orangefs_attr->attr.name, "reclaim_percentage"))
464 new_op->upcall.req.param.op =
465 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
467 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
468 if (!strcmp(orangefs_attr->attr.name, "timeout_msecs"))
469 new_op->upcall.req.param.op =
470 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
472 if (!strcmp(orangefs_attr->attr.name, "hard_limit"))
473 new_op->upcall.req.param.op =
474 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
476 if (!strcmp(orangefs_attr->attr.name, "soft_limit"))
477 new_op->upcall.req.param.op =
478 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
480 if (!strcmp(orangefs_attr->attr.name, "reclaim_percentage"))
481 new_op->upcall.req.param.op =
482 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
484 } else if (!strcmp(kobj_id, PC_KOBJ_ID)) {
485 if (!strcmp(orangefs_attr->attr.name, ACACHE_KOBJ_ID))
486 new_op->upcall.req.perf_count.type =
487 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
489 if (!strcmp(orangefs_attr->attr.name, CAPCACHE_KOBJ_ID))
490 new_op->upcall.req.perf_count.type =
491 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
493 if (!strcmp(orangefs_attr->attr.name, NCACHE_KOBJ_ID))
494 new_op->upcall.req.perf_count.type =
495 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
498 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
505 if (strcmp(kobj_id, PC_KOBJ_ID))
506 ser_op_type = "orangefs_param";
508 ser_op_type = "orangefs_perf_count";
511 * The service_operation will return an errno return code on
512 * error, and zero on success.
514 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
518 if (strcmp(kobj_id, PC_KOBJ_ID)) {
519 if (new_op->upcall.req.param.op ==
520 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
521 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
522 (int)new_op->downcall.resp.param.u.
524 (int)new_op->downcall.resp.param.u.
527 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
528 (int)new_op->downcall.resp.param.u.value64);
535 new_op->downcall.resp.perf_count.buffer);
545 static ssize_t service_orangefs_show(struct orangefs_attribute *attr,
550 rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr);
556 service_acache_show(struct orangefs_attribute *attr,
561 rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr);
566 static ssize_t service_capcache_show(struct orangefs_attribute *attr,
571 rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr);
576 static ssize_t service_ccache_show(struct orangefs_attribute *attr,
581 rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr);
587 service_ncache_show(struct orangefs_attribute *attr,
592 rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr);
598 service_pc_show(struct orangefs_attribute *attr,
603 rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr);
609 * pass attribute values back to userspace with a service operation.
611 * We have to do a memory allocation, an sscanf and a service operation.
612 * And we have to evaluate what the user entered, to make sure the
613 * value is within the range supported by the attribute. So, there's
614 * a lot of return code checking and mapping going on here.
616 * We want to return 1 if we think everything went OK, and
619 static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr)
621 struct orangefs_kernel_op_s *new_op = NULL;
624 struct orangefs_attribute *orangefs_attr = attr;
626 gossip_debug(GOSSIP_SYSFS_DEBUG,
627 "sysfs_service_op_store: id:%s:\n",
630 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
632 return -EINVAL; /* sic */
634 /* Can't do a service_operation if the client is not running... */
635 rc = is_daemon_in_service();
637 pr_info("%s: Client not running :%d:\n",
639 is_daemon_in_service());
644 * The value we want to send back to userspace is in buf, unless this
645 * there are two parameters, which is specially handled below.
647 if (strcmp(kobj_id, ORANGEFS_KOBJ_ID) ||
648 strcmp(((struct orangefs_attribute *)attr)->attr.name,
649 "readahead_count_size")) {
650 rc = kstrtoint(buf, 0, &val);
655 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
657 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
658 if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) {
660 new_op->upcall.req.param.op =
661 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
666 } else if (!strcmp(orangefs_attr->attr.name,
667 "perf_time_interval_secs")) {
669 new_op->upcall.req.param.op =
670 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
675 } else if (!strcmp(orangefs_attr->attr.name,
676 "perf_counter_reset")) {
677 if ((val == 0) || (val == 1)) {
678 new_op->upcall.req.param.op =
679 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
684 } else if (!strcmp(orangefs_attr->attr.name,
685 "readahead_count")) {
687 new_op->upcall.req.param.op =
688 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
693 } else if (!strcmp(orangefs_attr->attr.name,
696 new_op->upcall.req.param.op =
697 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
702 } else if (!strcmp(orangefs_attr->attr.name,
703 "readahead_count_size")) {
705 rc = sscanf(buf, "%d %d", &val1, &val2);
710 if ((val1 >= 0) && (val2 >= 0)) {
711 new_op->upcall.req.param.op =
712 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
717 new_op->upcall.req.param.u.value32[0] = val1;
718 new_op->upcall.req.param.u.value32[1] = val2;
720 } else if (!strcmp(orangefs_attr->attr.name,
721 "perf_counter_reset")) {
723 new_op->upcall.req.param.op =
724 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
731 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
732 if (!strcmp(orangefs_attr->attr.name, "hard_limit")) {
734 new_op->upcall.req.param.op =
735 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
740 } else if (!strcmp(orangefs_attr->attr.name, "soft_limit")) {
742 new_op->upcall.req.param.op =
743 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
748 } else if (!strcmp(orangefs_attr->attr.name,
749 "reclaim_percentage")) {
750 if ((val > -1) && (val < 101)) {
751 new_op->upcall.req.param.op =
752 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
757 } else if (!strcmp(orangefs_attr->attr.name, "timeout_msecs")) {
759 new_op->upcall.req.param.op =
760 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
767 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
768 if (!strcmp(orangefs_attr->attr.name, "hard_limit")) {
770 new_op->upcall.req.param.op =
771 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
776 } else if (!strcmp(orangefs_attr->attr.name, "soft_limit")) {
778 new_op->upcall.req.param.op =
779 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
784 } else if (!strcmp(orangefs_attr->attr.name,
785 "reclaim_percentage")) {
786 if ((val > -1) && (val < 101)) {
787 new_op->upcall.req.param.op =
788 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
793 } else if (!strcmp(orangefs_attr->attr.name, "timeout_secs")) {
795 new_op->upcall.req.param.op =
796 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
803 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
804 if (!strcmp(orangefs_attr->attr.name, "hard_limit")) {
806 new_op->upcall.req.param.op =
807 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
812 } else if (!strcmp(orangefs_attr->attr.name, "soft_limit")) {
814 new_op->upcall.req.param.op =
815 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
820 } else if (!strcmp(orangefs_attr->attr.name,
821 "reclaim_percentage")) {
822 if ((val > -1) && (val < 101)) {
823 new_op->upcall.req.param.op =
824 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
829 } else if (!strcmp(orangefs_attr->attr.name, "timeout_secs")) {
831 new_op->upcall.req.param.op =
832 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
839 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
840 if (!strcmp(orangefs_attr->attr.name, "hard_limit")) {
842 new_op->upcall.req.param.op =
843 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
848 } else if (!strcmp(orangefs_attr->attr.name, "soft_limit")) {
850 new_op->upcall.req.param.op =
851 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
856 } else if (!strcmp(orangefs_attr->attr.name,
857 "reclaim_percentage")) {
858 if ((val > -1) && (val < 101)) {
859 new_op->upcall.req.param.op =
860 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
865 } else if (!strcmp(orangefs_attr->attr.name, "timeout_msecs")) {
867 new_op->upcall.req.param.op =
868 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
876 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
882 new_op->upcall.req.param.u.value64 = val;
886 * The service_operation will return a errno return code on
887 * error, and zero on success.
889 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
892 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
902 if (rc == -ENOMEM || rc == 0)
909 service_orangefs_store(struct orangefs_attribute *attr,
915 rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr);
917 /* rc should have an errno value if the service_op went bad. */
925 service_acache_store(struct orangefs_attribute *attr,
931 rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr);
933 /* rc should have an errno value if the service_op went bad. */
941 service_capcache_store(struct orangefs_attribute *attr,
947 rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr);
949 /* rc should have an errno value if the service_op went bad. */
956 static ssize_t service_ccache_store(struct orangefs_attribute *attr,
962 rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr);
964 /* rc should have an errno value if the service_op went bad. */
972 service_ncache_store(struct orangefs_attribute *attr,
978 rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr);
980 /* rc should have an errno value if the service_op went bad. */
987 static struct orangefs_attribute op_timeout_secs_attribute =
988 __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store);
990 static struct orangefs_attribute slot_timeout_secs_attribute =
991 __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store);
993 static struct orangefs_attribute dcache_timeout_msecs_attribute =
994 __ATTR(dcache_timeout_msecs, 0664, int_orangefs_show, int_store);
996 static struct orangefs_attribute getattr_timeout_msecs_attribute =
997 __ATTR(getattr_timeout_msecs, 0664, int_orangefs_show, int_store);
999 static struct orangefs_attribute readahead_count_attribute =
1000 __ATTR(readahead_count, 0664, service_orangefs_show,
1001 service_orangefs_store);
1003 static struct orangefs_attribute readahead_size_attribute =
1004 __ATTR(readahead_size, 0664, service_orangefs_show,
1005 service_orangefs_store);
1007 static struct orangefs_attribute readahead_count_size_attribute =
1008 __ATTR(readahead_count_size, 0664, service_orangefs_show,
1009 service_orangefs_store);
1011 static struct orangefs_attribute perf_counter_reset_attribute =
1012 __ATTR(perf_counter_reset,
1014 service_orangefs_show,
1015 service_orangefs_store);
1017 static struct orangefs_attribute perf_history_size_attribute =
1018 __ATTR(perf_history_size,
1020 service_orangefs_show,
1021 service_orangefs_store);
1023 static struct orangefs_attribute perf_time_interval_secs_attribute =
1024 __ATTR(perf_time_interval_secs,
1026 service_orangefs_show,
1027 service_orangefs_store);
1029 static struct attribute *orangefs_default_attrs[] = {
1030 &op_timeout_secs_attribute.attr,
1031 &slot_timeout_secs_attribute.attr,
1032 &dcache_timeout_msecs_attribute.attr,
1033 &getattr_timeout_msecs_attribute.attr,
1034 &readahead_count_attribute.attr,
1035 &readahead_size_attribute.attr,
1036 &readahead_count_size_attribute.attr,
1037 &perf_counter_reset_attribute.attr,
1038 &perf_history_size_attribute.attr,
1039 &perf_time_interval_secs_attribute.attr,
1043 static struct kobj_type orangefs_ktype = {
1044 .sysfs_ops = &orangefs_sysfs_ops,
1045 .default_attrs = orangefs_default_attrs,
1048 static struct orangefs_attribute acache_hard_limit_attribute =
1051 service_acache_show,
1052 service_acache_store);
1054 static struct orangefs_attribute acache_reclaim_percent_attribute =
1055 __ATTR(reclaim_percentage,
1057 service_acache_show,
1058 service_acache_store);
1060 static struct orangefs_attribute acache_soft_limit_attribute =
1063 service_acache_show,
1064 service_acache_store);
1066 static struct orangefs_attribute acache_timeout_msecs_attribute =
1067 __ATTR(timeout_msecs,
1069 service_acache_show,
1070 service_acache_store);
1072 static struct attribute *acache_orangefs_default_attrs[] = {
1073 &acache_hard_limit_attribute.attr,
1074 &acache_reclaim_percent_attribute.attr,
1075 &acache_soft_limit_attribute.attr,
1076 &acache_timeout_msecs_attribute.attr,
1080 static struct kobj_type acache_orangefs_ktype = {
1081 .sysfs_ops = &acache_orangefs_sysfs_ops,
1082 .default_attrs = acache_orangefs_default_attrs,
1085 static struct orangefs_attribute capcache_hard_limit_attribute =
1088 service_capcache_show,
1089 service_capcache_store);
1091 static struct orangefs_attribute capcache_reclaim_percent_attribute =
1092 __ATTR(reclaim_percentage,
1094 service_capcache_show,
1095 service_capcache_store);
1097 static struct orangefs_attribute capcache_soft_limit_attribute =
1100 service_capcache_show,
1101 service_capcache_store);
1103 static struct orangefs_attribute capcache_timeout_secs_attribute =
1104 __ATTR(timeout_secs,
1106 service_capcache_show,
1107 service_capcache_store);
1109 static struct attribute *capcache_orangefs_default_attrs[] = {
1110 &capcache_hard_limit_attribute.attr,
1111 &capcache_reclaim_percent_attribute.attr,
1112 &capcache_soft_limit_attribute.attr,
1113 &capcache_timeout_secs_attribute.attr,
1117 static struct kobj_type capcache_orangefs_ktype = {
1118 .sysfs_ops = &capcache_orangefs_sysfs_ops,
1119 .default_attrs = capcache_orangefs_default_attrs,
1122 static struct orangefs_attribute ccache_hard_limit_attribute =
1125 service_ccache_show,
1126 service_ccache_store);
1128 static struct orangefs_attribute ccache_reclaim_percent_attribute =
1129 __ATTR(reclaim_percentage,
1131 service_ccache_show,
1132 service_ccache_store);
1134 static struct orangefs_attribute ccache_soft_limit_attribute =
1137 service_ccache_show,
1138 service_ccache_store);
1140 static struct orangefs_attribute ccache_timeout_secs_attribute =
1141 __ATTR(timeout_secs,
1143 service_ccache_show,
1144 service_ccache_store);
1146 static struct attribute *ccache_orangefs_default_attrs[] = {
1147 &ccache_hard_limit_attribute.attr,
1148 &ccache_reclaim_percent_attribute.attr,
1149 &ccache_soft_limit_attribute.attr,
1150 &ccache_timeout_secs_attribute.attr,
1154 static struct kobj_type ccache_orangefs_ktype = {
1155 .sysfs_ops = &ccache_orangefs_sysfs_ops,
1156 .default_attrs = ccache_orangefs_default_attrs,
1159 static struct orangefs_attribute ncache_hard_limit_attribute =
1162 service_ncache_show,
1163 service_ncache_store);
1165 static struct orangefs_attribute ncache_reclaim_percent_attribute =
1166 __ATTR(reclaim_percentage,
1168 service_ncache_show,
1169 service_ncache_store);
1171 static struct orangefs_attribute ncache_soft_limit_attribute =
1174 service_ncache_show,
1175 service_ncache_store);
1177 static struct orangefs_attribute ncache_timeout_msecs_attribute =
1178 __ATTR(timeout_msecs,
1180 service_ncache_show,
1181 service_ncache_store);
1183 static struct attribute *ncache_orangefs_default_attrs[] = {
1184 &ncache_hard_limit_attribute.attr,
1185 &ncache_reclaim_percent_attribute.attr,
1186 &ncache_soft_limit_attribute.attr,
1187 &ncache_timeout_msecs_attribute.attr,
1191 static struct kobj_type ncache_orangefs_ktype = {
1192 .sysfs_ops = &ncache_orangefs_sysfs_ops,
1193 .default_attrs = ncache_orangefs_default_attrs,
1196 static struct orangefs_attribute pc_acache_attribute =
1202 static struct orangefs_attribute pc_capcache_attribute =
1208 static struct orangefs_attribute pc_ncache_attribute =
1214 static struct attribute *pc_orangefs_default_attrs[] = {
1215 &pc_acache_attribute.attr,
1216 &pc_capcache_attribute.attr,
1217 &pc_ncache_attribute.attr,
1221 static struct kobj_type pc_orangefs_ktype = {
1222 .sysfs_ops = &pc_orangefs_sysfs_ops,
1223 .default_attrs = pc_orangefs_default_attrs,
1226 static struct orangefs_attribute stats_reads_attribute =
1232 static struct orangefs_attribute stats_writes_attribute =
1238 static struct attribute *stats_orangefs_default_attrs[] = {
1239 &stats_reads_attribute.attr,
1240 &stats_writes_attribute.attr,
1244 static struct kobj_type stats_orangefs_ktype = {
1245 .sysfs_ops = &stats_orangefs_sysfs_ops,
1246 .default_attrs = stats_orangefs_default_attrs,
1249 static struct kobject *orangefs_obj;
1250 static struct kobject *acache_orangefs_obj;
1251 static struct kobject *capcache_orangefs_obj;
1252 static struct kobject *ccache_orangefs_obj;
1253 static struct kobject *ncache_orangefs_obj;
1254 static struct kobject *pc_orangefs_obj;
1255 static struct kobject *stats_orangefs_obj;
1257 int orangefs_sysfs_init(void)
1261 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1263 /* create /sys/fs/orangefs. */
1264 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1268 rc = kobject_init_and_add(orangefs_obj,
1276 kobject_uevent(orangefs_obj, KOBJ_ADD);
1278 /* create /sys/fs/orangefs/acache. */
1279 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1280 if (!acache_orangefs_obj) {
1285 rc = kobject_init_and_add(acache_orangefs_obj,
1286 &acache_orangefs_ktype,
1291 goto acache_obj_bail;
1293 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
1295 /* create /sys/fs/orangefs/capcache. */
1296 capcache_orangefs_obj =
1297 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1298 if (!capcache_orangefs_obj) {
1300 goto acache_obj_bail;
1303 rc = kobject_init_and_add(capcache_orangefs_obj,
1304 &capcache_orangefs_ktype,
1308 goto capcache_obj_bail;
1310 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
1312 /* create /sys/fs/orangefs/ccache. */
1313 ccache_orangefs_obj =
1314 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1315 if (!ccache_orangefs_obj) {
1317 goto capcache_obj_bail;
1320 rc = kobject_init_and_add(ccache_orangefs_obj,
1321 &ccache_orangefs_ktype,
1325 goto ccache_obj_bail;
1327 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
1329 /* create /sys/fs/orangefs/ncache. */
1330 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1331 if (!ncache_orangefs_obj) {
1333 goto ccache_obj_bail;
1336 rc = kobject_init_and_add(ncache_orangefs_obj,
1337 &ncache_orangefs_ktype,
1342 goto ncache_obj_bail;
1344 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
1346 /* create /sys/fs/orangefs/perf_counters. */
1347 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1348 if (!pc_orangefs_obj) {
1350 goto ncache_obj_bail;
1353 rc = kobject_init_and_add(pc_orangefs_obj,
1361 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
1363 /* create /sys/fs/orangefs/stats. */
1364 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1365 if (!stats_orangefs_obj) {
1370 rc = kobject_init_and_add(stats_orangefs_obj,
1371 &stats_orangefs_ktype,
1376 goto stats_obj_bail;
1378 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
1382 kobject_put(stats_orangefs_obj);
1384 kobject_put(pc_orangefs_obj);
1386 kobject_put(ncache_orangefs_obj);
1388 kobject_put(ccache_orangefs_obj);
1390 kobject_put(capcache_orangefs_obj);
1392 kobject_put(acache_orangefs_obj);
1394 kobject_put(orangefs_obj);
1399 void orangefs_sysfs_exit(void)
1401 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1402 kobject_put(acache_orangefs_obj);
1403 kobject_put(capcache_orangefs_obj);
1404 kobject_put(ccache_orangefs_obj);
1405 kobject_put(ncache_orangefs_obj);
1406 kobject_put(pc_orangefs_obj);
1407 kobject_put(stats_orangefs_obj);
1408 kobject_put(orangefs_obj);