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"
143 * Every item calls orangefs_attr_show and orangefs_attr_store through
144 * orangefs_sysfs_ops. They look at the orangefs_attributes further below to
145 * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or
146 * sysfs_service_op_store.
149 struct orangefs_attribute {
150 struct attribute attr;
151 ssize_t (*show)(struct kobject *kobj,
152 struct orangefs_attribute *attr,
154 ssize_t (*store)(struct kobject *kobj,
155 struct orangefs_attribute *attr,
160 static ssize_t orangefs_attr_show(struct kobject *kobj,
161 struct attribute *attr,
164 struct orangefs_attribute *attribute;
166 attribute = container_of(attr, struct orangefs_attribute, attr);
167 if (!attribute->show)
169 return attribute->show(kobj, attribute, buf);
172 static ssize_t orangefs_attr_store(struct kobject *kobj,
173 struct attribute *attr,
177 struct orangefs_attribute *attribute;
179 if (!strcmp(kobj->name, PC_KOBJ_ID) ||
180 !strcmp(kobj->name, STATS_KOBJ_ID))
183 attribute = container_of(attr, struct orangefs_attribute, attr);
184 if (!attribute->store)
186 return attribute->store(kobj, attribute, buf, len);
189 static const struct sysfs_ops orangefs_sysfs_ops = {
190 .show = orangefs_attr_show,
191 .store = orangefs_attr_store,
194 static ssize_t sysfs_int_show(struct kobject *kobj,
195 struct orangefs_attribute *attr, char *buf)
199 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
202 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
203 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
209 } else if (!strcmp(attr->attr.name,
210 "slot_timeout_secs")) {
216 } else if (!strcmp(attr->attr.name,
217 "dcache_timeout_msecs")) {
221 orangefs_dcache_timeout_msecs);
223 } else if (!strcmp(attr->attr.name,
224 "getattr_timeout_msecs")) {
228 orangefs_getattr_timeout_msecs);
234 } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
235 if (!strcmp(attr->attr.name, "reads")) {
239 orangefs_stats.reads);
241 } else if (!strcmp(attr->attr.name, "writes")) {
245 orangefs_stats.writes);
257 static ssize_t sysfs_int_store(struct kobject *kobj,
258 struct orangefs_attribute *attr, const char *buf, size_t count)
262 gossip_debug(GOSSIP_SYSFS_DEBUG,
263 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
264 attr->attr.name, buf);
266 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
267 rc = kstrtoint(buf, 0, &op_timeout_secs);
269 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
270 rc = kstrtoint(buf, 0, &slot_timeout_secs);
272 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
273 rc = kstrtoint(buf, 0, &orangefs_dcache_timeout_msecs);
275 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
276 rc = kstrtoint(buf, 0, &orangefs_getattr_timeout_msecs);
292 * obtain attribute values from userspace with a service operation.
294 static ssize_t sysfs_service_op_show(struct kobject *kobj,
295 struct orangefs_attribute *attr, char *buf)
297 struct orangefs_kernel_op_s *new_op = NULL;
299 char *ser_op_type = NULL;
302 gossip_debug(GOSSIP_SYSFS_DEBUG,
303 "sysfs_service_op_show: id:%s:\n",
306 if (strcmp(kobj->name, PC_KOBJ_ID))
307 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
309 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
311 new_op = op_alloc(op_alloc_type);
315 /* Can't do a service_operation if the client is not running... */
316 rc = is_daemon_in_service();
318 pr_info_ratelimited("%s: Client not running :%d:\n",
320 is_daemon_in_service());
324 if (strcmp(kobj->name, PC_KOBJ_ID))
325 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
327 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
328 /* Drop unsupported requests first. */
329 if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
330 (!strcmp(attr->attr.name, "readahead_count") ||
331 !strcmp(attr->attr.name, "readahead_size") ||
332 !strcmp(attr->attr.name, "readahead_count_size"))) {
337 if (!strcmp(attr->attr.name, "perf_history_size"))
338 new_op->upcall.req.param.op =
339 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
340 else if (!strcmp(attr->attr.name,
341 "perf_time_interval_secs"))
342 new_op->upcall.req.param.op =
343 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
344 else if (!strcmp(attr->attr.name,
345 "perf_counter_reset"))
346 new_op->upcall.req.param.op =
347 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
349 else if (!strcmp(attr->attr.name,
351 new_op->upcall.req.param.op =
352 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
354 else if (!strcmp(attr->attr.name,
356 new_op->upcall.req.param.op =
357 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
359 else if (!strcmp(attr->attr.name,
360 "readahead_count_size"))
361 new_op->upcall.req.param.op =
362 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
363 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
364 if (!strcmp(attr->attr.name, "timeout_msecs"))
365 new_op->upcall.req.param.op =
366 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
368 if (!strcmp(attr->attr.name, "hard_limit"))
369 new_op->upcall.req.param.op =
370 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
372 if (!strcmp(attr->attr.name, "soft_limit"))
373 new_op->upcall.req.param.op =
374 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
376 if (!strcmp(attr->attr.name, "reclaim_percentage"))
377 new_op->upcall.req.param.op =
378 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
380 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
381 if (!strcmp(attr->attr.name, "timeout_secs"))
382 new_op->upcall.req.param.op =
383 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
385 if (!strcmp(attr->attr.name, "hard_limit"))
386 new_op->upcall.req.param.op =
387 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
389 if (!strcmp(attr->attr.name, "soft_limit"))
390 new_op->upcall.req.param.op =
391 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
393 if (!strcmp(attr->attr.name, "reclaim_percentage"))
394 new_op->upcall.req.param.op =
395 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
397 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
398 if (!strcmp(attr->attr.name, "timeout_secs"))
399 new_op->upcall.req.param.op =
400 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
402 if (!strcmp(attr->attr.name, "hard_limit"))
403 new_op->upcall.req.param.op =
404 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
406 if (!strcmp(attr->attr.name, "soft_limit"))
407 new_op->upcall.req.param.op =
408 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
410 if (!strcmp(attr->attr.name, "reclaim_percentage"))
411 new_op->upcall.req.param.op =
412 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
414 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
415 if (!strcmp(attr->attr.name, "timeout_msecs"))
416 new_op->upcall.req.param.op =
417 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
419 if (!strcmp(attr->attr.name, "hard_limit"))
420 new_op->upcall.req.param.op =
421 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
423 if (!strcmp(attr->attr.name, "soft_limit"))
424 new_op->upcall.req.param.op =
425 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
427 if (!strcmp(attr->attr.name, "reclaim_percentage"))
428 new_op->upcall.req.param.op =
429 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
431 } else if (!strcmp(kobj->name, PC_KOBJ_ID)) {
432 if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID))
433 new_op->upcall.req.perf_count.type =
434 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
436 if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID))
437 new_op->upcall.req.perf_count.type =
438 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
440 if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID))
441 new_op->upcall.req.perf_count.type =
442 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
445 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
452 if (strcmp(kobj->name, PC_KOBJ_ID))
453 ser_op_type = "orangefs_param";
455 ser_op_type = "orangefs_perf_count";
458 * The service_operation will return an errno return code on
459 * error, and zero on success.
461 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
465 if (strcmp(kobj->name, PC_KOBJ_ID)) {
466 if (new_op->upcall.req.param.op ==
467 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
468 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
469 (int)new_op->downcall.resp.param.u.
471 (int)new_op->downcall.resp.param.u.
474 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
475 (int)new_op->downcall.resp.param.u.value64);
482 new_op->downcall.resp.perf_count.buffer);
493 * pass attribute values back to userspace with a service operation.
495 * We have to do a memory allocation, an sscanf and a service operation.
496 * And we have to evaluate what the user entered, to make sure the
497 * value is within the range supported by the attribute. So, there's
498 * a lot of return code checking and mapping going on here.
500 * We want to return 1 if we think everything went OK, and
503 static ssize_t sysfs_service_op_store(struct kobject *kobj,
504 struct orangefs_attribute *attr, const char *buf, size_t count)
506 struct orangefs_kernel_op_s *new_op = NULL;
510 gossip_debug(GOSSIP_SYSFS_DEBUG,
511 "sysfs_service_op_store: id:%s:\n",
514 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
516 return -EINVAL; /* sic */
518 /* Can't do a service_operation if the client is not running... */
519 rc = is_daemon_in_service();
521 pr_info("%s: Client not running :%d:\n",
523 is_daemon_in_service());
528 * The value we want to send back to userspace is in buf, unless this
529 * there are two parameters, which is specially handled below.
531 if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) ||
532 strcmp(attr->attr.name, "readahead_count_size")) {
533 rc = kstrtoint(buf, 0, &val);
538 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
540 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
541 /* Drop unsupported requests first. */
542 if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
543 (!strcmp(attr->attr.name, "readahead_count") ||
544 !strcmp(attr->attr.name, "readahead_size") ||
545 !strcmp(attr->attr.name, "readahead_count_size"))) {
550 if (!strcmp(attr->attr.name, "perf_history_size")) {
552 new_op->upcall.req.param.op =
553 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
558 } else if (!strcmp(attr->attr.name,
559 "perf_time_interval_secs")) {
561 new_op->upcall.req.param.op =
562 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
567 } else if (!strcmp(attr->attr.name,
568 "perf_counter_reset")) {
569 if ((val == 0) || (val == 1)) {
570 new_op->upcall.req.param.op =
571 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
576 } else if (!strcmp(attr->attr.name,
577 "readahead_count")) {
579 new_op->upcall.req.param.op =
580 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
585 } else if (!strcmp(attr->attr.name,
588 new_op->upcall.req.param.op =
589 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
594 } else if (!strcmp(attr->attr.name,
595 "readahead_count_size")) {
597 rc = sscanf(buf, "%d %d", &val1, &val2);
602 if ((val1 >= 0) && (val2 >= 0)) {
603 new_op->upcall.req.param.op =
604 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
609 new_op->upcall.req.param.u.value32[0] = val1;
610 new_op->upcall.req.param.u.value32[1] = val2;
612 } else if (!strcmp(attr->attr.name,
613 "perf_counter_reset")) {
615 new_op->upcall.req.param.op =
616 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
623 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
624 if (!strcmp(attr->attr.name, "hard_limit")) {
626 new_op->upcall.req.param.op =
627 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
632 } else if (!strcmp(attr->attr.name, "soft_limit")) {
634 new_op->upcall.req.param.op =
635 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
640 } else if (!strcmp(attr->attr.name,
641 "reclaim_percentage")) {
642 if ((val > -1) && (val < 101)) {
643 new_op->upcall.req.param.op =
644 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
649 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
651 new_op->upcall.req.param.op =
652 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
659 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
660 if (!strcmp(attr->attr.name, "hard_limit")) {
662 new_op->upcall.req.param.op =
663 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
668 } else if (!strcmp(attr->attr.name, "soft_limit")) {
670 new_op->upcall.req.param.op =
671 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
676 } else if (!strcmp(attr->attr.name,
677 "reclaim_percentage")) {
678 if ((val > -1) && (val < 101)) {
679 new_op->upcall.req.param.op =
680 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
685 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
687 new_op->upcall.req.param.op =
688 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
695 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
696 if (!strcmp(attr->attr.name, "hard_limit")) {
698 new_op->upcall.req.param.op =
699 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
704 } else if (!strcmp(attr->attr.name, "soft_limit")) {
706 new_op->upcall.req.param.op =
707 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
712 } else if (!strcmp(attr->attr.name,
713 "reclaim_percentage")) {
714 if ((val > -1) && (val < 101)) {
715 new_op->upcall.req.param.op =
716 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
721 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
723 new_op->upcall.req.param.op =
724 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
731 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
732 if (!strcmp(attr->attr.name, "hard_limit")) {
734 new_op->upcall.req.param.op =
735 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
740 } else if (!strcmp(attr->attr.name, "soft_limit")) {
742 new_op->upcall.req.param.op =
743 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
748 } else if (!strcmp(attr->attr.name,
749 "reclaim_percentage")) {
750 if ((val > -1) && (val < 101)) {
751 new_op->upcall.req.param.op =
752 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
757 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
759 new_op->upcall.req.param.op =
760 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
768 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
774 new_op->upcall.req.param.u.value64 = val;
778 * The service_operation will return a errno return code on
779 * error, and zero on success.
781 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
784 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
794 if (rc == -ENOMEM || rc == 0)
800 static struct orangefs_attribute op_timeout_secs_attribute =
801 __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
803 static struct orangefs_attribute slot_timeout_secs_attribute =
804 __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
806 static struct orangefs_attribute dcache_timeout_msecs_attribute =
807 __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
809 static struct orangefs_attribute getattr_timeout_msecs_attribute =
810 __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
812 static struct orangefs_attribute readahead_count_attribute =
813 __ATTR(readahead_count, 0664, sysfs_service_op_show,
814 sysfs_service_op_store);
816 static struct orangefs_attribute readahead_size_attribute =
817 __ATTR(readahead_size, 0664, sysfs_service_op_show,
818 sysfs_service_op_store);
820 static struct orangefs_attribute readahead_count_size_attribute =
821 __ATTR(readahead_count_size, 0664, sysfs_service_op_show,
822 sysfs_service_op_store);
824 static struct orangefs_attribute perf_counter_reset_attribute =
825 __ATTR(perf_counter_reset,
827 sysfs_service_op_show,
828 sysfs_service_op_store);
830 static struct orangefs_attribute perf_history_size_attribute =
831 __ATTR(perf_history_size,
833 sysfs_service_op_show,
834 sysfs_service_op_store);
836 static struct orangefs_attribute perf_time_interval_secs_attribute =
837 __ATTR(perf_time_interval_secs,
839 sysfs_service_op_show,
840 sysfs_service_op_store);
842 static struct attribute *orangefs_default_attrs[] = {
843 &op_timeout_secs_attribute.attr,
844 &slot_timeout_secs_attribute.attr,
845 &dcache_timeout_msecs_attribute.attr,
846 &getattr_timeout_msecs_attribute.attr,
847 &readahead_count_attribute.attr,
848 &readahead_size_attribute.attr,
849 &readahead_count_size_attribute.attr,
850 &perf_counter_reset_attribute.attr,
851 &perf_history_size_attribute.attr,
852 &perf_time_interval_secs_attribute.attr,
856 static struct kobj_type orangefs_ktype = {
857 .sysfs_ops = &orangefs_sysfs_ops,
858 .default_attrs = orangefs_default_attrs,
861 static struct orangefs_attribute acache_hard_limit_attribute =
864 sysfs_service_op_show,
865 sysfs_service_op_store);
867 static struct orangefs_attribute acache_reclaim_percent_attribute =
868 __ATTR(reclaim_percentage,
870 sysfs_service_op_show,
871 sysfs_service_op_store);
873 static struct orangefs_attribute acache_soft_limit_attribute =
876 sysfs_service_op_show,
877 sysfs_service_op_store);
879 static struct orangefs_attribute acache_timeout_msecs_attribute =
880 __ATTR(timeout_msecs,
882 sysfs_service_op_show,
883 sysfs_service_op_store);
885 static struct attribute *acache_orangefs_default_attrs[] = {
886 &acache_hard_limit_attribute.attr,
887 &acache_reclaim_percent_attribute.attr,
888 &acache_soft_limit_attribute.attr,
889 &acache_timeout_msecs_attribute.attr,
893 static struct kobj_type acache_orangefs_ktype = {
894 .sysfs_ops = &orangefs_sysfs_ops,
895 .default_attrs = acache_orangefs_default_attrs,
898 static struct orangefs_attribute capcache_hard_limit_attribute =
901 sysfs_service_op_show,
902 sysfs_service_op_store);
904 static struct orangefs_attribute capcache_reclaim_percent_attribute =
905 __ATTR(reclaim_percentage,
907 sysfs_service_op_show,
908 sysfs_service_op_store);
910 static struct orangefs_attribute capcache_soft_limit_attribute =
913 sysfs_service_op_show,
914 sysfs_service_op_store);
916 static struct orangefs_attribute capcache_timeout_secs_attribute =
919 sysfs_service_op_show,
920 sysfs_service_op_store);
922 static struct attribute *capcache_orangefs_default_attrs[] = {
923 &capcache_hard_limit_attribute.attr,
924 &capcache_reclaim_percent_attribute.attr,
925 &capcache_soft_limit_attribute.attr,
926 &capcache_timeout_secs_attribute.attr,
930 static struct kobj_type capcache_orangefs_ktype = {
931 .sysfs_ops = &orangefs_sysfs_ops,
932 .default_attrs = capcache_orangefs_default_attrs,
935 static struct orangefs_attribute ccache_hard_limit_attribute =
938 sysfs_service_op_show,
939 sysfs_service_op_store);
941 static struct orangefs_attribute ccache_reclaim_percent_attribute =
942 __ATTR(reclaim_percentage,
944 sysfs_service_op_show,
945 sysfs_service_op_store);
947 static struct orangefs_attribute ccache_soft_limit_attribute =
950 sysfs_service_op_show,
951 sysfs_service_op_store);
953 static struct orangefs_attribute ccache_timeout_secs_attribute =
956 sysfs_service_op_show,
957 sysfs_service_op_store);
959 static struct attribute *ccache_orangefs_default_attrs[] = {
960 &ccache_hard_limit_attribute.attr,
961 &ccache_reclaim_percent_attribute.attr,
962 &ccache_soft_limit_attribute.attr,
963 &ccache_timeout_secs_attribute.attr,
967 static struct kobj_type ccache_orangefs_ktype = {
968 .sysfs_ops = &orangefs_sysfs_ops,
969 .default_attrs = ccache_orangefs_default_attrs,
972 static struct orangefs_attribute ncache_hard_limit_attribute =
975 sysfs_service_op_show,
976 sysfs_service_op_store);
978 static struct orangefs_attribute ncache_reclaim_percent_attribute =
979 __ATTR(reclaim_percentage,
981 sysfs_service_op_show,
982 sysfs_service_op_store);
984 static struct orangefs_attribute ncache_soft_limit_attribute =
987 sysfs_service_op_show,
988 sysfs_service_op_store);
990 static struct orangefs_attribute ncache_timeout_msecs_attribute =
991 __ATTR(timeout_msecs,
993 sysfs_service_op_show,
994 sysfs_service_op_store);
996 static struct attribute *ncache_orangefs_default_attrs[] = {
997 &ncache_hard_limit_attribute.attr,
998 &ncache_reclaim_percent_attribute.attr,
999 &ncache_soft_limit_attribute.attr,
1000 &ncache_timeout_msecs_attribute.attr,
1004 static struct kobj_type ncache_orangefs_ktype = {
1005 .sysfs_ops = &orangefs_sysfs_ops,
1006 .default_attrs = ncache_orangefs_default_attrs,
1009 static struct orangefs_attribute pc_acache_attribute =
1012 sysfs_service_op_show,
1015 static struct orangefs_attribute pc_capcache_attribute =
1018 sysfs_service_op_show,
1021 static struct orangefs_attribute pc_ncache_attribute =
1024 sysfs_service_op_show,
1027 static struct attribute *pc_orangefs_default_attrs[] = {
1028 &pc_acache_attribute.attr,
1029 &pc_capcache_attribute.attr,
1030 &pc_ncache_attribute.attr,
1034 static struct kobj_type pc_orangefs_ktype = {
1035 .sysfs_ops = &orangefs_sysfs_ops,
1036 .default_attrs = pc_orangefs_default_attrs,
1039 static struct orangefs_attribute stats_reads_attribute =
1045 static struct orangefs_attribute stats_writes_attribute =
1051 static struct attribute *stats_orangefs_default_attrs[] = {
1052 &stats_reads_attribute.attr,
1053 &stats_writes_attribute.attr,
1057 static struct kobj_type stats_orangefs_ktype = {
1058 .sysfs_ops = &orangefs_sysfs_ops,
1059 .default_attrs = stats_orangefs_default_attrs,
1062 static struct kobject *orangefs_obj;
1063 static struct kobject *acache_orangefs_obj;
1064 static struct kobject *capcache_orangefs_obj;
1065 static struct kobject *ccache_orangefs_obj;
1066 static struct kobject *ncache_orangefs_obj;
1067 static struct kobject *pc_orangefs_obj;
1068 static struct kobject *stats_orangefs_obj;
1070 int orangefs_sysfs_init(void)
1074 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1076 /* create /sys/fs/orangefs. */
1077 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1081 rc = kobject_init_and_add(orangefs_obj,
1089 kobject_uevent(orangefs_obj, KOBJ_ADD);
1091 /* create /sys/fs/orangefs/acache. */
1092 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1093 if (!acache_orangefs_obj) {
1098 rc = kobject_init_and_add(acache_orangefs_obj,
1099 &acache_orangefs_ktype,
1104 goto acache_obj_bail;
1106 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
1108 /* create /sys/fs/orangefs/capcache. */
1109 capcache_orangefs_obj =
1110 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1111 if (!capcache_orangefs_obj) {
1113 goto acache_obj_bail;
1116 rc = kobject_init_and_add(capcache_orangefs_obj,
1117 &capcache_orangefs_ktype,
1121 goto capcache_obj_bail;
1123 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
1125 /* create /sys/fs/orangefs/ccache. */
1126 ccache_orangefs_obj =
1127 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1128 if (!ccache_orangefs_obj) {
1130 goto capcache_obj_bail;
1133 rc = kobject_init_and_add(ccache_orangefs_obj,
1134 &ccache_orangefs_ktype,
1138 goto ccache_obj_bail;
1140 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
1142 /* create /sys/fs/orangefs/ncache. */
1143 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1144 if (!ncache_orangefs_obj) {
1146 goto ccache_obj_bail;
1149 rc = kobject_init_and_add(ncache_orangefs_obj,
1150 &ncache_orangefs_ktype,
1155 goto ncache_obj_bail;
1157 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
1159 /* create /sys/fs/orangefs/perf_counters. */
1160 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1161 if (!pc_orangefs_obj) {
1163 goto ncache_obj_bail;
1166 rc = kobject_init_and_add(pc_orangefs_obj,
1174 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
1176 /* create /sys/fs/orangefs/stats. */
1177 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1178 if (!stats_orangefs_obj) {
1183 rc = kobject_init_and_add(stats_orangefs_obj,
1184 &stats_orangefs_ktype,
1189 goto stats_obj_bail;
1191 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
1195 kobject_put(stats_orangefs_obj);
1197 kobject_put(pc_orangefs_obj);
1199 kobject_put(ncache_orangefs_obj);
1201 kobject_put(ccache_orangefs_obj);
1203 kobject_put(capcache_orangefs_obj);
1205 kobject_put(acache_orangefs_obj);
1207 kobject_put(orangefs_obj);
1212 void orangefs_sysfs_exit(void)
1214 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1215 kobject_put(acache_orangefs_obj);
1216 kobject_put(capcache_orangefs_obj);
1217 kobject_put(ccache_orangefs_obj);
1218 kobject_put(ncache_orangefs_obj);
1219 kobject_put(pc_orangefs_obj);
1220 kobject_put(stats_orangefs_obj);
1221 kobject_put(orangefs_obj);