]> Git Repo - linux.git/blame - fs/orangefs/orangefs-sysfs.c
orangefs: consolidate sysfs show and store functions
[linux.git] / fs / orangefs / orangefs-sysfs.c
CommitLineData
f7be4ee0
MM
1/*
2 * Documentation/ABI/stable/orangefs-sysfs:
3 *
4 * What: /sys/fs/orangefs/perf_counter_reset
5 * Date: June 2015
6 * Contact: Mike Marshall <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 *
4cd8f319
MB
64 * What: /sys/fs/orangefs/dcache_timeout_msecs
65 * Date: Jul 2016
66 * Contact: Martin Brandenburg <[email protected]>
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 <[email protected]>
73 * Description:
74 * Time getattr is valid in milliseconds.
f7be4ee0 75 *
4d20a756
MB
76 * What: /sys/fs/orangefs/readahead_count
77 * Date: Aug 2016
78 * Contact: Martin Brandenburg <[email protected]>
79 * Description:
80 * Readahead cache buffer count.
81 *
82 * What: /sys/fs/orangefs/readahead_size
83 * Date: Aug 2016
84 * Contact: Martin Brandenburg <[email protected]>
85 * Description:
86 * Readahead cache buffer size.
87 *
88 * What: /sys/fs/orangefs/readahead_count_size
89 * Date: Aug 2016
90 * Contact: Martin Brandenburg <[email protected]>
91 * Description:
92 * Readahead cache buffer count and size.
93 *
f7be4ee0
MM
94 * What: /sys/fs/orangefs/acache/...
95 * Date: Jun 2015
4cd8f319 96 * Contact: Martin Brandenburg <[email protected]>
f7be4ee0
MM
97 * Description:
98 * Attribute cache configurable settings.
99 *
100 *
101 * What: /sys/fs/orangefs/ncache/...
102 * Date: Jun 2015
103 * Contact: Mike Marshall <[email protected]>
104 * Description:
105 * Name cache configurable settings.
106 *
107 *
108 * What: /sys/fs/orangefs/capcache/...
109 * Date: Jun 2015
110 * Contact: Mike Marshall <[email protected]>
111 * Description:
112 * Capability cache configurable settings.
113 *
114 *
115 * What: /sys/fs/orangefs/ccache/...
116 * Date: Jun 2015
117 * Contact: Mike Marshall <[email protected]>
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"
575e9461
MM
131#include "orangefs-kernel.h"
132#include "orangefs-sysfs.h"
f7be4ee0
MM
133
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
f7be4ee0
MM
142struct orangefs_attribute {
143 struct attribute attr;
7b0cae60
MB
144 ssize_t (*show)(struct kobject *kobj,
145 struct orangefs_attribute *attr,
f7be4ee0 146 char *buf);
7b0cae60
MB
147 ssize_t (*store)(struct kobject *kobj,
148 struct orangefs_attribute *attr,
f7be4ee0
MM
149 const char *buf,
150 size_t count);
151};
152
f7be4ee0
MM
153static ssize_t orangefs_attr_show(struct kobject *kobj,
154 struct attribute *attr,
155 char *buf)
156{
157 struct orangefs_attribute *attribute;
f7be4ee0
MM
158 int rc;
159
160 attribute = container_of(attr, struct orangefs_attribute, attr);
f7be4ee0
MM
161
162 if (!attribute->show) {
163 rc = -EIO;
164 goto out;
165 }
166
7b0cae60 167 rc = attribute->show(kobj, attribute, buf);
f7be4ee0
MM
168
169out:
170 return rc;
171}
172
173static ssize_t orangefs_attr_store(struct kobject *kobj,
174 struct attribute *attr,
175 const char *buf,
176 size_t len)
177{
178 struct orangefs_attribute *attribute;
f7be4ee0
MM
179 int rc;
180
181 gossip_debug(GOSSIP_SYSFS_DEBUG,
182 "orangefs_attr_store: start\n");
183
184 attribute = container_of(attr, struct orangefs_attribute, attr);
f7be4ee0
MM
185
186 if (!attribute->store) {
187 rc = -EIO;
188 goto out;
189 }
190
7b0cae60 191 rc = attribute->store(kobj, attribute, buf, len);
f7be4ee0
MM
192
193out:
194 return rc;
195}
196
197static const struct sysfs_ops orangefs_sysfs_ops = {
198 .show = orangefs_attr_show,
199 .store = orangefs_attr_store,
200};
201
f7be4ee0 202static const struct sysfs_ops acache_orangefs_sysfs_ops = {
2e9f80da
MB
203 .show = orangefs_attr_show,
204 .store = orangefs_attr_store,
f7be4ee0
MM
205};
206
f7be4ee0 207static const struct sysfs_ops capcache_orangefs_sysfs_ops = {
2e9f80da
MB
208 .show = orangefs_attr_show,
209 .store = orangefs_attr_store,
f7be4ee0
MM
210};
211
f7be4ee0 212static const struct sysfs_ops ccache_orangefs_sysfs_ops = {
2e9f80da
MB
213 .show = orangefs_attr_show,
214 .store = orangefs_attr_store,
f7be4ee0
MM
215};
216
f7be4ee0 217static const struct sysfs_ops ncache_orangefs_sysfs_ops = {
2e9f80da
MB
218 .show = orangefs_attr_show,
219 .store = orangefs_attr_store,
f7be4ee0
MM
220};
221
f7be4ee0 222static const struct sysfs_ops pc_orangefs_sysfs_ops = {
2e9f80da 223 .show = orangefs_attr_show,
f7be4ee0
MM
224};
225
f7be4ee0 226static const struct sysfs_ops stats_orangefs_sysfs_ops = {
2e9f80da 227 .show = orangefs_attr_show,
f7be4ee0
MM
228};
229
7b0cae60
MB
230static ssize_t sysfs_int_show(struct kobject *kobj,
231 struct orangefs_attribute *attr, char *buf)
f7be4ee0
MM
232{
233 int rc = -EIO;
f7be4ee0 234
7b0cae60
MB
235 gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
236 kobj->name);
f7be4ee0 237
7b0cae60
MB
238 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
239 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
f7be4ee0
MM
240 rc = scnprintf(buf,
241 PAGE_SIZE,
242 "%d\n",
243 op_timeout_secs);
244 goto out;
7b0cae60 245 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
246 "slot_timeout_secs")) {
247 rc = scnprintf(buf,
248 PAGE_SIZE,
249 "%d\n",
250 slot_timeout_secs);
251 goto out;
7b0cae60 252 } else if (!strcmp(attr->attr.name,
4cd8f319
MB
253 "dcache_timeout_msecs")) {
254 rc = scnprintf(buf,
255 PAGE_SIZE,
256 "%d\n",
257 dcache_timeout_msecs);
258 goto out;
7b0cae60 259 } else if (!strcmp(attr->attr.name,
4cd8f319
MB
260 "getattr_timeout_msecs")) {
261 rc = scnprintf(buf,
262 PAGE_SIZE,
263 "%d\n",
264 getattr_timeout_msecs);
265 goto out;
f7be4ee0
MM
266 } else {
267 goto out;
268 }
269
7b0cae60
MB
270 } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
271 if (!strcmp(attr->attr.name, "reads")) {
f7be4ee0
MM
272 rc = scnprintf(buf,
273 PAGE_SIZE,
274 "%lu\n",
8bb8aefd 275 g_orangefs_stats.reads);
f7be4ee0 276 goto out;
7b0cae60 277 } else if (!strcmp(attr->attr.name, "writes")) {
f7be4ee0
MM
278 rc = scnprintf(buf,
279 PAGE_SIZE,
280 "%lu\n",
8bb8aefd 281 g_orangefs_stats.writes);
f7be4ee0
MM
282 goto out;
283 } else {
284 goto out;
285 }
286 }
287
288out:
289
290 return rc;
291}
292
7b0cae60
MB
293static ssize_t sysfs_int_store(struct kobject *kobj,
294 struct orangefs_attribute *attr, const char *buf, size_t count)
f7be4ee0
MM
295{
296 int rc = 0;
297
298 gossip_debug(GOSSIP_SYSFS_DEBUG,
7b0cae60 299 "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
f7be4ee0
MM
300 attr->attr.name, buf);
301
302 if (!strcmp(attr->attr.name, "op_timeout_secs")) {
303 rc = kstrtoint(buf, 0, &op_timeout_secs);
304 goto out;
305 } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
306 rc = kstrtoint(buf, 0, &slot_timeout_secs);
307 goto out;
4cd8f319
MB
308 } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
309 rc = kstrtoint(buf, 0, &dcache_timeout_msecs);
310 goto out;
311 } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
312 rc = kstrtoint(buf, 0, &getattr_timeout_msecs);
313 goto out;
f7be4ee0
MM
314 } else {
315 goto out;
316 }
317
318out:
319 if (rc)
320 rc = -EINVAL;
321 else
322 rc = count;
323
324 return rc;
325}
326
327/*
328 * obtain attribute values from userspace with a service operation.
329 */
7b0cae60
MB
330static ssize_t sysfs_service_op_show(struct kobject *kobj,
331 struct orangefs_attribute *attr, char *buf)
f7be4ee0 332{
8bb8aefd 333 struct orangefs_kernel_op_s *new_op = NULL;
f7be4ee0
MM
334 int rc = 0;
335 char *ser_op_type = NULL;
f7be4ee0
MM
336 __u32 op_alloc_type;
337
338 gossip_debug(GOSSIP_SYSFS_DEBUG,
339 "sysfs_service_op_show: id:%s:\n",
7b0cae60 340 kobj->name);
f7be4ee0 341
7b0cae60 342 if (strcmp(kobj->name, PC_KOBJ_ID))
8bb8aefd 343 op_alloc_type = ORANGEFS_VFS_OP_PARAM;
f7be4ee0 344 else
8bb8aefd 345 op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
f7be4ee0
MM
346
347 new_op = op_alloc(op_alloc_type);
ed42fe05
AV
348 if (!new_op)
349 return -ENOMEM;
f7be4ee0
MM
350
351 /* Can't do a service_operation if the client is not running... */
352 rc = is_daemon_in_service();
353 if (rc) {
354 pr_info("%s: Client not running :%d:\n",
355 __func__,
356 is_daemon_in_service());
357 goto out;
358 }
359
7b0cae60 360 if (strcmp(kobj->name, PC_KOBJ_ID))
8bb8aefd 361 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
f7be4ee0 362
7b0cae60
MB
363 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
364 if (!strcmp(attr->attr.name, "perf_history_size"))
f7be4ee0 365 new_op->upcall.req.param.op =
8bb8aefd 366 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
7b0cae60 367 else if (!strcmp(attr->attr.name,
f7be4ee0
MM
368 "perf_time_interval_secs"))
369 new_op->upcall.req.param.op =
8bb8aefd 370 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
7b0cae60 371 else if (!strcmp(attr->attr.name,
f7be4ee0
MM
372 "perf_counter_reset"))
373 new_op->upcall.req.param.op =
8bb8aefd 374 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
f7be4ee0 375
7b0cae60 376 else if (!strcmp(attr->attr.name,
4d20a756
MB
377 "readahead_count"))
378 new_op->upcall.req.param.op =
379 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
380
7b0cae60 381 else if (!strcmp(attr->attr.name,
4d20a756
MB
382 "readahead_size"))
383 new_op->upcall.req.param.op =
384 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
385
7b0cae60 386 else if (!strcmp(attr->attr.name,
4d20a756
MB
387 "readahead_count_size"))
388 new_op->upcall.req.param.op =
389 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
7b0cae60
MB
390 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
391 if (!strcmp(attr->attr.name, "timeout_msecs"))
f7be4ee0 392 new_op->upcall.req.param.op =
8bb8aefd 393 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
f7be4ee0 394
7b0cae60 395 if (!strcmp(attr->attr.name, "hard_limit"))
f7be4ee0 396 new_op->upcall.req.param.op =
8bb8aefd 397 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
f7be4ee0 398
7b0cae60 399 if (!strcmp(attr->attr.name, "soft_limit"))
f7be4ee0 400 new_op->upcall.req.param.op =
8bb8aefd 401 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
f7be4ee0 402
7b0cae60 403 if (!strcmp(attr->attr.name, "reclaim_percentage"))
f7be4ee0 404 new_op->upcall.req.param.op =
8bb8aefd 405 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
f7be4ee0 406
7b0cae60
MB
407 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
408 if (!strcmp(attr->attr.name, "timeout_secs"))
f7be4ee0 409 new_op->upcall.req.param.op =
8bb8aefd 410 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
f7be4ee0 411
7b0cae60 412 if (!strcmp(attr->attr.name, "hard_limit"))
f7be4ee0 413 new_op->upcall.req.param.op =
8bb8aefd 414 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
f7be4ee0 415
7b0cae60 416 if (!strcmp(attr->attr.name, "soft_limit"))
f7be4ee0 417 new_op->upcall.req.param.op =
8bb8aefd 418 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
f7be4ee0 419
7b0cae60 420 if (!strcmp(attr->attr.name, "reclaim_percentage"))
f7be4ee0 421 new_op->upcall.req.param.op =
8bb8aefd 422 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
f7be4ee0 423
7b0cae60
MB
424 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
425 if (!strcmp(attr->attr.name, "timeout_secs"))
f7be4ee0 426 new_op->upcall.req.param.op =
8bb8aefd 427 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
f7be4ee0 428
7b0cae60 429 if (!strcmp(attr->attr.name, "hard_limit"))
f7be4ee0 430 new_op->upcall.req.param.op =
8bb8aefd 431 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
f7be4ee0 432
7b0cae60 433 if (!strcmp(attr->attr.name, "soft_limit"))
f7be4ee0 434 new_op->upcall.req.param.op =
8bb8aefd 435 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
f7be4ee0 436
7b0cae60 437 if (!strcmp(attr->attr.name, "reclaim_percentage"))
f7be4ee0 438 new_op->upcall.req.param.op =
8bb8aefd 439 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
f7be4ee0 440
7b0cae60
MB
441 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
442 if (!strcmp(attr->attr.name, "timeout_msecs"))
f7be4ee0 443 new_op->upcall.req.param.op =
8bb8aefd 444 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
f7be4ee0 445
7b0cae60 446 if (!strcmp(attr->attr.name, "hard_limit"))
f7be4ee0 447 new_op->upcall.req.param.op =
8bb8aefd 448 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
f7be4ee0 449
7b0cae60 450 if (!strcmp(attr->attr.name, "soft_limit"))
f7be4ee0 451 new_op->upcall.req.param.op =
8bb8aefd 452 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
f7be4ee0 453
7b0cae60 454 if (!strcmp(attr->attr.name, "reclaim_percentage"))
f7be4ee0 455 new_op->upcall.req.param.op =
8bb8aefd 456 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
f7be4ee0 457
7b0cae60
MB
458 } else if (!strcmp(kobj->name, PC_KOBJ_ID)) {
459 if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID))
f7be4ee0 460 new_op->upcall.req.perf_count.type =
8bb8aefd 461 ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
f7be4ee0 462
7b0cae60 463 if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID))
f7be4ee0 464 new_op->upcall.req.perf_count.type =
8bb8aefd 465 ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
f7be4ee0 466
7b0cae60 467 if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID))
f7be4ee0 468 new_op->upcall.req.perf_count.type =
8bb8aefd 469 ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
f7be4ee0
MM
470
471 } else {
472 gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
7b0cae60 473 kobj->name);
f7be4ee0
MM
474 rc = -EINVAL;
475 goto out;
476 }
477
478
7b0cae60 479 if (strcmp(kobj->name, PC_KOBJ_ID))
8bb8aefd 480 ser_op_type = "orangefs_param";
f7be4ee0 481 else
8bb8aefd 482 ser_op_type = "orangefs_perf_count";
f7be4ee0
MM
483
484 /*
485 * The service_operation will return an errno return code on
486 * error, and zero on success.
487 */
8bb8aefd 488 rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
f7be4ee0
MM
489
490out:
491 if (!rc) {
7b0cae60 492 if (strcmp(kobj->name, PC_KOBJ_ID)) {
4d20a756
MB
493 if (new_op->upcall.req.param.op ==
494 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
495 rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
496 (int)new_op->downcall.resp.param.u.
497 value32[0],
498 (int)new_op->downcall.resp.param.u.
499 value32[1]);
500 } else {
501 rc = scnprintf(buf, PAGE_SIZE, "%d\n",
502 (int)new_op->downcall.resp.param.u.value64);
503 }
f7be4ee0
MM
504 } else {
505 rc = scnprintf(
506 buf,
507 PAGE_SIZE,
508 "%s",
509 new_op->downcall.resp.perf_count.buffer);
510 }
511 }
512
ed42fe05 513 op_release(new_op);
f7be4ee0
MM
514
515 return rc;
516
517}
518
f7be4ee0
MM
519/*
520 * pass attribute values back to userspace with a service operation.
521 *
522 * We have to do a memory allocation, an sscanf and a service operation.
523 * And we have to evaluate what the user entered, to make sure the
524 * value is within the range supported by the attribute. So, there's
525 * a lot of return code checking and mapping going on here.
526 *
527 * We want to return 1 if we think everything went OK, and
528 * EINVAL if not.
529 */
7b0cae60
MB
530static ssize_t sysfs_service_op_store(struct kobject *kobj,
531 struct orangefs_attribute *attr, const char *buf, size_t count)
f7be4ee0 532{
8bb8aefd 533 struct orangefs_kernel_op_s *new_op = NULL;
f7be4ee0
MM
534 int val = 0;
535 int rc = 0;
f7be4ee0
MM
536
537 gossip_debug(GOSSIP_SYSFS_DEBUG,
538 "sysfs_service_op_store: id:%s:\n",
7b0cae60 539 kobj->name);
f7be4ee0 540
8bb8aefd 541 new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
ed42fe05
AV
542 if (!new_op)
543 return -EINVAL; /* sic */
f7be4ee0
MM
544
545 /* Can't do a service_operation if the client is not running... */
546 rc = is_daemon_in_service();
547 if (rc) {
548 pr_info("%s: Client not running :%d:\n",
549 __func__,
550 is_daemon_in_service());
551 goto out;
552 }
553
554 /*
4d20a756
MB
555 * The value we want to send back to userspace is in buf, unless this
556 * there are two parameters, which is specially handled below.
f7be4ee0 557 */
7b0cae60
MB
558 if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) ||
559 strcmp(attr->attr.name, "readahead_count_size")) {
4d20a756
MB
560 rc = kstrtoint(buf, 0, &val);
561 if (rc)
562 goto out;
563 }
564
565 new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
f7be4ee0 566
7b0cae60
MB
567 if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
568 if (!strcmp(attr->attr.name, "perf_history_size")) {
f7be4ee0
MM
569 if (val > 0) {
570 new_op->upcall.req.param.op =
8bb8aefd 571 ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
f7be4ee0
MM
572 } else {
573 rc = 0;
574 goto out;
575 }
7b0cae60 576 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
577 "perf_time_interval_secs")) {
578 if (val > 0) {
579 new_op->upcall.req.param.op =
8bb8aefd 580 ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
f7be4ee0
MM
581 } else {
582 rc = 0;
583 goto out;
584 }
7b0cae60 585 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
586 "perf_counter_reset")) {
587 if ((val == 0) || (val == 1)) {
588 new_op->upcall.req.param.op =
8bb8aefd 589 ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
f7be4ee0
MM
590 } else {
591 rc = 0;
592 goto out;
593 }
7b0cae60 594 } else if (!strcmp(attr->attr.name,
4d20a756
MB
595 "readahead_count")) {
596 if ((val >= 0)) {
597 new_op->upcall.req.param.op =
598 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
599 } else {
600 rc = 0;
601 goto out;
602 }
7b0cae60 603 } else if (!strcmp(attr->attr.name,
4d20a756
MB
604 "readahead_size")) {
605 if ((val >= 0)) {
606 new_op->upcall.req.param.op =
607 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
608 } else {
609 rc = 0;
610 goto out;
611 }
7b0cae60 612 } else if (!strcmp(attr->attr.name,
4d20a756
MB
613 "readahead_count_size")) {
614 int val1, val2;
615 rc = sscanf(buf, "%d %d", &val1, &val2);
616 if (rc < 2) {
617 rc = 0;
618 goto out;
619 }
620 if ((val1 >= 0) && (val2 >= 0)) {
621 new_op->upcall.req.param.op =
622 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
623 } else {
624 rc = 0;
625 goto out;
626 }
627 new_op->upcall.req.param.u.value32[0] = val1;
628 new_op->upcall.req.param.u.value32[1] = val2;
629 goto value_set;
7b0cae60 630 } else if (!strcmp(attr->attr.name,
4d20a756
MB
631 "perf_counter_reset")) {
632 if ((val > 0)) {
633 new_op->upcall.req.param.op =
634 ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
635 } else {
636 rc = 0;
637 goto out;
638 }
f7be4ee0
MM
639 }
640
7b0cae60
MB
641 } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
642 if (!strcmp(attr->attr.name, "hard_limit")) {
f7be4ee0
MM
643 if (val > -1) {
644 new_op->upcall.req.param.op =
8bb8aefd 645 ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
f7be4ee0
MM
646 } else {
647 rc = 0;
648 goto out;
649 }
7b0cae60 650 } else if (!strcmp(attr->attr.name, "soft_limit")) {
f7be4ee0
MM
651 if (val > -1) {
652 new_op->upcall.req.param.op =
8bb8aefd 653 ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
f7be4ee0
MM
654 } else {
655 rc = 0;
656 goto out;
657 }
7b0cae60 658 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
659 "reclaim_percentage")) {
660 if ((val > -1) && (val < 101)) {
661 new_op->upcall.req.param.op =
8bb8aefd 662 ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
f7be4ee0
MM
663 } else {
664 rc = 0;
665 goto out;
666 }
7b0cae60 667 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
f7be4ee0
MM
668 if (val > -1) {
669 new_op->upcall.req.param.op =
8bb8aefd 670 ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
f7be4ee0
MM
671 } else {
672 rc = 0;
673 goto out;
674 }
675 }
676
7b0cae60
MB
677 } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
678 if (!strcmp(attr->attr.name, "hard_limit")) {
f7be4ee0
MM
679 if (val > -1) {
680 new_op->upcall.req.param.op =
8bb8aefd 681 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
f7be4ee0
MM
682 } else {
683 rc = 0;
684 goto out;
685 }
7b0cae60 686 } else if (!strcmp(attr->attr.name, "soft_limit")) {
f7be4ee0
MM
687 if (val > -1) {
688 new_op->upcall.req.param.op =
8bb8aefd 689 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
f7be4ee0
MM
690 } else {
691 rc = 0;
692 goto out;
693 }
7b0cae60 694 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
695 "reclaim_percentage")) {
696 if ((val > -1) && (val < 101)) {
697 new_op->upcall.req.param.op =
8bb8aefd 698 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
f7be4ee0
MM
699 } else {
700 rc = 0;
701 goto out;
702 }
7b0cae60 703 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
f7be4ee0
MM
704 if (val > -1) {
705 new_op->upcall.req.param.op =
8bb8aefd 706 ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
f7be4ee0
MM
707 } else {
708 rc = 0;
709 goto out;
710 }
711 }
712
7b0cae60
MB
713 } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
714 if (!strcmp(attr->attr.name, "hard_limit")) {
f7be4ee0
MM
715 if (val > -1) {
716 new_op->upcall.req.param.op =
8bb8aefd 717 ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
f7be4ee0
MM
718 } else {
719 rc = 0;
720 goto out;
721 }
7b0cae60 722 } else if (!strcmp(attr->attr.name, "soft_limit")) {
f7be4ee0
MM
723 if (val > -1) {
724 new_op->upcall.req.param.op =
8bb8aefd 725 ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
f7be4ee0
MM
726 } else {
727 rc = 0;
728 goto out;
729 }
7b0cae60 730 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
731 "reclaim_percentage")) {
732 if ((val > -1) && (val < 101)) {
733 new_op->upcall.req.param.op =
8bb8aefd 734 ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
f7be4ee0
MM
735 } else {
736 rc = 0;
737 goto out;
738 }
7b0cae60 739 } else if (!strcmp(attr->attr.name, "timeout_secs")) {
f7be4ee0
MM
740 if (val > -1) {
741 new_op->upcall.req.param.op =
8bb8aefd 742 ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
f7be4ee0
MM
743 } else {
744 rc = 0;
745 goto out;
746 }
747 }
748
7b0cae60
MB
749 } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
750 if (!strcmp(attr->attr.name, "hard_limit")) {
f7be4ee0
MM
751 if (val > -1) {
752 new_op->upcall.req.param.op =
8bb8aefd 753 ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
f7be4ee0
MM
754 } else {
755 rc = 0;
756 goto out;
757 }
7b0cae60 758 } else if (!strcmp(attr->attr.name, "soft_limit")) {
f7be4ee0
MM
759 if (val > -1) {
760 new_op->upcall.req.param.op =
8bb8aefd 761 ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
f7be4ee0
MM
762 } else {
763 rc = 0;
764 goto out;
765 }
7b0cae60 766 } else if (!strcmp(attr->attr.name,
f7be4ee0
MM
767 "reclaim_percentage")) {
768 if ((val > -1) && (val < 101)) {
769 new_op->upcall.req.param.op =
8bb8aefd 770 ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
f7be4ee0
MM
771 } else {
772 rc = 0;
773 goto out;
774 }
7b0cae60 775 } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
f7be4ee0
MM
776 if (val > -1) {
777 new_op->upcall.req.param.op =
8bb8aefd 778 ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
f7be4ee0
MM
779 } else {
780 rc = 0;
781 goto out;
782 }
783 }
784
785 } else {
786 gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
7b0cae60 787 kobj->name);
f7be4ee0
MM
788 rc = -EINVAL;
789 goto out;
790 }
791
680908e5 792 new_op->upcall.req.param.u.value64 = val;
4d20a756 793value_set:
f7be4ee0
MM
794
795 /*
796 * The service_operation will return a errno return code on
797 * error, and zero on success.
798 */
8bb8aefd 799 rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
f7be4ee0
MM
800
801 if (rc < 0) {
802 gossip_err("sysfs_service_op_store: service op returned:%d:\n",
803 rc);
804 rc = 0;
805 } else {
7b0cae60 806 rc = count;
f7be4ee0
MM
807 }
808
809out:
ed42fe05 810 op_release(new_op);
f7be4ee0 811
ed42fe05 812 if (rc == -ENOMEM || rc == 0)
f7be4ee0
MM
813 rc = -EINVAL;
814
815 return rc;
816}
817
f7be4ee0 818static struct orangefs_attribute op_timeout_secs_attribute =
7b0cae60 819 __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
f7be4ee0
MM
820
821static struct orangefs_attribute slot_timeout_secs_attribute =
7b0cae60 822 __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
f7be4ee0 823
4cd8f319 824static struct orangefs_attribute dcache_timeout_msecs_attribute =
7b0cae60 825 __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
4cd8f319
MB
826
827static struct orangefs_attribute getattr_timeout_msecs_attribute =
7b0cae60 828 __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
4cd8f319 829
4d20a756 830static struct orangefs_attribute readahead_count_attribute =
7b0cae60
MB
831 __ATTR(readahead_count, 0664, sysfs_service_op_show,
832 sysfs_service_op_store);
4d20a756
MB
833
834static struct orangefs_attribute readahead_size_attribute =
7b0cae60
MB
835 __ATTR(readahead_size, 0664, sysfs_service_op_show,
836 sysfs_service_op_store);
4d20a756
MB
837
838static struct orangefs_attribute readahead_count_size_attribute =
7b0cae60
MB
839 __ATTR(readahead_count_size, 0664, sysfs_service_op_show,
840 sysfs_service_op_store);
4d20a756 841
f7be4ee0
MM
842static struct orangefs_attribute perf_counter_reset_attribute =
843 __ATTR(perf_counter_reset,
844 0664,
7b0cae60
MB
845 sysfs_service_op_show,
846 sysfs_service_op_store);
f7be4ee0
MM
847
848static struct orangefs_attribute perf_history_size_attribute =
849 __ATTR(perf_history_size,
850 0664,
7b0cae60
MB
851 sysfs_service_op_show,
852 sysfs_service_op_store);
f7be4ee0
MM
853
854static struct orangefs_attribute perf_time_interval_secs_attribute =
855 __ATTR(perf_time_interval_secs,
856 0664,
7b0cae60
MB
857 sysfs_service_op_show,
858 sysfs_service_op_store);
f7be4ee0
MM
859
860static struct attribute *orangefs_default_attrs[] = {
861 &op_timeout_secs_attribute.attr,
862 &slot_timeout_secs_attribute.attr,
4cd8f319
MB
863 &dcache_timeout_msecs_attribute.attr,
864 &getattr_timeout_msecs_attribute.attr,
4d20a756
MB
865 &readahead_count_attribute.attr,
866 &readahead_size_attribute.attr,
867 &readahead_count_size_attribute.attr,
f7be4ee0
MM
868 &perf_counter_reset_attribute.attr,
869 &perf_history_size_attribute.attr,
870 &perf_time_interval_secs_attribute.attr,
871 NULL,
872};
873
874static struct kobj_type orangefs_ktype = {
875 .sysfs_ops = &orangefs_sysfs_ops,
f7be4ee0
MM
876 .default_attrs = orangefs_default_attrs,
877};
878
2e9f80da 879static struct orangefs_attribute acache_hard_limit_attribute =
f7be4ee0
MM
880 __ATTR(hard_limit,
881 0664,
7b0cae60
MB
882 sysfs_service_op_show,
883 sysfs_service_op_store);
f7be4ee0 884
2e9f80da 885static struct orangefs_attribute acache_reclaim_percent_attribute =
f7be4ee0
MM
886 __ATTR(reclaim_percentage,
887 0664,
7b0cae60
MB
888 sysfs_service_op_show,
889 sysfs_service_op_store);
f7be4ee0 890
2e9f80da 891static struct orangefs_attribute acache_soft_limit_attribute =
f7be4ee0
MM
892 __ATTR(soft_limit,
893 0664,
7b0cae60
MB
894 sysfs_service_op_show,
895 sysfs_service_op_store);
f7be4ee0 896
2e9f80da 897static struct orangefs_attribute acache_timeout_msecs_attribute =
f7be4ee0
MM
898 __ATTR(timeout_msecs,
899 0664,
7b0cae60
MB
900 sysfs_service_op_show,
901 sysfs_service_op_store);
f7be4ee0
MM
902
903static struct attribute *acache_orangefs_default_attrs[] = {
904 &acache_hard_limit_attribute.attr,
905 &acache_reclaim_percent_attribute.attr,
906 &acache_soft_limit_attribute.attr,
907 &acache_timeout_msecs_attribute.attr,
908 NULL,
909};
910
911static struct kobj_type acache_orangefs_ktype = {
912 .sysfs_ops = &acache_orangefs_sysfs_ops,
f7be4ee0
MM
913 .default_attrs = acache_orangefs_default_attrs,
914};
915
2e9f80da 916static struct orangefs_attribute capcache_hard_limit_attribute =
f7be4ee0
MM
917 __ATTR(hard_limit,
918 0664,
7b0cae60
MB
919 sysfs_service_op_show,
920 sysfs_service_op_store);
f7be4ee0 921
2e9f80da 922static struct orangefs_attribute capcache_reclaim_percent_attribute =
f7be4ee0
MM
923 __ATTR(reclaim_percentage,
924 0664,
7b0cae60
MB
925 sysfs_service_op_show,
926 sysfs_service_op_store);
f7be4ee0 927
2e9f80da 928static struct orangefs_attribute capcache_soft_limit_attribute =
f7be4ee0
MM
929 __ATTR(soft_limit,
930 0664,
7b0cae60
MB
931 sysfs_service_op_show,
932 sysfs_service_op_store);
f7be4ee0 933
2e9f80da 934static struct orangefs_attribute capcache_timeout_secs_attribute =
f7be4ee0
MM
935 __ATTR(timeout_secs,
936 0664,
7b0cae60
MB
937 sysfs_service_op_show,
938 sysfs_service_op_store);
f7be4ee0
MM
939
940static struct attribute *capcache_orangefs_default_attrs[] = {
941 &capcache_hard_limit_attribute.attr,
942 &capcache_reclaim_percent_attribute.attr,
943 &capcache_soft_limit_attribute.attr,
944 &capcache_timeout_secs_attribute.attr,
945 NULL,
946};
947
948static struct kobj_type capcache_orangefs_ktype = {
949 .sysfs_ops = &capcache_orangefs_sysfs_ops,
f7be4ee0
MM
950 .default_attrs = capcache_orangefs_default_attrs,
951};
952
2e9f80da 953static struct orangefs_attribute ccache_hard_limit_attribute =
f7be4ee0
MM
954 __ATTR(hard_limit,
955 0664,
7b0cae60
MB
956 sysfs_service_op_show,
957 sysfs_service_op_store);
f7be4ee0 958
2e9f80da 959static struct orangefs_attribute ccache_reclaim_percent_attribute =
f7be4ee0
MM
960 __ATTR(reclaim_percentage,
961 0664,
7b0cae60
MB
962 sysfs_service_op_show,
963 sysfs_service_op_store);
f7be4ee0 964
2e9f80da 965static struct orangefs_attribute ccache_soft_limit_attribute =
f7be4ee0
MM
966 __ATTR(soft_limit,
967 0664,
7b0cae60
MB
968 sysfs_service_op_show,
969 sysfs_service_op_store);
f7be4ee0 970
2e9f80da 971static struct orangefs_attribute ccache_timeout_secs_attribute =
f7be4ee0
MM
972 __ATTR(timeout_secs,
973 0664,
7b0cae60
MB
974 sysfs_service_op_show,
975 sysfs_service_op_store);
f7be4ee0
MM
976
977static struct attribute *ccache_orangefs_default_attrs[] = {
978 &ccache_hard_limit_attribute.attr,
979 &ccache_reclaim_percent_attribute.attr,
980 &ccache_soft_limit_attribute.attr,
981 &ccache_timeout_secs_attribute.attr,
982 NULL,
983};
984
985static struct kobj_type ccache_orangefs_ktype = {
986 .sysfs_ops = &ccache_orangefs_sysfs_ops,
f7be4ee0
MM
987 .default_attrs = ccache_orangefs_default_attrs,
988};
989
2e9f80da 990static struct orangefs_attribute ncache_hard_limit_attribute =
f7be4ee0
MM
991 __ATTR(hard_limit,
992 0664,
7b0cae60
MB
993 sysfs_service_op_show,
994 sysfs_service_op_store);
f7be4ee0 995
2e9f80da 996static struct orangefs_attribute ncache_reclaim_percent_attribute =
f7be4ee0
MM
997 __ATTR(reclaim_percentage,
998 0664,
7b0cae60
MB
999 sysfs_service_op_show,
1000 sysfs_service_op_store);
f7be4ee0 1001
2e9f80da 1002static struct orangefs_attribute ncache_soft_limit_attribute =
f7be4ee0
MM
1003 __ATTR(soft_limit,
1004 0664,
7b0cae60
MB
1005 sysfs_service_op_show,
1006 sysfs_service_op_store);
f7be4ee0 1007
2e9f80da 1008static struct orangefs_attribute ncache_timeout_msecs_attribute =
f7be4ee0
MM
1009 __ATTR(timeout_msecs,
1010 0664,
7b0cae60
MB
1011 sysfs_service_op_show,
1012 sysfs_service_op_store);
f7be4ee0
MM
1013
1014static struct attribute *ncache_orangefs_default_attrs[] = {
1015 &ncache_hard_limit_attribute.attr,
1016 &ncache_reclaim_percent_attribute.attr,
1017 &ncache_soft_limit_attribute.attr,
1018 &ncache_timeout_msecs_attribute.attr,
1019 NULL,
1020};
1021
1022static struct kobj_type ncache_orangefs_ktype = {
1023 .sysfs_ops = &ncache_orangefs_sysfs_ops,
f7be4ee0
MM
1024 .default_attrs = ncache_orangefs_default_attrs,
1025};
1026
2e9f80da 1027static struct orangefs_attribute pc_acache_attribute =
f7be4ee0
MM
1028 __ATTR(acache,
1029 0664,
7b0cae60 1030 sysfs_service_op_show,
f7be4ee0
MM
1031 NULL);
1032
2e9f80da 1033static struct orangefs_attribute pc_capcache_attribute =
f7be4ee0
MM
1034 __ATTR(capcache,
1035 0664,
7b0cae60 1036 sysfs_service_op_show,
f7be4ee0
MM
1037 NULL);
1038
2e9f80da 1039static struct orangefs_attribute pc_ncache_attribute =
f7be4ee0
MM
1040 __ATTR(ncache,
1041 0664,
7b0cae60 1042 sysfs_service_op_show,
f7be4ee0
MM
1043 NULL);
1044
1045static struct attribute *pc_orangefs_default_attrs[] = {
1046 &pc_acache_attribute.attr,
1047 &pc_capcache_attribute.attr,
1048 &pc_ncache_attribute.attr,
1049 NULL,
1050};
1051
1052static struct kobj_type pc_orangefs_ktype = {
1053 .sysfs_ops = &pc_orangefs_sysfs_ops,
f7be4ee0
MM
1054 .default_attrs = pc_orangefs_default_attrs,
1055};
1056
2e9f80da 1057static struct orangefs_attribute stats_reads_attribute =
f7be4ee0
MM
1058 __ATTR(reads,
1059 0664,
7b0cae60 1060 sysfs_int_show,
f7be4ee0
MM
1061 NULL);
1062
2e9f80da 1063static struct orangefs_attribute stats_writes_attribute =
f7be4ee0
MM
1064 __ATTR(writes,
1065 0664,
7b0cae60 1066 sysfs_int_show,
f7be4ee0
MM
1067 NULL);
1068
1069static struct attribute *stats_orangefs_default_attrs[] = {
1070 &stats_reads_attribute.attr,
1071 &stats_writes_attribute.attr,
1072 NULL,
1073};
1074
1075static struct kobj_type stats_orangefs_ktype = {
1076 .sysfs_ops = &stats_orangefs_sysfs_ops,
f7be4ee0
MM
1077 .default_attrs = stats_orangefs_default_attrs,
1078};
1079
dc3012a7
MB
1080static struct kobject *orangefs_obj;
1081static struct kobject *acache_orangefs_obj;
1082static struct kobject *capcache_orangefs_obj;
1083static struct kobject *ccache_orangefs_obj;
1084static struct kobject *ncache_orangefs_obj;
1085static struct kobject *pc_orangefs_obj;
1086static struct kobject *stats_orangefs_obj;
f7be4ee0
MM
1087
1088int orangefs_sysfs_init(void)
1089{
2180c52c 1090 int rc = -EINVAL;
f7be4ee0
MM
1091
1092 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1093
1094 /* create /sys/fs/orangefs. */
1095 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
2180c52c 1096 if (!orangefs_obj)
f7be4ee0 1097 goto out;
f7be4ee0 1098
dc3012a7 1099 rc = kobject_init_and_add(orangefs_obj,
f7be4ee0
MM
1100 &orangefs_ktype,
1101 fs_kobj,
1102 ORANGEFS_KOBJ_ID);
1103
2180c52c
MM
1104 if (rc)
1105 goto ofs_obj_bail;
f7be4ee0 1106
dc3012a7 1107 kobject_uevent(orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1108
1109 /* create /sys/fs/orangefs/acache. */
1110 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1111 if (!acache_orangefs_obj) {
1112 rc = -EINVAL;
2180c52c 1113 goto ofs_obj_bail;
f7be4ee0
MM
1114 }
1115
dc3012a7 1116 rc = kobject_init_and_add(acache_orangefs_obj,
f7be4ee0 1117 &acache_orangefs_ktype,
dc3012a7 1118 orangefs_obj,
f7be4ee0
MM
1119 ACACHE_KOBJ_ID);
1120
2180c52c
MM
1121 if (rc)
1122 goto acache_obj_bail;
f7be4ee0 1123
dc3012a7 1124 kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1125
1126 /* create /sys/fs/orangefs/capcache. */
1127 capcache_orangefs_obj =
1128 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1129 if (!capcache_orangefs_obj) {
1130 rc = -EINVAL;
2180c52c 1131 goto acache_obj_bail;
f7be4ee0
MM
1132 }
1133
dc3012a7 1134 rc = kobject_init_and_add(capcache_orangefs_obj,
f7be4ee0 1135 &capcache_orangefs_ktype,
dc3012a7 1136 orangefs_obj,
f7be4ee0 1137 CAPCACHE_KOBJ_ID);
2180c52c
MM
1138 if (rc)
1139 goto capcache_obj_bail;
f7be4ee0 1140
dc3012a7 1141 kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1142
1143 /* create /sys/fs/orangefs/ccache. */
1144 ccache_orangefs_obj =
1145 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1146 if (!ccache_orangefs_obj) {
1147 rc = -EINVAL;
2180c52c 1148 goto capcache_obj_bail;
f7be4ee0
MM
1149 }
1150
dc3012a7 1151 rc = kobject_init_and_add(ccache_orangefs_obj,
f7be4ee0 1152 &ccache_orangefs_ktype,
dc3012a7 1153 orangefs_obj,
f7be4ee0 1154 CCACHE_KOBJ_ID);
2180c52c
MM
1155 if (rc)
1156 goto ccache_obj_bail;
f7be4ee0 1157
dc3012a7 1158 kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1159
1160 /* create /sys/fs/orangefs/ncache. */
1161 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1162 if (!ncache_orangefs_obj) {
1163 rc = -EINVAL;
2180c52c 1164 goto ccache_obj_bail;
f7be4ee0
MM
1165 }
1166
dc3012a7 1167 rc = kobject_init_and_add(ncache_orangefs_obj,
f7be4ee0 1168 &ncache_orangefs_ktype,
dc3012a7 1169 orangefs_obj,
f7be4ee0
MM
1170 NCACHE_KOBJ_ID);
1171
2180c52c
MM
1172 if (rc)
1173 goto ncache_obj_bail;
f7be4ee0 1174
dc3012a7 1175 kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1176
1177 /* create /sys/fs/orangefs/perf_counters. */
1178 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1179 if (!pc_orangefs_obj) {
1180 rc = -EINVAL;
2180c52c 1181 goto ncache_obj_bail;
f7be4ee0
MM
1182 }
1183
dc3012a7 1184 rc = kobject_init_and_add(pc_orangefs_obj,
f7be4ee0 1185 &pc_orangefs_ktype,
dc3012a7 1186 orangefs_obj,
f7be4ee0
MM
1187 "perf_counters");
1188
2180c52c
MM
1189 if (rc)
1190 goto pc_obj_bail;
f7be4ee0 1191
dc3012a7 1192 kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
f7be4ee0
MM
1193
1194 /* create /sys/fs/orangefs/stats. */
1195 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1196 if (!stats_orangefs_obj) {
1197 rc = -EINVAL;
2180c52c 1198 goto pc_obj_bail;
f7be4ee0
MM
1199 }
1200
dc3012a7 1201 rc = kobject_init_and_add(stats_orangefs_obj,
f7be4ee0 1202 &stats_orangefs_ktype,
dc3012a7 1203 orangefs_obj,
f7be4ee0
MM
1204 STATS_KOBJ_ID);
1205
2180c52c
MM
1206 if (rc)
1207 goto stats_obj_bail;
f7be4ee0 1208
dc3012a7 1209 kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
2180c52c
MM
1210 goto out;
1211
1212stats_obj_bail:
dc3012a7 1213 kobject_put(stats_orangefs_obj);
2180c52c 1214pc_obj_bail:
dc3012a7 1215 kobject_put(pc_orangefs_obj);
2180c52c 1216ncache_obj_bail:
dc3012a7 1217 kobject_put(ncache_orangefs_obj);
2180c52c 1218ccache_obj_bail:
dc3012a7 1219 kobject_put(ccache_orangefs_obj);
2180c52c 1220capcache_obj_bail:
dc3012a7 1221 kobject_put(capcache_orangefs_obj);
2180c52c 1222acache_obj_bail:
dc3012a7 1223 kobject_put(acache_orangefs_obj);
2180c52c 1224ofs_obj_bail:
dc3012a7 1225 kobject_put(orangefs_obj);
f7be4ee0
MM
1226out:
1227 return rc;
1228}
1229
1230void orangefs_sysfs_exit(void)
1231{
1232 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
dc3012a7
MB
1233 kobject_put(acache_orangefs_obj);
1234 kobject_put(capcache_orangefs_obj);
1235 kobject_put(ccache_orangefs_obj);
1236 kobject_put(ncache_orangefs_obj);
1237 kobject_put(pc_orangefs_obj);
1238 kobject_put(stats_orangefs_obj);
1239 kobject_put(orangefs_obj);
f7be4ee0 1240}
This page took 0.243499 seconds and 4 git commands to generate.