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 kobject *kobj,
145 struct orangefs_attribute *attr,
147 ssize_t (*store)(struct kobject *kobj,
148 struct orangefs_attribute *attr,
153 static ssize_t orangefs_attr_show(struct kobject *kobj,
154 struct attribute *attr,
157 struct orangefs_attribute *attribute;
160 attribute = container_of(attr, struct orangefs_attribute, attr);
162 if (!attribute->show) {
167 rc = attribute->show(kobj, attribute, buf);
173 static ssize_t orangefs_attr_store(struct kobject *kobj,
174 struct attribute *attr,
178 struct orangefs_attribute *attribute;
181 gossip_debug(GOSSIP_SYSFS_DEBUG,
182 "orangefs_attr_store: start\n");
184 attribute = container_of(attr, struct orangefs_attribute, attr);
186 if (!attribute->store) {
191 rc = attribute->store(kobj, attribute, buf, len);
197 static const struct sysfs_ops orangefs_sysfs_ops = {
198 .show = orangefs_attr_show,
199 .store = orangefs_attr_store,
202 static const struct sysfs_ops acache_orangefs_sysfs_ops = {
203 .show = orangefs_attr_show,
204 .store = orangefs_attr_store,
207 static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
208 .show = orangefs_attr_show,
209 .store = orangefs_attr_store,
212 static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
213 .show = orangefs_attr_show,
214 .store = orangefs_attr_store,
217 static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
218 .show = orangefs_attr_show,
219 .store = orangefs_attr_store,
222 static const struct sysfs_ops pc_orangefs_sysfs_ops = {
223 .show = orangefs_attr_show,
226 static const struct sysfs_ops stats_orangefs_sysfs_ops = {
227 .show = orangefs_attr_show,
230 static ssize_t sysfs_int_show(struct kobject *kobj,
231 struct orangefs_attribute *attr, char *buf)
235 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
238 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
239 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
245 } else if (!strcmp(attr->attr.name,
246 "slot_timeout_secs")) {
252 } else if (!strcmp(attr->attr.name,
253 "dcache_timeout_msecs")) {
257 dcache_timeout_msecs);
259 } else if (!strcmp(attr->attr.name,
260 "getattr_timeout_msecs")) {
264 getattr_timeout_msecs);
270 } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
271 if (!strcmp(attr->attr.name, "reads")) {
275 g_orangefs_stats.reads);
277 } else if (!strcmp(attr->attr.name, "writes")) {
281 g_orangefs_stats.writes);
293 static ssize_t sysfs_int_store(struct kobject *kobj,
294 struct orangefs_attribute *attr, const char *buf, size_t count)
298 gossip_debug(GOSSIP_SYSFS_DEBUG,
299 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
300 attr->attr.name, buf);
302 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
303 rc = kstrtoint(buf, 0, &op_timeout_secs);
305 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
306 rc = kstrtoint(buf, 0, &slot_timeout_secs);
308 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
309 rc = kstrtoint(buf, 0, &dcache_timeout_msecs);
311 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
312 rc = kstrtoint(buf, 0, &getattr_timeout_msecs);
328 * obtain attribute values from userspace with a service operation.
330 static ssize_t sysfs_service_op_show(struct kobject *kobj,
331 struct orangefs_attribute *attr, char *buf)
333 struct orangefs_kernel_op_s *new_op = NULL;
335 char *ser_op_type = NULL;
338 gossip_debug(GOSSIP_SYSFS_DEBUG,
339 "sysfs_service_op_show: id:%s:\n",
342 if (strcmp(kobj->name, PC_KOBJ_ID))
343 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
345 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
347 new_op = op_alloc(op_alloc_type);
351 /* Can't do a service_operation if the client is not running... */
352 rc = is_daemon_in_service();
354 pr_info("%s: Client not running :%d:\n",
356 is_daemon_in_service());
360 if (strcmp(kobj->name, PC_KOBJ_ID))
361 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
363 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
364 if (!strcmp(attr->attr.name, "perf_history_size"))
365 new_op->upcall.req.param.op =
366 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
367 else if (!strcmp(attr->attr.name,
368 "perf_time_interval_secs"))
369 new_op->upcall.req.param.op =
370 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
371 else if (!strcmp(attr->attr.name,
372 "perf_counter_reset"))
373 new_op->upcall.req.param.op =
374 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
376 else if (!strcmp(attr->attr.name,
378 new_op->upcall.req.param.op =
379 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
381 else if (!strcmp(attr->attr.name,
383 new_op->upcall.req.param.op =
384 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
386 else if (!strcmp(attr->attr.name,
387 "readahead_count_size"))
388 new_op->upcall.req.param.op =
389 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
390 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
391 if (!strcmp(attr->attr.name, "timeout_msecs"))
392 new_op->upcall.req.param.op =
393 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
395 if (!strcmp(attr->attr.name, "hard_limit"))
396 new_op->upcall.req.param.op =
397 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
399 if (!strcmp(attr->attr.name, "soft_limit"))
400 new_op->upcall.req.param.op =
401 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
403 if (!strcmp(attr->attr.name, "reclaim_percentage"))
404 new_op->upcall.req.param.op =
405 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
407 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
408 if (!strcmp(attr->attr.name, "timeout_secs"))
409 new_op->upcall.req.param.op =
410 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
412 if (!strcmp(attr->attr.name, "hard_limit"))
413 new_op->upcall.req.param.op =
414 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
416 if (!strcmp(attr->attr.name, "soft_limit"))
417 new_op->upcall.req.param.op =
418 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
420 if (!strcmp(attr->attr.name, "reclaim_percentage"))
421 new_op->upcall.req.param.op =
422 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
424 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
425 if (!strcmp(attr->attr.name, "timeout_secs"))
426 new_op->upcall.req.param.op =
427 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
429 if (!strcmp(attr->attr.name, "hard_limit"))
430 new_op->upcall.req.param.op =
431 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
433 if (!strcmp(attr->attr.name, "soft_limit"))
434 new_op->upcall.req.param.op =
435 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
437 if (!strcmp(attr->attr.name, "reclaim_percentage"))
438 new_op->upcall.req.param.op =
439 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
441 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
442 if (!strcmp(attr->attr.name, "timeout_msecs"))
443 new_op->upcall.req.param.op =
444 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
446 if (!strcmp(attr->attr.name, "hard_limit"))
447 new_op->upcall.req.param.op =
448 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
450 if (!strcmp(attr->attr.name, "soft_limit"))
451 new_op->upcall.req.param.op =
452 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
454 if (!strcmp(attr->attr.name, "reclaim_percentage"))
455 new_op->upcall.req.param.op =
456 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
458 } else if (!strcmp(kobj->name, PC_KOBJ_ID)) {
459 if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID))
460 new_op->upcall.req.perf_count.type =
461 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
463 if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID))
464 new_op->upcall.req.perf_count.type =
465 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
467 if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID))
468 new_op->upcall.req.perf_count.type =
469 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
472 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
479 if (strcmp(kobj->name, PC_KOBJ_ID))
480 ser_op_type = "orangefs_param";
482 ser_op_type = "orangefs_perf_count";
485 * The service_operation will return an errno return code on
486 * error, and zero on success.
488 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
492 if (strcmp(kobj->name, PC_KOBJ_ID)) {
493 if (new_op->upcall.req.param.op ==
494 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
495 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
496 (int)new_op->downcall.resp.param.u.
498 (int)new_op->downcall.resp.param.u.
501 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
502 (int)new_op->downcall.resp.param.u.value64);
509 new_op->downcall.resp.perf_count.buffer);
520 * pass attribute values back to userspace with a service operation.
522 * We have to do a memory allocation, an sscanf and a service operation.
523 * And we have to evaluate what the user entered, to make sure the
524 * value is within the range supported by the attribute. So, there's
525 * a lot of return code checking and mapping going on here.
527 * We want to return 1 if we think everything went OK, and
530 static ssize_t sysfs_service_op_store(struct kobject *kobj,
531 struct orangefs_attribute *attr, const char *buf, size_t count)
533 struct orangefs_kernel_op_s *new_op = NULL;
537 gossip_debug(GOSSIP_SYSFS_DEBUG,
538 "sysfs_service_op_store: id:%s:\n",
541 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
543 return -EINVAL; /* sic */
545 /* Can't do a service_operation if the client is not running... */
546 rc = is_daemon_in_service();
548 pr_info("%s: Client not running :%d:\n",
550 is_daemon_in_service());
555 * The value we want to send back to userspace is in buf, unless this
556 * there are two parameters, which is specially handled below.
558 if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) ||
559 strcmp(attr->attr.name, "readahead_count_size")) {
560 rc = kstrtoint(buf, 0, &val);
565 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
567 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
568 if (!strcmp(attr->attr.name, "perf_history_size")) {
570 new_op->upcall.req.param.op =
571 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
576 } else if (!strcmp(attr->attr.name,
577 "perf_time_interval_secs")) {
579 new_op->upcall.req.param.op =
580 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
585 } else if (!strcmp(attr->attr.name,
586 "perf_counter_reset")) {
587 if ((val == 0) || (val == 1)) {
588 new_op->upcall.req.param.op =
589 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
594 } else if (!strcmp(attr->attr.name,
595 "readahead_count")) {
597 new_op->upcall.req.param.op =
598 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
603 } else if (!strcmp(attr->attr.name,
606 new_op->upcall.req.param.op =
607 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
612 } else if (!strcmp(attr->attr.name,
613 "readahead_count_size")) {
615 rc = sscanf(buf, "%d %d", &val1, &val2);
620 if ((val1 >= 0) && (val2 >= 0)) {
621 new_op->upcall.req.param.op =
622 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
627 new_op->upcall.req.param.u.value32[0] = val1;
628 new_op->upcall.req.param.u.value32[1] = val2;
630 } else if (!strcmp(attr->attr.name,
631 "perf_counter_reset")) {
633 new_op->upcall.req.param.op =
634 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
641 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
642 if (!strcmp(attr->attr.name, "hard_limit")) {
644 new_op->upcall.req.param.op =
645 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
650 } else if (!strcmp(attr->attr.name, "soft_limit")) {
652 new_op->upcall.req.param.op =
653 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
658 } else if (!strcmp(attr->attr.name,
659 "reclaim_percentage")) {
660 if ((val > -1) && (val < 101)) {
661 new_op->upcall.req.param.op =
662 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
667 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
669 new_op->upcall.req.param.op =
670 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
677 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
678 if (!strcmp(attr->attr.name, "hard_limit")) {
680 new_op->upcall.req.param.op =
681 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
686 } else if (!strcmp(attr->attr.name, "soft_limit")) {
688 new_op->upcall.req.param.op =
689 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
694 } else if (!strcmp(attr->attr.name,
695 "reclaim_percentage")) {
696 if ((val > -1) && (val < 101)) {
697 new_op->upcall.req.param.op =
698 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
703 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
705 new_op->upcall.req.param.op =
706 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
713 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
714 if (!strcmp(attr->attr.name, "hard_limit")) {
716 new_op->upcall.req.param.op =
717 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
722 } else if (!strcmp(attr->attr.name, "soft_limit")) {
724 new_op->upcall.req.param.op =
725 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
730 } else if (!strcmp(attr->attr.name,
731 "reclaim_percentage")) {
732 if ((val > -1) && (val < 101)) {
733 new_op->upcall.req.param.op =
734 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
739 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
741 new_op->upcall.req.param.op =
742 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
749 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
750 if (!strcmp(attr->attr.name, "hard_limit")) {
752 new_op->upcall.req.param.op =
753 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
758 } else if (!strcmp(attr->attr.name, "soft_limit")) {
760 new_op->upcall.req.param.op =
761 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
766 } else if (!strcmp(attr->attr.name,
767 "reclaim_percentage")) {
768 if ((val > -1) && (val < 101)) {
769 new_op->upcall.req.param.op =
770 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
775 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
777 new_op->upcall.req.param.op =
778 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
786 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
792 new_op->upcall.req.param.u.value64 = val;
796 * The service_operation will return a errno return code on
797 * error, and zero on success.
799 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
802 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
812 if (rc == -ENOMEM || rc == 0)
818 static struct orangefs_attribute op_timeout_secs_attribute =
819 __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
821 static struct orangefs_attribute slot_timeout_secs_attribute =
822 __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
824 static struct orangefs_attribute dcache_timeout_msecs_attribute =
825 __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
827 static struct orangefs_attribute getattr_timeout_msecs_attribute =
828 __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
830 static struct orangefs_attribute readahead_count_attribute =
831 __ATTR(readahead_count, 0664, sysfs_service_op_show,
832 sysfs_service_op_store);
834 static struct orangefs_attribute readahead_size_attribute =
835 __ATTR(readahead_size, 0664, sysfs_service_op_show,
836 sysfs_service_op_store);
838 static struct orangefs_attribute readahead_count_size_attribute =
839 __ATTR(readahead_count_size, 0664, sysfs_service_op_show,
840 sysfs_service_op_store);
842 static struct orangefs_attribute perf_counter_reset_attribute =
843 __ATTR(perf_counter_reset,
845 sysfs_service_op_show,
846 sysfs_service_op_store);
848 static struct orangefs_attribute perf_history_size_attribute =
849 __ATTR(perf_history_size,
851 sysfs_service_op_show,
852 sysfs_service_op_store);
854 static struct orangefs_attribute perf_time_interval_secs_attribute =
855 __ATTR(perf_time_interval_secs,
857 sysfs_service_op_show,
858 sysfs_service_op_store);
860 static struct attribute *orangefs_default_attrs[] = {
861 &op_timeout_secs_attribute.attr,
862 &slot_timeout_secs_attribute.attr,
863 &dcache_timeout_msecs_attribute.attr,
864 &getattr_timeout_msecs_attribute.attr,
865 &readahead_count_attribute.attr,
866 &readahead_size_attribute.attr,
867 &readahead_count_size_attribute.attr,
868 &perf_counter_reset_attribute.attr,
869 &perf_history_size_attribute.attr,
870 &perf_time_interval_secs_attribute.attr,
874 static struct kobj_type orangefs_ktype = {
875 .sysfs_ops = &orangefs_sysfs_ops,
876 .default_attrs = orangefs_default_attrs,
879 static struct orangefs_attribute acache_hard_limit_attribute =
882 sysfs_service_op_show,
883 sysfs_service_op_store);
885 static struct orangefs_attribute acache_reclaim_percent_attribute =
886 __ATTR(reclaim_percentage,
888 sysfs_service_op_show,
889 sysfs_service_op_store);
891 static struct orangefs_attribute acache_soft_limit_attribute =
894 sysfs_service_op_show,
895 sysfs_service_op_store);
897 static struct orangefs_attribute acache_timeout_msecs_attribute =
898 __ATTR(timeout_msecs,
900 sysfs_service_op_show,
901 sysfs_service_op_store);
903 static struct attribute *acache_orangefs_default_attrs[] = {
904 &acache_hard_limit_attribute.attr,
905 &acache_reclaim_percent_attribute.attr,
906 &acache_soft_limit_attribute.attr,
907 &acache_timeout_msecs_attribute.attr,
911 static struct kobj_type acache_orangefs_ktype = {
912 .sysfs_ops = &acache_orangefs_sysfs_ops,
913 .default_attrs = acache_orangefs_default_attrs,
916 static struct orangefs_attribute capcache_hard_limit_attribute =
919 sysfs_service_op_show,
920 sysfs_service_op_store);
922 static struct orangefs_attribute capcache_reclaim_percent_attribute =
923 __ATTR(reclaim_percentage,
925 sysfs_service_op_show,
926 sysfs_service_op_store);
928 static struct orangefs_attribute capcache_soft_limit_attribute =
931 sysfs_service_op_show,
932 sysfs_service_op_store);
934 static struct orangefs_attribute capcache_timeout_secs_attribute =
937 sysfs_service_op_show,
938 sysfs_service_op_store);
940 static struct attribute *capcache_orangefs_default_attrs[] = {
941 &capcache_hard_limit_attribute.attr,
942 &capcache_reclaim_percent_attribute.attr,
943 &capcache_soft_limit_attribute.attr,
944 &capcache_timeout_secs_attribute.attr,
948 static struct kobj_type capcache_orangefs_ktype = {
949 .sysfs_ops = &capcache_orangefs_sysfs_ops,
950 .default_attrs = capcache_orangefs_default_attrs,
953 static struct orangefs_attribute ccache_hard_limit_attribute =
956 sysfs_service_op_show,
957 sysfs_service_op_store);
959 static struct orangefs_attribute ccache_reclaim_percent_attribute =
960 __ATTR(reclaim_percentage,
962 sysfs_service_op_show,
963 sysfs_service_op_store);
965 static struct orangefs_attribute ccache_soft_limit_attribute =
968 sysfs_service_op_show,
969 sysfs_service_op_store);
971 static struct orangefs_attribute ccache_timeout_secs_attribute =
974 sysfs_service_op_show,
975 sysfs_service_op_store);
977 static struct attribute *ccache_orangefs_default_attrs[] = {
978 &ccache_hard_limit_attribute.attr,
979 &ccache_reclaim_percent_attribute.attr,
980 &ccache_soft_limit_attribute.attr,
981 &ccache_timeout_secs_attribute.attr,
985 static struct kobj_type ccache_orangefs_ktype = {
986 .sysfs_ops = &ccache_orangefs_sysfs_ops,
987 .default_attrs = ccache_orangefs_default_attrs,
990 static struct orangefs_attribute ncache_hard_limit_attribute =
993 sysfs_service_op_show,
994 sysfs_service_op_store);
996 static struct orangefs_attribute ncache_reclaim_percent_attribute =
997 __ATTR(reclaim_percentage,
999 sysfs_service_op_show,
1000 sysfs_service_op_store);
1002 static struct orangefs_attribute ncache_soft_limit_attribute =
1005 sysfs_service_op_show,
1006 sysfs_service_op_store);
1008 static struct orangefs_attribute ncache_timeout_msecs_attribute =
1009 __ATTR(timeout_msecs,
1011 sysfs_service_op_show,
1012 sysfs_service_op_store);
1014 static struct attribute *ncache_orangefs_default_attrs[] = {
1015 &ncache_hard_limit_attribute.attr,
1016 &ncache_reclaim_percent_attribute.attr,
1017 &ncache_soft_limit_attribute.attr,
1018 &ncache_timeout_msecs_attribute.attr,
1022 static struct kobj_type ncache_orangefs_ktype = {
1023 .sysfs_ops = &ncache_orangefs_sysfs_ops,
1024 .default_attrs = ncache_orangefs_default_attrs,
1027 static struct orangefs_attribute pc_acache_attribute =
1030 sysfs_service_op_show,
1033 static struct orangefs_attribute pc_capcache_attribute =
1036 sysfs_service_op_show,
1039 static struct orangefs_attribute pc_ncache_attribute =
1042 sysfs_service_op_show,
1045 static struct attribute *pc_orangefs_default_attrs[] = {
1046 &pc_acache_attribute.attr,
1047 &pc_capcache_attribute.attr,
1048 &pc_ncache_attribute.attr,
1052 static struct kobj_type pc_orangefs_ktype = {
1053 .sysfs_ops = &pc_orangefs_sysfs_ops,
1054 .default_attrs = pc_orangefs_default_attrs,
1057 static struct orangefs_attribute stats_reads_attribute =
1063 static struct orangefs_attribute stats_writes_attribute =
1069 static struct attribute *stats_orangefs_default_attrs[] = {
1070 &stats_reads_attribute.attr,
1071 &stats_writes_attribute.attr,
1075 static struct kobj_type stats_orangefs_ktype = {
1076 .sysfs_ops = &stats_orangefs_sysfs_ops,
1077 .default_attrs = stats_orangefs_default_attrs,
1080 static struct kobject *orangefs_obj;
1081 static struct kobject *acache_orangefs_obj;
1082 static struct kobject *capcache_orangefs_obj;
1083 static struct kobject *ccache_orangefs_obj;
1084 static struct kobject *ncache_orangefs_obj;
1085 static struct kobject *pc_orangefs_obj;
1086 static struct kobject *stats_orangefs_obj;
1088 int orangefs_sysfs_init(void)
1092 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1094 /* create /sys/fs/orangefs. */
1095 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1099 rc = kobject_init_and_add(orangefs_obj,
1107 kobject_uevent(orangefs_obj, KOBJ_ADD);
1109 /* create /sys/fs/orangefs/acache. */
1110 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1111 if (!acache_orangefs_obj) {
1116 rc = kobject_init_and_add(acache_orangefs_obj,
1117 &acache_orangefs_ktype,
1122 goto acache_obj_bail;
1124 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
1126 /* create /sys/fs/orangefs/capcache. */
1127 capcache_orangefs_obj =
1128 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1129 if (!capcache_orangefs_obj) {
1131 goto acache_obj_bail;
1134 rc = kobject_init_and_add(capcache_orangefs_obj,
1135 &capcache_orangefs_ktype,
1139 goto capcache_obj_bail;
1141 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
1143 /* create /sys/fs/orangefs/ccache. */
1144 ccache_orangefs_obj =
1145 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1146 if (!ccache_orangefs_obj) {
1148 goto capcache_obj_bail;
1151 rc = kobject_init_and_add(ccache_orangefs_obj,
1152 &ccache_orangefs_ktype,
1156 goto ccache_obj_bail;
1158 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
1160 /* create /sys/fs/orangefs/ncache. */
1161 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1162 if (!ncache_orangefs_obj) {
1164 goto ccache_obj_bail;
1167 rc = kobject_init_and_add(ncache_orangefs_obj,
1168 &ncache_orangefs_ktype,
1173 goto ncache_obj_bail;
1175 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
1177 /* create /sys/fs/orangefs/perf_counters. */
1178 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1179 if (!pc_orangefs_obj) {
1181 goto ncache_obj_bail;
1184 rc = kobject_init_and_add(pc_orangefs_obj,
1192 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
1194 /* create /sys/fs/orangefs/stats. */
1195 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1196 if (!stats_orangefs_obj) {
1201 rc = kobject_init_and_add(stats_orangefs_obj,
1202 &stats_orangefs_ktype,
1207 goto stats_obj_bail;
1209 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
1213 kobject_put(stats_orangefs_obj);
1215 kobject_put(pc_orangefs_obj);
1217 kobject_put(ncache_orangefs_obj);
1219 kobject_put(ccache_orangefs_obj);
1221 kobject_put(capcache_orangefs_obj);
1223 kobject_put(acache_orangefs_obj);
1225 kobject_put(orangefs_obj);
1230 void orangefs_sysfs_exit(void)
1232 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1233 kobject_put(acache_orangefs_obj);
1234 kobject_put(capcache_orangefs_obj);
1235 kobject_put(ccache_orangefs_obj);
1236 kobject_put(ncache_orangefs_obj);
1237 kobject_put(pc_orangefs_obj);
1238 kobject_put(stats_orangefs_obj);
1239 kobject_put(orangefs_obj);