2 * Documentation/ABI/stable/orangefs-sysfs:
4 * What: /sys/fs/orangefs/perf_counter_reset
6 * Contact: Mike Marshall <hubcap@omnibond.com>
8 * echo a 0 or a 1 into perf_counter_reset to
9 * reset all the counters in
10 * /sys/fs/orangefs/perf_counters
11 * except ones with PINT_PERF_PRESERVE set.
14 * What: /sys/fs/orangefs/perf_counters/...
16 * Contact: Mike Marshall <hubcap@omnibond.com>
18 * Counters and settings for various caches.
22 * What: /sys/fs/orangefs/perf_time_interval_secs
24 * Contact: Mike Marshall <hubcap@omnibond.com>
26 * Length of perf counter intervals in
30 * What: /sys/fs/orangefs/perf_history_size
32 * Contact: Mike Marshall <hubcap@omnibond.com>
34 * The perf_counters cache statistics have N, or
35 * perf_history_size, samples. The default is
38 * Every perf_time_interval_secs the (first)
41 * If N is greater than one, the "current" set
42 * of samples is reset, and the samples from the
43 * other N-1 intervals remain available.
46 * What: /sys/fs/orangefs/op_timeout_secs
48 * Contact: Mike Marshall <hubcap@omnibond.com>
50 * Service operation timeout in seconds.
53 * What: /sys/fs/orangefs/slot_timeout_secs
55 * Contact: Mike Marshall <hubcap@omnibond.com>
57 * "Slot" timeout in seconds. A "slot"
58 * is an indexed buffer in the shared
59 * memory segment used for communication
60 * between the kernel module and userspace.
61 * Slots are requested and waited for,
62 * the wait times out after slot_timeout_secs.
64 * What: /sys/fs/orangefs/dcache_timeout_msecs
66 * Contact: Martin Brandenburg <martin@omnibond.com>
68 * Time lookup is valid in milliseconds.
70 * What: /sys/fs/orangefs/getattr_timeout_msecs
72 * Contact: Martin Brandenburg <martin@omnibond.com>
74 * Time getattr is valid in milliseconds.
76 * What: /sys/fs/orangefs/readahead_count
78 * Contact: Martin Brandenburg <martin@omnibond.com>
80 * Readahead cache buffer count.
82 * What: /sys/fs/orangefs/readahead_size
84 * Contact: Martin Brandenburg <martin@omnibond.com>
86 * Readahead cache buffer size.
88 * What: /sys/fs/orangefs/readahead_count_size
90 * Contact: Martin Brandenburg <martin@omnibond.com>
92 * Readahead cache buffer count and size.
94 * What: /sys/fs/orangefs/acache/...
96 * Contact: Martin Brandenburg <martin@omnibond.com>
98 * Attribute cache configurable settings.
101 * What: /sys/fs/orangefs/ncache/...
103 * Contact: Mike Marshall <hubcap@omnibond.com>
105 * Name cache configurable settings.
108 * What: /sys/fs/orangefs/capcache/...
110 * Contact: Mike Marshall <hubcap@omnibond.com>
112 * Capability cache configurable settings.
115 * What: /sys/fs/orangefs/ccache/...
117 * Contact: Mike Marshall <hubcap@omnibond.com>
119 * Credential cache configurable settings.
123 #include <linux/fs.h>
124 #include <linux/kobject.h>
125 #include <linux/string.h>
126 #include <linux/sysfs.h>
127 #include <linux/module.h>
128 #include <linux/init.h>
130 #include "protocol.h"
131 #include "orangefs-kernel.h"
132 #include "orangefs-sysfs.h"
134 #define ORANGEFS_KOBJ_ID "orangefs"
135 #define ACACHE_KOBJ_ID "acache"
136 #define CAPCACHE_KOBJ_ID "capcache"
137 #define CCACHE_KOBJ_ID "ccache"
138 #define NCACHE_KOBJ_ID "ncache"
139 #define PC_KOBJ_ID "pc"
140 #define STATS_KOBJ_ID "stats"
142 struct orangefs_obj
{
145 int perf_counter_reset
;
146 int perf_history_size
;
147 int perf_time_interval_secs
;
148 int slot_timeout_secs
;
149 int dcache_timeout_msecs
;
150 int getattr_timeout_msecs
;
153 struct acache_orangefs_obj
{
156 int reclaim_percentage
;
161 struct capcache_orangefs_obj
{
164 int reclaim_percentage
;
169 struct ccache_orangefs_obj
{
172 int reclaim_percentage
;
177 struct ncache_orangefs_obj
{
180 int reclaim_percentage
;
185 struct pc_orangefs_obj
{
192 struct stats_orangefs_obj
{
198 struct orangefs_attribute
{
199 struct attribute attr
;
200 ssize_t (*show
)(struct orangefs_obj
*orangefs_obj
,
201 struct orangefs_attribute
*attr
,
203 ssize_t (*store
)(struct orangefs_obj
*orangefs_obj
,
204 struct orangefs_attribute
*attr
,
209 struct acache_orangefs_attribute
{
210 struct attribute attr
;
211 ssize_t (*show
)(struct acache_orangefs_obj
*acache_orangefs_obj
,
212 struct acache_orangefs_attribute
*attr
,
214 ssize_t (*store
)(struct acache_orangefs_obj
*acache_orangefs_obj
,
215 struct acache_orangefs_attribute
*attr
,
220 struct capcache_orangefs_attribute
{
221 struct attribute attr
;
222 ssize_t (*show
)(struct capcache_orangefs_obj
*capcache_orangefs_obj
,
223 struct capcache_orangefs_attribute
*attr
,
225 ssize_t (*store
)(struct capcache_orangefs_obj
*capcache_orangefs_obj
,
226 struct capcache_orangefs_attribute
*attr
,
231 struct ccache_orangefs_attribute
{
232 struct attribute attr
;
233 ssize_t (*show
)(struct ccache_orangefs_obj
*ccache_orangefs_obj
,
234 struct ccache_orangefs_attribute
*attr
,
236 ssize_t (*store
)(struct ccache_orangefs_obj
*ccache_orangefs_obj
,
237 struct ccache_orangefs_attribute
*attr
,
242 struct ncache_orangefs_attribute
{
243 struct attribute attr
;
244 ssize_t (*show
)(struct ncache_orangefs_obj
*ncache_orangefs_obj
,
245 struct ncache_orangefs_attribute
*attr
,
247 ssize_t (*store
)(struct ncache_orangefs_obj
*ncache_orangefs_obj
,
248 struct ncache_orangefs_attribute
*attr
,
253 struct pc_orangefs_attribute
{
254 struct attribute attr
;
255 ssize_t (*show
)(struct pc_orangefs_obj
*pc_orangefs_obj
,
256 struct pc_orangefs_attribute
*attr
,
258 ssize_t (*store
)(struct pc_orangefs_obj
*pc_orangefs_obj
,
259 struct pc_orangefs_attribute
*attr
,
264 struct stats_orangefs_attribute
{
265 struct attribute attr
;
266 ssize_t (*show
)(struct stats_orangefs_obj
*stats_orangefs_obj
,
267 struct stats_orangefs_attribute
*attr
,
269 ssize_t (*store
)(struct stats_orangefs_obj
*stats_orangefs_obj
,
270 struct stats_orangefs_attribute
*attr
,
275 static ssize_t
orangefs_attr_show(struct kobject
*kobj
,
276 struct attribute
*attr
,
279 struct orangefs_attribute
*attribute
;
280 struct orangefs_obj
*orangefs_obj
;
283 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
284 orangefs_obj
= container_of(kobj
, struct orangefs_obj
, kobj
);
286 if (!attribute
->show
) {
291 rc
= attribute
->show(orangefs_obj
, attribute
, buf
);
297 static ssize_t
orangefs_attr_store(struct kobject
*kobj
,
298 struct attribute
*attr
,
302 struct orangefs_attribute
*attribute
;
303 struct orangefs_obj
*orangefs_obj
;
306 gossip_debug(GOSSIP_SYSFS_DEBUG
,
307 "orangefs_attr_store: start\n");
309 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
310 orangefs_obj
= container_of(kobj
, struct orangefs_obj
, kobj
);
312 if (!attribute
->store
) {
317 rc
= attribute
->store(orangefs_obj
, attribute
, buf
, len
);
323 static const struct sysfs_ops orangefs_sysfs_ops
= {
324 .show
= orangefs_attr_show
,
325 .store
= orangefs_attr_store
,
328 static ssize_t
acache_orangefs_attr_show(struct kobject
*kobj
,
329 struct attribute
*attr
,
332 struct acache_orangefs_attribute
*attribute
;
333 struct acache_orangefs_obj
*acache_orangefs_obj
;
336 attribute
= container_of(attr
, struct acache_orangefs_attribute
, attr
);
337 acache_orangefs_obj
=
338 container_of(kobj
, struct acache_orangefs_obj
, kobj
);
340 if (!attribute
->show
) {
345 rc
= attribute
->show(acache_orangefs_obj
, attribute
, buf
);
351 static ssize_t
acache_orangefs_attr_store(struct kobject
*kobj
,
352 struct attribute
*attr
,
356 struct acache_orangefs_attribute
*attribute
;
357 struct acache_orangefs_obj
*acache_orangefs_obj
;
360 gossip_debug(GOSSIP_SYSFS_DEBUG
,
361 "acache_orangefs_attr_store: start\n");
363 attribute
= container_of(attr
, struct acache_orangefs_attribute
, attr
);
364 acache_orangefs_obj
=
365 container_of(kobj
, struct acache_orangefs_obj
, kobj
);
367 if (!attribute
->store
) {
372 rc
= attribute
->store(acache_orangefs_obj
, attribute
, buf
, len
);
378 static const struct sysfs_ops acache_orangefs_sysfs_ops
= {
379 .show
= acache_orangefs_attr_show
,
380 .store
= acache_orangefs_attr_store
,
383 static ssize_t
capcache_orangefs_attr_show(struct kobject
*kobj
,
384 struct attribute
*attr
,
387 struct capcache_orangefs_attribute
*attribute
;
388 struct capcache_orangefs_obj
*capcache_orangefs_obj
;
392 container_of(attr
, struct capcache_orangefs_attribute
, attr
);
393 capcache_orangefs_obj
=
394 container_of(kobj
, struct capcache_orangefs_obj
, kobj
);
396 if (!attribute
->show
) {
401 rc
= attribute
->show(capcache_orangefs_obj
, attribute
, buf
);
407 static ssize_t
capcache_orangefs_attr_store(struct kobject
*kobj
,
408 struct attribute
*attr
,
412 struct capcache_orangefs_attribute
*attribute
;
413 struct capcache_orangefs_obj
*capcache_orangefs_obj
;
416 gossip_debug(GOSSIP_SYSFS_DEBUG
,
417 "capcache_orangefs_attr_store: start\n");
420 container_of(attr
, struct capcache_orangefs_attribute
, attr
);
421 capcache_orangefs_obj
=
422 container_of(kobj
, struct capcache_orangefs_obj
, kobj
);
424 if (!attribute
->store
) {
429 rc
= attribute
->store(capcache_orangefs_obj
, attribute
, buf
, len
);
435 static const struct sysfs_ops capcache_orangefs_sysfs_ops
= {
436 .show
= capcache_orangefs_attr_show
,
437 .store
= capcache_orangefs_attr_store
,
440 static ssize_t
ccache_orangefs_attr_show(struct kobject
*kobj
,
441 struct attribute
*attr
,
444 struct ccache_orangefs_attribute
*attribute
;
445 struct ccache_orangefs_obj
*ccache_orangefs_obj
;
449 container_of(attr
, struct ccache_orangefs_attribute
, attr
);
450 ccache_orangefs_obj
=
451 container_of(kobj
, struct ccache_orangefs_obj
, kobj
);
453 if (!attribute
->show
) {
458 rc
= attribute
->show(ccache_orangefs_obj
, attribute
, buf
);
464 static ssize_t
ccache_orangefs_attr_store(struct kobject
*kobj
,
465 struct attribute
*attr
,
469 struct ccache_orangefs_attribute
*attribute
;
470 struct ccache_orangefs_obj
*ccache_orangefs_obj
;
473 gossip_debug(GOSSIP_SYSFS_DEBUG
,
474 "ccache_orangefs_attr_store: start\n");
477 container_of(attr
, struct ccache_orangefs_attribute
, attr
);
478 ccache_orangefs_obj
=
479 container_of(kobj
, struct ccache_orangefs_obj
, kobj
);
481 if (!attribute
->store
) {
486 rc
= attribute
->store(ccache_orangefs_obj
, attribute
, buf
, len
);
492 static const struct sysfs_ops ccache_orangefs_sysfs_ops
= {
493 .show
= ccache_orangefs_attr_show
,
494 .store
= ccache_orangefs_attr_store
,
497 static ssize_t
ncache_orangefs_attr_show(struct kobject
*kobj
,
498 struct attribute
*attr
,
501 struct ncache_orangefs_attribute
*attribute
;
502 struct ncache_orangefs_obj
*ncache_orangefs_obj
;
505 attribute
= container_of(attr
, struct ncache_orangefs_attribute
, attr
);
506 ncache_orangefs_obj
=
507 container_of(kobj
, struct ncache_orangefs_obj
, kobj
);
509 if (!attribute
->show
) {
514 rc
= attribute
->show(ncache_orangefs_obj
, attribute
, buf
);
520 static ssize_t
ncache_orangefs_attr_store(struct kobject
*kobj
,
521 struct attribute
*attr
,
525 struct ncache_orangefs_attribute
*attribute
;
526 struct ncache_orangefs_obj
*ncache_orangefs_obj
;
529 gossip_debug(GOSSIP_SYSFS_DEBUG
,
530 "ncache_orangefs_attr_store: start\n");
532 attribute
= container_of(attr
, struct ncache_orangefs_attribute
, attr
);
533 ncache_orangefs_obj
=
534 container_of(kobj
, struct ncache_orangefs_obj
, kobj
);
536 if (!attribute
->store
) {
541 rc
= attribute
->store(ncache_orangefs_obj
, attribute
, buf
, len
);
547 static const struct sysfs_ops ncache_orangefs_sysfs_ops
= {
548 .show
= ncache_orangefs_attr_show
,
549 .store
= ncache_orangefs_attr_store
,
552 static ssize_t
pc_orangefs_attr_show(struct kobject
*kobj
,
553 struct attribute
*attr
,
556 struct pc_orangefs_attribute
*attribute
;
557 struct pc_orangefs_obj
*pc_orangefs_obj
;
560 attribute
= container_of(attr
, struct pc_orangefs_attribute
, attr
);
562 container_of(kobj
, struct pc_orangefs_obj
, kobj
);
564 if (!attribute
->show
) {
569 rc
= attribute
->show(pc_orangefs_obj
, attribute
, buf
);
575 static const struct sysfs_ops pc_orangefs_sysfs_ops
= {
576 .show
= pc_orangefs_attr_show
,
579 static ssize_t
stats_orangefs_attr_show(struct kobject
*kobj
,
580 struct attribute
*attr
,
583 struct stats_orangefs_attribute
*attribute
;
584 struct stats_orangefs_obj
*stats_orangefs_obj
;
587 attribute
= container_of(attr
, struct stats_orangefs_attribute
, attr
);
589 container_of(kobj
, struct stats_orangefs_obj
, kobj
);
591 if (!attribute
->show
) {
596 rc
= attribute
->show(stats_orangefs_obj
, attribute
, buf
);
602 static const struct sysfs_ops stats_orangefs_sysfs_ops
= {
603 .show
= stats_orangefs_attr_show
,
606 static void orangefs_release(struct kobject
*kobj
)
608 struct orangefs_obj
*orangefs_obj
;
610 orangefs_obj
= container_of(kobj
, struct orangefs_obj
, kobj
);
614 static void acache_orangefs_release(struct kobject
*kobj
)
616 struct acache_orangefs_obj
*acache_orangefs_obj
;
618 acache_orangefs_obj
=
619 container_of(kobj
, struct acache_orangefs_obj
, kobj
);
620 kfree(acache_orangefs_obj
);
623 static void capcache_orangefs_release(struct kobject
*kobj
)
625 struct capcache_orangefs_obj
*capcache_orangefs_obj
;
627 capcache_orangefs_obj
=
628 container_of(kobj
, struct capcache_orangefs_obj
, kobj
);
629 kfree(capcache_orangefs_obj
);
632 static void ccache_orangefs_release(struct kobject
*kobj
)
634 struct ccache_orangefs_obj
*ccache_orangefs_obj
;
636 ccache_orangefs_obj
=
637 container_of(kobj
, struct ccache_orangefs_obj
, kobj
);
638 kfree(ccache_orangefs_obj
);
641 static void ncache_orangefs_release(struct kobject
*kobj
)
643 struct ncache_orangefs_obj
*ncache_orangefs_obj
;
645 ncache_orangefs_obj
=
646 container_of(kobj
, struct ncache_orangefs_obj
, kobj
);
647 kfree(ncache_orangefs_obj
);
650 static void pc_orangefs_release(struct kobject
*kobj
)
652 struct pc_orangefs_obj
*pc_orangefs_obj
;
655 container_of(kobj
, struct pc_orangefs_obj
, kobj
);
656 kfree(pc_orangefs_obj
);
659 static void stats_orangefs_release(struct kobject
*kobj
)
661 struct stats_orangefs_obj
*stats_orangefs_obj
;
664 container_of(kobj
, struct stats_orangefs_obj
, kobj
);
665 kfree(stats_orangefs_obj
);
668 static ssize_t
sysfs_int_show(char *kobj_id
, char *buf
, void *attr
)
671 struct orangefs_attribute
*orangefs_attr
;
672 struct stats_orangefs_attribute
*stats_orangefs_attr
;
674 gossip_debug(GOSSIP_SYSFS_DEBUG
, "sysfs_int_show: id:%s:\n", kobj_id
);
676 if (!strcmp(kobj_id
, ORANGEFS_KOBJ_ID
)) {
677 orangefs_attr
= (struct orangefs_attribute
*)attr
;
679 if (!strcmp(orangefs_attr
->attr
.name
, "op_timeout_secs")) {
685 } else if (!strcmp(orangefs_attr
->attr
.name
,
686 "slot_timeout_secs")) {
692 } else if (!strcmp(orangefs_attr
->attr
.name
,
693 "dcache_timeout_msecs")) {
697 dcache_timeout_msecs
);
699 } else if (!strcmp(orangefs_attr
->attr
.name
,
700 "getattr_timeout_msecs")) {
704 getattr_timeout_msecs
);
710 } else if (!strcmp(kobj_id
, STATS_KOBJ_ID
)) {
711 stats_orangefs_attr
= (struct stats_orangefs_attribute
*)attr
;
713 if (!strcmp(stats_orangefs_attr
->attr
.name
, "reads")) {
717 g_orangefs_stats
.reads
);
719 } else if (!strcmp(stats_orangefs_attr
->attr
.name
, "writes")) {
723 g_orangefs_stats
.writes
);
735 static ssize_t
int_orangefs_show(struct orangefs_obj
*orangefs_obj
,
736 struct orangefs_attribute
*attr
,
741 gossip_debug(GOSSIP_SYSFS_DEBUG
,
742 "int_orangefs_show:start attr->attr.name:%s:\n",
745 rc
= sysfs_int_show(ORANGEFS_KOBJ_ID
, buf
, (void *) attr
);
750 static ssize_t
int_stats_show(struct stats_orangefs_obj
*stats_orangefs_obj
,
751 struct stats_orangefs_attribute
*attr
,
756 gossip_debug(GOSSIP_SYSFS_DEBUG
,
757 "int_stats_show:start attr->attr.name:%s:\n",
760 rc
= sysfs_int_show(STATS_KOBJ_ID
, buf
, (void *) attr
);
765 static ssize_t
int_store(struct orangefs_obj
*orangefs_obj
,
766 struct orangefs_attribute
*attr
,
772 gossip_debug(GOSSIP_SYSFS_DEBUG
,
773 "int_store: start attr->attr.name:%s: buf:%s:\n",
774 attr
->attr
.name
, buf
);
776 if (!strcmp(attr
->attr
.name
, "op_timeout_secs")) {
777 rc
= kstrtoint(buf
, 0, &op_timeout_secs
);
779 } else if (!strcmp(attr
->attr
.name
, "slot_timeout_secs")) {
780 rc
= kstrtoint(buf
, 0, &slot_timeout_secs
);
782 } else if (!strcmp(attr
->attr
.name
, "dcache_timeout_msecs")) {
783 rc
= kstrtoint(buf
, 0, &dcache_timeout_msecs
);
785 } else if (!strcmp(attr
->attr
.name
, "getattr_timeout_msecs")) {
786 rc
= kstrtoint(buf
, 0, &getattr_timeout_msecs
);
802 * obtain attribute values from userspace with a service operation.
804 static int sysfs_service_op_show(char *kobj_id
, char *buf
, void *attr
)
806 struct orangefs_kernel_op_s
*new_op
= NULL
;
808 char *ser_op_type
= NULL
;
809 struct orangefs_attribute
*orangefs_attr
;
810 struct acache_orangefs_attribute
*acache_attr
;
811 struct capcache_orangefs_attribute
*capcache_attr
;
812 struct ccache_orangefs_attribute
*ccache_attr
;
813 struct ncache_orangefs_attribute
*ncache_attr
;
814 struct pc_orangefs_attribute
*pc_attr
;
817 gossip_debug(GOSSIP_SYSFS_DEBUG
,
818 "sysfs_service_op_show: id:%s:\n",
821 if (strcmp(kobj_id
, PC_KOBJ_ID
))
822 op_alloc_type
= ORANGEFS_VFS_OP_PARAM
;
824 op_alloc_type
= ORANGEFS_VFS_OP_PERF_COUNT
;
826 new_op
= op_alloc(op_alloc_type
);
830 /* Can't do a service_operation if the client is not running... */
831 rc
= is_daemon_in_service();
833 pr_info("%s: Client not running :%d:\n",
835 is_daemon_in_service());
839 if (strcmp(kobj_id
, PC_KOBJ_ID
))
840 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_GET
;
842 if (!strcmp(kobj_id
, ORANGEFS_KOBJ_ID
)) {
843 orangefs_attr
= (struct orangefs_attribute
*)attr
;
845 if (!strcmp(orangefs_attr
->attr
.name
, "perf_history_size"))
846 new_op
->upcall
.req
.param
.op
=
847 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
848 else if (!strcmp(orangefs_attr
->attr
.name
,
849 "perf_time_interval_secs"))
850 new_op
->upcall
.req
.param
.op
=
851 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
852 else if (!strcmp(orangefs_attr
->attr
.name
,
853 "perf_counter_reset"))
854 new_op
->upcall
.req
.param
.op
=
855 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
857 else if (!strcmp(orangefs_attr
->attr
.name
,
859 new_op
->upcall
.req
.param
.op
=
860 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
862 else if (!strcmp(orangefs_attr
->attr
.name
,
864 new_op
->upcall
.req
.param
.op
=
865 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
867 else if (!strcmp(orangefs_attr
->attr
.name
,
868 "readahead_count_size"))
869 new_op
->upcall
.req
.param
.op
=
870 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
871 } else if (!strcmp(kobj_id
, ACACHE_KOBJ_ID
)) {
872 acache_attr
= (struct acache_orangefs_attribute
*)attr
;
874 if (!strcmp(acache_attr
->attr
.name
, "timeout_msecs"))
875 new_op
->upcall
.req
.param
.op
=
876 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
878 if (!strcmp(acache_attr
->attr
.name
, "hard_limit"))
879 new_op
->upcall
.req
.param
.op
=
880 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
882 if (!strcmp(acache_attr
->attr
.name
, "soft_limit"))
883 new_op
->upcall
.req
.param
.op
=
884 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
886 if (!strcmp(acache_attr
->attr
.name
, "reclaim_percentage"))
887 new_op
->upcall
.req
.param
.op
=
888 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
890 } else if (!strcmp(kobj_id
, CAPCACHE_KOBJ_ID
)) {
891 capcache_attr
= (struct capcache_orangefs_attribute
*)attr
;
893 if (!strcmp(capcache_attr
->attr
.name
, "timeout_secs"))
894 new_op
->upcall
.req
.param
.op
=
895 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
897 if (!strcmp(capcache_attr
->attr
.name
, "hard_limit"))
898 new_op
->upcall
.req
.param
.op
=
899 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
901 if (!strcmp(capcache_attr
->attr
.name
, "soft_limit"))
902 new_op
->upcall
.req
.param
.op
=
903 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
905 if (!strcmp(capcache_attr
->attr
.name
, "reclaim_percentage"))
906 new_op
->upcall
.req
.param
.op
=
907 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
909 } else if (!strcmp(kobj_id
, CCACHE_KOBJ_ID
)) {
910 ccache_attr
= (struct ccache_orangefs_attribute
*)attr
;
912 if (!strcmp(ccache_attr
->attr
.name
, "timeout_secs"))
913 new_op
->upcall
.req
.param
.op
=
914 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
916 if (!strcmp(ccache_attr
->attr
.name
, "hard_limit"))
917 new_op
->upcall
.req
.param
.op
=
918 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
920 if (!strcmp(ccache_attr
->attr
.name
, "soft_limit"))
921 new_op
->upcall
.req
.param
.op
=
922 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
924 if (!strcmp(ccache_attr
->attr
.name
, "reclaim_percentage"))
925 new_op
->upcall
.req
.param
.op
=
926 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
928 } else if (!strcmp(kobj_id
, NCACHE_KOBJ_ID
)) {
929 ncache_attr
= (struct ncache_orangefs_attribute
*)attr
;
931 if (!strcmp(ncache_attr
->attr
.name
, "timeout_msecs"))
932 new_op
->upcall
.req
.param
.op
=
933 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
935 if (!strcmp(ncache_attr
->attr
.name
, "hard_limit"))
936 new_op
->upcall
.req
.param
.op
=
937 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
939 if (!strcmp(ncache_attr
->attr
.name
, "soft_limit"))
940 new_op
->upcall
.req
.param
.op
=
941 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
943 if (!strcmp(ncache_attr
->attr
.name
, "reclaim_percentage"))
944 new_op
->upcall
.req
.param
.op
=
945 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
947 } else if (!strcmp(kobj_id
, PC_KOBJ_ID
)) {
948 pc_attr
= (struct pc_orangefs_attribute
*)attr
;
950 if (!strcmp(pc_attr
->attr
.name
, ACACHE_KOBJ_ID
))
951 new_op
->upcall
.req
.perf_count
.type
=
952 ORANGEFS_PERF_COUNT_REQUEST_ACACHE
;
954 if (!strcmp(pc_attr
->attr
.name
, CAPCACHE_KOBJ_ID
))
955 new_op
->upcall
.req
.perf_count
.type
=
956 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE
;
958 if (!strcmp(pc_attr
->attr
.name
, NCACHE_KOBJ_ID
))
959 new_op
->upcall
.req
.perf_count
.type
=
960 ORANGEFS_PERF_COUNT_REQUEST_NCACHE
;
963 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
970 if (strcmp(kobj_id
, PC_KOBJ_ID
))
971 ser_op_type
= "orangefs_param";
973 ser_op_type
= "orangefs_perf_count";
976 * The service_operation will return an errno return code on
977 * error, and zero on success.
979 rc
= service_operation(new_op
, ser_op_type
, ORANGEFS_OP_INTERRUPTIBLE
);
983 if (strcmp(kobj_id
, PC_KOBJ_ID
)) {
984 if (new_op
->upcall
.req
.param
.op
==
985 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
) {
986 rc
= scnprintf(buf
, PAGE_SIZE
, "%d %d\n",
987 (int)new_op
->downcall
.resp
.param
.u
.
989 (int)new_op
->downcall
.resp
.param
.u
.
992 rc
= scnprintf(buf
, PAGE_SIZE
, "%d\n",
993 (int)new_op
->downcall
.resp
.param
.u
.value64
);
1000 new_op
->downcall
.resp
.perf_count
.buffer
);
1010 static ssize_t
service_orangefs_show(struct orangefs_obj
*orangefs_obj
,
1011 struct orangefs_attribute
*attr
,
1016 rc
= sysfs_service_op_show(ORANGEFS_KOBJ_ID
, buf
, (void *)attr
);
1022 service_acache_show(struct acache_orangefs_obj
*acache_orangefs_obj
,
1023 struct acache_orangefs_attribute
*attr
,
1028 rc
= sysfs_service_op_show(ACACHE_KOBJ_ID
, buf
, (void *)attr
);
1033 static ssize_t
service_capcache_show(struct capcache_orangefs_obj
1034 *capcache_orangefs_obj
,
1035 struct capcache_orangefs_attribute
*attr
,
1040 rc
= sysfs_service_op_show(CAPCACHE_KOBJ_ID
, buf
, (void *)attr
);
1045 static ssize_t
service_ccache_show(struct ccache_orangefs_obj
1046 *ccache_orangefs_obj
,
1047 struct ccache_orangefs_attribute
*attr
,
1052 rc
= sysfs_service_op_show(CCACHE_KOBJ_ID
, buf
, (void *)attr
);
1058 service_ncache_show(struct ncache_orangefs_obj
*ncache_orangefs_obj
,
1059 struct ncache_orangefs_attribute
*attr
,
1064 rc
= sysfs_service_op_show(NCACHE_KOBJ_ID
, buf
, (void *)attr
);
1070 service_pc_show(struct pc_orangefs_obj
*pc_orangefs_obj
,
1071 struct pc_orangefs_attribute
*attr
,
1076 rc
= sysfs_service_op_show(PC_KOBJ_ID
, buf
, (void *)attr
);
1082 * pass attribute values back to userspace with a service operation.
1084 * We have to do a memory allocation, an sscanf and a service operation.
1085 * And we have to evaluate what the user entered, to make sure the
1086 * value is within the range supported by the attribute. So, there's
1087 * a lot of return code checking and mapping going on here.
1089 * We want to return 1 if we think everything went OK, and
1092 static int sysfs_service_op_store(char *kobj_id
, const char *buf
, void *attr
)
1094 struct orangefs_kernel_op_s
*new_op
= NULL
;
1097 struct orangefs_attribute
*orangefs_attr
;
1098 struct acache_orangefs_attribute
*acache_attr
;
1099 struct capcache_orangefs_attribute
*capcache_attr
;
1100 struct ccache_orangefs_attribute
*ccache_attr
;
1101 struct ncache_orangefs_attribute
*ncache_attr
;
1103 gossip_debug(GOSSIP_SYSFS_DEBUG
,
1104 "sysfs_service_op_store: id:%s:\n",
1107 new_op
= op_alloc(ORANGEFS_VFS_OP_PARAM
);
1109 return -EINVAL
; /* sic */
1111 /* Can't do a service_operation if the client is not running... */
1112 rc
= is_daemon_in_service();
1114 pr_info("%s: Client not running :%d:\n",
1116 is_daemon_in_service());
1121 * The value we want to send back to userspace is in buf, unless this
1122 * there are two parameters, which is specially handled below.
1124 if (strcmp(kobj_id
, ORANGEFS_KOBJ_ID
) ||
1125 strcmp(((struct orangefs_attribute
*)attr
)->attr
.name
,
1126 "readahead_count_size")) {
1127 rc
= kstrtoint(buf
, 0, &val
);
1132 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_SET
;
1134 if (!strcmp(kobj_id
, ORANGEFS_KOBJ_ID
)) {
1135 orangefs_attr
= (struct orangefs_attribute
*)attr
;
1137 if (!strcmp(orangefs_attr
->attr
.name
, "perf_history_size")) {
1139 new_op
->upcall
.req
.param
.op
=
1140 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
1145 } else if (!strcmp(orangefs_attr
->attr
.name
,
1146 "perf_time_interval_secs")) {
1148 new_op
->upcall
.req
.param
.op
=
1149 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
1154 } else if (!strcmp(orangefs_attr
->attr
.name
,
1155 "perf_counter_reset")) {
1156 if ((val
== 0) || (val
== 1)) {
1157 new_op
->upcall
.req
.param
.op
=
1158 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
1163 } else if (!strcmp(orangefs_attr
->attr
.name
,
1164 "readahead_count")) {
1166 new_op
->upcall
.req
.param
.op
=
1167 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
1172 } else if (!strcmp(orangefs_attr
->attr
.name
,
1173 "readahead_size")) {
1175 new_op
->upcall
.req
.param
.op
=
1176 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
1181 } else if (!strcmp(orangefs_attr
->attr
.name
,
1182 "readahead_count_size")) {
1184 rc
= sscanf(buf
, "%d %d", &val1
, &val2
);
1189 if ((val1
>= 0) && (val2
>= 0)) {
1190 new_op
->upcall
.req
.param
.op
=
1191 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
1196 new_op
->upcall
.req
.param
.u
.value32
[0] = val1
;
1197 new_op
->upcall
.req
.param
.u
.value32
[1] = val2
;
1199 } else if (!strcmp(orangefs_attr
->attr
.name
,
1200 "perf_counter_reset")) {
1202 new_op
->upcall
.req
.param
.op
=
1203 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
1210 } else if (!strcmp(kobj_id
, ACACHE_KOBJ_ID
)) {
1211 acache_attr
= (struct acache_orangefs_attribute
*)attr
;
1213 if (!strcmp(acache_attr
->attr
.name
, "hard_limit")) {
1215 new_op
->upcall
.req
.param
.op
=
1216 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
1221 } else if (!strcmp(acache_attr
->attr
.name
, "soft_limit")) {
1223 new_op
->upcall
.req
.param
.op
=
1224 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
1229 } else if (!strcmp(acache_attr
->attr
.name
,
1230 "reclaim_percentage")) {
1231 if ((val
> -1) && (val
< 101)) {
1232 new_op
->upcall
.req
.param
.op
=
1233 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
1238 } else if (!strcmp(acache_attr
->attr
.name
, "timeout_msecs")) {
1240 new_op
->upcall
.req
.param
.op
=
1241 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
1248 } else if (!strcmp(kobj_id
, CAPCACHE_KOBJ_ID
)) {
1249 capcache_attr
= (struct capcache_orangefs_attribute
*)attr
;
1251 if (!strcmp(capcache_attr
->attr
.name
, "hard_limit")) {
1253 new_op
->upcall
.req
.param
.op
=
1254 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
1259 } else if (!strcmp(capcache_attr
->attr
.name
, "soft_limit")) {
1261 new_op
->upcall
.req
.param
.op
=
1262 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
1267 } else if (!strcmp(capcache_attr
->attr
.name
,
1268 "reclaim_percentage")) {
1269 if ((val
> -1) && (val
< 101)) {
1270 new_op
->upcall
.req
.param
.op
=
1271 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
1276 } else if (!strcmp(capcache_attr
->attr
.name
, "timeout_secs")) {
1278 new_op
->upcall
.req
.param
.op
=
1279 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
1286 } else if (!strcmp(kobj_id
, CCACHE_KOBJ_ID
)) {
1287 ccache_attr
= (struct ccache_orangefs_attribute
*)attr
;
1289 if (!strcmp(ccache_attr
->attr
.name
, "hard_limit")) {
1291 new_op
->upcall
.req
.param
.op
=
1292 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
1297 } else if (!strcmp(ccache_attr
->attr
.name
, "soft_limit")) {
1299 new_op
->upcall
.req
.param
.op
=
1300 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
1305 } else if (!strcmp(ccache_attr
->attr
.name
,
1306 "reclaim_percentage")) {
1307 if ((val
> -1) && (val
< 101)) {
1308 new_op
->upcall
.req
.param
.op
=
1309 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
1314 } else if (!strcmp(ccache_attr
->attr
.name
, "timeout_secs")) {
1316 new_op
->upcall
.req
.param
.op
=
1317 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
1324 } else if (!strcmp(kobj_id
, NCACHE_KOBJ_ID
)) {
1325 ncache_attr
= (struct ncache_orangefs_attribute
*)attr
;
1327 if (!strcmp(ncache_attr
->attr
.name
, "hard_limit")) {
1329 new_op
->upcall
.req
.param
.op
=
1330 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
1335 } else if (!strcmp(ncache_attr
->attr
.name
, "soft_limit")) {
1337 new_op
->upcall
.req
.param
.op
=
1338 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
1343 } else if (!strcmp(ncache_attr
->attr
.name
,
1344 "reclaim_percentage")) {
1345 if ((val
> -1) && (val
< 101)) {
1346 new_op
->upcall
.req
.param
.op
=
1347 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
1352 } else if (!strcmp(ncache_attr
->attr
.name
, "timeout_msecs")) {
1354 new_op
->upcall
.req
.param
.op
=
1355 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
1363 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
1369 new_op
->upcall
.req
.param
.u
.value64
= val
;
1373 * The service_operation will return a errno return code on
1374 * error, and zero on success.
1376 rc
= service_operation(new_op
, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE
);
1379 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
1389 if (rc
== -ENOMEM
|| rc
== 0)
1396 service_orangefs_store(struct orangefs_obj
*orangefs_obj
,
1397 struct orangefs_attribute
*attr
,
1403 rc
= sysfs_service_op_store(ORANGEFS_KOBJ_ID
, buf
, (void *) attr
);
1405 /* rc should have an errno value if the service_op went bad. */
1413 service_acache_store(struct acache_orangefs_obj
*acache_orangefs_obj
,
1414 struct acache_orangefs_attribute
*attr
,
1420 rc
= sysfs_service_op_store(ACACHE_KOBJ_ID
, buf
, (void *) attr
);
1422 /* rc should have an errno value if the service_op went bad. */
1430 service_capcache_store(struct capcache_orangefs_obj
1431 *capcache_orangefs_obj
,
1432 struct capcache_orangefs_attribute
*attr
,
1438 rc
= sysfs_service_op_store(CAPCACHE_KOBJ_ID
, buf
, (void *) attr
);
1440 /* rc should have an errno value if the service_op went bad. */
1447 static ssize_t
service_ccache_store(struct ccache_orangefs_obj
1448 *ccache_orangefs_obj
,
1449 struct ccache_orangefs_attribute
*attr
,
1455 rc
= sysfs_service_op_store(CCACHE_KOBJ_ID
, buf
, (void *) attr
);
1457 /* rc should have an errno value if the service_op went bad. */
1465 service_ncache_store(struct ncache_orangefs_obj
*ncache_orangefs_obj
,
1466 struct ncache_orangefs_attribute
*attr
,
1472 rc
= sysfs_service_op_store(NCACHE_KOBJ_ID
, buf
, (void *) attr
);
1474 /* rc should have an errno value if the service_op went bad. */
1481 static struct orangefs_attribute op_timeout_secs_attribute
=
1482 __ATTR(op_timeout_secs
, 0664, int_orangefs_show
, int_store
);
1484 static struct orangefs_attribute slot_timeout_secs_attribute
=
1485 __ATTR(slot_timeout_secs
, 0664, int_orangefs_show
, int_store
);
1487 static struct orangefs_attribute dcache_timeout_msecs_attribute
=
1488 __ATTR(dcache_timeout_msecs
, 0664, int_orangefs_show
, int_store
);
1490 static struct orangefs_attribute getattr_timeout_msecs_attribute
=
1491 __ATTR(getattr_timeout_msecs
, 0664, int_orangefs_show
, int_store
);
1493 static struct orangefs_attribute readahead_count_attribute
=
1494 __ATTR(readahead_count
, 0664, service_orangefs_show
,
1495 service_orangefs_store
);
1497 static struct orangefs_attribute readahead_size_attribute
=
1498 __ATTR(readahead_size
, 0664, service_orangefs_show
,
1499 service_orangefs_store
);
1501 static struct orangefs_attribute readahead_count_size_attribute
=
1502 __ATTR(readahead_count_size
, 0664, service_orangefs_show
,
1503 service_orangefs_store
);
1505 static struct orangefs_attribute perf_counter_reset_attribute
=
1506 __ATTR(perf_counter_reset
,
1508 service_orangefs_show
,
1509 service_orangefs_store
);
1511 static struct orangefs_attribute perf_history_size_attribute
=
1512 __ATTR(perf_history_size
,
1514 service_orangefs_show
,
1515 service_orangefs_store
);
1517 static struct orangefs_attribute perf_time_interval_secs_attribute
=
1518 __ATTR(perf_time_interval_secs
,
1520 service_orangefs_show
,
1521 service_orangefs_store
);
1523 static struct attribute
*orangefs_default_attrs
[] = {
1524 &op_timeout_secs_attribute
.attr
,
1525 &slot_timeout_secs_attribute
.attr
,
1526 &dcache_timeout_msecs_attribute
.attr
,
1527 &getattr_timeout_msecs_attribute
.attr
,
1528 &readahead_count_attribute
.attr
,
1529 &readahead_size_attribute
.attr
,
1530 &readahead_count_size_attribute
.attr
,
1531 &perf_counter_reset_attribute
.attr
,
1532 &perf_history_size_attribute
.attr
,
1533 &perf_time_interval_secs_attribute
.attr
,
1537 static struct kobj_type orangefs_ktype
= {
1538 .sysfs_ops
= &orangefs_sysfs_ops
,
1539 .release
= orangefs_release
,
1540 .default_attrs
= orangefs_default_attrs
,
1543 static struct acache_orangefs_attribute acache_hard_limit_attribute
=
1546 service_acache_show
,
1547 service_acache_store
);
1549 static struct acache_orangefs_attribute acache_reclaim_percent_attribute
=
1550 __ATTR(reclaim_percentage
,
1552 service_acache_show
,
1553 service_acache_store
);
1555 static struct acache_orangefs_attribute acache_soft_limit_attribute
=
1558 service_acache_show
,
1559 service_acache_store
);
1561 static struct acache_orangefs_attribute acache_timeout_msecs_attribute
=
1562 __ATTR(timeout_msecs
,
1564 service_acache_show
,
1565 service_acache_store
);
1567 static struct attribute
*acache_orangefs_default_attrs
[] = {
1568 &acache_hard_limit_attribute
.attr
,
1569 &acache_reclaim_percent_attribute
.attr
,
1570 &acache_soft_limit_attribute
.attr
,
1571 &acache_timeout_msecs_attribute
.attr
,
1575 static struct kobj_type acache_orangefs_ktype
= {
1576 .sysfs_ops
= &acache_orangefs_sysfs_ops
,
1577 .release
= acache_orangefs_release
,
1578 .default_attrs
= acache_orangefs_default_attrs
,
1581 static struct capcache_orangefs_attribute capcache_hard_limit_attribute
=
1584 service_capcache_show
,
1585 service_capcache_store
);
1587 static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute
=
1588 __ATTR(reclaim_percentage
,
1590 service_capcache_show
,
1591 service_capcache_store
);
1593 static struct capcache_orangefs_attribute capcache_soft_limit_attribute
=
1596 service_capcache_show
,
1597 service_capcache_store
);
1599 static struct capcache_orangefs_attribute capcache_timeout_secs_attribute
=
1600 __ATTR(timeout_secs
,
1602 service_capcache_show
,
1603 service_capcache_store
);
1605 static struct attribute
*capcache_orangefs_default_attrs
[] = {
1606 &capcache_hard_limit_attribute
.attr
,
1607 &capcache_reclaim_percent_attribute
.attr
,
1608 &capcache_soft_limit_attribute
.attr
,
1609 &capcache_timeout_secs_attribute
.attr
,
1613 static struct kobj_type capcache_orangefs_ktype
= {
1614 .sysfs_ops
= &capcache_orangefs_sysfs_ops
,
1615 .release
= capcache_orangefs_release
,
1616 .default_attrs
= capcache_orangefs_default_attrs
,
1619 static struct ccache_orangefs_attribute ccache_hard_limit_attribute
=
1622 service_ccache_show
,
1623 service_ccache_store
);
1625 static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute
=
1626 __ATTR(reclaim_percentage
,
1628 service_ccache_show
,
1629 service_ccache_store
);
1631 static struct ccache_orangefs_attribute ccache_soft_limit_attribute
=
1634 service_ccache_show
,
1635 service_ccache_store
);
1637 static struct ccache_orangefs_attribute ccache_timeout_secs_attribute
=
1638 __ATTR(timeout_secs
,
1640 service_ccache_show
,
1641 service_ccache_store
);
1643 static struct attribute
*ccache_orangefs_default_attrs
[] = {
1644 &ccache_hard_limit_attribute
.attr
,
1645 &ccache_reclaim_percent_attribute
.attr
,
1646 &ccache_soft_limit_attribute
.attr
,
1647 &ccache_timeout_secs_attribute
.attr
,
1651 static struct kobj_type ccache_orangefs_ktype
= {
1652 .sysfs_ops
= &ccache_orangefs_sysfs_ops
,
1653 .release
= ccache_orangefs_release
,
1654 .default_attrs
= ccache_orangefs_default_attrs
,
1657 static struct ncache_orangefs_attribute ncache_hard_limit_attribute
=
1660 service_ncache_show
,
1661 service_ncache_store
);
1663 static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute
=
1664 __ATTR(reclaim_percentage
,
1666 service_ncache_show
,
1667 service_ncache_store
);
1669 static struct ncache_orangefs_attribute ncache_soft_limit_attribute
=
1672 service_ncache_show
,
1673 service_ncache_store
);
1675 static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute
=
1676 __ATTR(timeout_msecs
,
1678 service_ncache_show
,
1679 service_ncache_store
);
1681 static struct attribute
*ncache_orangefs_default_attrs
[] = {
1682 &ncache_hard_limit_attribute
.attr
,
1683 &ncache_reclaim_percent_attribute
.attr
,
1684 &ncache_soft_limit_attribute
.attr
,
1685 &ncache_timeout_msecs_attribute
.attr
,
1689 static struct kobj_type ncache_orangefs_ktype
= {
1690 .sysfs_ops
= &ncache_orangefs_sysfs_ops
,
1691 .release
= ncache_orangefs_release
,
1692 .default_attrs
= ncache_orangefs_default_attrs
,
1695 static struct pc_orangefs_attribute pc_acache_attribute
=
1701 static struct pc_orangefs_attribute pc_capcache_attribute
=
1707 static struct pc_orangefs_attribute pc_ncache_attribute
=
1713 static struct attribute
*pc_orangefs_default_attrs
[] = {
1714 &pc_acache_attribute
.attr
,
1715 &pc_capcache_attribute
.attr
,
1716 &pc_ncache_attribute
.attr
,
1720 static struct kobj_type pc_orangefs_ktype
= {
1721 .sysfs_ops
= &pc_orangefs_sysfs_ops
,
1722 .release
= pc_orangefs_release
,
1723 .default_attrs
= pc_orangefs_default_attrs
,
1726 static struct stats_orangefs_attribute stats_reads_attribute
=
1732 static struct stats_orangefs_attribute stats_writes_attribute
=
1738 static struct attribute
*stats_orangefs_default_attrs
[] = {
1739 &stats_reads_attribute
.attr
,
1740 &stats_writes_attribute
.attr
,
1744 static struct kobj_type stats_orangefs_ktype
= {
1745 .sysfs_ops
= &stats_orangefs_sysfs_ops
,
1746 .release
= stats_orangefs_release
,
1747 .default_attrs
= stats_orangefs_default_attrs
,
1750 static struct orangefs_obj
*orangefs_obj
;
1751 static struct acache_orangefs_obj
*acache_orangefs_obj
;
1752 static struct capcache_orangefs_obj
*capcache_orangefs_obj
;
1753 static struct ccache_orangefs_obj
*ccache_orangefs_obj
;
1754 static struct ncache_orangefs_obj
*ncache_orangefs_obj
;
1755 static struct pc_orangefs_obj
*pc_orangefs_obj
;
1756 static struct stats_orangefs_obj
*stats_orangefs_obj
;
1758 int orangefs_sysfs_init(void)
1762 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_init: start\n");
1764 /* create /sys/fs/orangefs. */
1765 orangefs_obj
= kzalloc(sizeof(*orangefs_obj
), GFP_KERNEL
);
1769 rc
= kobject_init_and_add(&orangefs_obj
->kobj
,
1777 kobject_uevent(&orangefs_obj
->kobj
, KOBJ_ADD
);
1779 /* create /sys/fs/orangefs/acache. */
1780 acache_orangefs_obj
= kzalloc(sizeof(*acache_orangefs_obj
), GFP_KERNEL
);
1781 if (!acache_orangefs_obj
) {
1786 rc
= kobject_init_and_add(&acache_orangefs_obj
->kobj
,
1787 &acache_orangefs_ktype
,
1788 &orangefs_obj
->kobj
,
1792 goto acache_obj_bail
;
1794 kobject_uevent(&acache_orangefs_obj
->kobj
, KOBJ_ADD
);
1796 /* create /sys/fs/orangefs/capcache. */
1797 capcache_orangefs_obj
=
1798 kzalloc(sizeof(*capcache_orangefs_obj
), GFP_KERNEL
);
1799 if (!capcache_orangefs_obj
) {
1801 goto acache_obj_bail
;
1804 rc
= kobject_init_and_add(&capcache_orangefs_obj
->kobj
,
1805 &capcache_orangefs_ktype
,
1806 &orangefs_obj
->kobj
,
1809 goto capcache_obj_bail
;
1811 kobject_uevent(&capcache_orangefs_obj
->kobj
, KOBJ_ADD
);
1813 /* create /sys/fs/orangefs/ccache. */
1814 ccache_orangefs_obj
=
1815 kzalloc(sizeof(*ccache_orangefs_obj
), GFP_KERNEL
);
1816 if (!ccache_orangefs_obj
) {
1818 goto capcache_obj_bail
;
1821 rc
= kobject_init_and_add(&ccache_orangefs_obj
->kobj
,
1822 &ccache_orangefs_ktype
,
1823 &orangefs_obj
->kobj
,
1826 goto ccache_obj_bail
;
1828 kobject_uevent(&ccache_orangefs_obj
->kobj
, KOBJ_ADD
);
1830 /* create /sys/fs/orangefs/ncache. */
1831 ncache_orangefs_obj
= kzalloc(sizeof(*ncache_orangefs_obj
), GFP_KERNEL
);
1832 if (!ncache_orangefs_obj
) {
1834 goto ccache_obj_bail
;
1837 rc
= kobject_init_and_add(&ncache_orangefs_obj
->kobj
,
1838 &ncache_orangefs_ktype
,
1839 &orangefs_obj
->kobj
,
1843 goto ncache_obj_bail
;
1845 kobject_uevent(&ncache_orangefs_obj
->kobj
, KOBJ_ADD
);
1847 /* create /sys/fs/orangefs/perf_counters. */
1848 pc_orangefs_obj
= kzalloc(sizeof(*pc_orangefs_obj
), GFP_KERNEL
);
1849 if (!pc_orangefs_obj
) {
1851 goto ncache_obj_bail
;
1854 rc
= kobject_init_and_add(&pc_orangefs_obj
->kobj
,
1856 &orangefs_obj
->kobj
,
1862 kobject_uevent(&pc_orangefs_obj
->kobj
, KOBJ_ADD
);
1864 /* create /sys/fs/orangefs/stats. */
1865 stats_orangefs_obj
= kzalloc(sizeof(*stats_orangefs_obj
), GFP_KERNEL
);
1866 if (!stats_orangefs_obj
) {
1871 rc
= kobject_init_and_add(&stats_orangefs_obj
->kobj
,
1872 &stats_orangefs_ktype
,
1873 &orangefs_obj
->kobj
,
1877 goto stats_obj_bail
;
1879 kobject_uevent(&stats_orangefs_obj
->kobj
, KOBJ_ADD
);
1883 kobject_put(&stats_orangefs_obj
->kobj
);
1886 kobject_put(&pc_orangefs_obj
->kobj
);
1889 kobject_put(&ncache_orangefs_obj
->kobj
);
1892 kobject_put(&ccache_orangefs_obj
->kobj
);
1895 kobject_put(&capcache_orangefs_obj
->kobj
);
1898 kobject_put(&acache_orangefs_obj
->kobj
);
1901 kobject_put(&orangefs_obj
->kobj
);
1906 void orangefs_sysfs_exit(void)
1908 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_exit: start\n");
1910 kobject_put(&acache_orangefs_obj
->kobj
);
1911 kobject_put(&capcache_orangefs_obj
->kobj
);
1912 kobject_put(&ccache_orangefs_obj
->kobj
);
1913 kobject_put(&ncache_orangefs_obj
->kobj
);
1914 kobject_put(&pc_orangefs_obj
->kobj
);
1915 kobject_put(&stats_orangefs_obj
->kobj
);
1917 kobject_put(&orangefs_obj
->kobj
);