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/cache_timeout_msecs
67 * Contact: Martin Brandenburg <martin@omnibond.com>
69 * Time in milliseconds between which
70 * orangefs_revalidate_mapping will invalidate the page
73 * What: /sys/fs/orangefs/dcache_timeout_msecs
75 * Contact: Martin Brandenburg <martin@omnibond.com>
77 * Time lookup is valid in milliseconds.
79 * What: /sys/fs/orangefs/getattr_timeout_msecs
81 * Contact: Martin Brandenburg <martin@omnibond.com>
83 * Time getattr is valid in milliseconds.
85 * What: /sys/fs/orangefs/readahead_count
87 * Contact: Martin Brandenburg <martin@omnibond.com>
89 * Readahead cache buffer count.
91 * What: /sys/fs/orangefs/readahead_size
93 * Contact: Martin Brandenburg <martin@omnibond.com>
95 * Readahead cache buffer size.
97 * What: /sys/fs/orangefs/readahead_count_size
99 * Contact: Martin Brandenburg <martin@omnibond.com>
101 * Readahead cache buffer count and size.
103 * What: /sys/fs/orangefs/readahead_readcnt
105 * Contact: Martin Brandenburg <martin@omnibond.com>
107 * Number of buffers (in multiples of readahead_size)
108 * which can be read ahead for a single file at once.
110 * What: /sys/fs/orangefs/acache/...
112 * Contact: Martin Brandenburg <martin@omnibond.com>
114 * Attribute cache configurable settings.
117 * What: /sys/fs/orangefs/ncache/...
119 * Contact: Mike Marshall <hubcap@omnibond.com>
121 * Name cache configurable settings.
124 * What: /sys/fs/orangefs/capcache/...
126 * Contact: Mike Marshall <hubcap@omnibond.com>
128 * Capability cache configurable settings.
131 * What: /sys/fs/orangefs/ccache/...
133 * Contact: Mike Marshall <hubcap@omnibond.com>
135 * Credential cache configurable settings.
139 #include <linux/fs.h>
140 #include <linux/kobject.h>
141 #include <linux/string.h>
142 #include <linux/sysfs.h>
143 #include <linux/module.h>
144 #include <linux/init.h>
146 #include "protocol.h"
147 #include "orangefs-kernel.h"
148 #include "orangefs-sysfs.h"
150 #define ORANGEFS_KOBJ_ID "orangefs"
151 #define ACACHE_KOBJ_ID "acache"
152 #define CAPCACHE_KOBJ_ID "capcache"
153 #define CCACHE_KOBJ_ID "ccache"
154 #define NCACHE_KOBJ_ID "ncache"
155 #define PC_KOBJ_ID "pc"
156 #define STATS_KOBJ_ID "stats"
159 * Every item calls orangefs_attr_show and orangefs_attr_store through
160 * orangefs_sysfs_ops. They look at the orangefs_attributes further below to
161 * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or
162 * sysfs_service_op_store.
165 struct orangefs_attribute
{
166 struct attribute attr
;
167 ssize_t (*show
)(struct kobject
*kobj
,
168 struct orangefs_attribute
*attr
,
170 ssize_t (*store
)(struct kobject
*kobj
,
171 struct orangefs_attribute
*attr
,
176 static ssize_t
orangefs_attr_show(struct kobject
*kobj
,
177 struct attribute
*attr
,
180 struct orangefs_attribute
*attribute
;
182 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
183 if (!attribute
->show
)
185 return attribute
->show(kobj
, attribute
, buf
);
188 static ssize_t
orangefs_attr_store(struct kobject
*kobj
,
189 struct attribute
*attr
,
193 struct orangefs_attribute
*attribute
;
195 if (!strcmp(kobj
->name
, PC_KOBJ_ID
) ||
196 !strcmp(kobj
->name
, STATS_KOBJ_ID
))
199 attribute
= container_of(attr
, struct orangefs_attribute
, attr
);
200 if (!attribute
->store
)
202 return attribute
->store(kobj
, attribute
, buf
, len
);
205 static const struct sysfs_ops orangefs_sysfs_ops
= {
206 .show
= orangefs_attr_show
,
207 .store
= orangefs_attr_store
,
210 static ssize_t
sysfs_int_show(struct kobject
*kobj
,
211 struct orangefs_attribute
*attr
, char *buf
)
215 gossip_debug(GOSSIP_SYSFS_DEBUG
, "sysfs_int_show: id:%s:\n",
218 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
219 if (!strcmp(attr
->attr
.name
, "op_timeout_secs")) {
225 } else if (!strcmp(attr
->attr
.name
,
226 "slot_timeout_secs")) {
232 } else if (!strcmp(attr
->attr
.name
,
233 "cache_timeout_msecs")) {
237 orangefs_cache_timeout_msecs
);
239 } else if (!strcmp(attr
->attr
.name
,
240 "dcache_timeout_msecs")) {
244 orangefs_dcache_timeout_msecs
);
246 } else if (!strcmp(attr
->attr
.name
,
247 "getattr_timeout_msecs")) {
251 orangefs_getattr_timeout_msecs
);
257 } else if (!strcmp(kobj
->name
, STATS_KOBJ_ID
)) {
258 if (!strcmp(attr
->attr
.name
, "reads")) {
262 orangefs_stats
.reads
);
264 } else if (!strcmp(attr
->attr
.name
, "writes")) {
268 orangefs_stats
.writes
);
280 static ssize_t
sysfs_int_store(struct kobject
*kobj
,
281 struct orangefs_attribute
*attr
, const char *buf
, size_t count
)
285 gossip_debug(GOSSIP_SYSFS_DEBUG
,
286 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
287 attr
->attr
.name
, buf
);
289 if (!strcmp(attr
->attr
.name
, "op_timeout_secs")) {
290 rc
= kstrtoint(buf
, 0, &op_timeout_secs
);
292 } else if (!strcmp(attr
->attr
.name
, "slot_timeout_secs")) {
293 rc
= kstrtoint(buf
, 0, &slot_timeout_secs
);
295 } else if (!strcmp(attr
->attr
.name
, "cache_timeout_msecs")) {
296 rc
= kstrtoint(buf
, 0, &orangefs_cache_timeout_msecs
);
298 } else if (!strcmp(attr
->attr
.name
, "dcache_timeout_msecs")) {
299 rc
= kstrtoint(buf
, 0, &orangefs_dcache_timeout_msecs
);
301 } else if (!strcmp(attr
->attr
.name
, "getattr_timeout_msecs")) {
302 rc
= kstrtoint(buf
, 0, &orangefs_getattr_timeout_msecs
);
318 * obtain attribute values from userspace with a service operation.
320 static ssize_t
sysfs_service_op_show(struct kobject
*kobj
,
321 struct orangefs_attribute
*attr
, char *buf
)
323 struct orangefs_kernel_op_s
*new_op
= NULL
;
325 char *ser_op_type
= NULL
;
328 gossip_debug(GOSSIP_SYSFS_DEBUG
,
329 "sysfs_service_op_show: id:%s:\n",
332 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
333 op_alloc_type
= ORANGEFS_VFS_OP_PARAM
;
335 op_alloc_type
= ORANGEFS_VFS_OP_PERF_COUNT
;
337 new_op
= op_alloc(op_alloc_type
);
341 /* Can't do a service_operation if the client is not running... */
342 rc
= is_daemon_in_service();
344 pr_info_ratelimited("%s: Client not running :%d:\n",
346 is_daemon_in_service());
350 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
351 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_GET
;
353 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
354 /* Drop unsupported requests first. */
355 if (!(orangefs_features
& ORANGEFS_FEATURE_READAHEAD
) &&
356 (!strcmp(attr
->attr
.name
, "readahead_count") ||
357 !strcmp(attr
->attr
.name
, "readahead_size") ||
358 !strcmp(attr
->attr
.name
, "readahead_count_size") ||
359 !strcmp(attr
->attr
.name
, "readahead_readcnt"))) {
364 if (!strcmp(attr
->attr
.name
, "perf_history_size"))
365 new_op
->upcall
.req
.param
.op
=
366 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
367 else if (!strcmp(attr
->attr
.name
,
368 "perf_time_interval_secs"))
369 new_op
->upcall
.req
.param
.op
=
370 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
371 else if (!strcmp(attr
->attr
.name
,
372 "perf_counter_reset"))
373 new_op
->upcall
.req
.param
.op
=
374 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
376 else if (!strcmp(attr
->attr
.name
,
378 new_op
->upcall
.req
.param
.op
=
379 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
381 else if (!strcmp(attr
->attr
.name
,
383 new_op
->upcall
.req
.param
.op
=
384 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
386 else if (!strcmp(attr
->attr
.name
,
387 "readahead_count_size"))
388 new_op
->upcall
.req
.param
.op
=
389 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
391 else if (!strcmp(attr
->attr
.name
,
392 "readahead_readcnt"))
393 new_op
->upcall
.req
.param
.op
=
394 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT
;
395 } else if (!strcmp(kobj
->name
, ACACHE_KOBJ_ID
)) {
396 if (!strcmp(attr
->attr
.name
, "timeout_msecs"))
397 new_op
->upcall
.req
.param
.op
=
398 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
400 if (!strcmp(attr
->attr
.name
, "hard_limit"))
401 new_op
->upcall
.req
.param
.op
=
402 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
404 if (!strcmp(attr
->attr
.name
, "soft_limit"))
405 new_op
->upcall
.req
.param
.op
=
406 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
408 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
409 new_op
->upcall
.req
.param
.op
=
410 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
412 } else if (!strcmp(kobj
->name
, CAPCACHE_KOBJ_ID
)) {
413 if (!strcmp(attr
->attr
.name
, "timeout_secs"))
414 new_op
->upcall
.req
.param
.op
=
415 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
417 if (!strcmp(attr
->attr
.name
, "hard_limit"))
418 new_op
->upcall
.req
.param
.op
=
419 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
421 if (!strcmp(attr
->attr
.name
, "soft_limit"))
422 new_op
->upcall
.req
.param
.op
=
423 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
425 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
426 new_op
->upcall
.req
.param
.op
=
427 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
429 } else if (!strcmp(kobj
->name
, CCACHE_KOBJ_ID
)) {
430 if (!strcmp(attr
->attr
.name
, "timeout_secs"))
431 new_op
->upcall
.req
.param
.op
=
432 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
434 if (!strcmp(attr
->attr
.name
, "hard_limit"))
435 new_op
->upcall
.req
.param
.op
=
436 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
438 if (!strcmp(attr
->attr
.name
, "soft_limit"))
439 new_op
->upcall
.req
.param
.op
=
440 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
442 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
443 new_op
->upcall
.req
.param
.op
=
444 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
446 } else if (!strcmp(kobj
->name
, NCACHE_KOBJ_ID
)) {
447 if (!strcmp(attr
->attr
.name
, "timeout_msecs"))
448 new_op
->upcall
.req
.param
.op
=
449 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
451 if (!strcmp(attr
->attr
.name
, "hard_limit"))
452 new_op
->upcall
.req
.param
.op
=
453 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
455 if (!strcmp(attr
->attr
.name
, "soft_limit"))
456 new_op
->upcall
.req
.param
.op
=
457 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
459 if (!strcmp(attr
->attr
.name
, "reclaim_percentage"))
460 new_op
->upcall
.req
.param
.op
=
461 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
463 } else if (!strcmp(kobj
->name
, PC_KOBJ_ID
)) {
464 if (!strcmp(attr
->attr
.name
, ACACHE_KOBJ_ID
))
465 new_op
->upcall
.req
.perf_count
.type
=
466 ORANGEFS_PERF_COUNT_REQUEST_ACACHE
;
468 if (!strcmp(attr
->attr
.name
, CAPCACHE_KOBJ_ID
))
469 new_op
->upcall
.req
.perf_count
.type
=
470 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE
;
472 if (!strcmp(attr
->attr
.name
, NCACHE_KOBJ_ID
))
473 new_op
->upcall
.req
.perf_count
.type
=
474 ORANGEFS_PERF_COUNT_REQUEST_NCACHE
;
477 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
484 if (strcmp(kobj
->name
, PC_KOBJ_ID
))
485 ser_op_type
= "orangefs_param";
487 ser_op_type
= "orangefs_perf_count";
490 * The service_operation will return an errno return code on
491 * error, and zero on success.
493 rc
= service_operation(new_op
, ser_op_type
, ORANGEFS_OP_INTERRUPTIBLE
);
497 if (strcmp(kobj
->name
, PC_KOBJ_ID
)) {
498 if (new_op
->upcall
.req
.param
.op
==
499 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
) {
500 rc
= scnprintf(buf
, PAGE_SIZE
, "%d %d\n",
501 (int)new_op
->downcall
.resp
.param
.u
.
503 (int)new_op
->downcall
.resp
.param
.u
.
506 rc
= scnprintf(buf
, PAGE_SIZE
, "%d\n",
507 (int)new_op
->downcall
.resp
.param
.u
.value64
);
514 new_op
->downcall
.resp
.perf_count
.buffer
);
525 * pass attribute values back to userspace with a service operation.
527 * We have to do a memory allocation, an sscanf and a service operation.
528 * And we have to evaluate what the user entered, to make sure the
529 * value is within the range supported by the attribute. So, there's
530 * a lot of return code checking and mapping going on here.
532 * We want to return 1 if we think everything went OK, and
535 static ssize_t
sysfs_service_op_store(struct kobject
*kobj
,
536 struct orangefs_attribute
*attr
, const char *buf
, size_t count
)
538 struct orangefs_kernel_op_s
*new_op
= NULL
;
542 gossip_debug(GOSSIP_SYSFS_DEBUG
,
543 "sysfs_service_op_store: id:%s:\n",
546 new_op
= op_alloc(ORANGEFS_VFS_OP_PARAM
);
548 return -EINVAL
; /* sic */
550 /* Can't do a service_operation if the client is not running... */
551 rc
= is_daemon_in_service();
553 pr_info("%s: Client not running :%d:\n",
555 is_daemon_in_service());
560 * The value we want to send back to userspace is in buf, unless this
561 * there are two parameters, which is specially handled below.
563 if (strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
) ||
564 strcmp(attr
->attr
.name
, "readahead_count_size")) {
565 rc
= kstrtoint(buf
, 0, &val
);
570 new_op
->upcall
.req
.param
.type
= ORANGEFS_PARAM_REQUEST_SET
;
572 if (!strcmp(kobj
->name
, ORANGEFS_KOBJ_ID
)) {
573 /* Drop unsupported requests first. */
574 if (!(orangefs_features
& ORANGEFS_FEATURE_READAHEAD
) &&
575 (!strcmp(attr
->attr
.name
, "readahead_count") ||
576 !strcmp(attr
->attr
.name
, "readahead_size") ||
577 !strcmp(attr
->attr
.name
, "readahead_count_size") ||
578 !strcmp(attr
->attr
.name
, "readahead_readcnt"))) {
583 if (!strcmp(attr
->attr
.name
, "perf_history_size")) {
585 new_op
->upcall
.req
.param
.op
=
586 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE
;
591 } else if (!strcmp(attr
->attr
.name
,
592 "perf_time_interval_secs")) {
594 new_op
->upcall
.req
.param
.op
=
595 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS
;
600 } else if (!strcmp(attr
->attr
.name
,
601 "perf_counter_reset")) {
602 if ((val
== 0) || (val
== 1)) {
603 new_op
->upcall
.req
.param
.op
=
604 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET
;
609 } else if (!strcmp(attr
->attr
.name
,
610 "readahead_count")) {
612 new_op
->upcall
.req
.param
.op
=
613 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT
;
618 } else if (!strcmp(attr
->attr
.name
,
621 new_op
->upcall
.req
.param
.op
=
622 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE
;
627 } else if (!strcmp(attr
->attr
.name
,
628 "readahead_count_size")) {
630 rc
= sscanf(buf
, "%d %d", &val1
, &val2
);
635 if ((val1
>= 0) && (val2
>= 0)) {
636 new_op
->upcall
.req
.param
.op
=
637 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE
;
642 new_op
->upcall
.req
.param
.u
.value32
[0] = val1
;
643 new_op
->upcall
.req
.param
.u
.value32
[1] = val2
;
645 } else if (!strcmp(attr
->attr
.name
,
646 "readahead_readcnt")) {
648 new_op
->upcall
.req
.param
.op
=
649 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT
;
656 } else if (!strcmp(kobj
->name
, ACACHE_KOBJ_ID
)) {
657 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
659 new_op
->upcall
.req
.param
.op
=
660 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT
;
665 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
667 new_op
->upcall
.req
.param
.op
=
668 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT
;
673 } else if (!strcmp(attr
->attr
.name
,
674 "reclaim_percentage")) {
675 if ((val
> -1) && (val
< 101)) {
676 new_op
->upcall
.req
.param
.op
=
677 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE
;
682 } else if (!strcmp(attr
->attr
.name
, "timeout_msecs")) {
684 new_op
->upcall
.req
.param
.op
=
685 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS
;
692 } else if (!strcmp(kobj
->name
, CAPCACHE_KOBJ_ID
)) {
693 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
695 new_op
->upcall
.req
.param
.op
=
696 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT
;
701 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
703 new_op
->upcall
.req
.param
.op
=
704 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT
;
709 } else if (!strcmp(attr
->attr
.name
,
710 "reclaim_percentage")) {
711 if ((val
> -1) && (val
< 101)) {
712 new_op
->upcall
.req
.param
.op
=
713 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE
;
718 } else if (!strcmp(attr
->attr
.name
, "timeout_secs")) {
720 new_op
->upcall
.req
.param
.op
=
721 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS
;
728 } else if (!strcmp(kobj
->name
, CCACHE_KOBJ_ID
)) {
729 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
731 new_op
->upcall
.req
.param
.op
=
732 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT
;
737 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
739 new_op
->upcall
.req
.param
.op
=
740 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT
;
745 } else if (!strcmp(attr
->attr
.name
,
746 "reclaim_percentage")) {
747 if ((val
> -1) && (val
< 101)) {
748 new_op
->upcall
.req
.param
.op
=
749 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE
;
754 } else if (!strcmp(attr
->attr
.name
, "timeout_secs")) {
756 new_op
->upcall
.req
.param
.op
=
757 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS
;
764 } else if (!strcmp(kobj
->name
, NCACHE_KOBJ_ID
)) {
765 if (!strcmp(attr
->attr
.name
, "hard_limit")) {
767 new_op
->upcall
.req
.param
.op
=
768 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT
;
773 } else if (!strcmp(attr
->attr
.name
, "soft_limit")) {
775 new_op
->upcall
.req
.param
.op
=
776 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT
;
781 } else if (!strcmp(attr
->attr
.name
,
782 "reclaim_percentage")) {
783 if ((val
> -1) && (val
< 101)) {
784 new_op
->upcall
.req
.param
.op
=
785 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE
;
790 } else if (!strcmp(attr
->attr
.name
, "timeout_msecs")) {
792 new_op
->upcall
.req
.param
.op
=
793 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS
;
801 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
807 new_op
->upcall
.req
.param
.u
.value64
= val
;
811 * The service_operation will return a errno return code on
812 * error, and zero on success.
814 rc
= service_operation(new_op
, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE
);
817 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
827 if (rc
== -ENOMEM
|| rc
== 0)
833 static struct orangefs_attribute op_timeout_secs_attribute
=
834 __ATTR(op_timeout_secs
, 0664, sysfs_int_show
, sysfs_int_store
);
836 static struct orangefs_attribute slot_timeout_secs_attribute
=
837 __ATTR(slot_timeout_secs
, 0664, sysfs_int_show
, sysfs_int_store
);
839 static struct orangefs_attribute cache_timeout_msecs_attribute
=
840 __ATTR(cache_timeout_msecs
, 0664, sysfs_int_show
, sysfs_int_store
);
842 static struct orangefs_attribute dcache_timeout_msecs_attribute
=
843 __ATTR(dcache_timeout_msecs
, 0664, sysfs_int_show
, sysfs_int_store
);
845 static struct orangefs_attribute getattr_timeout_msecs_attribute
=
846 __ATTR(getattr_timeout_msecs
, 0664, sysfs_int_show
, sysfs_int_store
);
848 static struct orangefs_attribute readahead_count_attribute
=
849 __ATTR(readahead_count
, 0664, sysfs_service_op_show
,
850 sysfs_service_op_store
);
852 static struct orangefs_attribute readahead_size_attribute
=
853 __ATTR(readahead_size
, 0664, sysfs_service_op_show
,
854 sysfs_service_op_store
);
856 static struct orangefs_attribute readahead_count_size_attribute
=
857 __ATTR(readahead_count_size
, 0664, sysfs_service_op_show
,
858 sysfs_service_op_store
);
860 static struct orangefs_attribute readahead_readcnt_attribute
=
861 __ATTR(readahead_readcnt
, 0664, sysfs_service_op_show
,
862 sysfs_service_op_store
);
864 static struct orangefs_attribute perf_counter_reset_attribute
=
865 __ATTR(perf_counter_reset
,
867 sysfs_service_op_show
,
868 sysfs_service_op_store
);
870 static struct orangefs_attribute perf_history_size_attribute
=
871 __ATTR(perf_history_size
,
873 sysfs_service_op_show
,
874 sysfs_service_op_store
);
876 static struct orangefs_attribute perf_time_interval_secs_attribute
=
877 __ATTR(perf_time_interval_secs
,
879 sysfs_service_op_show
,
880 sysfs_service_op_store
);
882 static struct attribute
*orangefs_default_attrs
[] = {
883 &op_timeout_secs_attribute
.attr
,
884 &slot_timeout_secs_attribute
.attr
,
885 &cache_timeout_msecs_attribute
.attr
,
886 &dcache_timeout_msecs_attribute
.attr
,
887 &getattr_timeout_msecs_attribute
.attr
,
888 &readahead_count_attribute
.attr
,
889 &readahead_size_attribute
.attr
,
890 &readahead_count_size_attribute
.attr
,
891 &readahead_readcnt_attribute
.attr
,
892 &perf_counter_reset_attribute
.attr
,
893 &perf_history_size_attribute
.attr
,
894 &perf_time_interval_secs_attribute
.attr
,
898 static struct kobj_type orangefs_ktype
= {
899 .sysfs_ops
= &orangefs_sysfs_ops
,
900 .default_attrs
= orangefs_default_attrs
,
903 static struct orangefs_attribute acache_hard_limit_attribute
=
906 sysfs_service_op_show
,
907 sysfs_service_op_store
);
909 static struct orangefs_attribute acache_reclaim_percent_attribute
=
910 __ATTR(reclaim_percentage
,
912 sysfs_service_op_show
,
913 sysfs_service_op_store
);
915 static struct orangefs_attribute acache_soft_limit_attribute
=
918 sysfs_service_op_show
,
919 sysfs_service_op_store
);
921 static struct orangefs_attribute acache_timeout_msecs_attribute
=
922 __ATTR(timeout_msecs
,
924 sysfs_service_op_show
,
925 sysfs_service_op_store
);
927 static struct attribute
*acache_orangefs_default_attrs
[] = {
928 &acache_hard_limit_attribute
.attr
,
929 &acache_reclaim_percent_attribute
.attr
,
930 &acache_soft_limit_attribute
.attr
,
931 &acache_timeout_msecs_attribute
.attr
,
935 static struct kobj_type acache_orangefs_ktype
= {
936 .sysfs_ops
= &orangefs_sysfs_ops
,
937 .default_attrs
= acache_orangefs_default_attrs
,
940 static struct orangefs_attribute capcache_hard_limit_attribute
=
943 sysfs_service_op_show
,
944 sysfs_service_op_store
);
946 static struct orangefs_attribute capcache_reclaim_percent_attribute
=
947 __ATTR(reclaim_percentage
,
949 sysfs_service_op_show
,
950 sysfs_service_op_store
);
952 static struct orangefs_attribute capcache_soft_limit_attribute
=
955 sysfs_service_op_show
,
956 sysfs_service_op_store
);
958 static struct orangefs_attribute capcache_timeout_secs_attribute
=
961 sysfs_service_op_show
,
962 sysfs_service_op_store
);
964 static struct attribute
*capcache_orangefs_default_attrs
[] = {
965 &capcache_hard_limit_attribute
.attr
,
966 &capcache_reclaim_percent_attribute
.attr
,
967 &capcache_soft_limit_attribute
.attr
,
968 &capcache_timeout_secs_attribute
.attr
,
972 static struct kobj_type capcache_orangefs_ktype
= {
973 .sysfs_ops
= &orangefs_sysfs_ops
,
974 .default_attrs
= capcache_orangefs_default_attrs
,
977 static struct orangefs_attribute ccache_hard_limit_attribute
=
980 sysfs_service_op_show
,
981 sysfs_service_op_store
);
983 static struct orangefs_attribute ccache_reclaim_percent_attribute
=
984 __ATTR(reclaim_percentage
,
986 sysfs_service_op_show
,
987 sysfs_service_op_store
);
989 static struct orangefs_attribute ccache_soft_limit_attribute
=
992 sysfs_service_op_show
,
993 sysfs_service_op_store
);
995 static struct orangefs_attribute ccache_timeout_secs_attribute
=
998 sysfs_service_op_show
,
999 sysfs_service_op_store
);
1001 static struct attribute
*ccache_orangefs_default_attrs
[] = {
1002 &ccache_hard_limit_attribute
.attr
,
1003 &ccache_reclaim_percent_attribute
.attr
,
1004 &ccache_soft_limit_attribute
.attr
,
1005 &ccache_timeout_secs_attribute
.attr
,
1009 static struct kobj_type ccache_orangefs_ktype
= {
1010 .sysfs_ops
= &orangefs_sysfs_ops
,
1011 .default_attrs
= ccache_orangefs_default_attrs
,
1014 static struct orangefs_attribute ncache_hard_limit_attribute
=
1017 sysfs_service_op_show
,
1018 sysfs_service_op_store
);
1020 static struct orangefs_attribute ncache_reclaim_percent_attribute
=
1021 __ATTR(reclaim_percentage
,
1023 sysfs_service_op_show
,
1024 sysfs_service_op_store
);
1026 static struct orangefs_attribute ncache_soft_limit_attribute
=
1029 sysfs_service_op_show
,
1030 sysfs_service_op_store
);
1032 static struct orangefs_attribute ncache_timeout_msecs_attribute
=
1033 __ATTR(timeout_msecs
,
1035 sysfs_service_op_show
,
1036 sysfs_service_op_store
);
1038 static struct attribute
*ncache_orangefs_default_attrs
[] = {
1039 &ncache_hard_limit_attribute
.attr
,
1040 &ncache_reclaim_percent_attribute
.attr
,
1041 &ncache_soft_limit_attribute
.attr
,
1042 &ncache_timeout_msecs_attribute
.attr
,
1046 static struct kobj_type ncache_orangefs_ktype
= {
1047 .sysfs_ops
= &orangefs_sysfs_ops
,
1048 .default_attrs
= ncache_orangefs_default_attrs
,
1051 static struct orangefs_attribute pc_acache_attribute
=
1054 sysfs_service_op_show
,
1057 static struct orangefs_attribute pc_capcache_attribute
=
1060 sysfs_service_op_show
,
1063 static struct orangefs_attribute pc_ncache_attribute
=
1066 sysfs_service_op_show
,
1069 static struct attribute
*pc_orangefs_default_attrs
[] = {
1070 &pc_acache_attribute
.attr
,
1071 &pc_capcache_attribute
.attr
,
1072 &pc_ncache_attribute
.attr
,
1076 static struct kobj_type pc_orangefs_ktype
= {
1077 .sysfs_ops
= &orangefs_sysfs_ops
,
1078 .default_attrs
= pc_orangefs_default_attrs
,
1081 static struct orangefs_attribute stats_reads_attribute
=
1087 static struct orangefs_attribute stats_writes_attribute
=
1093 static struct attribute
*stats_orangefs_default_attrs
[] = {
1094 &stats_reads_attribute
.attr
,
1095 &stats_writes_attribute
.attr
,
1099 static struct kobj_type stats_orangefs_ktype
= {
1100 .sysfs_ops
= &orangefs_sysfs_ops
,
1101 .default_attrs
= stats_orangefs_default_attrs
,
1104 static struct kobject
*orangefs_obj
;
1105 static struct kobject
*acache_orangefs_obj
;
1106 static struct kobject
*capcache_orangefs_obj
;
1107 static struct kobject
*ccache_orangefs_obj
;
1108 static struct kobject
*ncache_orangefs_obj
;
1109 static struct kobject
*pc_orangefs_obj
;
1110 static struct kobject
*stats_orangefs_obj
;
1112 int orangefs_sysfs_init(void)
1116 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_init: start\n");
1118 /* create /sys/fs/orangefs. */
1119 orangefs_obj
= kzalloc(sizeof(*orangefs_obj
), GFP_KERNEL
);
1123 rc
= kobject_init_and_add(orangefs_obj
,
1131 kobject_uevent(orangefs_obj
, KOBJ_ADD
);
1133 /* create /sys/fs/orangefs/acache. */
1134 acache_orangefs_obj
= kzalloc(sizeof(*acache_orangefs_obj
), GFP_KERNEL
);
1135 if (!acache_orangefs_obj
) {
1140 rc
= kobject_init_and_add(acache_orangefs_obj
,
1141 &acache_orangefs_ktype
,
1146 goto acache_obj_bail
;
1148 kobject_uevent(acache_orangefs_obj
, KOBJ_ADD
);
1150 /* create /sys/fs/orangefs/capcache. */
1151 capcache_orangefs_obj
=
1152 kzalloc(sizeof(*capcache_orangefs_obj
), GFP_KERNEL
);
1153 if (!capcache_orangefs_obj
) {
1155 goto acache_obj_bail
;
1158 rc
= kobject_init_and_add(capcache_orangefs_obj
,
1159 &capcache_orangefs_ktype
,
1163 goto capcache_obj_bail
;
1165 kobject_uevent(capcache_orangefs_obj
, KOBJ_ADD
);
1167 /* create /sys/fs/orangefs/ccache. */
1168 ccache_orangefs_obj
=
1169 kzalloc(sizeof(*ccache_orangefs_obj
), GFP_KERNEL
);
1170 if (!ccache_orangefs_obj
) {
1172 goto capcache_obj_bail
;
1175 rc
= kobject_init_and_add(ccache_orangefs_obj
,
1176 &ccache_orangefs_ktype
,
1180 goto ccache_obj_bail
;
1182 kobject_uevent(ccache_orangefs_obj
, KOBJ_ADD
);
1184 /* create /sys/fs/orangefs/ncache. */
1185 ncache_orangefs_obj
= kzalloc(sizeof(*ncache_orangefs_obj
), GFP_KERNEL
);
1186 if (!ncache_orangefs_obj
) {
1188 goto ccache_obj_bail
;
1191 rc
= kobject_init_and_add(ncache_orangefs_obj
,
1192 &ncache_orangefs_ktype
,
1197 goto ncache_obj_bail
;
1199 kobject_uevent(ncache_orangefs_obj
, KOBJ_ADD
);
1201 /* create /sys/fs/orangefs/perf_counters. */
1202 pc_orangefs_obj
= kzalloc(sizeof(*pc_orangefs_obj
), GFP_KERNEL
);
1203 if (!pc_orangefs_obj
) {
1205 goto ncache_obj_bail
;
1208 rc
= kobject_init_and_add(pc_orangefs_obj
,
1216 kobject_uevent(pc_orangefs_obj
, KOBJ_ADD
);
1218 /* create /sys/fs/orangefs/stats. */
1219 stats_orangefs_obj
= kzalloc(sizeof(*stats_orangefs_obj
), GFP_KERNEL
);
1220 if (!stats_orangefs_obj
) {
1225 rc
= kobject_init_and_add(stats_orangefs_obj
,
1226 &stats_orangefs_ktype
,
1231 goto stats_obj_bail
;
1233 kobject_uevent(stats_orangefs_obj
, KOBJ_ADD
);
1237 kobject_put(stats_orangefs_obj
);
1239 kobject_put(pc_orangefs_obj
);
1241 kobject_put(ncache_orangefs_obj
);
1243 kobject_put(ccache_orangefs_obj
);
1245 kobject_put(capcache_orangefs_obj
);
1247 kobject_put(acache_orangefs_obj
);
1249 kobject_put(orangefs_obj
);
1254 void orangefs_sysfs_exit(void)
1256 gossip_debug(GOSSIP_SYSFS_DEBUG
, "orangefs_sysfs_exit: start\n");
1257 kobject_put(acache_orangefs_obj
);
1258 kobject_put(capcache_orangefs_obj
);
1259 kobject_put(ccache_orangefs_obj
);
1260 kobject_put(ncache_orangefs_obj
);
1261 kobject_put(pc_orangefs_obj
);
1262 kobject_put(stats_orangefs_obj
);
1263 kobject_put(orangefs_obj
);