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/readahead_readcnt
96 * Contact: Martin Brandenburg <martin@omnibond.com>
98 * Number of buffers (in multiples of readahead_size)
99 * which can be read ahead for a single file at once.
101 * What: /sys/fs/orangefs/acache/...
103 * Contact: Martin Brandenburg <martin@omnibond.com>
105 * Attribute cache configurable settings.
108 * What: /sys/fs/orangefs/ncache/...
110 * Contact: Mike Marshall <hubcap@omnibond.com>
112 * Name cache configurable settings.
115 * What: /sys/fs/orangefs/capcache/...
117 * Contact: Mike Marshall <hubcap@omnibond.com>
119 * Capability cache configurable settings.
122 * What: /sys/fs/orangefs/ccache/...
124 * Contact: Mike Marshall <hubcap@omnibond.com>
126 * Credential cache configurable settings.
130 #include <linux/fs.h>
131 #include <linux/kobject.h>
132 #include <linux/string.h>
133 #include <linux/sysfs.h>
134 #include <linux/module.h>
135 #include <linux/init.h>
137 #include "protocol.h"
138 #include "orangefs-kernel.h"
139 #include "orangefs-sysfs.h"
141 #define ORANGEFS_KOBJ_ID "orangefs"
142 #define ACACHE_KOBJ_ID "acache"
143 #define CAPCACHE_KOBJ_ID "capcache"
144 #define CCACHE_KOBJ_ID "ccache"
145 #define NCACHE_KOBJ_ID "ncache"
146 #define PC_KOBJ_ID "pc"
147 #define STATS_KOBJ_ID "stats"
150 * Every item calls orangefs_attr_show and orangefs_attr_store through
151 * orangefs_sysfs_ops. They look at the orangefs_attributes further below to
152 * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or
153 * sysfs_service_op_store.
156 struct orangefs_attribute {
157 struct attribute attr;
158 ssize_t (*show)(struct kobject *kobj,
159 struct orangefs_attribute *attr,
161 ssize_t (*store)(struct kobject *kobj,
162 struct orangefs_attribute *attr,
167 static ssize_t orangefs_attr_show(struct kobject *kobj,
168 struct attribute *attr,
171 struct orangefs_attribute *attribute;
173 attribute = container_of(attr, struct orangefs_attribute, attr);
174 if (!attribute->show)
176 return attribute->show(kobj, attribute, buf);
179 static ssize_t orangefs_attr_store(struct kobject *kobj,
180 struct attribute *attr,
184 struct orangefs_attribute *attribute;
186 if (!strcmp(kobj->name, PC_KOBJ_ID) ||
187 !strcmp(kobj->name, STATS_KOBJ_ID))
190 attribute = container_of(attr, struct orangefs_attribute, attr);
191 if (!attribute->store)
193 return attribute->store(kobj, attribute, buf, len);
196 static const struct sysfs_ops orangefs_sysfs_ops = {
197 .show = orangefs_attr_show,
198 .store = orangefs_attr_store,
201 static ssize_t sysfs_int_show(struct kobject *kobj,
202 struct orangefs_attribute *attr, char *buf)
206 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
209 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
210 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
216 } else if (!strcmp(attr->attr.name,
217 "slot_timeout_secs")) {
223 } else if (!strcmp(attr->attr.name,
224 "dcache_timeout_msecs")) {
228 orangefs_dcache_timeout_msecs);
230 } else if (!strcmp(attr->attr.name,
231 "getattr_timeout_msecs")) {
235 orangefs_getattr_timeout_msecs);
241 } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
242 if (!strcmp(attr->attr.name, "reads")) {
246 orangefs_stats.reads);
248 } else if (!strcmp(attr->attr.name, "writes")) {
252 orangefs_stats.writes);
264 static ssize_t sysfs_int_store(struct kobject *kobj,
265 struct orangefs_attribute *attr, const char *buf, size_t count)
269 gossip_debug(GOSSIP_SYSFS_DEBUG,
270 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
271 attr->attr.name, buf);
273 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
274 rc = kstrtoint(buf, 0, &op_timeout_secs);
276 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
277 rc = kstrtoint(buf, 0, &slot_timeout_secs);
279 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
280 rc = kstrtoint(buf, 0, &orangefs_dcache_timeout_msecs);
282 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
283 rc = kstrtoint(buf, 0, &orangefs_getattr_timeout_msecs);
299 * obtain attribute values from userspace with a service operation.
301 static ssize_t sysfs_service_op_show(struct kobject *kobj,
302 struct orangefs_attribute *attr, char *buf)
304 struct orangefs_kernel_op_s *new_op = NULL;
306 char *ser_op_type = NULL;
309 gossip_debug(GOSSIP_SYSFS_DEBUG,
310 "sysfs_service_op_show: id:%s:\n",
313 if (strcmp(kobj->name, PC_KOBJ_ID))
314 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
316 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
318 new_op = op_alloc(op_alloc_type);
322 /* Can't do a service_operation if the client is not running... */
323 rc = is_daemon_in_service();
325 pr_info("%s: Client not running :%d:\n",
327 is_daemon_in_service());
331 if (strcmp(kobj->name, PC_KOBJ_ID))
332 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
334 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
335 /* Drop unsupported requests first. */
336 if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
337 (!strcmp(attr->attr.name, "readahead_count") ||
338 !strcmp(attr->attr.name, "readahead_size") ||
339 !strcmp(attr->attr.name, "readahead_count_size") ||
340 !strcmp(attr->attr.name, "readahead_readcnt"))) {
345 if (!strcmp(attr->attr.name, "perf_history_size"))
346 new_op->upcall.req.param.op =
347 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
348 else if (!strcmp(attr->attr.name,
349 "perf_time_interval_secs"))
350 new_op->upcall.req.param.op =
351 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
352 else if (!strcmp(attr->attr.name,
353 "perf_counter_reset"))
354 new_op->upcall.req.param.op =
355 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
357 else if (!strcmp(attr->attr.name,
359 new_op->upcall.req.param.op =
360 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
362 else if (!strcmp(attr->attr.name,
364 new_op->upcall.req.param.op =
365 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
367 else if (!strcmp(attr->attr.name,
368 "readahead_count_size"))
369 new_op->upcall.req.param.op =
370 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
372 else if (!strcmp(attr->attr.name,
373 "readahead_readcnt"))
374 new_op->upcall.req.param.op =
375 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT;
376 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
377 if (!strcmp(attr->attr.name, "timeout_msecs"))
378 new_op->upcall.req.param.op =
379 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
381 if (!strcmp(attr->attr.name, "hard_limit"))
382 new_op->upcall.req.param.op =
383 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
385 if (!strcmp(attr->attr.name, "soft_limit"))
386 new_op->upcall.req.param.op =
387 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
389 if (!strcmp(attr->attr.name, "reclaim_percentage"))
390 new_op->upcall.req.param.op =
391 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
393 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
394 if (!strcmp(attr->attr.name, "timeout_secs"))
395 new_op->upcall.req.param.op =
396 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
398 if (!strcmp(attr->attr.name, "hard_limit"))
399 new_op->upcall.req.param.op =
400 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
402 if (!strcmp(attr->attr.name, "soft_limit"))
403 new_op->upcall.req.param.op =
404 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
406 if (!strcmp(attr->attr.name, "reclaim_percentage"))
407 new_op->upcall.req.param.op =
408 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
410 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
411 if (!strcmp(attr->attr.name, "timeout_secs"))
412 new_op->upcall.req.param.op =
413 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
415 if (!strcmp(attr->attr.name, "hard_limit"))
416 new_op->upcall.req.param.op =
417 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
419 if (!strcmp(attr->attr.name, "soft_limit"))
420 new_op->upcall.req.param.op =
421 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
423 if (!strcmp(attr->attr.name, "reclaim_percentage"))
424 new_op->upcall.req.param.op =
425 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
427 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
428 if (!strcmp(attr->attr.name, "timeout_msecs"))
429 new_op->upcall.req.param.op =
430 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
432 if (!strcmp(attr->attr.name, "hard_limit"))
433 new_op->upcall.req.param.op =
434 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
436 if (!strcmp(attr->attr.name, "soft_limit"))
437 new_op->upcall.req.param.op =
438 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
440 if (!strcmp(attr->attr.name, "reclaim_percentage"))
441 new_op->upcall.req.param.op =
442 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
444 } else if (!strcmp(kobj->name, PC_KOBJ_ID)) {
445 if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID))
446 new_op->upcall.req.perf_count.type =
447 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
449 if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID))
450 new_op->upcall.req.perf_count.type =
451 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
453 if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID))
454 new_op->upcall.req.perf_count.type =
455 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
458 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
465 if (strcmp(kobj->name, PC_KOBJ_ID))
466 ser_op_type = "orangefs_param";
468 ser_op_type = "orangefs_perf_count";
471 * The service_operation will return an errno return code on
472 * error, and zero on success.
474 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
478 if (strcmp(kobj->name, PC_KOBJ_ID)) {
479 if (new_op->upcall.req.param.op ==
480 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
481 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
482 (int)new_op->downcall.resp.param.u.
484 (int)new_op->downcall.resp.param.u.
487 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
488 (int)new_op->downcall.resp.param.u.value64);
495 new_op->downcall.resp.perf_count.buffer);
506 * pass attribute values back to userspace with a service operation.
508 * We have to do a memory allocation, an sscanf and a service operation.
509 * And we have to evaluate what the user entered, to make sure the
510 * value is within the range supported by the attribute. So, there's
511 * a lot of return code checking and mapping going on here.
513 * We want to return 1 if we think everything went OK, and
516 static ssize_t sysfs_service_op_store(struct kobject *kobj,
517 struct orangefs_attribute *attr, const char *buf, size_t count)
519 struct orangefs_kernel_op_s *new_op = NULL;
523 gossip_debug(GOSSIP_SYSFS_DEBUG,
524 "sysfs_service_op_store: id:%s:\n",
527 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
529 return -EINVAL; /* sic */
531 /* Can't do a service_operation if the client is not running... */
532 rc = is_daemon_in_service();
534 pr_info("%s: Client not running :%d:\n",
536 is_daemon_in_service());
541 * The value we want to send back to userspace is in buf, unless this
542 * there are two parameters, which is specially handled below.
544 if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) ||
545 strcmp(attr->attr.name, "readahead_count_size")) {
546 rc = kstrtoint(buf, 0, &val);
551 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
553 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
554 /* Drop unsupported requests first. */
555 if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
556 (!strcmp(attr->attr.name, "readahead_count") ||
557 !strcmp(attr->attr.name, "readahead_size") ||
558 !strcmp(attr->attr.name, "readahead_count_size") ||
559 !strcmp(attr->attr.name, "readahead_readcnt"))) {
564 if (!strcmp(attr->attr.name, "perf_history_size")) {
566 new_op->upcall.req.param.op =
567 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
572 } else if (!strcmp(attr->attr.name,
573 "perf_time_interval_secs")) {
575 new_op->upcall.req.param.op =
576 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
581 } else if (!strcmp(attr->attr.name,
582 "perf_counter_reset")) {
583 if ((val == 0) || (val == 1)) {
584 new_op->upcall.req.param.op =
585 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
590 } else if (!strcmp(attr->attr.name,
591 "readahead_count")) {
593 new_op->upcall.req.param.op =
594 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
599 } else if (!strcmp(attr->attr.name,
602 new_op->upcall.req.param.op =
603 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
608 } else if (!strcmp(attr->attr.name,
609 "readahead_count_size")) {
611 rc = sscanf(buf, "%d %d", &val1, &val2);
616 if ((val1 >= 0) && (val2 >= 0)) {
617 new_op->upcall.req.param.op =
618 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
623 new_op->upcall.req.param.u.value32[0] = val1;
624 new_op->upcall.req.param.u.value32[1] = val2;
626 } else if (!strcmp(attr->attr.name,
627 "readahead_readcnt")) {
629 new_op->upcall.req.param.op =
630 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT;
637 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
638 if (!strcmp(attr->attr.name, "hard_limit")) {
640 new_op->upcall.req.param.op =
641 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
646 } else if (!strcmp(attr->attr.name, "soft_limit")) {
648 new_op->upcall.req.param.op =
649 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
654 } else if (!strcmp(attr->attr.name,
655 "reclaim_percentage")) {
656 if ((val > -1) && (val < 101)) {
657 new_op->upcall.req.param.op =
658 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
663 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
665 new_op->upcall.req.param.op =
666 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
673 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
674 if (!strcmp(attr->attr.name, "hard_limit")) {
676 new_op->upcall.req.param.op =
677 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
682 } else if (!strcmp(attr->attr.name, "soft_limit")) {
684 new_op->upcall.req.param.op =
685 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
690 } else if (!strcmp(attr->attr.name,
691 "reclaim_percentage")) {
692 if ((val > -1) && (val < 101)) {
693 new_op->upcall.req.param.op =
694 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
699 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
701 new_op->upcall.req.param.op =
702 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
709 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
710 if (!strcmp(attr->attr.name, "hard_limit")) {
712 new_op->upcall.req.param.op =
713 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
718 } else if (!strcmp(attr->attr.name, "soft_limit")) {
720 new_op->upcall.req.param.op =
721 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
726 } else if (!strcmp(attr->attr.name,
727 "reclaim_percentage")) {
728 if ((val > -1) && (val < 101)) {
729 new_op->upcall.req.param.op =
730 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
735 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
737 new_op->upcall.req.param.op =
738 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
745 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
746 if (!strcmp(attr->attr.name, "hard_limit")) {
748 new_op->upcall.req.param.op =
749 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
754 } else if (!strcmp(attr->attr.name, "soft_limit")) {
756 new_op->upcall.req.param.op =
757 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
762 } else if (!strcmp(attr->attr.name,
763 "reclaim_percentage")) {
764 if ((val > -1) && (val < 101)) {
765 new_op->upcall.req.param.op =
766 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
771 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
773 new_op->upcall.req.param.op =
774 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
782 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
788 new_op->upcall.req.param.u.value64 = val;
792 * The service_operation will return a errno return code on
793 * error, and zero on success.
795 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
798 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
808 if (rc == -ENOMEM || rc == 0)
814 static struct orangefs_attribute op_timeout_secs_attribute =
815 __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
817 static struct orangefs_attribute slot_timeout_secs_attribute =
818 __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
820 static struct orangefs_attribute dcache_timeout_msecs_attribute =
821 __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
823 static struct orangefs_attribute getattr_timeout_msecs_attribute =
824 __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
826 static struct orangefs_attribute readahead_count_attribute =
827 __ATTR(readahead_count, 0664, sysfs_service_op_show,
828 sysfs_service_op_store);
830 static struct orangefs_attribute readahead_size_attribute =
831 __ATTR(readahead_size, 0664, sysfs_service_op_show,
832 sysfs_service_op_store);
834 static struct orangefs_attribute readahead_count_size_attribute =
835 __ATTR(readahead_count_size, 0664, sysfs_service_op_show,
836 sysfs_service_op_store);
838 static struct orangefs_attribute readahead_readcnt_attribute =
839 __ATTR(readahead_readcnt, 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 &readahead_readcnt_attribute.attr,
869 &perf_counter_reset_attribute.attr,
870 &perf_history_size_attribute.attr,
871 &perf_time_interval_secs_attribute.attr,
875 static struct kobj_type orangefs_ktype = {
876 .sysfs_ops = &orangefs_sysfs_ops,
877 .default_attrs = orangefs_default_attrs,
880 static struct orangefs_attribute acache_hard_limit_attribute =
883 sysfs_service_op_show,
884 sysfs_service_op_store);
886 static struct orangefs_attribute acache_reclaim_percent_attribute =
887 __ATTR(reclaim_percentage,
889 sysfs_service_op_show,
890 sysfs_service_op_store);
892 static struct orangefs_attribute acache_soft_limit_attribute =
895 sysfs_service_op_show,
896 sysfs_service_op_store);
898 static struct orangefs_attribute acache_timeout_msecs_attribute =
899 __ATTR(timeout_msecs,
901 sysfs_service_op_show,
902 sysfs_service_op_store);
904 static struct attribute *acache_orangefs_default_attrs[] = {
905 &acache_hard_limit_attribute.attr,
906 &acache_reclaim_percent_attribute.attr,
907 &acache_soft_limit_attribute.attr,
908 &acache_timeout_msecs_attribute.attr,
912 static struct kobj_type acache_orangefs_ktype = {
913 .sysfs_ops = &orangefs_sysfs_ops,
914 .default_attrs = acache_orangefs_default_attrs,
917 static struct orangefs_attribute capcache_hard_limit_attribute =
920 sysfs_service_op_show,
921 sysfs_service_op_store);
923 static struct orangefs_attribute capcache_reclaim_percent_attribute =
924 __ATTR(reclaim_percentage,
926 sysfs_service_op_show,
927 sysfs_service_op_store);
929 static struct orangefs_attribute capcache_soft_limit_attribute =
932 sysfs_service_op_show,
933 sysfs_service_op_store);
935 static struct orangefs_attribute capcache_timeout_secs_attribute =
938 sysfs_service_op_show,
939 sysfs_service_op_store);
941 static struct attribute *capcache_orangefs_default_attrs[] = {
942 &capcache_hard_limit_attribute.attr,
943 &capcache_reclaim_percent_attribute.attr,
944 &capcache_soft_limit_attribute.attr,
945 &capcache_timeout_secs_attribute.attr,
949 static struct kobj_type capcache_orangefs_ktype = {
950 .sysfs_ops = &orangefs_sysfs_ops,
951 .default_attrs = capcache_orangefs_default_attrs,
954 static struct orangefs_attribute ccache_hard_limit_attribute =
957 sysfs_service_op_show,
958 sysfs_service_op_store);
960 static struct orangefs_attribute ccache_reclaim_percent_attribute =
961 __ATTR(reclaim_percentage,
963 sysfs_service_op_show,
964 sysfs_service_op_store);
966 static struct orangefs_attribute ccache_soft_limit_attribute =
969 sysfs_service_op_show,
970 sysfs_service_op_store);
972 static struct orangefs_attribute ccache_timeout_secs_attribute =
975 sysfs_service_op_show,
976 sysfs_service_op_store);
978 static struct attribute *ccache_orangefs_default_attrs[] = {
979 &ccache_hard_limit_attribute.attr,
980 &ccache_reclaim_percent_attribute.attr,
981 &ccache_soft_limit_attribute.attr,
982 &ccache_timeout_secs_attribute.attr,
986 static struct kobj_type ccache_orangefs_ktype = {
987 .sysfs_ops = &orangefs_sysfs_ops,
988 .default_attrs = ccache_orangefs_default_attrs,
991 static struct orangefs_attribute ncache_hard_limit_attribute =
994 sysfs_service_op_show,
995 sysfs_service_op_store);
997 static struct orangefs_attribute ncache_reclaim_percent_attribute =
998 __ATTR(reclaim_percentage,
1000 sysfs_service_op_show,
1001 sysfs_service_op_store);
1003 static struct orangefs_attribute ncache_soft_limit_attribute =
1006 sysfs_service_op_show,
1007 sysfs_service_op_store);
1009 static struct orangefs_attribute ncache_timeout_msecs_attribute =
1010 __ATTR(timeout_msecs,
1012 sysfs_service_op_show,
1013 sysfs_service_op_store);
1015 static struct attribute *ncache_orangefs_default_attrs[] = {
1016 &ncache_hard_limit_attribute.attr,
1017 &ncache_reclaim_percent_attribute.attr,
1018 &ncache_soft_limit_attribute.attr,
1019 &ncache_timeout_msecs_attribute.attr,
1023 static struct kobj_type ncache_orangefs_ktype = {
1024 .sysfs_ops = &orangefs_sysfs_ops,
1025 .default_attrs = ncache_orangefs_default_attrs,
1028 static struct orangefs_attribute pc_acache_attribute =
1031 sysfs_service_op_show,
1034 static struct orangefs_attribute pc_capcache_attribute =
1037 sysfs_service_op_show,
1040 static struct orangefs_attribute pc_ncache_attribute =
1043 sysfs_service_op_show,
1046 static struct attribute *pc_orangefs_default_attrs[] = {
1047 &pc_acache_attribute.attr,
1048 &pc_capcache_attribute.attr,
1049 &pc_ncache_attribute.attr,
1053 static struct kobj_type pc_orangefs_ktype = {
1054 .sysfs_ops = &orangefs_sysfs_ops,
1055 .default_attrs = pc_orangefs_default_attrs,
1058 static struct orangefs_attribute stats_reads_attribute =
1064 static struct orangefs_attribute stats_writes_attribute =
1070 static struct attribute *stats_orangefs_default_attrs[] = {
1071 &stats_reads_attribute.attr,
1072 &stats_writes_attribute.attr,
1076 static struct kobj_type stats_orangefs_ktype = {
1077 .sysfs_ops = &orangefs_sysfs_ops,
1078 .default_attrs = stats_orangefs_default_attrs,
1081 static struct kobject *orangefs_obj;
1082 static struct kobject *acache_orangefs_obj;
1083 static struct kobject *capcache_orangefs_obj;
1084 static struct kobject *ccache_orangefs_obj;
1085 static struct kobject *ncache_orangefs_obj;
1086 static struct kobject *pc_orangefs_obj;
1087 static struct kobject *stats_orangefs_obj;
1089 int orangefs_sysfs_init(void)
1093 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1095 /* create /sys/fs/orangefs. */
1096 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1100 rc = kobject_init_and_add(orangefs_obj,
1108 kobject_uevent(orangefs_obj, KOBJ_ADD);
1110 /* create /sys/fs/orangefs/acache. */
1111 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1112 if (!acache_orangefs_obj) {
1117 rc = kobject_init_and_add(acache_orangefs_obj,
1118 &acache_orangefs_ktype,
1123 goto acache_obj_bail;
1125 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
1127 /* create /sys/fs/orangefs/capcache. */
1128 capcache_orangefs_obj =
1129 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1130 if (!capcache_orangefs_obj) {
1132 goto acache_obj_bail;
1135 rc = kobject_init_and_add(capcache_orangefs_obj,
1136 &capcache_orangefs_ktype,
1140 goto capcache_obj_bail;
1142 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
1144 /* create /sys/fs/orangefs/ccache. */
1145 ccache_orangefs_obj =
1146 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1147 if (!ccache_orangefs_obj) {
1149 goto capcache_obj_bail;
1152 rc = kobject_init_and_add(ccache_orangefs_obj,
1153 &ccache_orangefs_ktype,
1157 goto ccache_obj_bail;
1159 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
1161 /* create /sys/fs/orangefs/ncache. */
1162 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1163 if (!ncache_orangefs_obj) {
1165 goto ccache_obj_bail;
1168 rc = kobject_init_and_add(ncache_orangefs_obj,
1169 &ncache_orangefs_ktype,
1174 goto ncache_obj_bail;
1176 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
1178 /* create /sys/fs/orangefs/perf_counters. */
1179 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1180 if (!pc_orangefs_obj) {
1182 goto ncache_obj_bail;
1185 rc = kobject_init_and_add(pc_orangefs_obj,
1193 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
1195 /* create /sys/fs/orangefs/stats. */
1196 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1197 if (!stats_orangefs_obj) {
1202 rc = kobject_init_and_add(stats_orangefs_obj,
1203 &stats_orangefs_ktype,
1208 goto stats_obj_bail;
1210 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
1214 kobject_put(stats_orangefs_obj);
1216 kobject_put(pc_orangefs_obj);
1218 kobject_put(ncache_orangefs_obj);
1220 kobject_put(ccache_orangefs_obj);
1222 kobject_put(capcache_orangefs_obj);
1224 kobject_put(acache_orangefs_obj);
1226 kobject_put(orangefs_obj);
1231 void orangefs_sysfs_exit(void)
1233 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1234 kobject_put(acache_orangefs_obj);
1235 kobject_put(capcache_orangefs_obj);
1236 kobject_put(ccache_orangefs_obj);
1237 kobject_put(ncache_orangefs_obj);
1238 kobject_put(pc_orangefs_obj);
1239 kobject_put(stats_orangefs_obj);
1240 kobject_put(orangefs_obj);