blob: 6137434ff08c0e81a729f72f1b39b9bb0285e861 [file] [log] [blame]
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001/*
2 * Documentation/ABI/stable/orangefs-sysfs:
3 *
4 * What: /sys/fs/orangefs/perf_counter_reset
5 * Date: June 2015
6 * Contact: Mike Marshall <hubcap@omnibond.com>
7 * Description:
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.
12 *
13 *
14 * What: /sys/fs/orangefs/perf_counters/...
15 * Date: Jun 2015
16 * Contact: Mike Marshall <hubcap@omnibond.com>
17 * Description:
18 * Counters and settings for various caches.
19 * Read only.
20 *
21 *
22 * What: /sys/fs/orangefs/perf_time_interval_secs
23 * Date: Jun 2015
24 * Contact: Mike Marshall <hubcap@omnibond.com>
25 * Description:
26 * Length of perf counter intervals in
27 * seconds.
28 *
29 *
30 * What: /sys/fs/orangefs/perf_history_size
31 * Date: Jun 2015
32 * Contact: Mike Marshall <hubcap@omnibond.com>
33 * Description:
34 * The perf_counters cache statistics have N, or
35 * perf_history_size, samples. The default is
36 * one.
37 *
38 * Every perf_time_interval_secs the (first)
39 * samples are reset.
40 *
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.
44 *
45 *
46 * What: /sys/fs/orangefs/op_timeout_secs
47 * Date: Jun 2015
48 * Contact: Mike Marshall <hubcap@omnibond.com>
49 * Description:
50 * Service operation timeout in seconds.
51 *
52 *
53 * What: /sys/fs/orangefs/slot_timeout_secs
54 * Date: Jun 2015
55 * Contact: Mike Marshall <hubcap@omnibond.com>
56 * Description:
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.
63 *
Martin Brandenburg4cd8f312016-07-25 13:58:24 -040064 * What: /sys/fs/orangefs/dcache_timeout_msecs
65 * Date: Jul 2016
66 * Contact: Martin Brandenburg <martin@omnibond.com>
67 * Description:
68 * Time lookup is valid in milliseconds.
69 *
70 * What: /sys/fs/orangefs/getattr_timeout_msecs
71 * Date: Jul 2016
72 * Contact: Martin Brandenburg <martin@omnibond.com>
73 * Description:
74 * Time getattr is valid in milliseconds.
Mike Marshallf7be4ee2015-07-17 10:38:14 -040075 *
Martin Brandenburg4d20a752016-08-03 13:47:28 -040076 * What: /sys/fs/orangefs/readahead_count
77 * Date: Aug 2016
78 * Contact: Martin Brandenburg <martin@omnibond.com>
79 * Description:
80 * Readahead cache buffer count.
81 *
82 * What: /sys/fs/orangefs/readahead_size
83 * Date: Aug 2016
84 * Contact: Martin Brandenburg <martin@omnibond.com>
85 * Description:
86 * Readahead cache buffer size.
87 *
88 * What: /sys/fs/orangefs/readahead_count_size
89 * Date: Aug 2016
90 * Contact: Martin Brandenburg <martin@omnibond.com>
91 * Description:
92 * Readahead cache buffer count and size.
93 *
Mike Marshallf7be4ee2015-07-17 10:38:14 -040094 * What: /sys/fs/orangefs/acache/...
95 * Date: Jun 2015
Martin Brandenburg4cd8f312016-07-25 13:58:24 -040096 * Contact: Martin Brandenburg <martin@omnibond.com>
Mike Marshallf7be4ee2015-07-17 10:38:14 -040097 * Description:
98 * Attribute cache configurable settings.
99 *
100 *
101 * What: /sys/fs/orangefs/ncache/...
102 * Date: Jun 2015
103 * Contact: Mike Marshall <hubcap@omnibond.com>
104 * Description:
105 * Name cache configurable settings.
106 *
107 *
108 * What: /sys/fs/orangefs/capcache/...
109 * Date: Jun 2015
110 * Contact: Mike Marshall <hubcap@omnibond.com>
111 * Description:
112 * Capability cache configurable settings.
113 *
114 *
115 * What: /sys/fs/orangefs/ccache/...
116 * Date: Jun 2015
117 * Contact: Mike Marshall <hubcap@omnibond.com>
118 * Description:
119 * Credential cache configurable settings.
120 *
121 */
122
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>
129
130#include "protocol.h"
Mike Marshall575e9462015-12-04 12:56:14 -0500131#include "orangefs-kernel.h"
132#include "orangefs-sysfs.h"
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400133
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"
141
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400142struct orangefs_attribute {
143 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400144 ssize_t (*show)(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400145 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400146 ssize_t (*store)(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400147 const char *buf,
148 size_t count);
149};
150
151struct acache_orangefs_attribute {
152 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400153 ssize_t (*show)(struct acache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400154 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400155 ssize_t (*store)(struct acache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400156 const char *buf,
157 size_t count);
158};
159
160struct capcache_orangefs_attribute {
161 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400162 ssize_t (*show)(struct capcache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400163 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400164 ssize_t (*store)(struct capcache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400165 const char *buf,
166 size_t count);
167};
168
169struct ccache_orangefs_attribute {
170 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400171 ssize_t (*show)(struct ccache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400172 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400173 ssize_t (*store)(struct ccache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400174 const char *buf,
175 size_t count);
176};
177
178struct ncache_orangefs_attribute {
179 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400180 ssize_t (*show)(struct ncache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400181 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400182 ssize_t (*store)(struct ncache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400183 const char *buf,
184 size_t count);
185};
186
187struct pc_orangefs_attribute {
188 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400189 ssize_t (*show)(struct pc_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400190 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400191 ssize_t (*store)(struct pc_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400192 const char *buf,
193 size_t count);
194};
195
196struct stats_orangefs_attribute {
197 struct attribute attr;
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400198 ssize_t (*show)(struct stats_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400199 char *buf);
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400200 ssize_t (*store)(struct stats_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400201 const char *buf,
202 size_t count);
203};
204
205static ssize_t orangefs_attr_show(struct kobject *kobj,
206 struct attribute *attr,
207 char *buf)
208{
209 struct orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400210 int rc;
211
212 attribute = container_of(attr, struct orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400213
214 if (!attribute->show) {
215 rc = -EIO;
216 goto out;
217 }
218
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400219 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400220
221out:
222 return rc;
223}
224
225static ssize_t orangefs_attr_store(struct kobject *kobj,
226 struct attribute *attr,
227 const char *buf,
228 size_t len)
229{
230 struct orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400231 int rc;
232
233 gossip_debug(GOSSIP_SYSFS_DEBUG,
234 "orangefs_attr_store: start\n");
235
236 attribute = container_of(attr, struct orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400237
238 if (!attribute->store) {
239 rc = -EIO;
240 goto out;
241 }
242
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400243 rc = attribute->store(attribute, buf, len);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400244
245out:
246 return rc;
247}
248
249static const struct sysfs_ops orangefs_sysfs_ops = {
250 .show = orangefs_attr_show,
251 .store = orangefs_attr_store,
252};
253
254static ssize_t acache_orangefs_attr_show(struct kobject *kobj,
255 struct attribute *attr,
256 char *buf)
257{
258 struct acache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400259 int rc;
260
261 attribute = container_of(attr, struct acache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400262
263 if (!attribute->show) {
264 rc = -EIO;
265 goto out;
266 }
267
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400268 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400269
270out:
271 return rc;
272}
273
274static ssize_t acache_orangefs_attr_store(struct kobject *kobj,
275 struct attribute *attr,
276 const char *buf,
277 size_t len)
278{
279 struct acache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400280 int rc;
281
282 gossip_debug(GOSSIP_SYSFS_DEBUG,
283 "acache_orangefs_attr_store: start\n");
284
285 attribute = container_of(attr, struct acache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400286
287 if (!attribute->store) {
288 rc = -EIO;
289 goto out;
290 }
291
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400292 rc = attribute->store(attribute, buf, len);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400293
294out:
295 return rc;
296}
297
298static const struct sysfs_ops acache_orangefs_sysfs_ops = {
299 .show = acache_orangefs_attr_show,
300 .store = acache_orangefs_attr_store,
301};
302
303static ssize_t capcache_orangefs_attr_show(struct kobject *kobj,
304 struct attribute *attr,
305 char *buf)
306{
307 struct capcache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400308 int rc;
309
310 attribute =
311 container_of(attr, struct capcache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400312
313 if (!attribute->show) {
314 rc = -EIO;
315 goto out;
316 }
317
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400318 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400319
320out:
321 return rc;
322}
323
324static ssize_t capcache_orangefs_attr_store(struct kobject *kobj,
325 struct attribute *attr,
326 const char *buf,
327 size_t len)
328{
329 struct capcache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400330 int rc;
331
332 gossip_debug(GOSSIP_SYSFS_DEBUG,
333 "capcache_orangefs_attr_store: start\n");
334
335 attribute =
336 container_of(attr, struct capcache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400337
338 if (!attribute->store) {
339 rc = -EIO;
340 goto out;
341 }
342
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400343 rc = attribute->store(attribute, buf, len);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400344
345out:
346 return rc;
347}
348
349static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
350 .show = capcache_orangefs_attr_show,
351 .store = capcache_orangefs_attr_store,
352};
353
354static ssize_t ccache_orangefs_attr_show(struct kobject *kobj,
355 struct attribute *attr,
356 char *buf)
357{
358 struct ccache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400359 int rc;
360
361 attribute =
362 container_of(attr, struct ccache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400363
364 if (!attribute->show) {
365 rc = -EIO;
366 goto out;
367 }
368
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400369 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400370
371out:
372 return rc;
373}
374
375static ssize_t ccache_orangefs_attr_store(struct kobject *kobj,
376 struct attribute *attr,
377 const char *buf,
378 size_t len)
379{
380 struct ccache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400381 int rc;
382
383 gossip_debug(GOSSIP_SYSFS_DEBUG,
384 "ccache_orangefs_attr_store: start\n");
385
386 attribute =
387 container_of(attr, struct ccache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400388
389 if (!attribute->store) {
390 rc = -EIO;
391 goto out;
392 }
393
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400394 rc = attribute->store(attribute, buf, len);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400395
396out:
397 return rc;
398}
399
400static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
401 .show = ccache_orangefs_attr_show,
402 .store = ccache_orangefs_attr_store,
403};
404
405static ssize_t ncache_orangefs_attr_show(struct kobject *kobj,
406 struct attribute *attr,
407 char *buf)
408{
409 struct ncache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400410 int rc;
411
412 attribute = container_of(attr, struct ncache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400413
414 if (!attribute->show) {
415 rc = -EIO;
416 goto out;
417 }
418
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400419 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400420
421out:
422 return rc;
423}
424
425static ssize_t ncache_orangefs_attr_store(struct kobject *kobj,
426 struct attribute *attr,
427 const char *buf,
428 size_t len)
429{
430 struct ncache_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400431 int rc;
432
433 gossip_debug(GOSSIP_SYSFS_DEBUG,
434 "ncache_orangefs_attr_store: start\n");
435
436 attribute = container_of(attr, struct ncache_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400437
438 if (!attribute->store) {
439 rc = -EIO;
440 goto out;
441 }
442
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400443 rc = attribute->store(attribute, buf, len);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400444
445out:
446 return rc;
447}
448
449static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
450 .show = ncache_orangefs_attr_show,
451 .store = ncache_orangefs_attr_store,
452};
453
454static ssize_t pc_orangefs_attr_show(struct kobject *kobj,
455 struct attribute *attr,
456 char *buf)
457{
458 struct pc_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400459 int rc;
460
461 attribute = container_of(attr, struct pc_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400462
463 if (!attribute->show) {
464 rc = -EIO;
465 goto out;
466 }
467
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400468 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400469
470out:
471 return rc;
472}
473
474static const struct sysfs_ops pc_orangefs_sysfs_ops = {
475 .show = pc_orangefs_attr_show,
476};
477
478static ssize_t stats_orangefs_attr_show(struct kobject *kobj,
479 struct attribute *attr,
480 char *buf)
481{
482 struct stats_orangefs_attribute *attribute;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400483 int rc;
484
485 attribute = container_of(attr, struct stats_orangefs_attribute, attr);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400486
487 if (!attribute->show) {
488 rc = -EIO;
489 goto out;
490 }
491
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400492 rc = attribute->show(attribute, buf);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400493
494out:
495 return rc;
496}
497
498static const struct sysfs_ops stats_orangefs_sysfs_ops = {
499 .show = stats_orangefs_attr_show,
500};
501
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400502static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr)
503{
504 int rc = -EIO;
505 struct orangefs_attribute *orangefs_attr;
506 struct stats_orangefs_attribute *stats_orangefs_attr;
507
508 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id);
509
510 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
511 orangefs_attr = (struct orangefs_attribute *)attr;
512
513 if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) {
514 rc = scnprintf(buf,
515 PAGE_SIZE,
516 "%d\n",
517 op_timeout_secs);
518 goto out;
519 } else if (!strcmp(orangefs_attr->attr.name,
520 "slot_timeout_secs")) {
521 rc = scnprintf(buf,
522 PAGE_SIZE,
523 "%d\n",
524 slot_timeout_secs);
525 goto out;
Martin Brandenburg4cd8f312016-07-25 13:58:24 -0400526 } else if (!strcmp(orangefs_attr->attr.name,
527 "dcache_timeout_msecs")) {
528 rc = scnprintf(buf,
529 PAGE_SIZE,
530 "%d\n",
531 dcache_timeout_msecs);
532 goto out;
533 } else if (!strcmp(orangefs_attr->attr.name,
534 "getattr_timeout_msecs")) {
535 rc = scnprintf(buf,
536 PAGE_SIZE,
537 "%d\n",
538 getattr_timeout_msecs);
539 goto out;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400540 } else {
541 goto out;
542 }
543
544 } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) {
545 stats_orangefs_attr = (struct stats_orangefs_attribute *)attr;
546
547 if (!strcmp(stats_orangefs_attr->attr.name, "reads")) {
548 rc = scnprintf(buf,
549 PAGE_SIZE,
550 "%lu\n",
Yi Liu8bb8aef2015-11-24 15:12:14 -0500551 g_orangefs_stats.reads);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400552 goto out;
553 } else if (!strcmp(stats_orangefs_attr->attr.name, "writes")) {
554 rc = scnprintf(buf,
555 PAGE_SIZE,
556 "%lu\n",
Yi Liu8bb8aef2015-11-24 15:12:14 -0500557 g_orangefs_stats.writes);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400558 goto out;
559 } else {
560 goto out;
561 }
562 }
563
564out:
565
566 return rc;
567}
568
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400569static ssize_t int_orangefs_show(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400570 char *buf)
571{
572 int rc;
573
574 gossip_debug(GOSSIP_SYSFS_DEBUG,
575 "int_orangefs_show:start attr->attr.name:%s:\n",
576 attr->attr.name);
577
578 rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr);
579
580 return rc;
581}
582
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400583static ssize_t int_stats_show(struct stats_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400584 char *buf)
585{
586 int rc;
587
588 gossip_debug(GOSSIP_SYSFS_DEBUG,
589 "int_stats_show:start attr->attr.name:%s:\n",
590 attr->attr.name);
591
592 rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr);
593
594 return rc;
595}
596
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400597static ssize_t int_store(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400598 const char *buf,
599 size_t count)
600{
601 int rc = 0;
602
603 gossip_debug(GOSSIP_SYSFS_DEBUG,
604 "int_store: start attr->attr.name:%s: buf:%s:\n",
605 attr->attr.name, buf);
606
607 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
608 rc = kstrtoint(buf, 0, &op_timeout_secs);
609 goto out;
610 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
611 rc = kstrtoint(buf, 0, &slot_timeout_secs);
612 goto out;
Martin Brandenburg4cd8f312016-07-25 13:58:24 -0400613 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
614 rc = kstrtoint(buf, 0, &dcache_timeout_msecs);
615 goto out;
616 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
617 rc = kstrtoint(buf, 0, &getattr_timeout_msecs);
618 goto out;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400619 } else {
620 goto out;
621 }
622
623out:
624 if (rc)
625 rc = -EINVAL;
626 else
627 rc = count;
628
629 return rc;
630}
631
632/*
633 * obtain attribute values from userspace with a service operation.
634 */
Mike Marshall84d02152015-07-28 13:27:51 -0400635static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr)
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400636{
Yi Liu8bb8aef2015-11-24 15:12:14 -0500637 struct orangefs_kernel_op_s *new_op = NULL;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400638 int rc = 0;
639 char *ser_op_type = NULL;
640 struct orangefs_attribute *orangefs_attr;
641 struct acache_orangefs_attribute *acache_attr;
642 struct capcache_orangefs_attribute *capcache_attr;
643 struct ccache_orangefs_attribute *ccache_attr;
644 struct ncache_orangefs_attribute *ncache_attr;
645 struct pc_orangefs_attribute *pc_attr;
646 __u32 op_alloc_type;
647
648 gossip_debug(GOSSIP_SYSFS_DEBUG,
649 "sysfs_service_op_show: id:%s:\n",
650 kobj_id);
651
652 if (strcmp(kobj_id, PC_KOBJ_ID))
Yi Liu8bb8aef2015-11-24 15:12:14 -0500653 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400654 else
Yi Liu8bb8aef2015-11-24 15:12:14 -0500655 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400656
657 new_op = op_alloc(op_alloc_type);
Al Viroed42fe02016-01-22 19:47:47 -0500658 if (!new_op)
659 return -ENOMEM;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400660
661 /* Can't do a service_operation if the client is not running... */
662 rc = is_daemon_in_service();
663 if (rc) {
664 pr_info("%s: Client not running :%d:\n",
665 __func__,
666 is_daemon_in_service());
667 goto out;
668 }
669
670 if (strcmp(kobj_id, PC_KOBJ_ID))
Yi Liu8bb8aef2015-11-24 15:12:14 -0500671 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400672
673 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
674 orangefs_attr = (struct orangefs_attribute *)attr;
675
676 if (!strcmp(orangefs_attr->attr.name, "perf_history_size"))
677 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500678 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400679 else if (!strcmp(orangefs_attr->attr.name,
680 "perf_time_interval_secs"))
681 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500682 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400683 else if (!strcmp(orangefs_attr->attr.name,
684 "perf_counter_reset"))
685 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500686 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400687
Martin Brandenburg4d20a752016-08-03 13:47:28 -0400688 else if (!strcmp(orangefs_attr->attr.name,
689 "readahead_count"))
690 new_op->upcall.req.param.op =
691 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
692
693 else if (!strcmp(orangefs_attr->attr.name,
694 "readahead_size"))
695 new_op->upcall.req.param.op =
696 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
697
698 else if (!strcmp(orangefs_attr->attr.name,
699 "readahead_count_size"))
700 new_op->upcall.req.param.op =
701 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400702 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
703 acache_attr = (struct acache_orangefs_attribute *)attr;
704
705 if (!strcmp(acache_attr->attr.name, "timeout_msecs"))
706 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500707 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400708
709 if (!strcmp(acache_attr->attr.name, "hard_limit"))
710 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500711 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400712
713 if (!strcmp(acache_attr->attr.name, "soft_limit"))
714 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500715 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400716
717 if (!strcmp(acache_attr->attr.name, "reclaim_percentage"))
718 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500719 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400720
721 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
722 capcache_attr = (struct capcache_orangefs_attribute *)attr;
723
724 if (!strcmp(capcache_attr->attr.name, "timeout_secs"))
725 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500726 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400727
728 if (!strcmp(capcache_attr->attr.name, "hard_limit"))
729 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500730 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400731
732 if (!strcmp(capcache_attr->attr.name, "soft_limit"))
733 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500734 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400735
736 if (!strcmp(capcache_attr->attr.name, "reclaim_percentage"))
737 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500738 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400739
740 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
741 ccache_attr = (struct ccache_orangefs_attribute *)attr;
742
743 if (!strcmp(ccache_attr->attr.name, "timeout_secs"))
744 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500745 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400746
747 if (!strcmp(ccache_attr->attr.name, "hard_limit"))
748 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500749 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400750
751 if (!strcmp(ccache_attr->attr.name, "soft_limit"))
752 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500753 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400754
755 if (!strcmp(ccache_attr->attr.name, "reclaim_percentage"))
756 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500757 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400758
759 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
760 ncache_attr = (struct ncache_orangefs_attribute *)attr;
761
762 if (!strcmp(ncache_attr->attr.name, "timeout_msecs"))
763 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500764 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400765
766 if (!strcmp(ncache_attr->attr.name, "hard_limit"))
767 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500768 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400769
770 if (!strcmp(ncache_attr->attr.name, "soft_limit"))
771 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500772 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400773
774 if (!strcmp(ncache_attr->attr.name, "reclaim_percentage"))
775 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500776 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400777
778 } else if (!strcmp(kobj_id, PC_KOBJ_ID)) {
779 pc_attr = (struct pc_orangefs_attribute *)attr;
780
781 if (!strcmp(pc_attr->attr.name, ACACHE_KOBJ_ID))
782 new_op->upcall.req.perf_count.type =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500783 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400784
785 if (!strcmp(pc_attr->attr.name, CAPCACHE_KOBJ_ID))
786 new_op->upcall.req.perf_count.type =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500787 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400788
789 if (!strcmp(pc_attr->attr.name, NCACHE_KOBJ_ID))
790 new_op->upcall.req.perf_count.type =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500791 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400792
793 } else {
794 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
795 kobj_id);
796 rc = -EINVAL;
797 goto out;
798 }
799
800
801 if (strcmp(kobj_id, PC_KOBJ_ID))
Yi Liu8bb8aef2015-11-24 15:12:14 -0500802 ser_op_type = "orangefs_param";
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400803 else
Yi Liu8bb8aef2015-11-24 15:12:14 -0500804 ser_op_type = "orangefs_perf_count";
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400805
806 /*
807 * The service_operation will return an errno return code on
808 * error, and zero on success.
809 */
Yi Liu8bb8aef2015-11-24 15:12:14 -0500810 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400811
812out:
813 if (!rc) {
814 if (strcmp(kobj_id, PC_KOBJ_ID)) {
Martin Brandenburg4d20a752016-08-03 13:47:28 -0400815 if (new_op->upcall.req.param.op ==
816 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
817 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
818 (int)new_op->downcall.resp.param.u.
819 value32[0],
820 (int)new_op->downcall.resp.param.u.
821 value32[1]);
822 } else {
823 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
824 (int)new_op->downcall.resp.param.u.value64);
825 }
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400826 } else {
827 rc = scnprintf(
828 buf,
829 PAGE_SIZE,
830 "%s",
831 new_op->downcall.resp.perf_count.buffer);
832 }
833 }
834
Al Viroed42fe02016-01-22 19:47:47 -0500835 op_release(new_op);
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400836
837 return rc;
838
839}
840
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400841static ssize_t service_orangefs_show(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400842 char *buf)
843{
844 int rc = 0;
845
846 rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr);
847
848 return rc;
849}
850
851static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400852 service_acache_show(struct acache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400853 char *buf)
854{
855 int rc = 0;
856
857 rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr);
858
859 return rc;
860}
861
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400862static ssize_t service_capcache_show(struct capcache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400863 char *buf)
864{
865 int rc = 0;
866
867 rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr);
868
869 return rc;
870}
871
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400872static ssize_t service_ccache_show(struct ccache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400873 char *buf)
874{
875 int rc = 0;
876
877 rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr);
878
879 return rc;
880}
881
882static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400883 service_ncache_show(struct ncache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400884 char *buf)
885{
886 int rc = 0;
887
888 rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr);
889
890 return rc;
891}
892
893static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -0400894 service_pc_show(struct pc_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400895 char *buf)
896{
897 int rc = 0;
898
899 rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr);
900
901 return rc;
902}
903
904/*
905 * pass attribute values back to userspace with a service operation.
906 *
907 * We have to do a memory allocation, an sscanf and a service operation.
908 * And we have to evaluate what the user entered, to make sure the
909 * value is within the range supported by the attribute. So, there's
910 * a lot of return code checking and mapping going on here.
911 *
912 * We want to return 1 if we think everything went OK, and
913 * EINVAL if not.
914 */
Mike Marshall84d02152015-07-28 13:27:51 -0400915static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr)
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400916{
Yi Liu8bb8aef2015-11-24 15:12:14 -0500917 struct orangefs_kernel_op_s *new_op = NULL;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400918 int val = 0;
919 int rc = 0;
920 struct orangefs_attribute *orangefs_attr;
921 struct acache_orangefs_attribute *acache_attr;
922 struct capcache_orangefs_attribute *capcache_attr;
923 struct ccache_orangefs_attribute *ccache_attr;
924 struct ncache_orangefs_attribute *ncache_attr;
925
926 gossip_debug(GOSSIP_SYSFS_DEBUG,
927 "sysfs_service_op_store: id:%s:\n",
928 kobj_id);
929
Yi Liu8bb8aef2015-11-24 15:12:14 -0500930 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
Al Viroed42fe02016-01-22 19:47:47 -0500931 if (!new_op)
932 return -EINVAL; /* sic */
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400933
934 /* Can't do a service_operation if the client is not running... */
935 rc = is_daemon_in_service();
936 if (rc) {
937 pr_info("%s: Client not running :%d:\n",
938 __func__,
939 is_daemon_in_service());
940 goto out;
941 }
942
943 /*
Martin Brandenburg4d20a752016-08-03 13:47:28 -0400944 * The value we want to send back to userspace is in buf, unless this
945 * there are two parameters, which is specially handled below.
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400946 */
Martin Brandenburg4d20a752016-08-03 13:47:28 -0400947 if (strcmp(kobj_id, ORANGEFS_KOBJ_ID) ||
948 strcmp(((struct orangefs_attribute *)attr)->attr.name,
949 "readahead_count_size")) {
950 rc = kstrtoint(buf, 0, &val);
951 if (rc)
952 goto out;
953 }
954
955 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400956
957 if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
958 orangefs_attr = (struct orangefs_attribute *)attr;
959
960 if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) {
961 if (val > 0) {
962 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500963 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400964 } else {
965 rc = 0;
966 goto out;
967 }
968 } else if (!strcmp(orangefs_attr->attr.name,
969 "perf_time_interval_secs")) {
970 if (val > 0) {
971 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500972 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400973 } else {
974 rc = 0;
975 goto out;
976 }
977 } else if (!strcmp(orangefs_attr->attr.name,
978 "perf_counter_reset")) {
979 if ((val == 0) || (val == 1)) {
980 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -0500981 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
Mike Marshallf7be4ee2015-07-17 10:38:14 -0400982 } else {
983 rc = 0;
984 goto out;
985 }
Martin Brandenburg4d20a752016-08-03 13:47:28 -0400986 } else if (!strcmp(orangefs_attr->attr.name,
987 "readahead_count")) {
988 if ((val >= 0)) {
989 new_op->upcall.req.param.op =
990 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
991 } else {
992 rc = 0;
993 goto out;
994 }
995 } else if (!strcmp(orangefs_attr->attr.name,
996 "readahead_size")) {
997 if ((val >= 0)) {
998 new_op->upcall.req.param.op =
999 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
1000 } else {
1001 rc = 0;
1002 goto out;
1003 }
1004 } else if (!strcmp(orangefs_attr->attr.name,
1005 "readahead_count_size")) {
1006 int val1, val2;
1007 rc = sscanf(buf, "%d %d", &val1, &val2);
1008 if (rc < 2) {
1009 rc = 0;
1010 goto out;
1011 }
1012 if ((val1 >= 0) && (val2 >= 0)) {
1013 new_op->upcall.req.param.op =
1014 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
1015 } else {
1016 rc = 0;
1017 goto out;
1018 }
1019 new_op->upcall.req.param.u.value32[0] = val1;
1020 new_op->upcall.req.param.u.value32[1] = val2;
1021 goto value_set;
1022 } else if (!strcmp(orangefs_attr->attr.name,
1023 "perf_counter_reset")) {
1024 if ((val > 0)) {
1025 new_op->upcall.req.param.op =
1026 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
1027 } else {
1028 rc = 0;
1029 goto out;
1030 }
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001031 }
1032
1033 } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) {
1034 acache_attr = (struct acache_orangefs_attribute *)attr;
1035
1036 if (!strcmp(acache_attr->attr.name, "hard_limit")) {
1037 if (val > -1) {
1038 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001039 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001040 } else {
1041 rc = 0;
1042 goto out;
1043 }
1044 } else if (!strcmp(acache_attr->attr.name, "soft_limit")) {
1045 if (val > -1) {
1046 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001047 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001048 } else {
1049 rc = 0;
1050 goto out;
1051 }
1052 } else if (!strcmp(acache_attr->attr.name,
1053 "reclaim_percentage")) {
1054 if ((val > -1) && (val < 101)) {
1055 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001056 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001057 } else {
1058 rc = 0;
1059 goto out;
1060 }
1061 } else if (!strcmp(acache_attr->attr.name, "timeout_msecs")) {
1062 if (val > -1) {
1063 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001064 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001065 } else {
1066 rc = 0;
1067 goto out;
1068 }
1069 }
1070
1071 } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) {
1072 capcache_attr = (struct capcache_orangefs_attribute *)attr;
1073
1074 if (!strcmp(capcache_attr->attr.name, "hard_limit")) {
1075 if (val > -1) {
1076 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001077 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001078 } else {
1079 rc = 0;
1080 goto out;
1081 }
1082 } else if (!strcmp(capcache_attr->attr.name, "soft_limit")) {
1083 if (val > -1) {
1084 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001085 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001086 } else {
1087 rc = 0;
1088 goto out;
1089 }
1090 } else if (!strcmp(capcache_attr->attr.name,
1091 "reclaim_percentage")) {
1092 if ((val > -1) && (val < 101)) {
1093 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001094 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001095 } else {
1096 rc = 0;
1097 goto out;
1098 }
1099 } else if (!strcmp(capcache_attr->attr.name, "timeout_secs")) {
1100 if (val > -1) {
1101 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001102 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001103 } else {
1104 rc = 0;
1105 goto out;
1106 }
1107 }
1108
1109 } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) {
1110 ccache_attr = (struct ccache_orangefs_attribute *)attr;
1111
1112 if (!strcmp(ccache_attr->attr.name, "hard_limit")) {
1113 if (val > -1) {
1114 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001115 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001116 } else {
1117 rc = 0;
1118 goto out;
1119 }
1120 } else if (!strcmp(ccache_attr->attr.name, "soft_limit")) {
1121 if (val > -1) {
1122 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001123 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001124 } else {
1125 rc = 0;
1126 goto out;
1127 }
1128 } else if (!strcmp(ccache_attr->attr.name,
1129 "reclaim_percentage")) {
1130 if ((val > -1) && (val < 101)) {
1131 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001132 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001133 } else {
1134 rc = 0;
1135 goto out;
1136 }
1137 } else if (!strcmp(ccache_attr->attr.name, "timeout_secs")) {
1138 if (val > -1) {
1139 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001140 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001141 } else {
1142 rc = 0;
1143 goto out;
1144 }
1145 }
1146
1147 } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) {
1148 ncache_attr = (struct ncache_orangefs_attribute *)attr;
1149
1150 if (!strcmp(ncache_attr->attr.name, "hard_limit")) {
1151 if (val > -1) {
1152 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001153 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001154 } else {
1155 rc = 0;
1156 goto out;
1157 }
1158 } else if (!strcmp(ncache_attr->attr.name, "soft_limit")) {
1159 if (val > -1) {
1160 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001161 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001162 } else {
1163 rc = 0;
1164 goto out;
1165 }
1166 } else if (!strcmp(ncache_attr->attr.name,
1167 "reclaim_percentage")) {
1168 if ((val > -1) && (val < 101)) {
1169 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001170 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001171 } else {
1172 rc = 0;
1173 goto out;
1174 }
1175 } else if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) {
1176 if (val > -1) {
1177 new_op->upcall.req.param.op =
Yi Liu8bb8aef2015-11-24 15:12:14 -05001178 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001179 } else {
1180 rc = 0;
1181 goto out;
1182 }
1183 }
1184
1185 } else {
1186 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
1187 kobj_id);
1188 rc = -EINVAL;
1189 goto out;
1190 }
1191
Martin Brandenburg680908e2016-08-02 16:33:34 -04001192 new_op->upcall.req.param.u.value64 = val;
Martin Brandenburg4d20a752016-08-03 13:47:28 -04001193value_set:
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001194
1195 /*
1196 * The service_operation will return a errno return code on
1197 * error, and zero on success.
1198 */
Yi Liu8bb8aef2015-11-24 15:12:14 -05001199 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001200
1201 if (rc < 0) {
1202 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
1203 rc);
1204 rc = 0;
1205 } else {
1206 rc = 1;
1207 }
1208
1209out:
Al Viroed42fe02016-01-22 19:47:47 -05001210 op_release(new_op);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001211
Al Viroed42fe02016-01-22 19:47:47 -05001212 if (rc == -ENOMEM || rc == 0)
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001213 rc = -EINVAL;
1214
1215 return rc;
1216}
1217
1218static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001219 service_orangefs_store(struct orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001220 const char *buf,
1221 size_t count)
1222{
1223 int rc = 0;
1224
1225 rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr);
1226
1227 /* rc should have an errno value if the service_op went bad. */
1228 if (rc == 1)
1229 rc = count;
1230
1231 return rc;
1232}
1233
1234static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001235 service_acache_store(struct acache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001236 const char *buf,
1237 size_t count)
1238{
1239 int rc = 0;
1240
1241 rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr);
1242
1243 /* rc should have an errno value if the service_op went bad. */
1244 if (rc == 1)
1245 rc = count;
1246
1247 return rc;
1248}
1249
1250static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001251 service_capcache_store(struct capcache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001252 const char *buf,
1253 size_t count)
1254{
1255 int rc = 0;
1256
1257 rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr);
1258
1259 /* rc should have an errno value if the service_op went bad. */
1260 if (rc == 1)
1261 rc = count;
1262
1263 return rc;
1264}
1265
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001266static ssize_t service_ccache_store(struct ccache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001267 const char *buf,
1268 size_t count)
1269{
1270 int rc = 0;
1271
1272 rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr);
1273
1274 /* rc should have an errno value if the service_op went bad. */
1275 if (rc == 1)
1276 rc = count;
1277
1278 return rc;
1279}
1280
1281static ssize_t
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001282 service_ncache_store(struct ncache_orangefs_attribute *attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001283 const char *buf,
1284 size_t count)
1285{
1286 int rc = 0;
1287
1288 rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr);
1289
1290 /* rc should have an errno value if the service_op went bad. */
1291 if (rc == 1)
1292 rc = count;
1293
1294 return rc;
1295}
1296
1297static struct orangefs_attribute op_timeout_secs_attribute =
1298 __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store);
1299
1300static struct orangefs_attribute slot_timeout_secs_attribute =
1301 __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store);
1302
Martin Brandenburg4cd8f312016-07-25 13:58:24 -04001303static struct orangefs_attribute dcache_timeout_msecs_attribute =
1304 __ATTR(dcache_timeout_msecs, 0664, int_orangefs_show, int_store);
1305
1306static struct orangefs_attribute getattr_timeout_msecs_attribute =
1307 __ATTR(getattr_timeout_msecs, 0664, int_orangefs_show, int_store);
1308
Martin Brandenburg4d20a752016-08-03 13:47:28 -04001309static struct orangefs_attribute readahead_count_attribute =
1310 __ATTR(readahead_count, 0664, service_orangefs_show,
1311 service_orangefs_store);
1312
1313static struct orangefs_attribute readahead_size_attribute =
1314 __ATTR(readahead_size, 0664, service_orangefs_show,
1315 service_orangefs_store);
1316
1317static struct orangefs_attribute readahead_count_size_attribute =
1318 __ATTR(readahead_count_size, 0664, service_orangefs_show,
1319 service_orangefs_store);
1320
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001321static struct orangefs_attribute perf_counter_reset_attribute =
1322 __ATTR(perf_counter_reset,
1323 0664,
1324 service_orangefs_show,
1325 service_orangefs_store);
1326
1327static struct orangefs_attribute perf_history_size_attribute =
1328 __ATTR(perf_history_size,
1329 0664,
1330 service_orangefs_show,
1331 service_orangefs_store);
1332
1333static struct orangefs_attribute perf_time_interval_secs_attribute =
1334 __ATTR(perf_time_interval_secs,
1335 0664,
1336 service_orangefs_show,
1337 service_orangefs_store);
1338
1339static struct attribute *orangefs_default_attrs[] = {
1340 &op_timeout_secs_attribute.attr,
1341 &slot_timeout_secs_attribute.attr,
Martin Brandenburg4cd8f312016-07-25 13:58:24 -04001342 &dcache_timeout_msecs_attribute.attr,
1343 &getattr_timeout_msecs_attribute.attr,
Martin Brandenburg4d20a752016-08-03 13:47:28 -04001344 &readahead_count_attribute.attr,
1345 &readahead_size_attribute.attr,
1346 &readahead_count_size_attribute.attr,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001347 &perf_counter_reset_attribute.attr,
1348 &perf_history_size_attribute.attr,
1349 &perf_time_interval_secs_attribute.attr,
1350 NULL,
1351};
1352
1353static struct kobj_type orangefs_ktype = {
1354 .sysfs_ops = &orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001355 .default_attrs = orangefs_default_attrs,
1356};
1357
1358static struct acache_orangefs_attribute acache_hard_limit_attribute =
1359 __ATTR(hard_limit,
1360 0664,
1361 service_acache_show,
1362 service_acache_store);
1363
1364static struct acache_orangefs_attribute acache_reclaim_percent_attribute =
1365 __ATTR(reclaim_percentage,
1366 0664,
1367 service_acache_show,
1368 service_acache_store);
1369
1370static struct acache_orangefs_attribute acache_soft_limit_attribute =
1371 __ATTR(soft_limit,
1372 0664,
1373 service_acache_show,
1374 service_acache_store);
1375
1376static struct acache_orangefs_attribute acache_timeout_msecs_attribute =
1377 __ATTR(timeout_msecs,
1378 0664,
1379 service_acache_show,
1380 service_acache_store);
1381
1382static struct attribute *acache_orangefs_default_attrs[] = {
1383 &acache_hard_limit_attribute.attr,
1384 &acache_reclaim_percent_attribute.attr,
1385 &acache_soft_limit_attribute.attr,
1386 &acache_timeout_msecs_attribute.attr,
1387 NULL,
1388};
1389
1390static struct kobj_type acache_orangefs_ktype = {
1391 .sysfs_ops = &acache_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001392 .default_attrs = acache_orangefs_default_attrs,
1393};
1394
1395static struct capcache_orangefs_attribute capcache_hard_limit_attribute =
1396 __ATTR(hard_limit,
1397 0664,
1398 service_capcache_show,
1399 service_capcache_store);
1400
1401static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute =
1402 __ATTR(reclaim_percentage,
1403 0664,
1404 service_capcache_show,
1405 service_capcache_store);
1406
1407static struct capcache_orangefs_attribute capcache_soft_limit_attribute =
1408 __ATTR(soft_limit,
1409 0664,
1410 service_capcache_show,
1411 service_capcache_store);
1412
1413static struct capcache_orangefs_attribute capcache_timeout_secs_attribute =
1414 __ATTR(timeout_secs,
1415 0664,
1416 service_capcache_show,
1417 service_capcache_store);
1418
1419static struct attribute *capcache_orangefs_default_attrs[] = {
1420 &capcache_hard_limit_attribute.attr,
1421 &capcache_reclaim_percent_attribute.attr,
1422 &capcache_soft_limit_attribute.attr,
1423 &capcache_timeout_secs_attribute.attr,
1424 NULL,
1425};
1426
1427static struct kobj_type capcache_orangefs_ktype = {
1428 .sysfs_ops = &capcache_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001429 .default_attrs = capcache_orangefs_default_attrs,
1430};
1431
1432static struct ccache_orangefs_attribute ccache_hard_limit_attribute =
1433 __ATTR(hard_limit,
1434 0664,
1435 service_ccache_show,
1436 service_ccache_store);
1437
1438static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute =
1439 __ATTR(reclaim_percentage,
1440 0664,
1441 service_ccache_show,
1442 service_ccache_store);
1443
1444static struct ccache_orangefs_attribute ccache_soft_limit_attribute =
1445 __ATTR(soft_limit,
1446 0664,
1447 service_ccache_show,
1448 service_ccache_store);
1449
1450static struct ccache_orangefs_attribute ccache_timeout_secs_attribute =
1451 __ATTR(timeout_secs,
1452 0664,
1453 service_ccache_show,
1454 service_ccache_store);
1455
1456static struct attribute *ccache_orangefs_default_attrs[] = {
1457 &ccache_hard_limit_attribute.attr,
1458 &ccache_reclaim_percent_attribute.attr,
1459 &ccache_soft_limit_attribute.attr,
1460 &ccache_timeout_secs_attribute.attr,
1461 NULL,
1462};
1463
1464static struct kobj_type ccache_orangefs_ktype = {
1465 .sysfs_ops = &ccache_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001466 .default_attrs = ccache_orangefs_default_attrs,
1467};
1468
1469static struct ncache_orangefs_attribute ncache_hard_limit_attribute =
1470 __ATTR(hard_limit,
1471 0664,
1472 service_ncache_show,
1473 service_ncache_store);
1474
1475static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute =
1476 __ATTR(reclaim_percentage,
1477 0664,
1478 service_ncache_show,
1479 service_ncache_store);
1480
1481static struct ncache_orangefs_attribute ncache_soft_limit_attribute =
1482 __ATTR(soft_limit,
1483 0664,
1484 service_ncache_show,
1485 service_ncache_store);
1486
1487static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute =
1488 __ATTR(timeout_msecs,
1489 0664,
1490 service_ncache_show,
1491 service_ncache_store);
1492
1493static struct attribute *ncache_orangefs_default_attrs[] = {
1494 &ncache_hard_limit_attribute.attr,
1495 &ncache_reclaim_percent_attribute.attr,
1496 &ncache_soft_limit_attribute.attr,
1497 &ncache_timeout_msecs_attribute.attr,
1498 NULL,
1499};
1500
1501static struct kobj_type ncache_orangefs_ktype = {
1502 .sysfs_ops = &ncache_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001503 .default_attrs = ncache_orangefs_default_attrs,
1504};
1505
1506static struct pc_orangefs_attribute pc_acache_attribute =
1507 __ATTR(acache,
1508 0664,
1509 service_pc_show,
1510 NULL);
1511
1512static struct pc_orangefs_attribute pc_capcache_attribute =
1513 __ATTR(capcache,
1514 0664,
1515 service_pc_show,
1516 NULL);
1517
1518static struct pc_orangefs_attribute pc_ncache_attribute =
1519 __ATTR(ncache,
1520 0664,
1521 service_pc_show,
1522 NULL);
1523
1524static struct attribute *pc_orangefs_default_attrs[] = {
1525 &pc_acache_attribute.attr,
1526 &pc_capcache_attribute.attr,
1527 &pc_ncache_attribute.attr,
1528 NULL,
1529};
1530
1531static struct kobj_type pc_orangefs_ktype = {
1532 .sysfs_ops = &pc_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001533 .default_attrs = pc_orangefs_default_attrs,
1534};
1535
1536static struct stats_orangefs_attribute stats_reads_attribute =
1537 __ATTR(reads,
1538 0664,
1539 int_stats_show,
1540 NULL);
1541
1542static struct stats_orangefs_attribute stats_writes_attribute =
1543 __ATTR(writes,
1544 0664,
1545 int_stats_show,
1546 NULL);
1547
1548static struct attribute *stats_orangefs_default_attrs[] = {
1549 &stats_reads_attribute.attr,
1550 &stats_writes_attribute.attr,
1551 NULL,
1552};
1553
1554static struct kobj_type stats_orangefs_ktype = {
1555 .sysfs_ops = &stats_orangefs_sysfs_ops,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001556 .default_attrs = stats_orangefs_default_attrs,
1557};
1558
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001559static struct kobject *orangefs_obj;
1560static struct kobject *acache_orangefs_obj;
1561static struct kobject *capcache_orangefs_obj;
1562static struct kobject *ccache_orangefs_obj;
1563static struct kobject *ncache_orangefs_obj;
1564static struct kobject *pc_orangefs_obj;
1565static struct kobject *stats_orangefs_obj;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001566
1567int orangefs_sysfs_init(void)
1568{
Mike Marshall2180c522016-03-14 15:30:39 -04001569 int rc = -EINVAL;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001570
1571 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1572
1573 /* create /sys/fs/orangefs. */
1574 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
Mike Marshall2180c522016-03-14 15:30:39 -04001575 if (!orangefs_obj)
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001576 goto out;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001577
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001578 rc = kobject_init_and_add(orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001579 &orangefs_ktype,
1580 fs_kobj,
1581 ORANGEFS_KOBJ_ID);
1582
Mike Marshall2180c522016-03-14 15:30:39 -04001583 if (rc)
1584 goto ofs_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001585
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001586 kobject_uevent(orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001587
1588 /* create /sys/fs/orangefs/acache. */
1589 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1590 if (!acache_orangefs_obj) {
1591 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001592 goto ofs_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001593 }
1594
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001595 rc = kobject_init_and_add(acache_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001596 &acache_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001597 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001598 ACACHE_KOBJ_ID);
1599
Mike Marshall2180c522016-03-14 15:30:39 -04001600 if (rc)
1601 goto acache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001602
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001603 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001604
1605 /* create /sys/fs/orangefs/capcache. */
1606 capcache_orangefs_obj =
1607 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1608 if (!capcache_orangefs_obj) {
1609 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001610 goto acache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001611 }
1612
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001613 rc = kobject_init_and_add(capcache_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001614 &capcache_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001615 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001616 CAPCACHE_KOBJ_ID);
Mike Marshall2180c522016-03-14 15:30:39 -04001617 if (rc)
1618 goto capcache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001619
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001620 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001621
1622 /* create /sys/fs/orangefs/ccache. */
1623 ccache_orangefs_obj =
1624 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1625 if (!ccache_orangefs_obj) {
1626 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001627 goto capcache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001628 }
1629
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001630 rc = kobject_init_and_add(ccache_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001631 &ccache_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001632 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001633 CCACHE_KOBJ_ID);
Mike Marshall2180c522016-03-14 15:30:39 -04001634 if (rc)
1635 goto ccache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001636
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001637 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001638
1639 /* create /sys/fs/orangefs/ncache. */
1640 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1641 if (!ncache_orangefs_obj) {
1642 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001643 goto ccache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001644 }
1645
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001646 rc = kobject_init_and_add(ncache_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001647 &ncache_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001648 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001649 NCACHE_KOBJ_ID);
1650
Mike Marshall2180c522016-03-14 15:30:39 -04001651 if (rc)
1652 goto ncache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001653
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001654 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001655
1656 /* create /sys/fs/orangefs/perf_counters. */
1657 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1658 if (!pc_orangefs_obj) {
1659 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001660 goto ncache_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001661 }
1662
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001663 rc = kobject_init_and_add(pc_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001664 &pc_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001665 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001666 "perf_counters");
1667
Mike Marshall2180c522016-03-14 15:30:39 -04001668 if (rc)
1669 goto pc_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001670
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001671 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001672
1673 /* create /sys/fs/orangefs/stats. */
1674 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1675 if (!stats_orangefs_obj) {
1676 rc = -EINVAL;
Mike Marshall2180c522016-03-14 15:30:39 -04001677 goto pc_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001678 }
1679
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001680 rc = kobject_init_and_add(stats_orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001681 &stats_orangefs_ktype,
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001682 orangefs_obj,
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001683 STATS_KOBJ_ID);
1684
Mike Marshall2180c522016-03-14 15:30:39 -04001685 if (rc)
1686 goto stats_obj_bail;
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001687
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001688 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
Mike Marshall2180c522016-03-14 15:30:39 -04001689 goto out;
1690
1691stats_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001692 kobject_put(stats_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001693pc_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001694 kobject_put(pc_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001695ncache_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001696 kobject_put(ncache_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001697ccache_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001698 kobject_put(ccache_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001699capcache_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001700 kobject_put(capcache_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001701acache_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001702 kobject_put(acache_orangefs_obj);
Mike Marshall2180c522016-03-14 15:30:39 -04001703ofs_obj_bail:
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001704 kobject_put(orangefs_obj);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001705out:
1706 return rc;
1707}
1708
1709void orangefs_sysfs_exit(void)
1710{
1711 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
Martin Brandenburgdc3012a2016-08-15 13:28:51 -04001712 kobject_put(acache_orangefs_obj);
1713 kobject_put(capcache_orangefs_obj);
1714 kobject_put(ccache_orangefs_obj);
1715 kobject_put(ncache_orangefs_obj);
1716 kobject_put(pc_orangefs_obj);
1717 kobject_put(stats_orangefs_obj);
1718 kobject_put(orangefs_obj);
Mike Marshallf7be4ee2015-07-17 10:38:14 -04001719}