1 // SPDX-License-Identifier: GPL-2.0
3 * Documentation/ABI/stable/sysfs-fs-orangefs:
5 * What: /sys/fs/orangefs/perf_counter_reset
7 * Contact: Mike Marshall <hubcap@omnibond.com>
9 * echo a 0 or a 1 into perf_counter_reset to
10 * reset all the counters in
11 * /sys/fs/orangefs/perf_counters
12 * except ones with PINT_PERF_PRESERVE set.
15 * What: /sys/fs/orangefs/perf_counters/...
17 * Contact: Mike Marshall <hubcap@omnibond.com>
19 * Counters and settings for various caches.
23 * What: /sys/fs/orangefs/perf_time_interval_secs
25 * Contact: Mike Marshall <hubcap@omnibond.com>
27 * Length of perf counter intervals in
31 * What: /sys/fs/orangefs/perf_history_size
33 * Contact: Mike Marshall <hubcap@omnibond.com>
35 * The perf_counters cache statistics have N, or
36 * perf_history_size, samples. The default is
39 * Every perf_time_interval_secs the (first)
42 * If N is greater than one, the "current" set
43 * of samples is reset, and the samples from the
44 * other N-1 intervals remain available.
47 * What: /sys/fs/orangefs/op_timeout_secs
49 * Contact: Mike Marshall <hubcap@omnibond.com>
51 * Service operation timeout in seconds.
54 * What: /sys/fs/orangefs/slot_timeout_secs
56 * Contact: Mike Marshall <hubcap@omnibond.com>
58 * "Slot" timeout in seconds. A "slot"
59 * is an indexed buffer in the shared
60 * memory segment used for communication
61 * between the kernel module and userspace.
62 * Slots are requested and waited for,
63 * the wait times out after slot_timeout_secs.
65 * What: /sys/fs/orangefs/dcache_timeout_msecs
67 * Contact: Martin Brandenburg <martin@omnibond.com>
69 * Time lookup is valid in milliseconds.
71 * What: /sys/fs/orangefs/getattr_timeout_msecs
73 * Contact: Martin Brandenburg <martin@omnibond.com>
75 * Time getattr is valid in milliseconds.
77 * What: /sys/fs/orangefs/readahead_count
79 * Contact: Martin Brandenburg <martin@omnibond.com>
81 * Readahead cache buffer count.
83 * What: /sys/fs/orangefs/readahead_size
85 * Contact: Martin Brandenburg <martin@omnibond.com>
87 * Readahead cache buffer size.
89 * What: /sys/fs/orangefs/readahead_count_size
91 * Contact: Martin Brandenburg <martin@omnibond.com>
93 * Readahead cache buffer count and size.
95 * What: /sys/fs/orangefs/readahead_readcnt
97 * Contact: Martin Brandenburg <martin@omnibond.com>
99 * Number of buffers (in multiples of readahead_size)
100 * which can be read ahead for a single file at once.
102 * What: /sys/fs/orangefs/acache/...
104 * Contact: Martin Brandenburg <martin@omnibond.com>
106 * Attribute cache configurable settings.
109 * What: /sys/fs/orangefs/ncache/...
111 * Contact: Mike Marshall <hubcap@omnibond.com>
113 * Name cache configurable settings.
116 * What: /sys/fs/orangefs/capcache/...
118 * Contact: Mike Marshall <hubcap@omnibond.com>
120 * Capability cache configurable settings.
123 * What: /sys/fs/orangefs/ccache/...
125 * Contact: Mike Marshall <hubcap@omnibond.com>
127 * Credential cache configurable settings.
131 #include <linux/fs.h>
132 #include <linux/kobject.h>
133 #include <linux/string.h>
134 #include <linux/sysfs.h>
135 #include <linux/module.h>
136 #include <linux/init.h>
138 #include "protocol.h"
139 #include "orangefs-kernel.h"
140 #include "orangefs-sysfs.h"
142 #define ORANGEFS_KOBJ_ID "orangefs"
143 #define ACACHE_KOBJ_ID "acache"
144 #define CAPCACHE_KOBJ_ID "capcache"
145 #define CCACHE_KOBJ_ID "ccache"
146 #define NCACHE_KOBJ_ID "ncache"
147 #define PC_KOBJ_ID "pc"
148 #define STATS_KOBJ_ID "stats"
151 * Every item calls orangefs_attr_show and orangefs_attr_store through
152 * orangefs_sysfs_ops. They look at the orangefs_attributes further below to
153 * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or
154 * sysfs_service_op_store.
157 struct orangefs_attribute
{
158 struct attribute attr
;
159 ssize_t (*show
)(struct kobject
*kobj
,
160 struct orangefs_attribute
*attr
,
162 ssize_t (*store
)(struct kobject
*kobj
,
163 struct orangefs_attribute
*attr
,
168 static ssize_t
orangefs_attr_show(struct kobject
*kobj
,
169 struct attribute
*attr
,
172 struct orangefs_attribute
*attribute
;
174 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
175 if (!attribute
->show
)
177 return attribute
->show(kobj
, attribute
, buf
);
180 static ssize_t
orangefs_attr_store(struct kobject
*kobj
,
181 struct attribute
*attr
,
185 struct orangefs_attribute
*attribute
;
187 if (!strcmp(kobj
->name
, PC_KOBJ_ID
) ||
188 !strcmp(kobj
->name
, STATS_KOBJ_ID
))
191 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
192 if (!attribute
->store
)
194 return attribute
->store(kobj
, attribute
, buf
, len
);
197 static const struct sysfs_ops orangefs_sysfs_ops
= {
198 .show
= orangefs_attr_show
,
199 .store
= orangefs_attr_store
,
202 static ssize_t
sysfs_int_show(struct kobject
*kobj
,
203 struct orangefs_attribute
*attr
, char *buf
)
207 gossip_debug(GOSSIP_SYSFS_DEBUG
, "sysfs_int_show: id:%s:\n",
210 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
211 if (!strcmp(attr
->attr
.name
, "op_timeout_secs")) {
217 } else if (!strcmp(attr
->attr
.name
,
218 "slot_timeout_secs")) {
224 } else if (!strcmp(attr
->attr
.name
,
225 "dcache_timeout_msecs")) {
229 orangefs_dcache_timeout_msecs
);
231 } else if (!strcmp(attr
->attr
.name
,
232 "getattr_timeout_msecs")) {
236 orangefs_getattr_timeout_msecs
);
242 } else if (!strcmp(kobj
->name
, STATS_KOBJ_ID
)) {
243 if (!strcmp(attr
->attr
.name
, "reads")) {
247 orangefs_stats
.reads
);
249 } else if (!strcmp(attr
->attr
.name
, "writes")) {
253 orangefs_stats
.writes
);
265 static ssize_t
sysfs_int_store(struct kobject
*kobj
,
266 struct orangefs_attribute
*attr
, const char *buf
, size_t count
)
270 gossip_debug(GOSSIP_SYSFS_DEBUG
,
271 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
272 attr
->attr
.name
, buf
);
274 if (!strcmp(attr
->attr
.name
, "op_timeout_secs")) {
275 rc
= kstrtoint(buf
, 0, &op_timeout_secs
);
277 } else if (!strcmp(attr
->attr
.name
, "slot_timeout_secs")) {
278 rc
= kstrtoint(buf
, 0, &slot_timeout_secs
);
280 } else if (!strcmp(attr
->attr
.name
, "dcache_timeout_msecs")) {
281 rc
= kstrtoint(buf
, 0, &orangefs_dcache_timeout_msecs
);
283 } else if (!strcmp(attr
->attr
.name
, "getattr_timeout_msecs")) {
284 rc
= kstrtoint(buf
, 0, &orangefs_getattr_timeout_msecs
);
300 * obtain attribute values from userspace with a service operation.
302 static ssize_t
sysfs_service_op_show(struct kobject
*kobj
,
303 struct orangefs_attribute
*attr
, char *buf
)
305 struct orangefs_kernel_op_s
*new_op
= NULL
;
307 char *ser_op_type
= NULL
;
310 gossip_debug(GOSSIP_SYSFS_DEBUG
,
311 "sysfs_service_op_show: id:%s:\n",
314 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
315 op_alloc_type
= ORANGEFS_VFS_OP_PARAM
;
317 op_alloc_type
= ORANGEFS_VFS_OP_PERF_COUNT
;
319 new_op
= op_alloc(op_alloc_type
);
323 /* Can't do a service_operation if the client is not running... */
324 rc
= is_daemon_in_service();
326 pr_info("%s: Client not running :%d:\n",
328 is_daemon_in_service());
332 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
333 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_GET
;
335 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
336 /* Drop unsupported requests first. */
337 if (!(orangefs_features
& ORANGEFS_FEATURE_READAHEAD
) &&
338 (!strcmp(attr
->attr
.name
, "readahead_count") ||
339 !strcmp(attr
->attr
.name
, "readahead_size") ||
340 !strcmp(attr
->attr
.name
, "readahead_count_size") ||
341 !strcmp(attr
->attr
.name
, "readahead_readcnt"))) {
346 if (!strcmp(attr
->attr
.name
, "perf_history_size"))
347 new_op
->upcall
.req
.param
.op
=
348 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
349 else if (!strcmp(attr
->attr
.name
,
350 "perf_time_interval_secs"))
351 new_op
->upcall
.req
.param
.op
=
352 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
353 else if (!strcmp(attr
->attr
.name
,
354 "perf_counter_reset"))
355 new_op
->upcall
.req
.param
.op
=
356 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
358 else if (!strcmp(attr
->attr
.name
,
360 new_op
->upcall
.req
.param
.op
=
361 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
363 else if (!strcmp(attr
->attr
.name
,
365 new_op
->upcall
.req
.param
.op
=
366 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
368 else if (!strcmp(attr
->attr
.name
,
369 "readahead_count_size"))
370 new_op
->upcall
.req
.param
.op
=
371 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
373 else if (!strcmp(attr
->attr
.name
,
374 "readahead_readcnt"))
375 new_op
->upcall
.req
.param
.op
=
376 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT
;
377 } else if (!strcmp(kobj
->name
, ACACHE_KOBJ_ID
)) {
378 if (!strcmp(attr
->attr
.name
, "timeout_msecs"))
379 new_op
->upcall
.req
.param
.op
=
380 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
382 if (!strcmp(attr
->attr
.name
, "hard_limit"))
383 new_op
->upcall
.req
.param
.op
=
384 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
386 if (!strcmp(attr
->attr
.name
, "soft_limit"))
387 new_op
->upcall
.req
.param
.op
=
388 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
390 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
391 new_op
->upcall
.req
.param
.op
=
392 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
394 } else if (!strcmp(kobj
->name
, CAPCACHE_KOBJ_ID
)) {
395 if (!strcmp(attr
->attr
.name
, "timeout_secs"))
396 new_op
->upcall
.req
.param
.op
=
397 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
399 if (!strcmp(attr
->attr
.name
, "hard_limit"))
400 new_op
->upcall
.req
.param
.op
=
401 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
403 if (!strcmp(attr
->attr
.name
, "soft_limit"))
404 new_op
->upcall
.req
.param
.op
=
405 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
407 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
408 new_op
->upcall
.req
.param
.op
=
409 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
411 } else if (!strcmp(kobj
->name
, CCACHE_KOBJ_ID
)) {
412 if (!strcmp(attr
->attr
.name
, "timeout_secs"))
413 new_op
->upcall
.req
.param
.op
=
414 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
416 if (!strcmp(attr
->attr
.name
, "hard_limit"))
417 new_op
->upcall
.req
.param
.op
=
418 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
420 if (!strcmp(attr
->attr
.name
, "soft_limit"))
421 new_op
->upcall
.req
.param
.op
=
422 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
424 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
425 new_op
->upcall
.req
.param
.op
=
426 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
428 } else if (!strcmp(kobj
->name
, NCACHE_KOBJ_ID
)) {
429 if (!strcmp(attr
->attr
.name
, "timeout_msecs"))
430 new_op
->upcall
.req
.param
.op
=
431 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
433 if (!strcmp(attr
->attr
.name
, "hard_limit"))
434 new_op
->upcall
.req
.param
.op
=
435 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
437 if (!strcmp(attr
->attr
.name
, "soft_limit"))
438 new_op
->upcall
.req
.param
.op
=
439 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
441 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
442 new_op
->upcall
.req
.param
.op
=
443 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
445 } else if (!strcmp(kobj
->name
, PC_KOBJ_ID
)) {
446 if (!strcmp(attr
->attr
.name
, ACACHE_KOBJ_ID
))
447 new_op
->upcall
.req
.perf_count
.type
=
448 ORANGEFS_PERF_COUNT_REQUEST_ACACHE
;
450 if (!strcmp(attr
->attr
.name
, CAPCACHE_KOBJ_ID
))
451 new_op
->upcall
.req
.perf_count
.type
=
452 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE
;
454 if (!strcmp(attr
->attr
.name
, NCACHE_KOBJ_ID
))
455 new_op
->upcall
.req
.perf_count
.type
=
456 ORANGEFS_PERF_COUNT_REQUEST_NCACHE
;
459 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
466 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
467 ser_op_type
= "orangefs_param";
469 ser_op_type
= "orangefs_perf_count";
472 * The service_operation will return an errno return code on
473 * error, and zero on success.
475 rc
= service_operation(new_op
, ser_op_type
, ORANGEFS_OP_INTERRUPTIBLE
);
479 if (strcmp(kobj
->name
, PC_KOBJ_ID
)) {
480 if (new_op
->upcall
.req
.param
.op
==
481 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
) {
482 rc
= scnprintf(buf
, PAGE_SIZE
, "%d %d\n",
483 (int)new_op
->downcall
.resp
.param
.u
.
485 (int)new_op
->downcall
.resp
.param
.u
.
488 rc
= scnprintf(buf
, PAGE_SIZE
, "%d\n",
489 (int)new_op
->downcall
.resp
.param
.u
.value64
);
496 new_op
->downcall
.resp
.perf_count
.buffer
);
507 * pass attribute values back to userspace with a service operation.
509 * We have to do a memory allocation, an sscanf and a service operation.
510 * And we have to evaluate what the user entered, to make sure the
511 * value is within the range supported by the attribute. So, there's
512 * a lot of return code checking and mapping going on here.
514 * We want to return 1 if we think everything went OK, and
517 static ssize_t
sysfs_service_op_store(struct kobject
*kobj
,
518 struct orangefs_attribute
*attr
, const char *buf
, size_t count
)
520 struct orangefs_kernel_op_s
*new_op
= NULL
;
524 gossip_debug(GOSSIP_SYSFS_DEBUG
,
525 "sysfs_service_op_store: id:%s:\n",
528 new_op
= op_alloc(ORANGEFS_VFS_OP_PARAM
);
530 return -EINVAL
; /* sic */
532 /* Can't do a service_operation if the client is not running... */
533 rc
= is_daemon_in_service();
535 pr_info("%s: Client not running :%d:\n",
537 is_daemon_in_service());
542 * The value we want to send back to userspace is in buf, unless this
543 * there are two parameters, which is specially handled below.
545 if (strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
) ||
546 strcmp(attr
->attr
.name
, "readahead_count_size")) {
547 rc
= kstrtoint(buf
, 0, &val
);
552 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_SET
;
554 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
555 /* Drop unsupported requests first. */
556 if (!(orangefs_features
& ORANGEFS_FEATURE_READAHEAD
) &&
557 (!strcmp(attr
->attr
.name
, "readahead_count") ||
558 !strcmp(attr
->attr
.name
, "readahead_size") ||
559 !strcmp(attr
->attr
.name
, "readahead_count_size") ||
560 !strcmp(attr
->attr
.name
, "readahead_readcnt"))) {
565 if (!strcmp(attr
->attr
.name
, "perf_history_size")) {
567 new_op
->upcall
.req
.param
.op
=
568 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
573 } else if (!strcmp(attr
->attr
.name
,
574 "perf_time_interval_secs")) {
576 new_op
->upcall
.req
.param
.op
=
577 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
582 } else if (!strcmp(attr
->attr
.name
,
583 "perf_counter_reset")) {
584 if ((val
== 0) || (val
== 1)) {
585 new_op
->upcall
.req
.param
.op
=
586 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
591 } else if (!strcmp(attr
->attr
.name
,
592 "readahead_count")) {
594 new_op
->upcall
.req
.param
.op
=
595 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
600 } else if (!strcmp(attr
->attr
.name
,
603 new_op
->upcall
.req
.param
.op
=
604 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
609 } else if (!strcmp(attr
->attr
.name
,
610 "readahead_count_size")) {
612 rc
= sscanf(buf
, "%d %d", &val1
, &val2
);
617 if ((val1
>= 0) && (val2
>= 0)) {
618 new_op
->upcall
.req
.param
.op
=
619 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
624 new_op
->upcall
.req
.param
.u
.value32
[0] = val1
;
625 new_op
->upcall
.req
.param
.u
.value32
[1] = val2
;
627 } else if (!strcmp(attr
->attr
.name
,
628 "readahead_readcnt")) {
630 new_op
->upcall
.req
.param
.op
=
631 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT
;
638 } else if (!strcmp(kobj
->name
, ACACHE_KOBJ_ID
)) {
639 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
641 new_op
->upcall
.req
.param
.op
=
642 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
647 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
649 new_op
->upcall
.req
.param
.op
=
650 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
655 } else if (!strcmp(attr
->attr
.name
,
656 "reclaim_percentage")) {
657 if ((val
> -1) && (val
< 101)) {
658 new_op
->upcall
.req
.param
.op
=
659 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
664 } else if (!strcmp(attr
->attr
.name
, "timeout_msecs")) {
666 new_op
->upcall
.req
.param
.op
=
667 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
674 } else if (!strcmp(kobj
->name
, CAPCACHE_KOBJ_ID
)) {
675 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
677 new_op
->upcall
.req
.param
.op
=
678 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
683 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
685 new_op
->upcall
.req
.param
.op
=
686 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
691 } else if (!strcmp(attr
->attr
.name
,
692 "reclaim_percentage")) {
693 if ((val
> -1) && (val
< 101)) {
694 new_op
->upcall
.req
.param
.op
=
695 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
700 } else if (!strcmp(attr
->attr
.name
, "timeout_secs")) {
702 new_op
->upcall
.req
.param
.op
=
703 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
710 } else if (!strcmp(kobj
->name
, CCACHE_KOBJ_ID
)) {
711 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
713 new_op
->upcall
.req
.param
.op
=
714 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
719 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
721 new_op
->upcall
.req
.param
.op
=
722 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
727 } else if (!strcmp(attr
->attr
.name
,
728 "reclaim_percentage")) {
729 if ((val
> -1) && (val
< 101)) {
730 new_op
->upcall
.req
.param
.op
=
731 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
736 } else if (!strcmp(attr
->attr
.name
, "timeout_secs")) {
738 new_op
->upcall
.req
.param
.op
=
739 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
746 } else if (!strcmp(kobj
->name
, NCACHE_KOBJ_ID
)) {
747 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
749 new_op
->upcall
.req
.param
.op
=
750 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
755 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
757 new_op
->upcall
.req
.param
.op
=
758 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
763 } else if (!strcmp(attr
->attr
.name
,
764 "reclaim_percentage")) {
765 if ((val
> -1) && (val
< 101)) {
766 new_op
->upcall
.req
.param
.op
=
767 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
772 } else if (!strcmp(attr
->attr
.name
, "timeout_msecs")) {
774 new_op
->upcall
.req
.param
.op
=
775 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
783 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
789 new_op
->upcall
.req
.param
.u
.value64
= val
;
793 * The service_operation will return a errno return code on
794 * error, and zero on success.
796 rc
= service_operation(new_op
, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE
);
799 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
809 if (rc
== -ENOMEM
|| rc
== 0)
815 static struct orangefs_attribute op_timeout_secs_attribute
=
816 __ATTR(op_timeout_secs
, 0664, sysfs_int_show
, sysfs_int_store
);
818 static struct orangefs_attribute slot_timeout_secs_attribute
=
819 __ATTR(slot_timeout_secs
, 0664, sysfs_int_show
, sysfs_int_store
);
821 static struct orangefs_attribute dcache_timeout_msecs_attribute
=
822 __ATTR(dcache_timeout_msecs
, 0664, sysfs_int_show
, sysfs_int_store
);
824 static struct orangefs_attribute getattr_timeout_msecs_attribute
=
825 __ATTR(getattr_timeout_msecs
, 0664, sysfs_int_show
, sysfs_int_store
);
827 static struct orangefs_attribute readahead_count_attribute
=
828 __ATTR(readahead_count
, 0664, sysfs_service_op_show
,
829 sysfs_service_op_store
);
831 static struct orangefs_attribute readahead_size_attribute
=
832 __ATTR(readahead_size
, 0664, sysfs_service_op_show
,
833 sysfs_service_op_store
);
835 static struct orangefs_attribute readahead_count_size_attribute
=
836 __ATTR(readahead_count_size
, 0664, sysfs_service_op_show
,
837 sysfs_service_op_store
);
839 static struct orangefs_attribute readahead_readcnt_attribute
=
840 __ATTR(readahead_readcnt
, 0664, sysfs_service_op_show
,
841 sysfs_service_op_store
);
843 static struct orangefs_attribute perf_counter_reset_attribute
=
844 __ATTR(perf_counter_reset
,
846 sysfs_service_op_show
,
847 sysfs_service_op_store
);
849 static struct orangefs_attribute perf_history_size_attribute
=
850 __ATTR(perf_history_size
,
852 sysfs_service_op_show
,
853 sysfs_service_op_store
);
855 static struct orangefs_attribute perf_time_interval_secs_attribute
=
856 __ATTR(perf_time_interval_secs
,
858 sysfs_service_op_show
,
859 sysfs_service_op_store
);
861 static struct attribute
*orangefs_default_attrs
[] = {
862 &op_timeout_secs_attribute
.attr
,
863 &slot_timeout_secs_attribute
.attr
,
864 &dcache_timeout_msecs_attribute
.attr
,
865 &getattr_timeout_msecs_attribute
.attr
,
866 &readahead_count_attribute
.attr
,
867 &readahead_size_attribute
.attr
,
868 &readahead_count_size_attribute
.attr
,
869 &readahead_readcnt_attribute
.attr
,
870 &perf_counter_reset_attribute
.attr
,
871 &perf_history_size_attribute
.attr
,
872 &perf_time_interval_secs_attribute
.attr
,
876 static struct kobj_type orangefs_ktype
= {
877 .sysfs_ops
= &orangefs_sysfs_ops
,
878 .default_attrs
= orangefs_default_attrs
,
881 static struct orangefs_attribute acache_hard_limit_attribute
=
884 sysfs_service_op_show
,
885 sysfs_service_op_store
);
887 static struct orangefs_attribute acache_reclaim_percent_attribute
=
888 __ATTR(reclaim_percentage
,
890 sysfs_service_op_show
,
891 sysfs_service_op_store
);
893 static struct orangefs_attribute acache_soft_limit_attribute
=
896 sysfs_service_op_show
,
897 sysfs_service_op_store
);
899 static struct orangefs_attribute acache_timeout_msecs_attribute
=
900 __ATTR(timeout_msecs
,
902 sysfs_service_op_show
,
903 sysfs_service_op_store
);
905 static struct attribute
*acache_orangefs_default_attrs
[] = {
906 &acache_hard_limit_attribute
.attr
,
907 &acache_reclaim_percent_attribute
.attr
,
908 &acache_soft_limit_attribute
.attr
,
909 &acache_timeout_msecs_attribute
.attr
,
913 static struct kobj_type acache_orangefs_ktype
= {
914 .sysfs_ops
= &orangefs_sysfs_ops
,
915 .default_attrs
= acache_orangefs_default_attrs
,
918 static struct orangefs_attribute capcache_hard_limit_attribute
=
921 sysfs_service_op_show
,
922 sysfs_service_op_store
);
924 static struct orangefs_attribute capcache_reclaim_percent_attribute
=
925 __ATTR(reclaim_percentage
,
927 sysfs_service_op_show
,
928 sysfs_service_op_store
);
930 static struct orangefs_attribute capcache_soft_limit_attribute
=
933 sysfs_service_op_show
,
934 sysfs_service_op_store
);
936 static struct orangefs_attribute capcache_timeout_secs_attribute
=
939 sysfs_service_op_show
,
940 sysfs_service_op_store
);
942 static struct attribute
*capcache_orangefs_default_attrs
[] = {
943 &capcache_hard_limit_attribute
.attr
,
944 &capcache_reclaim_percent_attribute
.attr
,
945 &capcache_soft_limit_attribute
.attr
,
946 &capcache_timeout_secs_attribute
.attr
,
950 static struct kobj_type capcache_orangefs_ktype
= {
951 .sysfs_ops
= &orangefs_sysfs_ops
,
952 .default_attrs
= capcache_orangefs_default_attrs
,
955 static struct orangefs_attribute ccache_hard_limit_attribute
=
958 sysfs_service_op_show
,
959 sysfs_service_op_store
);
961 static struct orangefs_attribute ccache_reclaim_percent_attribute
=
962 __ATTR(reclaim_percentage
,
964 sysfs_service_op_show
,
965 sysfs_service_op_store
);
967 static struct orangefs_attribute ccache_soft_limit_attribute
=
970 sysfs_service_op_show
,
971 sysfs_service_op_store
);
973 static struct orangefs_attribute ccache_timeout_secs_attribute
=
976 sysfs_service_op_show
,
977 sysfs_service_op_store
);
979 static struct attribute
*ccache_orangefs_default_attrs
[] = {
980 &ccache_hard_limit_attribute
.attr
,
981 &ccache_reclaim_percent_attribute
.attr
,
982 &ccache_soft_limit_attribute
.attr
,
983 &ccache_timeout_secs_attribute
.attr
,
987 static struct kobj_type ccache_orangefs_ktype
= {
988 .sysfs_ops
= &orangefs_sysfs_ops
,
989 .default_attrs
= ccache_orangefs_default_attrs
,
992 static struct orangefs_attribute ncache_hard_limit_attribute
=
995 sysfs_service_op_show
,
996 sysfs_service_op_store
);
998 static struct orangefs_attribute ncache_reclaim_percent_attribute
=
999 __ATTR(reclaim_percentage
,
1001 sysfs_service_op_show
,
1002 sysfs_service_op_store
);
1004 static struct orangefs_attribute ncache_soft_limit_attribute
=
1007 sysfs_service_op_show
,
1008 sysfs_service_op_store
);
1010 static struct orangefs_attribute ncache_timeout_msecs_attribute
=
1011 __ATTR(timeout_msecs
,
1013 sysfs_service_op_show
,
1014 sysfs_service_op_store
);
1016 static struct attribute
*ncache_orangefs_default_attrs
[] = {
1017 &ncache_hard_limit_attribute
.attr
,
1018 &ncache_reclaim_percent_attribute
.attr
,
1019 &ncache_soft_limit_attribute
.attr
,
1020 &ncache_timeout_msecs_attribute
.attr
,
1024 static struct kobj_type ncache_orangefs_ktype
= {
1025 .sysfs_ops
= &orangefs_sysfs_ops
,
1026 .default_attrs
= ncache_orangefs_default_attrs
,
1029 static struct orangefs_attribute pc_acache_attribute
=
1032 sysfs_service_op_show
,
1035 static struct orangefs_attribute pc_capcache_attribute
=
1038 sysfs_service_op_show
,
1041 static struct orangefs_attribute pc_ncache_attribute
=
1044 sysfs_service_op_show
,
1047 static struct attribute
*pc_orangefs_default_attrs
[] = {
1048 &pc_acache_attribute
.attr
,
1049 &pc_capcache_attribute
.attr
,
1050 &pc_ncache_attribute
.attr
,
1054 static struct kobj_type pc_orangefs_ktype
= {
1055 .sysfs_ops
= &orangefs_sysfs_ops
,
1056 .default_attrs
= pc_orangefs_default_attrs
,
1059 static struct orangefs_attribute stats_reads_attribute
=
1065 static struct orangefs_attribute stats_writes_attribute
=
1071 static struct attribute
*stats_orangefs_default_attrs
[] = {
1072 &stats_reads_attribute
.attr
,
1073 &stats_writes_attribute
.attr
,
1077 static struct kobj_type stats_orangefs_ktype
= {
1078 .sysfs_ops
= &orangefs_sysfs_ops
,
1079 .default_attrs
= stats_orangefs_default_attrs
,
1082 static struct kobject
*orangefs_obj
;
1083 static struct kobject
*acache_orangefs_obj
;
1084 static struct kobject
*capcache_orangefs_obj
;
1085 static struct kobject
*ccache_orangefs_obj
;
1086 static struct kobject
*ncache_orangefs_obj
;
1087 static struct kobject
*pc_orangefs_obj
;
1088 static struct kobject
*stats_orangefs_obj
;
1090 int orangefs_sysfs_init(void)
1094 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_init: start\n");
1096 /* create /sys/fs/orangefs. */
1097 orangefs_obj
= kzalloc(sizeof(*orangefs_obj
), GFP_KERNEL
);
1101 rc
= kobject_init_and_add(orangefs_obj
,
1109 kobject_uevent(orangefs_obj
, KOBJ_ADD
);
1111 /* create /sys/fs/orangefs/acache. */
1112 acache_orangefs_obj
= kzalloc(sizeof(*acache_orangefs_obj
), GFP_KERNEL
);
1113 if (!acache_orangefs_obj
) {
1118 rc
= kobject_init_and_add(acache_orangefs_obj
,
1119 &acache_orangefs_ktype
,
1124 goto acache_obj_bail
;
1126 kobject_uevent(acache_orangefs_obj
, KOBJ_ADD
);
1128 /* create /sys/fs/orangefs/capcache. */
1129 capcache_orangefs_obj
=
1130 kzalloc(sizeof(*capcache_orangefs_obj
), GFP_KERNEL
);
1131 if (!capcache_orangefs_obj
) {
1133 goto acache_obj_bail
;
1136 rc
= kobject_init_and_add(capcache_orangefs_obj
,
1137 &capcache_orangefs_ktype
,
1141 goto capcache_obj_bail
;
1143 kobject_uevent(capcache_orangefs_obj
, KOBJ_ADD
);
1145 /* create /sys/fs/orangefs/ccache. */
1146 ccache_orangefs_obj
=
1147 kzalloc(sizeof(*ccache_orangefs_obj
), GFP_KERNEL
);
1148 if (!ccache_orangefs_obj
) {
1150 goto capcache_obj_bail
;
1153 rc
= kobject_init_and_add(ccache_orangefs_obj
,
1154 &ccache_orangefs_ktype
,
1158 goto ccache_obj_bail
;
1160 kobject_uevent(ccache_orangefs_obj
, KOBJ_ADD
);
1162 /* create /sys/fs/orangefs/ncache. */
1163 ncache_orangefs_obj
= kzalloc(sizeof(*ncache_orangefs_obj
), GFP_KERNEL
);
1164 if (!ncache_orangefs_obj
) {
1166 goto ccache_obj_bail
;
1169 rc
= kobject_init_and_add(ncache_orangefs_obj
,
1170 &ncache_orangefs_ktype
,
1175 goto ncache_obj_bail
;
1177 kobject_uevent(ncache_orangefs_obj
, KOBJ_ADD
);
1179 /* create /sys/fs/orangefs/perf_counters. */
1180 pc_orangefs_obj
= kzalloc(sizeof(*pc_orangefs_obj
), GFP_KERNEL
);
1181 if (!pc_orangefs_obj
) {
1183 goto ncache_obj_bail
;
1186 rc
= kobject_init_and_add(pc_orangefs_obj
,
1194 kobject_uevent(pc_orangefs_obj
, KOBJ_ADD
);
1196 /* create /sys/fs/orangefs/stats. */
1197 stats_orangefs_obj
= kzalloc(sizeof(*stats_orangefs_obj
), GFP_KERNEL
);
1198 if (!stats_orangefs_obj
) {
1203 rc
= kobject_init_and_add(stats_orangefs_obj
,
1204 &stats_orangefs_ktype
,
1209 goto stats_obj_bail
;
1211 kobject_uevent(stats_orangefs_obj
, KOBJ_ADD
);
1215 kobject_put(stats_orangefs_obj
);
1217 kobject_put(pc_orangefs_obj
);
1219 kobject_put(ncache_orangefs_obj
);
1221 kobject_put(ccache_orangefs_obj
);
1223 kobject_put(capcache_orangefs_obj
);
1225 kobject_put(acache_orangefs_obj
);
1227 kobject_put(orangefs_obj
);
1232 void orangefs_sysfs_exit(void)
1234 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_exit: start\n");
1235 kobject_put(acache_orangefs_obj
);
1236 kobject_put(capcache_orangefs_obj
);
1237 kobject_put(ccache_orangefs_obj
);
1238 kobject_put(ncache_orangefs_obj
);
1239 kobject_put(pc_orangefs_obj
);
1240 kobject_put(stats_orangefs_obj
);
1241 kobject_put(orangefs_obj
);