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.
65 * What: /sys/fs/orangefs/acache/...
67 * Contact: Mike Marshall <hubcap@omnibond.com>
69 * Attribute cache configurable settings.
72 * What: /sys/fs/orangefs/ncache/...
74 * Contact: Mike Marshall <hubcap@omnibond.com>
76 * Name cache configurable settings.
79 * What: /sys/fs/orangefs/capcache/...
81 * Contact: Mike Marshall <hubcap@omnibond.com>
83 * Capability cache configurable settings.
86 * What: /sys/fs/orangefs/ccache/...
88 * Contact: Mike Marshall <hubcap@omnibond.com>
90 * Credential cache configurable settings.
95 #include <linux/kobject.h>
96 #include <linux/string.h>
97 #include <linux/sysfs.h>
98 #include <linux/module.h>
99 #include <linux/init.h>
101 #include "protocol.h"
102 #include "pvfs2-kernel.h"
103 #include "pvfs2-sysfs.h"
105 #define ORANGEFS_KOBJ_ID "orangefs"
106 #define ACACHE_KOBJ_ID "acache"
107 #define CAPCACHE_KOBJ_ID "capcache"
108 #define CCACHE_KOBJ_ID "ccache"
109 #define NCACHE_KOBJ_ID "ncache"
110 #define PC_KOBJ_ID "pc"
111 #define STATS_KOBJ_ID "stats"
113 struct orangefs_obj {
116 int perf_counter_reset;
117 int perf_history_size;
118 int perf_time_interval_secs;
119 int slot_timeout_secs;
122 struct acache_orangefs_obj {
125 int reclaim_percentage;
130 struct capcache_orangefs_obj {
133 int reclaim_percentage;
138 struct ccache_orangefs_obj {
141 int reclaim_percentage;
146 struct ncache_orangefs_obj {
149 int reclaim_percentage;
154 struct pc_orangefs_obj {
161 struct stats_orangefs_obj {
167 struct orangefs_attribute {
168 struct attribute attr;
169 ssize_t (*show)(struct orangefs_obj *orangefs_obj,
170 struct orangefs_attribute *attr,
172 ssize_t (*store)(struct orangefs_obj *orangefs_obj,
173 struct orangefs_attribute *attr,
178 struct acache_orangefs_attribute {
179 struct attribute attr;
180 ssize_t (*show)(struct acache_orangefs_obj *acache_orangefs_obj,
181 struct acache_orangefs_attribute *attr,
183 ssize_t (*store)(struct acache_orangefs_obj *acache_orangefs_obj,
184 struct acache_orangefs_attribute *attr,
189 struct capcache_orangefs_attribute {
190 struct attribute attr;
191 ssize_t (*show)(struct capcache_orangefs_obj *capcache_orangefs_obj,
192 struct capcache_orangefs_attribute *attr,
194 ssize_t (*store)(struct capcache_orangefs_obj *capcache_orangefs_obj,
195 struct capcache_orangefs_attribute *attr,
200 struct ccache_orangefs_attribute {
201 struct attribute attr;
202 ssize_t (*show)(struct ccache_orangefs_obj *ccache_orangefs_obj,
203 struct ccache_orangefs_attribute *attr,
205 ssize_t (*store)(struct ccache_orangefs_obj *ccache_orangefs_obj,
206 struct ccache_orangefs_attribute *attr,
211 struct ncache_orangefs_attribute {
212 struct attribute attr;
213 ssize_t (*show)(struct ncache_orangefs_obj *ncache_orangefs_obj,
214 struct ncache_orangefs_attribute *attr,
216 ssize_t (*store)(struct ncache_orangefs_obj *ncache_orangefs_obj,
217 struct ncache_orangefs_attribute *attr,
222 struct pc_orangefs_attribute {
223 struct attribute attr;
224 ssize_t (*show)(struct pc_orangefs_obj *pc_orangefs_obj,
225 struct pc_orangefs_attribute *attr,
227 ssize_t (*store)(struct pc_orangefs_obj *pc_orangefs_obj,
228 struct pc_orangefs_attribute *attr,
233 struct stats_orangefs_attribute {
234 struct attribute attr;
235 ssize_t (*show)(struct stats_orangefs_obj *stats_orangefs_obj,
236 struct stats_orangefs_attribute *attr,
238 ssize_t (*store)(struct stats_orangefs_obj *stats_orangefs_obj,
239 struct stats_orangefs_attribute *attr,
244 static ssize_t orangefs_attr_show(struct kobject *kobj,
245 struct attribute *attr,
248 struct orangefs_attribute *attribute;
249 struct orangefs_obj *orangefs_obj;
252 attribute = container_of(attr, struct orangefs_attribute, attr);
253 orangefs_obj = container_of(kobj, struct orangefs_obj, kobj);
255 if (!attribute->show) {
260 rc = attribute->show(orangefs_obj, attribute, buf);
266 static ssize_t orangefs_attr_store(struct kobject *kobj,
267 struct attribute *attr,
271 struct orangefs_attribute *attribute;
272 struct orangefs_obj *orangefs_obj;
275 gossip_debug(GOSSIP_SYSFS_DEBUG,
276 "orangefs_attr_store: start\n");
278 attribute = container_of(attr, struct orangefs_attribute, attr);
279 orangefs_obj = container_of(kobj, struct orangefs_obj, kobj);
281 if (!attribute->store) {
286 rc = attribute->store(orangefs_obj, attribute, buf, len);
292 static const struct sysfs_ops orangefs_sysfs_ops = {
293 .show = orangefs_attr_show,
294 .store = orangefs_attr_store,
297 static ssize_t acache_orangefs_attr_show(struct kobject *kobj,
298 struct attribute *attr,
301 struct acache_orangefs_attribute *attribute;
302 struct acache_orangefs_obj *acache_orangefs_obj;
305 attribute = container_of(attr, struct acache_orangefs_attribute, attr);
306 acache_orangefs_obj =
307 container_of(kobj, struct acache_orangefs_obj, kobj);
309 if (!attribute->show) {
314 rc = attribute->show(acache_orangefs_obj, attribute, buf);
320 static ssize_t acache_orangefs_attr_store(struct kobject *kobj,
321 struct attribute *attr,
325 struct acache_orangefs_attribute *attribute;
326 struct acache_orangefs_obj *acache_orangefs_obj;
329 gossip_debug(GOSSIP_SYSFS_DEBUG,
330 "acache_orangefs_attr_store: start\n");
332 attribute = container_of(attr, struct acache_orangefs_attribute, attr);
333 acache_orangefs_obj =
334 container_of(kobj, struct acache_orangefs_obj, kobj);
336 if (!attribute->store) {
341 rc = attribute->store(acache_orangefs_obj, attribute, buf, len);
347 static const struct sysfs_ops acache_orangefs_sysfs_ops = {
348 .show = acache_orangefs_attr_show,
349 .store = acache_orangefs_attr_store,
352 static ssize_t capcache_orangefs_attr_show(struct kobject *kobj,
353 struct attribute *attr,
356 struct capcache_orangefs_attribute *attribute;
357 struct capcache_orangefs_obj *capcache_orangefs_obj;
361 container_of(attr, struct capcache_orangefs_attribute, attr);
362 capcache_orangefs_obj =
363 container_of(kobj, struct capcache_orangefs_obj, kobj);
365 if (!attribute->show) {
370 rc = attribute->show(capcache_orangefs_obj, attribute, buf);
376 static ssize_t capcache_orangefs_attr_store(struct kobject *kobj,
377 struct attribute *attr,
381 struct capcache_orangefs_attribute *attribute;
382 struct capcache_orangefs_obj *capcache_orangefs_obj;
385 gossip_debug(GOSSIP_SYSFS_DEBUG,
386 "capcache_orangefs_attr_store: start\n");
389 container_of(attr, struct capcache_orangefs_attribute, attr);
390 capcache_orangefs_obj =
391 container_of(kobj, struct capcache_orangefs_obj, kobj);
393 if (!attribute->store) {
398 rc = attribute->store(capcache_orangefs_obj, attribute, buf, len);
404 static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
405 .show = capcache_orangefs_attr_show,
406 .store = capcache_orangefs_attr_store,
409 static ssize_t ccache_orangefs_attr_show(struct kobject *kobj,
410 struct attribute *attr,
413 struct ccache_orangefs_attribute *attribute;
414 struct ccache_orangefs_obj *ccache_orangefs_obj;
418 container_of(attr, struct ccache_orangefs_attribute, attr);
419 ccache_orangefs_obj =
420 container_of(kobj, struct ccache_orangefs_obj, kobj);
422 if (!attribute->show) {
427 rc = attribute->show(ccache_orangefs_obj, attribute, buf);
433 static ssize_t ccache_orangefs_attr_store(struct kobject *kobj,
434 struct attribute *attr,
438 struct ccache_orangefs_attribute *attribute;
439 struct ccache_orangefs_obj *ccache_orangefs_obj;
442 gossip_debug(GOSSIP_SYSFS_DEBUG,
443 "ccache_orangefs_attr_store: start\n");
446 container_of(attr, struct ccache_orangefs_attribute, attr);
447 ccache_orangefs_obj =
448 container_of(kobj, struct ccache_orangefs_obj, kobj);
450 if (!attribute->store) {
455 rc = attribute->store(ccache_orangefs_obj, attribute, buf, len);
461 static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
462 .show = ccache_orangefs_attr_show,
463 .store = ccache_orangefs_attr_store,
466 static ssize_t ncache_orangefs_attr_show(struct kobject *kobj,
467 struct attribute *attr,
470 struct ncache_orangefs_attribute *attribute;
471 struct ncache_orangefs_obj *ncache_orangefs_obj;
474 attribute = container_of(attr, struct ncache_orangefs_attribute, attr);
475 ncache_orangefs_obj =
476 container_of(kobj, struct ncache_orangefs_obj, kobj);
478 if (!attribute->show) {
483 rc = attribute->show(ncache_orangefs_obj, attribute, buf);
489 static ssize_t ncache_orangefs_attr_store(struct kobject *kobj,
490 struct attribute *attr,
494 struct ncache_orangefs_attribute *attribute;
495 struct ncache_orangefs_obj *ncache_orangefs_obj;
498 gossip_debug(GOSSIP_SYSFS_DEBUG,
499 "ncache_orangefs_attr_store: start\n");
501 attribute = container_of(attr, struct ncache_orangefs_attribute, attr);
502 ncache_orangefs_obj =
503 container_of(kobj, struct ncache_orangefs_obj, kobj);
505 if (!attribute->store) {
510 rc = attribute->store(ncache_orangefs_obj, attribute, buf, len);
516 static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
517 .show = ncache_orangefs_attr_show,
518 .store = ncache_orangefs_attr_store,
521 static ssize_t pc_orangefs_attr_show(struct kobject *kobj,
522 struct attribute *attr,
525 struct pc_orangefs_attribute *attribute;
526 struct pc_orangefs_obj *pc_orangefs_obj;
529 attribute = container_of(attr, struct pc_orangefs_attribute, attr);
531 container_of(kobj, struct pc_orangefs_obj, kobj);
533 if (!attribute->show) {
538 rc = attribute->show(pc_orangefs_obj, attribute, buf);
544 static const struct sysfs_ops pc_orangefs_sysfs_ops = {
545 .show = pc_orangefs_attr_show,
548 static ssize_t stats_orangefs_attr_show(struct kobject *kobj,
549 struct attribute *attr,
552 struct stats_orangefs_attribute *attribute;
553 struct stats_orangefs_obj *stats_orangefs_obj;
556 attribute = container_of(attr, struct stats_orangefs_attribute, attr);
558 container_of(kobj, struct stats_orangefs_obj, kobj);
560 if (!attribute->show) {
565 rc = attribute->show(stats_orangefs_obj, attribute, buf);
571 static const struct sysfs_ops stats_orangefs_sysfs_ops = {
572 .show = stats_orangefs_attr_show,
575 static void orangefs_release(struct kobject *kobj)
577 struct orangefs_obj *orangefs_obj;
579 orangefs_obj = container_of(kobj, struct orangefs_obj, kobj);
583 static void acache_orangefs_release(struct kobject *kobj)
585 struct acache_orangefs_obj *acache_orangefs_obj;
587 acache_orangefs_obj =
588 container_of(kobj, struct acache_orangefs_obj, kobj);
589 kfree(acache_orangefs_obj);
592 static void capcache_orangefs_release(struct kobject *kobj)
594 struct capcache_orangefs_obj *capcache_orangefs_obj;
596 capcache_orangefs_obj =
597 container_of(kobj, struct capcache_orangefs_obj, kobj);
598 kfree(capcache_orangefs_obj);
601 static void ccache_orangefs_release(struct kobject *kobj)
603 struct ccache_orangefs_obj *ccache_orangefs_obj;
605 ccache_orangefs_obj =
606 container_of(kobj, struct ccache_orangefs_obj, kobj);
607 kfree(ccache_orangefs_obj);
610 static void ncache_orangefs_release(struct kobject *kobj)
612 struct ncache_orangefs_obj *ncache_orangefs_obj;
614 ncache_orangefs_obj =
615 container_of(kobj, struct ncache_orangefs_obj, kobj);
616 kfree(ncache_orangefs_obj);
619 static void pc_orangefs_release(struct kobject *kobj)
621 struct pc_orangefs_obj *pc_orangefs_obj;
624 container_of(kobj, struct pc_orangefs_obj, kobj);
625 kfree(pc_orangefs_obj);
628 static void stats_orangefs_release(struct kobject *kobj)
630 struct stats_orangefs_obj *stats_orangefs_obj;
633 container_of(kobj, struct stats_orangefs_obj, kobj);
634 kfree(stats_orangefs_obj);
637 static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr)
640 struct orangefs_attribute *orangefs_attr;
641 struct stats_orangefs_attribute *stats_orangefs_attr;
643 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id);
645 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
646 orangefs_attr = (struct orangefs_attribute *)attr;
648 if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) {
654 } else if (!strcmp(orangefs_attr->attr.name,
655 "slot_timeout_secs")) {
665 } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) {
666 stats_orangefs_attr = (struct stats_orangefs_attribute *)attr;
668 if (!strcmp(stats_orangefs_attr->attr.name, "reads")) {
672 g_pvfs2_stats.reads);
674 } else if (!strcmp(stats_orangefs_attr->attr.name, "writes")) {
678 g_pvfs2_stats.writes);
690 static ssize_t int_orangefs_show(struct orangefs_obj *orangefs_obj,
691 struct orangefs_attribute *attr,
696 gossip_debug(GOSSIP_SYSFS_DEBUG,
697 "int_orangefs_show:start attr->attr.name:%s:\n",
700 rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr);
705 static ssize_t int_stats_show(struct stats_orangefs_obj *stats_orangefs_obj,
706 struct stats_orangefs_attribute *attr,
711 gossip_debug(GOSSIP_SYSFS_DEBUG,
712 "int_stats_show:start attr->attr.name:%s:\n",
715 rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr);
720 static ssize_t int_store(struct orangefs_obj *orangefs_obj,
721 struct orangefs_attribute *attr,
727 gossip_debug(GOSSIP_SYSFS_DEBUG,
728 "int_store: start attr->attr.name:%s: buf:%s:\n",
729 attr->attr.name, buf);
731 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
732 rc = kstrtoint(buf, 0, &op_timeout_secs);
734 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
735 rc = kstrtoint(buf, 0, &slot_timeout_secs);
751 * obtain attribute values from userspace with a service operation.
753 static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr)
755 struct pvfs2_kernel_op_s *new_op = NULL;
757 char *ser_op_type = NULL;
758 struct orangefs_attribute *orangefs_attr;
759 struct acache_orangefs_attribute *acache_attr;
760 struct capcache_orangefs_attribute *capcache_attr;
761 struct ccache_orangefs_attribute *ccache_attr;
762 struct ncache_orangefs_attribute *ncache_attr;
763 struct pc_orangefs_attribute *pc_attr;
766 gossip_debug(GOSSIP_SYSFS_DEBUG,
767 "sysfs_service_op_show: id:%s:\n",
770 if (strcmp(kobj_id, PC_KOBJ_ID))
771 op_alloc_type = PVFS2_VFS_OP_PARAM;
773 op_alloc_type = PVFS2_VFS_OP_PERF_COUNT;
775 new_op = op_alloc(op_alloc_type);
781 /* Can't do a service_operation if the client is not running... */
782 rc = is_daemon_in_service();
784 pr_info("%s: Client not running :%d:\n",
786 is_daemon_in_service());
790 if (strcmp(kobj_id, PC_KOBJ_ID))
791 new_op->upcall.req.param.type = PVFS2_PARAM_REQUEST_GET;
793 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
794 orangefs_attr = (struct orangefs_attribute *)attr;
796 if (!strcmp(orangefs_attr->attr.name, "perf_history_size"))
797 new_op->upcall.req.param.op =
798 PVFS2_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
799 else if (!strcmp(orangefs_attr->attr.name,
800 "perf_time_interval_secs"))
801 new_op->upcall.req.param.op =
802 PVFS2_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
803 else if (!strcmp(orangefs_attr->attr.name,
804 "perf_counter_reset"))
805 new_op->upcall.req.param.op =
806 PVFS2_PARAM_REQUEST_OP_PERF_RESET;
808 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
809 acache_attr = (struct acache_orangefs_attribute *)attr;
811 if (!strcmp(acache_attr->attr.name, "timeout_msecs"))
812 new_op->upcall.req.param.op =
813 PVFS2_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
815 if (!strcmp(acache_attr->attr.name, "hard_limit"))
816 new_op->upcall.req.param.op =
817 PVFS2_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
819 if (!strcmp(acache_attr->attr.name, "soft_limit"))
820 new_op->upcall.req.param.op =
821 PVFS2_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
823 if (!strcmp(acache_attr->attr.name, "reclaim_percentage"))
824 new_op->upcall.req.param.op =
825 PVFS2_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
827 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
828 capcache_attr = (struct capcache_orangefs_attribute *)attr;
830 if (!strcmp(capcache_attr->attr.name, "timeout_secs"))
831 new_op->upcall.req.param.op =
832 PVFS2_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
834 if (!strcmp(capcache_attr->attr.name, "hard_limit"))
835 new_op->upcall.req.param.op =
836 PVFS2_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
838 if (!strcmp(capcache_attr->attr.name, "soft_limit"))
839 new_op->upcall.req.param.op =
840 PVFS2_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
842 if (!strcmp(capcache_attr->attr.name, "reclaim_percentage"))
843 new_op->upcall.req.param.op =
844 PVFS2_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
846 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
847 ccache_attr = (struct ccache_orangefs_attribute *)attr;
849 if (!strcmp(ccache_attr->attr.name, "timeout_secs"))
850 new_op->upcall.req.param.op =
851 PVFS2_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
853 if (!strcmp(ccache_attr->attr.name, "hard_limit"))
854 new_op->upcall.req.param.op =
855 PVFS2_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
857 if (!strcmp(ccache_attr->attr.name, "soft_limit"))
858 new_op->upcall.req.param.op =
859 PVFS2_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
861 if (!strcmp(ccache_attr->attr.name, "reclaim_percentage"))
862 new_op->upcall.req.param.op =
863 PVFS2_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
865 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
866 ncache_attr = (struct ncache_orangefs_attribute *)attr;
868 if (!strcmp(ncache_attr->attr.name, "timeout_msecs"))
869 new_op->upcall.req.param.op =
870 PVFS2_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
872 if (!strcmp(ncache_attr->attr.name, "hard_limit"))
873 new_op->upcall.req.param.op =
874 PVFS2_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
876 if (!strcmp(ncache_attr->attr.name, "soft_limit"))
877 new_op->upcall.req.param.op =
878 PVFS2_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
880 if (!strcmp(ncache_attr->attr.name, "reclaim_percentage"))
881 new_op->upcall.req.param.op =
882 PVFS2_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
884 } else if (!strcmp(kobj_id, PC_KOBJ_ID)) {
885 pc_attr = (struct pc_orangefs_attribute *)attr;
887 if (!strcmp(pc_attr->attr.name, ACACHE_KOBJ_ID))
888 new_op->upcall.req.perf_count.type =
889 PVFS2_PERF_COUNT_REQUEST_ACACHE;
891 if (!strcmp(pc_attr->attr.name, CAPCACHE_KOBJ_ID))
892 new_op->upcall.req.perf_count.type =
893 PVFS2_PERF_COUNT_REQUEST_CAPCACHE;
895 if (!strcmp(pc_attr->attr.name, NCACHE_KOBJ_ID))
896 new_op->upcall.req.perf_count.type =
897 PVFS2_PERF_COUNT_REQUEST_NCACHE;
900 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
907 if (strcmp(kobj_id, PC_KOBJ_ID))
908 ser_op_type = "pvfs2_param";
910 ser_op_type = "pvfs2_perf_count";
913 * The service_operation will return an errno return code on
914 * error, and zero on success.
916 rc = service_operation(new_op, ser_op_type, PVFS2_OP_INTERRUPTIBLE);
920 if (strcmp(kobj_id, PC_KOBJ_ID)) {
924 (int)new_op->downcall.resp.param.value);
930 new_op->downcall.resp.perf_count.buffer);
935 * if we got ENOMEM, then op_alloc probably failed...
944 static ssize_t service_orangefs_show(struct orangefs_obj *orangefs_obj,
945 struct orangefs_attribute *attr,
950 rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr);
956 service_acache_show(struct acache_orangefs_obj *acache_orangefs_obj,
957 struct acache_orangefs_attribute *attr,
962 rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr);
967 static ssize_t service_capcache_show(struct capcache_orangefs_obj
968 *capcache_orangefs_obj,
969 struct capcache_orangefs_attribute *attr,
974 rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr);
979 static ssize_t service_ccache_show(struct ccache_orangefs_obj
980 *ccache_orangefs_obj,
981 struct ccache_orangefs_attribute *attr,
986 rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr);
992 service_ncache_show(struct ncache_orangefs_obj *ncache_orangefs_obj,
993 struct ncache_orangefs_attribute *attr,
998 rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr);
1004 service_pc_show(struct pc_orangefs_obj *pc_orangefs_obj,
1005 struct pc_orangefs_attribute *attr,
1010 rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr);
1016 * pass attribute values back to userspace with a service operation.
1018 * We have to do a memory allocation, an sscanf and a service operation.
1019 * And we have to evaluate what the user entered, to make sure the
1020 * value is within the range supported by the attribute. So, there's
1021 * a lot of return code checking and mapping going on here.
1023 * We want to return 1 if we think everything went OK, and
1026 static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr)
1028 struct pvfs2_kernel_op_s *new_op = NULL;
1031 struct orangefs_attribute *orangefs_attr;
1032 struct acache_orangefs_attribute *acache_attr;
1033 struct capcache_orangefs_attribute *capcache_attr;
1034 struct ccache_orangefs_attribute *ccache_attr;
1035 struct ncache_orangefs_attribute *ncache_attr;
1037 gossip_debug(GOSSIP_SYSFS_DEBUG,
1038 "sysfs_service_op_store: id:%s:\n",
1041 new_op = op_alloc(PVFS2_VFS_OP_PARAM);
1047 /* Can't do a service_operation if the client is not running... */
1048 rc = is_daemon_in_service();
1050 pr_info("%s: Client not running :%d:\n",
1052 is_daemon_in_service());
1057 * The value we want to send back to userspace is in buf.
1059 rc = kstrtoint(buf, 0, &val);
1063 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
1064 orangefs_attr = (struct orangefs_attribute *)attr;
1066 if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) {
1068 new_op->upcall.req.param.op =
1069 PVFS2_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
1074 } else if (!strcmp(orangefs_attr->attr.name,
1075 "perf_time_interval_secs")) {
1077 new_op->upcall.req.param.op =
1078 PVFS2_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
1083 } else if (!strcmp(orangefs_attr->attr.name,
1084 "perf_counter_reset")) {
1085 if ((val == 0) || (val == 1)) {
1086 new_op->upcall.req.param.op =
1087 PVFS2_PARAM_REQUEST_OP_PERF_RESET;
1094 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
1095 acache_attr = (struct acache_orangefs_attribute *)attr;
1097 if (!strcmp(acache_attr->attr.name, "hard_limit")) {
1099 new_op->upcall.req.param.op =
1100 PVFS2_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
1105 } else if (!strcmp(acache_attr->attr.name, "soft_limit")) {
1107 new_op->upcall.req.param.op =
1108 PVFS2_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
1113 } else if (!strcmp(acache_attr->attr.name,
1114 "reclaim_percentage")) {
1115 if ((val > -1) && (val < 101)) {
1116 new_op->upcall.req.param.op =
1117 PVFS2_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
1122 } else if (!strcmp(acache_attr->attr.name, "timeout_msecs")) {
1124 new_op->upcall.req.param.op =
1125 PVFS2_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
1132 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
1133 capcache_attr = (struct capcache_orangefs_attribute *)attr;
1135 if (!strcmp(capcache_attr->attr.name, "hard_limit")) {
1137 new_op->upcall.req.param.op =
1138 PVFS2_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
1143 } else if (!strcmp(capcache_attr->attr.name, "soft_limit")) {
1145 new_op->upcall.req.param.op =
1146 PVFS2_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
1151 } else if (!strcmp(capcache_attr->attr.name,
1152 "reclaim_percentage")) {
1153 if ((val > -1) && (val < 101)) {
1154 new_op->upcall.req.param.op =
1155 PVFS2_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
1160 } else if (!strcmp(capcache_attr->attr.name, "timeout_secs")) {
1162 new_op->upcall.req.param.op =
1163 PVFS2_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
1170 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
1171 ccache_attr = (struct ccache_orangefs_attribute *)attr;
1173 if (!strcmp(ccache_attr->attr.name, "hard_limit")) {
1175 new_op->upcall.req.param.op =
1176 PVFS2_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
1181 } else if (!strcmp(ccache_attr->attr.name, "soft_limit")) {
1183 new_op->upcall.req.param.op =
1184 PVFS2_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
1189 } else if (!strcmp(ccache_attr->attr.name,
1190 "reclaim_percentage")) {
1191 if ((val > -1) && (val < 101)) {
1192 new_op->upcall.req.param.op =
1193 PVFS2_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
1198 } else if (!strcmp(ccache_attr->attr.name, "timeout_secs")) {
1200 new_op->upcall.req.param.op =
1201 PVFS2_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
1208 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
1209 ncache_attr = (struct ncache_orangefs_attribute *)attr;
1211 if (!strcmp(ncache_attr->attr.name, "hard_limit")) {
1213 new_op->upcall.req.param.op =
1214 PVFS2_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
1219 } else if (!strcmp(ncache_attr->attr.name, "soft_limit")) {
1221 new_op->upcall.req.param.op =
1222 PVFS2_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
1227 } else if (!strcmp(ncache_attr->attr.name,
1228 "reclaim_percentage")) {
1229 if ((val > -1) && (val < 101)) {
1230 new_op->upcall.req.param.op =
1231 PVFS2_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
1236 } else if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) {
1238 new_op->upcall.req.param.op =
1239 PVFS2_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
1247 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
1253 new_op->upcall.req.param.type = PVFS2_PARAM_REQUEST_SET;
1255 new_op->upcall.req.param.value = val;
1258 * The service_operation will return a errno return code on
1259 * error, and zero on success.
1261 rc = service_operation(new_op, "pvfs2_param", PVFS2_OP_INTERRUPTIBLE);
1264 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
1273 * if we got ENOMEM, then op_alloc probably failed...
1287 service_orangefs_store(struct orangefs_obj *orangefs_obj,
1288 struct orangefs_attribute *attr,
1294 rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr);
1296 /* rc should have an errno value if the service_op went bad. */
1304 service_acache_store(struct acache_orangefs_obj *acache_orangefs_obj,
1305 struct acache_orangefs_attribute *attr,
1311 rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr);
1313 /* rc should have an errno value if the service_op went bad. */
1321 service_capcache_store(struct capcache_orangefs_obj
1322 *capcache_orangefs_obj,
1323 struct capcache_orangefs_attribute *attr,
1329 rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr);
1331 /* rc should have an errno value if the service_op went bad. */
1338 static ssize_t service_ccache_store(struct ccache_orangefs_obj
1339 *ccache_orangefs_obj,
1340 struct ccache_orangefs_attribute *attr,
1346 rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr);
1348 /* rc should have an errno value if the service_op went bad. */
1356 service_ncache_store(struct ncache_orangefs_obj *ncache_orangefs_obj,
1357 struct ncache_orangefs_attribute *attr,
1363 rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr);
1365 /* rc should have an errno value if the service_op went bad. */
1372 static struct orangefs_attribute op_timeout_secs_attribute =
1373 __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store);
1375 static struct orangefs_attribute slot_timeout_secs_attribute =
1376 __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store);
1378 static struct orangefs_attribute perf_counter_reset_attribute =
1379 __ATTR(perf_counter_reset,
1381 service_orangefs_show,
1382 service_orangefs_store);
1384 static struct orangefs_attribute perf_history_size_attribute =
1385 __ATTR(perf_history_size,
1387 service_orangefs_show,
1388 service_orangefs_store);
1390 static struct orangefs_attribute perf_time_interval_secs_attribute =
1391 __ATTR(perf_time_interval_secs,
1393 service_orangefs_show,
1394 service_orangefs_store);
1396 static struct attribute *orangefs_default_attrs[] = {
1397 &op_timeout_secs_attribute.attr,
1398 &slot_timeout_secs_attribute.attr,
1399 &perf_counter_reset_attribute.attr,
1400 &perf_history_size_attribute.attr,
1401 &perf_time_interval_secs_attribute.attr,
1405 static struct kobj_type orangefs_ktype = {
1406 .sysfs_ops = &orangefs_sysfs_ops,
1407 .release = orangefs_release,
1408 .default_attrs = orangefs_default_attrs,
1411 static struct acache_orangefs_attribute acache_hard_limit_attribute =
1414 service_acache_show,
1415 service_acache_store);
1417 static struct acache_orangefs_attribute acache_reclaim_percent_attribute =
1418 __ATTR(reclaim_percentage,
1420 service_acache_show,
1421 service_acache_store);
1423 static struct acache_orangefs_attribute acache_soft_limit_attribute =
1426 service_acache_show,
1427 service_acache_store);
1429 static struct acache_orangefs_attribute acache_timeout_msecs_attribute =
1430 __ATTR(timeout_msecs,
1432 service_acache_show,
1433 service_acache_store);
1435 static struct attribute *acache_orangefs_default_attrs[] = {
1436 &acache_hard_limit_attribute.attr,
1437 &acache_reclaim_percent_attribute.attr,
1438 &acache_soft_limit_attribute.attr,
1439 &acache_timeout_msecs_attribute.attr,
1443 static struct kobj_type acache_orangefs_ktype = {
1444 .sysfs_ops = &acache_orangefs_sysfs_ops,
1445 .release = acache_orangefs_release,
1446 .default_attrs = acache_orangefs_default_attrs,
1449 static struct capcache_orangefs_attribute capcache_hard_limit_attribute =
1452 service_capcache_show,
1453 service_capcache_store);
1455 static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute =
1456 __ATTR(reclaim_percentage,
1458 service_capcache_show,
1459 service_capcache_store);
1461 static struct capcache_orangefs_attribute capcache_soft_limit_attribute =
1464 service_capcache_show,
1465 service_capcache_store);
1467 static struct capcache_orangefs_attribute capcache_timeout_secs_attribute =
1468 __ATTR(timeout_secs,
1470 service_capcache_show,
1471 service_capcache_store);
1473 static struct attribute *capcache_orangefs_default_attrs[] = {
1474 &capcache_hard_limit_attribute.attr,
1475 &capcache_reclaim_percent_attribute.attr,
1476 &capcache_soft_limit_attribute.attr,
1477 &capcache_timeout_secs_attribute.attr,
1481 static struct kobj_type capcache_orangefs_ktype = {
1482 .sysfs_ops = &capcache_orangefs_sysfs_ops,
1483 .release = capcache_orangefs_release,
1484 .default_attrs = capcache_orangefs_default_attrs,
1487 static struct ccache_orangefs_attribute ccache_hard_limit_attribute =
1490 service_ccache_show,
1491 service_ccache_store);
1493 static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute =
1494 __ATTR(reclaim_percentage,
1496 service_ccache_show,
1497 service_ccache_store);
1499 static struct ccache_orangefs_attribute ccache_soft_limit_attribute =
1502 service_ccache_show,
1503 service_ccache_store);
1505 static struct ccache_orangefs_attribute ccache_timeout_secs_attribute =
1506 __ATTR(timeout_secs,
1508 service_ccache_show,
1509 service_ccache_store);
1511 static struct attribute *ccache_orangefs_default_attrs[] = {
1512 &ccache_hard_limit_attribute.attr,
1513 &ccache_reclaim_percent_attribute.attr,
1514 &ccache_soft_limit_attribute.attr,
1515 &ccache_timeout_secs_attribute.attr,
1519 static struct kobj_type ccache_orangefs_ktype = {
1520 .sysfs_ops = &ccache_orangefs_sysfs_ops,
1521 .release = ccache_orangefs_release,
1522 .default_attrs = ccache_orangefs_default_attrs,
1525 static struct ncache_orangefs_attribute ncache_hard_limit_attribute =
1528 service_ncache_show,
1529 service_ncache_store);
1531 static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute =
1532 __ATTR(reclaim_percentage,
1534 service_ncache_show,
1535 service_ncache_store);
1537 static struct ncache_orangefs_attribute ncache_soft_limit_attribute =
1540 service_ncache_show,
1541 service_ncache_store);
1543 static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute =
1544 __ATTR(timeout_msecs,
1546 service_ncache_show,
1547 service_ncache_store);
1549 static struct attribute *ncache_orangefs_default_attrs[] = {
1550 &ncache_hard_limit_attribute.attr,
1551 &ncache_reclaim_percent_attribute.attr,
1552 &ncache_soft_limit_attribute.attr,
1553 &ncache_timeout_msecs_attribute.attr,
1557 static struct kobj_type ncache_orangefs_ktype = {
1558 .sysfs_ops = &ncache_orangefs_sysfs_ops,
1559 .release = ncache_orangefs_release,
1560 .default_attrs = ncache_orangefs_default_attrs,
1563 static struct pc_orangefs_attribute pc_acache_attribute =
1569 static struct pc_orangefs_attribute pc_capcache_attribute =
1575 static struct pc_orangefs_attribute pc_ncache_attribute =
1581 static struct attribute *pc_orangefs_default_attrs[] = {
1582 &pc_acache_attribute.attr,
1583 &pc_capcache_attribute.attr,
1584 &pc_ncache_attribute.attr,
1588 static struct kobj_type pc_orangefs_ktype = {
1589 .sysfs_ops = &pc_orangefs_sysfs_ops,
1590 .release = pc_orangefs_release,
1591 .default_attrs = pc_orangefs_default_attrs,
1594 static struct stats_orangefs_attribute stats_reads_attribute =
1600 static struct stats_orangefs_attribute stats_writes_attribute =
1606 static struct attribute *stats_orangefs_default_attrs[] = {
1607 &stats_reads_attribute.attr,
1608 &stats_writes_attribute.attr,
1612 static struct kobj_type stats_orangefs_ktype = {
1613 .sysfs_ops = &stats_orangefs_sysfs_ops,
1614 .release = stats_orangefs_release,
1615 .default_attrs = stats_orangefs_default_attrs,
1618 static struct orangefs_obj *orangefs_obj;
1619 static struct acache_orangefs_obj *acache_orangefs_obj;
1620 static struct capcache_orangefs_obj *capcache_orangefs_obj;
1621 static struct ccache_orangefs_obj *ccache_orangefs_obj;
1622 static struct ncache_orangefs_obj *ncache_orangefs_obj;
1623 static struct pc_orangefs_obj *pc_orangefs_obj;
1624 static struct stats_orangefs_obj *stats_orangefs_obj;
1626 int orangefs_sysfs_init(void)
1630 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1632 /* create /sys/fs/orangefs. */
1633 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1634 if (!orangefs_obj) {
1639 rc = kobject_init_and_add(&orangefs_obj->kobj,
1645 kobject_put(&orangefs_obj->kobj);
1650 kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD);
1652 /* create /sys/fs/orangefs/acache. */
1653 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1654 if (!acache_orangefs_obj) {
1659 rc = kobject_init_and_add(&acache_orangefs_obj->kobj,
1660 &acache_orangefs_ktype,
1661 &orangefs_obj->kobj,
1665 kobject_put(&acache_orangefs_obj->kobj);
1670 kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD);
1672 /* create /sys/fs/orangefs/capcache. */
1673 capcache_orangefs_obj =
1674 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1675 if (!capcache_orangefs_obj) {
1680 rc = kobject_init_and_add(&capcache_orangefs_obj->kobj,
1681 &capcache_orangefs_ktype,
1682 &orangefs_obj->kobj,
1685 kobject_put(&capcache_orangefs_obj->kobj);
1690 kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD);
1692 /* create /sys/fs/orangefs/ccache. */
1693 ccache_orangefs_obj =
1694 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1695 if (!ccache_orangefs_obj) {
1700 rc = kobject_init_and_add(&ccache_orangefs_obj->kobj,
1701 &ccache_orangefs_ktype,
1702 &orangefs_obj->kobj,
1705 kobject_put(&ccache_orangefs_obj->kobj);
1710 kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD);
1712 /* create /sys/fs/orangefs/ncache. */
1713 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1714 if (!ncache_orangefs_obj) {
1719 rc = kobject_init_and_add(&ncache_orangefs_obj->kobj,
1720 &ncache_orangefs_ktype,
1721 &orangefs_obj->kobj,
1725 kobject_put(&ncache_orangefs_obj->kobj);
1730 kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD);
1732 /* create /sys/fs/orangefs/perf_counters. */
1733 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1734 if (!pc_orangefs_obj) {
1739 rc = kobject_init_and_add(&pc_orangefs_obj->kobj,
1741 &orangefs_obj->kobj,
1745 kobject_put(&pc_orangefs_obj->kobj);
1750 kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD);
1752 /* create /sys/fs/orangefs/stats. */
1753 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1754 if (!stats_orangefs_obj) {
1759 rc = kobject_init_and_add(&stats_orangefs_obj->kobj,
1760 &stats_orangefs_ktype,
1761 &orangefs_obj->kobj,
1765 kobject_put(&stats_orangefs_obj->kobj);
1770 kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD);
1775 void orangefs_sysfs_exit(void)
1777 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1779 kobject_put(&acache_orangefs_obj->kobj);
1780 kobject_put(&capcache_orangefs_obj->kobj);
1781 kobject_put(&ccache_orangefs_obj->kobj);
1782 kobject_put(&ncache_orangefs_obj->kobj);
1783 kobject_put(&pc_orangefs_obj->kobj);
1784 kobject_put(&stats_orangefs_obj->kobj);
1786 kobject_put(&orangefs_obj->kobj);