]>
Commit | Line | Data |
---|---|---|
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 <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 | * | |
4cd8f319 MB |
64 | * 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. | |
f7be4ee0 | 75 | * |
4d20a756 MB |
76 | * 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 | * | |
f7be4ee0 MM |
94 | * What: /sys/fs/orangefs/acache/... |
95 | * Date: Jun 2015 | |
4cd8f319 | 96 | * Contact: Martin Brandenburg <martin@omnibond.com> |
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 <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" | |
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 | ||
142 | struct orangefs_obj { | |
143 | struct kobject kobj; | |
144 | int op_timeout_secs; | |
145 | int perf_counter_reset; | |
146 | int perf_history_size; | |
147 | int perf_time_interval_secs; | |
148 | int slot_timeout_secs; | |
4cd8f319 MB |
149 | int dcache_timeout_msecs; |
150 | int getattr_timeout_msecs; | |
f7be4ee0 MM |
151 | }; |
152 | ||
153 | struct acache_orangefs_obj { | |
154 | struct kobject kobj; | |
155 | int hard_limit; | |
156 | int reclaim_percentage; | |
157 | int soft_limit; | |
158 | int timeout_msecs; | |
159 | }; | |
160 | ||
161 | struct capcache_orangefs_obj { | |
162 | struct kobject kobj; | |
163 | int hard_limit; | |
164 | int reclaim_percentage; | |
165 | int soft_limit; | |
166 | int timeout_secs; | |
167 | }; | |
168 | ||
169 | struct ccache_orangefs_obj { | |
170 | struct kobject kobj; | |
171 | int hard_limit; | |
172 | int reclaim_percentage; | |
173 | int soft_limit; | |
174 | int timeout_secs; | |
175 | }; | |
176 | ||
177 | struct ncache_orangefs_obj { | |
178 | struct kobject kobj; | |
179 | int hard_limit; | |
180 | int reclaim_percentage; | |
181 | int soft_limit; | |
182 | int timeout_msecs; | |
183 | }; | |
184 | ||
185 | struct pc_orangefs_obj { | |
186 | struct kobject kobj; | |
187 | char *acache; | |
188 | char *capcache; | |
189 | char *ncache; | |
190 | }; | |
191 | ||
192 | struct stats_orangefs_obj { | |
193 | struct kobject kobj; | |
194 | int reads; | |
195 | int writes; | |
196 | }; | |
197 | ||
198 | struct orangefs_attribute { | |
199 | struct attribute attr; | |
200 | ssize_t (*show)(struct orangefs_obj *orangefs_obj, | |
201 | struct orangefs_attribute *attr, | |
202 | char *buf); | |
203 | ssize_t (*store)(struct orangefs_obj *orangefs_obj, | |
204 | struct orangefs_attribute *attr, | |
205 | const char *buf, | |
206 | size_t count); | |
207 | }; | |
208 | ||
209 | struct acache_orangefs_attribute { | |
210 | struct attribute attr; | |
211 | ssize_t (*show)(struct acache_orangefs_obj *acache_orangefs_obj, | |
212 | struct acache_orangefs_attribute *attr, | |
213 | char *buf); | |
214 | ssize_t (*store)(struct acache_orangefs_obj *acache_orangefs_obj, | |
215 | struct acache_orangefs_attribute *attr, | |
216 | const char *buf, | |
217 | size_t count); | |
218 | }; | |
219 | ||
220 | struct capcache_orangefs_attribute { | |
221 | struct attribute attr; | |
222 | ssize_t (*show)(struct capcache_orangefs_obj *capcache_orangefs_obj, | |
223 | struct capcache_orangefs_attribute *attr, | |
224 | char *buf); | |
225 | ssize_t (*store)(struct capcache_orangefs_obj *capcache_orangefs_obj, | |
226 | struct capcache_orangefs_attribute *attr, | |
227 | const char *buf, | |
228 | size_t count); | |
229 | }; | |
230 | ||
231 | struct ccache_orangefs_attribute { | |
232 | struct attribute attr; | |
233 | ssize_t (*show)(struct ccache_orangefs_obj *ccache_orangefs_obj, | |
234 | struct ccache_orangefs_attribute *attr, | |
235 | char *buf); | |
236 | ssize_t (*store)(struct ccache_orangefs_obj *ccache_orangefs_obj, | |
237 | struct ccache_orangefs_attribute *attr, | |
238 | const char *buf, | |
239 | size_t count); | |
240 | }; | |
241 | ||
242 | struct ncache_orangefs_attribute { | |
243 | struct attribute attr; | |
244 | ssize_t (*show)(struct ncache_orangefs_obj *ncache_orangefs_obj, | |
245 | struct ncache_orangefs_attribute *attr, | |
246 | char *buf); | |
247 | ssize_t (*store)(struct ncache_orangefs_obj *ncache_orangefs_obj, | |
248 | struct ncache_orangefs_attribute *attr, | |
249 | const char *buf, | |
250 | size_t count); | |
251 | }; | |
252 | ||
253 | struct pc_orangefs_attribute { | |
254 | struct attribute attr; | |
255 | ssize_t (*show)(struct pc_orangefs_obj *pc_orangefs_obj, | |
256 | struct pc_orangefs_attribute *attr, | |
257 | char *buf); | |
258 | ssize_t (*store)(struct pc_orangefs_obj *pc_orangefs_obj, | |
259 | struct pc_orangefs_attribute *attr, | |
260 | const char *buf, | |
261 | size_t count); | |
262 | }; | |
263 | ||
264 | struct stats_orangefs_attribute { | |
265 | struct attribute attr; | |
266 | ssize_t (*show)(struct stats_orangefs_obj *stats_orangefs_obj, | |
267 | struct stats_orangefs_attribute *attr, | |
268 | char *buf); | |
269 | ssize_t (*store)(struct stats_orangefs_obj *stats_orangefs_obj, | |
270 | struct stats_orangefs_attribute *attr, | |
271 | const char *buf, | |
272 | size_t count); | |
273 | }; | |
274 | ||
275 | static ssize_t orangefs_attr_show(struct kobject *kobj, | |
276 | struct attribute *attr, | |
277 | char *buf) | |
278 | { | |
279 | struct orangefs_attribute *attribute; | |
280 | struct orangefs_obj *orangefs_obj; | |
281 | int rc; | |
282 | ||
283 | attribute = container_of(attr, struct orangefs_attribute, attr); | |
284 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | |
285 | ||
286 | if (!attribute->show) { | |
287 | rc = -EIO; | |
288 | goto out; | |
289 | } | |
290 | ||
291 | rc = attribute->show(orangefs_obj, attribute, buf); | |
292 | ||
293 | out: | |
294 | return rc; | |
295 | } | |
296 | ||
297 | static ssize_t orangefs_attr_store(struct kobject *kobj, | |
298 | struct attribute *attr, | |
299 | const char *buf, | |
300 | size_t len) | |
301 | { | |
302 | struct orangefs_attribute *attribute; | |
303 | struct orangefs_obj *orangefs_obj; | |
304 | int rc; | |
305 | ||
306 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
307 | "orangefs_attr_store: start\n"); | |
308 | ||
309 | attribute = container_of(attr, struct orangefs_attribute, attr); | |
310 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | |
311 | ||
312 | if (!attribute->store) { | |
313 | rc = -EIO; | |
314 | goto out; | |
315 | } | |
316 | ||
317 | rc = attribute->store(orangefs_obj, attribute, buf, len); | |
318 | ||
319 | out: | |
320 | return rc; | |
321 | } | |
322 | ||
323 | static const struct sysfs_ops orangefs_sysfs_ops = { | |
324 | .show = orangefs_attr_show, | |
325 | .store = orangefs_attr_store, | |
326 | }; | |
327 | ||
328 | static ssize_t acache_orangefs_attr_show(struct kobject *kobj, | |
329 | struct attribute *attr, | |
330 | char *buf) | |
331 | { | |
332 | struct acache_orangefs_attribute *attribute; | |
333 | struct acache_orangefs_obj *acache_orangefs_obj; | |
334 | int rc; | |
335 | ||
336 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); | |
337 | acache_orangefs_obj = | |
338 | container_of(kobj, struct acache_orangefs_obj, kobj); | |
339 | ||
340 | if (!attribute->show) { | |
341 | rc = -EIO; | |
342 | goto out; | |
343 | } | |
344 | ||
345 | rc = attribute->show(acache_orangefs_obj, attribute, buf); | |
346 | ||
347 | out: | |
348 | return rc; | |
349 | } | |
350 | ||
351 | static ssize_t acache_orangefs_attr_store(struct kobject *kobj, | |
352 | struct attribute *attr, | |
353 | const char *buf, | |
354 | size_t len) | |
355 | { | |
356 | struct acache_orangefs_attribute *attribute; | |
357 | struct acache_orangefs_obj *acache_orangefs_obj; | |
358 | int rc; | |
359 | ||
360 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
361 | "acache_orangefs_attr_store: start\n"); | |
362 | ||
363 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); | |
364 | acache_orangefs_obj = | |
365 | container_of(kobj, struct acache_orangefs_obj, kobj); | |
366 | ||
367 | if (!attribute->store) { | |
368 | rc = -EIO; | |
369 | goto out; | |
370 | } | |
371 | ||
372 | rc = attribute->store(acache_orangefs_obj, attribute, buf, len); | |
373 | ||
374 | out: | |
375 | return rc; | |
376 | } | |
377 | ||
378 | static const struct sysfs_ops acache_orangefs_sysfs_ops = { | |
379 | .show = acache_orangefs_attr_show, | |
380 | .store = acache_orangefs_attr_store, | |
381 | }; | |
382 | ||
383 | static ssize_t capcache_orangefs_attr_show(struct kobject *kobj, | |
384 | struct attribute *attr, | |
385 | char *buf) | |
386 | { | |
387 | struct capcache_orangefs_attribute *attribute; | |
388 | struct capcache_orangefs_obj *capcache_orangefs_obj; | |
389 | int rc; | |
390 | ||
391 | attribute = | |
392 | container_of(attr, struct capcache_orangefs_attribute, attr); | |
393 | capcache_orangefs_obj = | |
394 | container_of(kobj, struct capcache_orangefs_obj, kobj); | |
395 | ||
396 | if (!attribute->show) { | |
397 | rc = -EIO; | |
398 | goto out; | |
399 | } | |
400 | ||
401 | rc = attribute->show(capcache_orangefs_obj, attribute, buf); | |
402 | ||
403 | out: | |
404 | return rc; | |
405 | } | |
406 | ||
407 | static ssize_t capcache_orangefs_attr_store(struct kobject *kobj, | |
408 | struct attribute *attr, | |
409 | const char *buf, | |
410 | size_t len) | |
411 | { | |
412 | struct capcache_orangefs_attribute *attribute; | |
413 | struct capcache_orangefs_obj *capcache_orangefs_obj; | |
414 | int rc; | |
415 | ||
416 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
417 | "capcache_orangefs_attr_store: start\n"); | |
418 | ||
419 | attribute = | |
420 | container_of(attr, struct capcache_orangefs_attribute, attr); | |
421 | capcache_orangefs_obj = | |
422 | container_of(kobj, struct capcache_orangefs_obj, kobj); | |
423 | ||
424 | if (!attribute->store) { | |
425 | rc = -EIO; | |
426 | goto out; | |
427 | } | |
428 | ||
429 | rc = attribute->store(capcache_orangefs_obj, attribute, buf, len); | |
430 | ||
431 | out: | |
432 | return rc; | |
433 | } | |
434 | ||
435 | static const struct sysfs_ops capcache_orangefs_sysfs_ops = { | |
436 | .show = capcache_orangefs_attr_show, | |
437 | .store = capcache_orangefs_attr_store, | |
438 | }; | |
439 | ||
440 | static ssize_t ccache_orangefs_attr_show(struct kobject *kobj, | |
441 | struct attribute *attr, | |
442 | char *buf) | |
443 | { | |
444 | struct ccache_orangefs_attribute *attribute; | |
445 | struct ccache_orangefs_obj *ccache_orangefs_obj; | |
446 | int rc; | |
447 | ||
448 | attribute = | |
449 | container_of(attr, struct ccache_orangefs_attribute, attr); | |
450 | ccache_orangefs_obj = | |
451 | container_of(kobj, struct ccache_orangefs_obj, kobj); | |
452 | ||
453 | if (!attribute->show) { | |
454 | rc = -EIO; | |
455 | goto out; | |
456 | } | |
457 | ||
458 | rc = attribute->show(ccache_orangefs_obj, attribute, buf); | |
459 | ||
460 | out: | |
461 | return rc; | |
462 | } | |
463 | ||
464 | static ssize_t ccache_orangefs_attr_store(struct kobject *kobj, | |
465 | struct attribute *attr, | |
466 | const char *buf, | |
467 | size_t len) | |
468 | { | |
469 | struct ccache_orangefs_attribute *attribute; | |
470 | struct ccache_orangefs_obj *ccache_orangefs_obj; | |
471 | int rc; | |
472 | ||
473 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
474 | "ccache_orangefs_attr_store: start\n"); | |
475 | ||
476 | attribute = | |
477 | container_of(attr, struct ccache_orangefs_attribute, attr); | |
478 | ccache_orangefs_obj = | |
479 | container_of(kobj, struct ccache_orangefs_obj, kobj); | |
480 | ||
481 | if (!attribute->store) { | |
482 | rc = -EIO; | |
483 | goto out; | |
484 | } | |
485 | ||
486 | rc = attribute->store(ccache_orangefs_obj, attribute, buf, len); | |
487 | ||
488 | out: | |
489 | return rc; | |
490 | } | |
491 | ||
492 | static const struct sysfs_ops ccache_orangefs_sysfs_ops = { | |
493 | .show = ccache_orangefs_attr_show, | |
494 | .store = ccache_orangefs_attr_store, | |
495 | }; | |
496 | ||
497 | static ssize_t ncache_orangefs_attr_show(struct kobject *kobj, | |
498 | struct attribute *attr, | |
499 | char *buf) | |
500 | { | |
501 | struct ncache_orangefs_attribute *attribute; | |
502 | struct ncache_orangefs_obj *ncache_orangefs_obj; | |
503 | int rc; | |
504 | ||
505 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); | |
506 | ncache_orangefs_obj = | |
507 | container_of(kobj, struct ncache_orangefs_obj, kobj); | |
508 | ||
509 | if (!attribute->show) { | |
510 | rc = -EIO; | |
511 | goto out; | |
512 | } | |
513 | ||
514 | rc = attribute->show(ncache_orangefs_obj, attribute, buf); | |
515 | ||
516 | out: | |
517 | return rc; | |
518 | } | |
519 | ||
520 | static ssize_t ncache_orangefs_attr_store(struct kobject *kobj, | |
521 | struct attribute *attr, | |
522 | const char *buf, | |
523 | size_t len) | |
524 | { | |
525 | struct ncache_orangefs_attribute *attribute; | |
526 | struct ncache_orangefs_obj *ncache_orangefs_obj; | |
527 | int rc; | |
528 | ||
529 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
530 | "ncache_orangefs_attr_store: start\n"); | |
531 | ||
532 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); | |
533 | ncache_orangefs_obj = | |
534 | container_of(kobj, struct ncache_orangefs_obj, kobj); | |
535 | ||
536 | if (!attribute->store) { | |
537 | rc = -EIO; | |
538 | goto out; | |
539 | } | |
540 | ||
541 | rc = attribute->store(ncache_orangefs_obj, attribute, buf, len); | |
542 | ||
543 | out: | |
544 | return rc; | |
545 | } | |
546 | ||
547 | static const struct sysfs_ops ncache_orangefs_sysfs_ops = { | |
548 | .show = ncache_orangefs_attr_show, | |
549 | .store = ncache_orangefs_attr_store, | |
550 | }; | |
551 | ||
552 | static ssize_t pc_orangefs_attr_show(struct kobject *kobj, | |
553 | struct attribute *attr, | |
554 | char *buf) | |
555 | { | |
556 | struct pc_orangefs_attribute *attribute; | |
557 | struct pc_orangefs_obj *pc_orangefs_obj; | |
558 | int rc; | |
559 | ||
560 | attribute = container_of(attr, struct pc_orangefs_attribute, attr); | |
561 | pc_orangefs_obj = | |
562 | container_of(kobj, struct pc_orangefs_obj, kobj); | |
563 | ||
564 | if (!attribute->show) { | |
565 | rc = -EIO; | |
566 | goto out; | |
567 | } | |
568 | ||
569 | rc = attribute->show(pc_orangefs_obj, attribute, buf); | |
570 | ||
571 | out: | |
572 | return rc; | |
573 | } | |
574 | ||
575 | static const struct sysfs_ops pc_orangefs_sysfs_ops = { | |
576 | .show = pc_orangefs_attr_show, | |
577 | }; | |
578 | ||
579 | static ssize_t stats_orangefs_attr_show(struct kobject *kobj, | |
580 | struct attribute *attr, | |
581 | char *buf) | |
582 | { | |
583 | struct stats_orangefs_attribute *attribute; | |
584 | struct stats_orangefs_obj *stats_orangefs_obj; | |
585 | int rc; | |
586 | ||
587 | attribute = container_of(attr, struct stats_orangefs_attribute, attr); | |
588 | stats_orangefs_obj = | |
589 | container_of(kobj, struct stats_orangefs_obj, kobj); | |
590 | ||
591 | if (!attribute->show) { | |
592 | rc = -EIO; | |
593 | goto out; | |
594 | } | |
595 | ||
596 | rc = attribute->show(stats_orangefs_obj, attribute, buf); | |
597 | ||
598 | out: | |
599 | return rc; | |
600 | } | |
601 | ||
602 | static const struct sysfs_ops stats_orangefs_sysfs_ops = { | |
603 | .show = stats_orangefs_attr_show, | |
604 | }; | |
605 | ||
606 | static void orangefs_release(struct kobject *kobj) | |
607 | { | |
608 | struct orangefs_obj *orangefs_obj; | |
609 | ||
610 | orangefs_obj = container_of(kobj, struct orangefs_obj, kobj); | |
611 | kfree(orangefs_obj); | |
612 | } | |
613 | ||
614 | static void acache_orangefs_release(struct kobject *kobj) | |
615 | { | |
616 | struct acache_orangefs_obj *acache_orangefs_obj; | |
617 | ||
618 | acache_orangefs_obj = | |
619 | container_of(kobj, struct acache_orangefs_obj, kobj); | |
620 | kfree(acache_orangefs_obj); | |
621 | } | |
622 | ||
623 | static void capcache_orangefs_release(struct kobject *kobj) | |
624 | { | |
625 | struct capcache_orangefs_obj *capcache_orangefs_obj; | |
626 | ||
627 | capcache_orangefs_obj = | |
628 | container_of(kobj, struct capcache_orangefs_obj, kobj); | |
629 | kfree(capcache_orangefs_obj); | |
630 | } | |
631 | ||
632 | static void ccache_orangefs_release(struct kobject *kobj) | |
633 | { | |
634 | struct ccache_orangefs_obj *ccache_orangefs_obj; | |
635 | ||
636 | ccache_orangefs_obj = | |
637 | container_of(kobj, struct ccache_orangefs_obj, kobj); | |
638 | kfree(ccache_orangefs_obj); | |
639 | } | |
640 | ||
641 | static void ncache_orangefs_release(struct kobject *kobj) | |
642 | { | |
643 | struct ncache_orangefs_obj *ncache_orangefs_obj; | |
644 | ||
645 | ncache_orangefs_obj = | |
646 | container_of(kobj, struct ncache_orangefs_obj, kobj); | |
647 | kfree(ncache_orangefs_obj); | |
648 | } | |
649 | ||
650 | static void pc_orangefs_release(struct kobject *kobj) | |
651 | { | |
652 | struct pc_orangefs_obj *pc_orangefs_obj; | |
653 | ||
654 | pc_orangefs_obj = | |
655 | container_of(kobj, struct pc_orangefs_obj, kobj); | |
656 | kfree(pc_orangefs_obj); | |
657 | } | |
658 | ||
659 | static void stats_orangefs_release(struct kobject *kobj) | |
660 | { | |
661 | struct stats_orangefs_obj *stats_orangefs_obj; | |
662 | ||
663 | stats_orangefs_obj = | |
664 | container_of(kobj, struct stats_orangefs_obj, kobj); | |
665 | kfree(stats_orangefs_obj); | |
666 | } | |
667 | ||
668 | static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr) | |
669 | { | |
670 | int rc = -EIO; | |
671 | struct orangefs_attribute *orangefs_attr; | |
672 | struct stats_orangefs_attribute *stats_orangefs_attr; | |
673 | ||
674 | gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id); | |
675 | ||
676 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | |
677 | orangefs_attr = (struct orangefs_attribute *)attr; | |
678 | ||
679 | if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) { | |
680 | rc = scnprintf(buf, | |
681 | PAGE_SIZE, | |
682 | "%d\n", | |
683 | op_timeout_secs); | |
684 | goto out; | |
685 | } else if (!strcmp(orangefs_attr->attr.name, | |
686 | "slot_timeout_secs")) { | |
687 | rc = scnprintf(buf, | |
688 | PAGE_SIZE, | |
689 | "%d\n", | |
690 | slot_timeout_secs); | |
691 | goto out; | |
4cd8f319 MB |
692 | } else if (!strcmp(orangefs_attr->attr.name, |
693 | "dcache_timeout_msecs")) { | |
694 | rc = scnprintf(buf, | |
695 | PAGE_SIZE, | |
696 | "%d\n", | |
697 | dcache_timeout_msecs); | |
698 | goto out; | |
699 | } else if (!strcmp(orangefs_attr->attr.name, | |
700 | "getattr_timeout_msecs")) { | |
701 | rc = scnprintf(buf, | |
702 | PAGE_SIZE, | |
703 | "%d\n", | |
704 | getattr_timeout_msecs); | |
705 | goto out; | |
f7be4ee0 MM |
706 | } else { |
707 | goto out; | |
708 | } | |
709 | ||
710 | } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) { | |
711 | stats_orangefs_attr = (struct stats_orangefs_attribute *)attr; | |
712 | ||
713 | if (!strcmp(stats_orangefs_attr->attr.name, "reads")) { | |
714 | rc = scnprintf(buf, | |
715 | PAGE_SIZE, | |
716 | "%lu\n", | |
8bb8aefd | 717 | g_orangefs_stats.reads); |
f7be4ee0 MM |
718 | goto out; |
719 | } else if (!strcmp(stats_orangefs_attr->attr.name, "writes")) { | |
720 | rc = scnprintf(buf, | |
721 | PAGE_SIZE, | |
722 | "%lu\n", | |
8bb8aefd | 723 | g_orangefs_stats.writes); |
f7be4ee0 MM |
724 | goto out; |
725 | } else { | |
726 | goto out; | |
727 | } | |
728 | } | |
729 | ||
730 | out: | |
731 | ||
732 | return rc; | |
733 | } | |
734 | ||
735 | static ssize_t int_orangefs_show(struct orangefs_obj *orangefs_obj, | |
736 | struct orangefs_attribute *attr, | |
737 | char *buf) | |
738 | { | |
739 | int rc; | |
740 | ||
741 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
742 | "int_orangefs_show:start attr->attr.name:%s:\n", | |
743 | attr->attr.name); | |
744 | ||
745 | rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr); | |
746 | ||
747 | return rc; | |
748 | } | |
749 | ||
750 | static ssize_t int_stats_show(struct stats_orangefs_obj *stats_orangefs_obj, | |
751 | struct stats_orangefs_attribute *attr, | |
752 | char *buf) | |
753 | { | |
754 | int rc; | |
755 | ||
756 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
757 | "int_stats_show:start attr->attr.name:%s:\n", | |
758 | attr->attr.name); | |
759 | ||
760 | rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr); | |
761 | ||
762 | return rc; | |
763 | } | |
764 | ||
765 | static ssize_t int_store(struct orangefs_obj *orangefs_obj, | |
766 | struct orangefs_attribute *attr, | |
767 | const char *buf, | |
768 | size_t count) | |
769 | { | |
770 | int rc = 0; | |
771 | ||
772 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
773 | "int_store: start attr->attr.name:%s: buf:%s:\n", | |
774 | attr->attr.name, buf); | |
775 | ||
776 | if (!strcmp(attr->attr.name, "op_timeout_secs")) { | |
777 | rc = kstrtoint(buf, 0, &op_timeout_secs); | |
778 | goto out; | |
779 | } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) { | |
780 | rc = kstrtoint(buf, 0, &slot_timeout_secs); | |
781 | goto out; | |
4cd8f319 MB |
782 | } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) { |
783 | rc = kstrtoint(buf, 0, &dcache_timeout_msecs); | |
784 | goto out; | |
785 | } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { | |
786 | rc = kstrtoint(buf, 0, &getattr_timeout_msecs); | |
787 | goto out; | |
f7be4ee0 MM |
788 | } else { |
789 | goto out; | |
790 | } | |
791 | ||
792 | out: | |
793 | if (rc) | |
794 | rc = -EINVAL; | |
795 | else | |
796 | rc = count; | |
797 | ||
798 | return rc; | |
799 | } | |
800 | ||
801 | /* | |
802 | * obtain attribute values from userspace with a service operation. | |
803 | */ | |
84d02150 | 804 | static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr) |
f7be4ee0 | 805 | { |
8bb8aefd | 806 | struct orangefs_kernel_op_s *new_op = NULL; |
f7be4ee0 MM |
807 | int rc = 0; |
808 | char *ser_op_type = NULL; | |
809 | struct orangefs_attribute *orangefs_attr; | |
810 | struct acache_orangefs_attribute *acache_attr; | |
811 | struct capcache_orangefs_attribute *capcache_attr; | |
812 | struct ccache_orangefs_attribute *ccache_attr; | |
813 | struct ncache_orangefs_attribute *ncache_attr; | |
814 | struct pc_orangefs_attribute *pc_attr; | |
815 | __u32 op_alloc_type; | |
816 | ||
817 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
818 | "sysfs_service_op_show: id:%s:\n", | |
819 | kobj_id); | |
820 | ||
821 | if (strcmp(kobj_id, PC_KOBJ_ID)) | |
8bb8aefd | 822 | op_alloc_type = ORANGEFS_VFS_OP_PARAM; |
f7be4ee0 | 823 | else |
8bb8aefd | 824 | op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT; |
f7be4ee0 MM |
825 | |
826 | new_op = op_alloc(op_alloc_type); | |
ed42fe05 AV |
827 | if (!new_op) |
828 | return -ENOMEM; | |
f7be4ee0 MM |
829 | |
830 | /* Can't do a service_operation if the client is not running... */ | |
831 | rc = is_daemon_in_service(); | |
832 | if (rc) { | |
833 | pr_info("%s: Client not running :%d:\n", | |
834 | __func__, | |
835 | is_daemon_in_service()); | |
836 | goto out; | |
837 | } | |
838 | ||
839 | if (strcmp(kobj_id, PC_KOBJ_ID)) | |
8bb8aefd | 840 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET; |
f7be4ee0 MM |
841 | |
842 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | |
843 | orangefs_attr = (struct orangefs_attribute *)attr; | |
844 | ||
845 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) | |
846 | new_op->upcall.req.param.op = | |
8bb8aefd | 847 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
f7be4ee0 MM |
848 | else if (!strcmp(orangefs_attr->attr.name, |
849 | "perf_time_interval_secs")) | |
850 | new_op->upcall.req.param.op = | |
8bb8aefd | 851 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
f7be4ee0 MM |
852 | else if (!strcmp(orangefs_attr->attr.name, |
853 | "perf_counter_reset")) | |
854 | new_op->upcall.req.param.op = | |
8bb8aefd | 855 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
f7be4ee0 | 856 | |
4d20a756 MB |
857 | else if (!strcmp(orangefs_attr->attr.name, |
858 | "readahead_count")) | |
859 | new_op->upcall.req.param.op = | |
860 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; | |
861 | ||
862 | else if (!strcmp(orangefs_attr->attr.name, | |
863 | "readahead_size")) | |
864 | new_op->upcall.req.param.op = | |
865 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; | |
866 | ||
867 | else if (!strcmp(orangefs_attr->attr.name, | |
868 | "readahead_count_size")) | |
869 | new_op->upcall.req.param.op = | |
870 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; | |
f7be4ee0 MM |
871 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { |
872 | acache_attr = (struct acache_orangefs_attribute *)attr; | |
873 | ||
874 | if (!strcmp(acache_attr->attr.name, "timeout_msecs")) | |
875 | new_op->upcall.req.param.op = | |
8bb8aefd | 876 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
f7be4ee0 MM |
877 | |
878 | if (!strcmp(acache_attr->attr.name, "hard_limit")) | |
879 | new_op->upcall.req.param.op = | |
8bb8aefd | 880 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
f7be4ee0 MM |
881 | |
882 | if (!strcmp(acache_attr->attr.name, "soft_limit")) | |
883 | new_op->upcall.req.param.op = | |
8bb8aefd | 884 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
f7be4ee0 MM |
885 | |
886 | if (!strcmp(acache_attr->attr.name, "reclaim_percentage")) | |
887 | new_op->upcall.req.param.op = | |
8bb8aefd | 888 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
889 | |
890 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { | |
891 | capcache_attr = (struct capcache_orangefs_attribute *)attr; | |
892 | ||
893 | if (!strcmp(capcache_attr->attr.name, "timeout_secs")) | |
894 | new_op->upcall.req.param.op = | |
8bb8aefd | 895 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
f7be4ee0 MM |
896 | |
897 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) | |
898 | new_op->upcall.req.param.op = | |
8bb8aefd | 899 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
f7be4ee0 MM |
900 | |
901 | if (!strcmp(capcache_attr->attr.name, "soft_limit")) | |
902 | new_op->upcall.req.param.op = | |
8bb8aefd | 903 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
904 | |
905 | if (!strcmp(capcache_attr->attr.name, "reclaim_percentage")) | |
906 | new_op->upcall.req.param.op = | |
8bb8aefd | 907 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
908 | |
909 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { | |
910 | ccache_attr = (struct ccache_orangefs_attribute *)attr; | |
911 | ||
912 | if (!strcmp(ccache_attr->attr.name, "timeout_secs")) | |
913 | new_op->upcall.req.param.op = | |
8bb8aefd | 914 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
f7be4ee0 MM |
915 | |
916 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) | |
917 | new_op->upcall.req.param.op = | |
8bb8aefd | 918 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
f7be4ee0 MM |
919 | |
920 | if (!strcmp(ccache_attr->attr.name, "soft_limit")) | |
921 | new_op->upcall.req.param.op = | |
8bb8aefd | 922 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
923 | |
924 | if (!strcmp(ccache_attr->attr.name, "reclaim_percentage")) | |
925 | new_op->upcall.req.param.op = | |
8bb8aefd | 926 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
927 | |
928 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { | |
929 | ncache_attr = (struct ncache_orangefs_attribute *)attr; | |
930 | ||
931 | if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) | |
932 | new_op->upcall.req.param.op = | |
8bb8aefd | 933 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
f7be4ee0 MM |
934 | |
935 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) | |
936 | new_op->upcall.req.param.op = | |
8bb8aefd | 937 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
f7be4ee0 MM |
938 | |
939 | if (!strcmp(ncache_attr->attr.name, "soft_limit")) | |
940 | new_op->upcall.req.param.op = | |
8bb8aefd | 941 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
942 | |
943 | if (!strcmp(ncache_attr->attr.name, "reclaim_percentage")) | |
944 | new_op->upcall.req.param.op = | |
8bb8aefd | 945 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
946 | |
947 | } else if (!strcmp(kobj_id, PC_KOBJ_ID)) { | |
948 | pc_attr = (struct pc_orangefs_attribute *)attr; | |
949 | ||
950 | if (!strcmp(pc_attr->attr.name, ACACHE_KOBJ_ID)) | |
951 | new_op->upcall.req.perf_count.type = | |
8bb8aefd | 952 | ORANGEFS_PERF_COUNT_REQUEST_ACACHE; |
f7be4ee0 MM |
953 | |
954 | if (!strcmp(pc_attr->attr.name, CAPCACHE_KOBJ_ID)) | |
955 | new_op->upcall.req.perf_count.type = | |
8bb8aefd | 956 | ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE; |
f7be4ee0 MM |
957 | |
958 | if (!strcmp(pc_attr->attr.name, NCACHE_KOBJ_ID)) | |
959 | new_op->upcall.req.perf_count.type = | |
8bb8aefd | 960 | ORANGEFS_PERF_COUNT_REQUEST_NCACHE; |
f7be4ee0 MM |
961 | |
962 | } else { | |
963 | gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n", | |
964 | kobj_id); | |
965 | rc = -EINVAL; | |
966 | goto out; | |
967 | } | |
968 | ||
969 | ||
970 | if (strcmp(kobj_id, PC_KOBJ_ID)) | |
8bb8aefd | 971 | ser_op_type = "orangefs_param"; |
f7be4ee0 | 972 | else |
8bb8aefd | 973 | ser_op_type = "orangefs_perf_count"; |
f7be4ee0 MM |
974 | |
975 | /* | |
976 | * The service_operation will return an errno return code on | |
977 | * error, and zero on success. | |
978 | */ | |
8bb8aefd | 979 | rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE); |
f7be4ee0 MM |
980 | |
981 | out: | |
982 | if (!rc) { | |
983 | if (strcmp(kobj_id, PC_KOBJ_ID)) { | |
4d20a756 MB |
984 | if (new_op->upcall.req.param.op == |
985 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { | |
986 | rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", | |
987 | (int)new_op->downcall.resp.param.u. | |
988 | value32[0], | |
989 | (int)new_op->downcall.resp.param.u. | |
990 | value32[1]); | |
991 | } else { | |
992 | rc = scnprintf(buf, PAGE_SIZE, "%d\n", | |
993 | (int)new_op->downcall.resp.param.u.value64); | |
994 | } | |
f7be4ee0 MM |
995 | } else { |
996 | rc = scnprintf( | |
997 | buf, | |
998 | PAGE_SIZE, | |
999 | "%s", | |
1000 | new_op->downcall.resp.perf_count.buffer); | |
1001 | } | |
1002 | } | |
1003 | ||
ed42fe05 | 1004 | op_release(new_op); |
f7be4ee0 MM |
1005 | |
1006 | return rc; | |
1007 | ||
1008 | } | |
1009 | ||
1010 | static ssize_t service_orangefs_show(struct orangefs_obj *orangefs_obj, | |
1011 | struct orangefs_attribute *attr, | |
1012 | char *buf) | |
1013 | { | |
1014 | int rc = 0; | |
1015 | ||
1016 | rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr); | |
1017 | ||
1018 | return rc; | |
1019 | } | |
1020 | ||
1021 | static ssize_t | |
1022 | service_acache_show(struct acache_orangefs_obj *acache_orangefs_obj, | |
1023 | struct acache_orangefs_attribute *attr, | |
1024 | char *buf) | |
1025 | { | |
1026 | int rc = 0; | |
1027 | ||
1028 | rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr); | |
1029 | ||
1030 | return rc; | |
1031 | } | |
1032 | ||
1033 | static ssize_t service_capcache_show(struct capcache_orangefs_obj | |
1034 | *capcache_orangefs_obj, | |
1035 | struct capcache_orangefs_attribute *attr, | |
1036 | char *buf) | |
1037 | { | |
1038 | int rc = 0; | |
1039 | ||
1040 | rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr); | |
1041 | ||
1042 | return rc; | |
1043 | } | |
1044 | ||
1045 | static ssize_t service_ccache_show(struct ccache_orangefs_obj | |
1046 | *ccache_orangefs_obj, | |
1047 | struct ccache_orangefs_attribute *attr, | |
1048 | char *buf) | |
1049 | { | |
1050 | int rc = 0; | |
1051 | ||
1052 | rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr); | |
1053 | ||
1054 | return rc; | |
1055 | } | |
1056 | ||
1057 | static ssize_t | |
1058 | service_ncache_show(struct ncache_orangefs_obj *ncache_orangefs_obj, | |
1059 | struct ncache_orangefs_attribute *attr, | |
1060 | char *buf) | |
1061 | { | |
1062 | int rc = 0; | |
1063 | ||
1064 | rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr); | |
1065 | ||
1066 | return rc; | |
1067 | } | |
1068 | ||
1069 | static ssize_t | |
1070 | service_pc_show(struct pc_orangefs_obj *pc_orangefs_obj, | |
1071 | struct pc_orangefs_attribute *attr, | |
1072 | char *buf) | |
1073 | { | |
1074 | int rc = 0; | |
1075 | ||
1076 | rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr); | |
1077 | ||
1078 | return rc; | |
1079 | } | |
1080 | ||
1081 | /* | |
1082 | * pass attribute values back to userspace with a service operation. | |
1083 | * | |
1084 | * We have to do a memory allocation, an sscanf and a service operation. | |
1085 | * And we have to evaluate what the user entered, to make sure the | |
1086 | * value is within the range supported by the attribute. So, there's | |
1087 | * a lot of return code checking and mapping going on here. | |
1088 | * | |
1089 | * We want to return 1 if we think everything went OK, and | |
1090 | * EINVAL if not. | |
1091 | */ | |
84d02150 | 1092 | static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) |
f7be4ee0 | 1093 | { |
8bb8aefd | 1094 | struct orangefs_kernel_op_s *new_op = NULL; |
f7be4ee0 MM |
1095 | int val = 0; |
1096 | int rc = 0; | |
1097 | struct orangefs_attribute *orangefs_attr; | |
1098 | struct acache_orangefs_attribute *acache_attr; | |
1099 | struct capcache_orangefs_attribute *capcache_attr; | |
1100 | struct ccache_orangefs_attribute *ccache_attr; | |
1101 | struct ncache_orangefs_attribute *ncache_attr; | |
1102 | ||
1103 | gossip_debug(GOSSIP_SYSFS_DEBUG, | |
1104 | "sysfs_service_op_store: id:%s:\n", | |
1105 | kobj_id); | |
1106 | ||
8bb8aefd | 1107 | new_op = op_alloc(ORANGEFS_VFS_OP_PARAM); |
ed42fe05 AV |
1108 | if (!new_op) |
1109 | return -EINVAL; /* sic */ | |
f7be4ee0 MM |
1110 | |
1111 | /* Can't do a service_operation if the client is not running... */ | |
1112 | rc = is_daemon_in_service(); | |
1113 | if (rc) { | |
1114 | pr_info("%s: Client not running :%d:\n", | |
1115 | __func__, | |
1116 | is_daemon_in_service()); | |
1117 | goto out; | |
1118 | } | |
1119 | ||
1120 | /* | |
4d20a756 MB |
1121 | * The value we want to send back to userspace is in buf, unless this |
1122 | * there are two parameters, which is specially handled below. | |
f7be4ee0 | 1123 | */ |
4d20a756 MB |
1124 | if (strcmp(kobj_id, ORANGEFS_KOBJ_ID) || |
1125 | strcmp(((struct orangefs_attribute *)attr)->attr.name, | |
1126 | "readahead_count_size")) { | |
1127 | rc = kstrtoint(buf, 0, &val); | |
1128 | if (rc) | |
1129 | goto out; | |
1130 | } | |
1131 | ||
1132 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET; | |
f7be4ee0 MM |
1133 | |
1134 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { | |
1135 | orangefs_attr = (struct orangefs_attribute *)attr; | |
1136 | ||
1137 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) { | |
1138 | if (val > 0) { | |
1139 | new_op->upcall.req.param.op = | |
8bb8aefd | 1140 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
f7be4ee0 MM |
1141 | } else { |
1142 | rc = 0; | |
1143 | goto out; | |
1144 | } | |
1145 | } else if (!strcmp(orangefs_attr->attr.name, | |
1146 | "perf_time_interval_secs")) { | |
1147 | if (val > 0) { | |
1148 | new_op->upcall.req.param.op = | |
8bb8aefd | 1149 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
f7be4ee0 MM |
1150 | } else { |
1151 | rc = 0; | |
1152 | goto out; | |
1153 | } | |
1154 | } else if (!strcmp(orangefs_attr->attr.name, | |
1155 | "perf_counter_reset")) { | |
1156 | if ((val == 0) || (val == 1)) { | |
1157 | new_op->upcall.req.param.op = | |
8bb8aefd | 1158 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
f7be4ee0 MM |
1159 | } else { |
1160 | rc = 0; | |
1161 | goto out; | |
1162 | } | |
4d20a756 MB |
1163 | } else if (!strcmp(orangefs_attr->attr.name, |
1164 | "readahead_count")) { | |
1165 | if ((val >= 0)) { | |
1166 | new_op->upcall.req.param.op = | |
1167 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; | |
1168 | } else { | |
1169 | rc = 0; | |
1170 | goto out; | |
1171 | } | |
1172 | } else if (!strcmp(orangefs_attr->attr.name, | |
1173 | "readahead_size")) { | |
1174 | if ((val >= 0)) { | |
1175 | new_op->upcall.req.param.op = | |
1176 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; | |
1177 | } else { | |
1178 | rc = 0; | |
1179 | goto out; | |
1180 | } | |
1181 | } else if (!strcmp(orangefs_attr->attr.name, | |
1182 | "readahead_count_size")) { | |
1183 | int val1, val2; | |
1184 | rc = sscanf(buf, "%d %d", &val1, &val2); | |
1185 | if (rc < 2) { | |
1186 | rc = 0; | |
1187 | goto out; | |
1188 | } | |
1189 | if ((val1 >= 0) && (val2 >= 0)) { | |
1190 | new_op->upcall.req.param.op = | |
1191 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; | |
1192 | } else { | |
1193 | rc = 0; | |
1194 | goto out; | |
1195 | } | |
1196 | new_op->upcall.req.param.u.value32[0] = val1; | |
1197 | new_op->upcall.req.param.u.value32[1] = val2; | |
1198 | goto value_set; | |
1199 | } else if (!strcmp(orangefs_attr->attr.name, | |
1200 | "perf_counter_reset")) { | |
1201 | if ((val > 0)) { | |
1202 | new_op->upcall.req.param.op = | |
1203 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; | |
1204 | } else { | |
1205 | rc = 0; | |
1206 | goto out; | |
1207 | } | |
f7be4ee0 MM |
1208 | } |
1209 | ||
1210 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { | |
1211 | acache_attr = (struct acache_orangefs_attribute *)attr; | |
1212 | ||
1213 | if (!strcmp(acache_attr->attr.name, "hard_limit")) { | |
1214 | if (val > -1) { | |
1215 | new_op->upcall.req.param.op = | |
8bb8aefd | 1216 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
f7be4ee0 MM |
1217 | } else { |
1218 | rc = 0; | |
1219 | goto out; | |
1220 | } | |
1221 | } else if (!strcmp(acache_attr->attr.name, "soft_limit")) { | |
1222 | if (val > -1) { | |
1223 | new_op->upcall.req.param.op = | |
8bb8aefd | 1224 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
f7be4ee0 MM |
1225 | } else { |
1226 | rc = 0; | |
1227 | goto out; | |
1228 | } | |
1229 | } else if (!strcmp(acache_attr->attr.name, | |
1230 | "reclaim_percentage")) { | |
1231 | if ((val > -1) && (val < 101)) { | |
1232 | new_op->upcall.req.param.op = | |
8bb8aefd | 1233 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
1234 | } else { |
1235 | rc = 0; | |
1236 | goto out; | |
1237 | } | |
1238 | } else if (!strcmp(acache_attr->attr.name, "timeout_msecs")) { | |
1239 | if (val > -1) { | |
1240 | new_op->upcall.req.param.op = | |
8bb8aefd | 1241 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
f7be4ee0 MM |
1242 | } else { |
1243 | rc = 0; | |
1244 | goto out; | |
1245 | } | |
1246 | } | |
1247 | ||
1248 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { | |
1249 | capcache_attr = (struct capcache_orangefs_attribute *)attr; | |
1250 | ||
1251 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) { | |
1252 | if (val > -1) { | |
1253 | new_op->upcall.req.param.op = | |
8bb8aefd | 1254 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
f7be4ee0 MM |
1255 | } else { |
1256 | rc = 0; | |
1257 | goto out; | |
1258 | } | |
1259 | } else if (!strcmp(capcache_attr->attr.name, "soft_limit")) { | |
1260 | if (val > -1) { | |
1261 | new_op->upcall.req.param.op = | |
8bb8aefd | 1262 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
1263 | } else { |
1264 | rc = 0; | |
1265 | goto out; | |
1266 | } | |
1267 | } else if (!strcmp(capcache_attr->attr.name, | |
1268 | "reclaim_percentage")) { | |
1269 | if ((val > -1) && (val < 101)) { | |
1270 | new_op->upcall.req.param.op = | |
8bb8aefd | 1271 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
1272 | } else { |
1273 | rc = 0; | |
1274 | goto out; | |
1275 | } | |
1276 | } else if (!strcmp(capcache_attr->attr.name, "timeout_secs")) { | |
1277 | if (val > -1) { | |
1278 | new_op->upcall.req.param.op = | |
8bb8aefd | 1279 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
f7be4ee0 MM |
1280 | } else { |
1281 | rc = 0; | |
1282 | goto out; | |
1283 | } | |
1284 | } | |
1285 | ||
1286 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { | |
1287 | ccache_attr = (struct ccache_orangefs_attribute *)attr; | |
1288 | ||
1289 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) { | |
1290 | if (val > -1) { | |
1291 | new_op->upcall.req.param.op = | |
8bb8aefd | 1292 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
f7be4ee0 MM |
1293 | } else { |
1294 | rc = 0; | |
1295 | goto out; | |
1296 | } | |
1297 | } else if (!strcmp(ccache_attr->attr.name, "soft_limit")) { | |
1298 | if (val > -1) { | |
1299 | new_op->upcall.req.param.op = | |
8bb8aefd | 1300 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
1301 | } else { |
1302 | rc = 0; | |
1303 | goto out; | |
1304 | } | |
1305 | } else if (!strcmp(ccache_attr->attr.name, | |
1306 | "reclaim_percentage")) { | |
1307 | if ((val > -1) && (val < 101)) { | |
1308 | new_op->upcall.req.param.op = | |
8bb8aefd | 1309 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
1310 | } else { |
1311 | rc = 0; | |
1312 | goto out; | |
1313 | } | |
1314 | } else if (!strcmp(ccache_attr->attr.name, "timeout_secs")) { | |
1315 | if (val > -1) { | |
1316 | new_op->upcall.req.param.op = | |
8bb8aefd | 1317 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
f7be4ee0 MM |
1318 | } else { |
1319 | rc = 0; | |
1320 | goto out; | |
1321 | } | |
1322 | } | |
1323 | ||
1324 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { | |
1325 | ncache_attr = (struct ncache_orangefs_attribute *)attr; | |
1326 | ||
1327 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) { | |
1328 | if (val > -1) { | |
1329 | new_op->upcall.req.param.op = | |
8bb8aefd | 1330 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
f7be4ee0 MM |
1331 | } else { |
1332 | rc = 0; | |
1333 | goto out; | |
1334 | } | |
1335 | } else if (!strcmp(ncache_attr->attr.name, "soft_limit")) { | |
1336 | if (val > -1) { | |
1337 | new_op->upcall.req.param.op = | |
8bb8aefd | 1338 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
f7be4ee0 MM |
1339 | } else { |
1340 | rc = 0; | |
1341 | goto out; | |
1342 | } | |
1343 | } else if (!strcmp(ncache_attr->attr.name, | |
1344 | "reclaim_percentage")) { | |
1345 | if ((val > -1) && (val < 101)) { | |
1346 | new_op->upcall.req.param.op = | |
8bb8aefd | 1347 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
f7be4ee0 MM |
1348 | } else { |
1349 | rc = 0; | |
1350 | goto out; | |
1351 | } | |
1352 | } else if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) { | |
1353 | if (val > -1) { | |
1354 | new_op->upcall.req.param.op = | |
8bb8aefd | 1355 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
f7be4ee0 MM |
1356 | } else { |
1357 | rc = 0; | |
1358 | goto out; | |
1359 | } | |
1360 | } | |
1361 | ||
1362 | } else { | |
1363 | gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n", | |
1364 | kobj_id); | |
1365 | rc = -EINVAL; | |
1366 | goto out; | |
1367 | } | |
1368 | ||
680908e5 | 1369 | new_op->upcall.req.param.u.value64 = val; |
4d20a756 | 1370 | value_set: |
f7be4ee0 MM |
1371 | |
1372 | /* | |
1373 | * The service_operation will return a errno return code on | |
1374 | * error, and zero on success. | |
1375 | */ | |
8bb8aefd | 1376 | rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE); |
f7be4ee0 MM |
1377 | |
1378 | if (rc < 0) { | |
1379 | gossip_err("sysfs_service_op_store: service op returned:%d:\n", | |
1380 | rc); | |
1381 | rc = 0; | |
1382 | } else { | |
1383 | rc = 1; | |
1384 | } | |
1385 | ||
1386 | out: | |
ed42fe05 | 1387 | op_release(new_op); |
f7be4ee0 | 1388 | |
ed42fe05 | 1389 | if (rc == -ENOMEM || rc == 0) |
f7be4ee0 MM |
1390 | rc = -EINVAL; |
1391 | ||
1392 | return rc; | |
1393 | } | |
1394 | ||
1395 | static ssize_t | |
1396 | service_orangefs_store(struct orangefs_obj *orangefs_obj, | |
1397 | struct orangefs_attribute *attr, | |
1398 | const char *buf, | |
1399 | size_t count) | |
1400 | { | |
1401 | int rc = 0; | |
1402 | ||
1403 | rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr); | |
1404 | ||
1405 | /* rc should have an errno value if the service_op went bad. */ | |
1406 | if (rc == 1) | |
1407 | rc = count; | |
1408 | ||
1409 | return rc; | |
1410 | } | |
1411 | ||
1412 | static ssize_t | |
1413 | service_acache_store(struct acache_orangefs_obj *acache_orangefs_obj, | |
1414 | struct acache_orangefs_attribute *attr, | |
1415 | const char *buf, | |
1416 | size_t count) | |
1417 | { | |
1418 | int rc = 0; | |
1419 | ||
1420 | rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr); | |
1421 | ||
1422 | /* rc should have an errno value if the service_op went bad. */ | |
1423 | if (rc == 1) | |
1424 | rc = count; | |
1425 | ||
1426 | return rc; | |
1427 | } | |
1428 | ||
1429 | static ssize_t | |
1430 | service_capcache_store(struct capcache_orangefs_obj | |
1431 | *capcache_orangefs_obj, | |
1432 | struct capcache_orangefs_attribute *attr, | |
1433 | const char *buf, | |
1434 | size_t count) | |
1435 | { | |
1436 | int rc = 0; | |
1437 | ||
1438 | rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr); | |
1439 | ||
1440 | /* rc should have an errno value if the service_op went bad. */ | |
1441 | if (rc == 1) | |
1442 | rc = count; | |
1443 | ||
1444 | return rc; | |
1445 | } | |
1446 | ||
1447 | static ssize_t service_ccache_store(struct ccache_orangefs_obj | |
1448 | *ccache_orangefs_obj, | |
1449 | struct ccache_orangefs_attribute *attr, | |
1450 | const char *buf, | |
1451 | size_t count) | |
1452 | { | |
1453 | int rc = 0; | |
1454 | ||
1455 | rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr); | |
1456 | ||
1457 | /* rc should have an errno value if the service_op went bad. */ | |
1458 | if (rc == 1) | |
1459 | rc = count; | |
1460 | ||
1461 | return rc; | |
1462 | } | |
1463 | ||
1464 | static ssize_t | |
1465 | service_ncache_store(struct ncache_orangefs_obj *ncache_orangefs_obj, | |
1466 | struct ncache_orangefs_attribute *attr, | |
1467 | const char *buf, | |
1468 | size_t count) | |
1469 | { | |
1470 | int rc = 0; | |
1471 | ||
1472 | rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr); | |
1473 | ||
1474 | /* rc should have an errno value if the service_op went bad. */ | |
1475 | if (rc == 1) | |
1476 | rc = count; | |
1477 | ||
1478 | return rc; | |
1479 | } | |
1480 | ||
1481 | static struct orangefs_attribute op_timeout_secs_attribute = | |
1482 | __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store); | |
1483 | ||
1484 | static struct orangefs_attribute slot_timeout_secs_attribute = | |
1485 | __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store); | |
1486 | ||
4cd8f319 MB |
1487 | static struct orangefs_attribute dcache_timeout_msecs_attribute = |
1488 | __ATTR(dcache_timeout_msecs, 0664, int_orangefs_show, int_store); | |
1489 | ||
1490 | static struct orangefs_attribute getattr_timeout_msecs_attribute = | |
1491 | __ATTR(getattr_timeout_msecs, 0664, int_orangefs_show, int_store); | |
1492 | ||
4d20a756 MB |
1493 | static struct orangefs_attribute readahead_count_attribute = |
1494 | __ATTR(readahead_count, 0664, service_orangefs_show, | |
1495 | service_orangefs_store); | |
1496 | ||
1497 | static struct orangefs_attribute readahead_size_attribute = | |
1498 | __ATTR(readahead_size, 0664, service_orangefs_show, | |
1499 | service_orangefs_store); | |
1500 | ||
1501 | static struct orangefs_attribute readahead_count_size_attribute = | |
1502 | __ATTR(readahead_count_size, 0664, service_orangefs_show, | |
1503 | service_orangefs_store); | |
1504 | ||
f7be4ee0 MM |
1505 | static struct orangefs_attribute perf_counter_reset_attribute = |
1506 | __ATTR(perf_counter_reset, | |
1507 | 0664, | |
1508 | service_orangefs_show, | |
1509 | service_orangefs_store); | |
1510 | ||
1511 | static struct orangefs_attribute perf_history_size_attribute = | |
1512 | __ATTR(perf_history_size, | |
1513 | 0664, | |
1514 | service_orangefs_show, | |
1515 | service_orangefs_store); | |
1516 | ||
1517 | static struct orangefs_attribute perf_time_interval_secs_attribute = | |
1518 | __ATTR(perf_time_interval_secs, | |
1519 | 0664, | |
1520 | service_orangefs_show, | |
1521 | service_orangefs_store); | |
1522 | ||
1523 | static struct attribute *orangefs_default_attrs[] = { | |
1524 | &op_timeout_secs_attribute.attr, | |
1525 | &slot_timeout_secs_attribute.attr, | |
4cd8f319 MB |
1526 | &dcache_timeout_msecs_attribute.attr, |
1527 | &getattr_timeout_msecs_attribute.attr, | |
4d20a756 MB |
1528 | &readahead_count_attribute.attr, |
1529 | &readahead_size_attribute.attr, | |
1530 | &readahead_count_size_attribute.attr, | |
f7be4ee0 MM |
1531 | &perf_counter_reset_attribute.attr, |
1532 | &perf_history_size_attribute.attr, | |
1533 | &perf_time_interval_secs_attribute.attr, | |
1534 | NULL, | |
1535 | }; | |
1536 | ||
1537 | static struct kobj_type orangefs_ktype = { | |
1538 | .sysfs_ops = &orangefs_sysfs_ops, | |
1539 | .release = orangefs_release, | |
1540 | .default_attrs = orangefs_default_attrs, | |
1541 | }; | |
1542 | ||
1543 | static struct acache_orangefs_attribute acache_hard_limit_attribute = | |
1544 | __ATTR(hard_limit, | |
1545 | 0664, | |
1546 | service_acache_show, | |
1547 | service_acache_store); | |
1548 | ||
1549 | static struct acache_orangefs_attribute acache_reclaim_percent_attribute = | |
1550 | __ATTR(reclaim_percentage, | |
1551 | 0664, | |
1552 | service_acache_show, | |
1553 | service_acache_store); | |
1554 | ||
1555 | static struct acache_orangefs_attribute acache_soft_limit_attribute = | |
1556 | __ATTR(soft_limit, | |
1557 | 0664, | |
1558 | service_acache_show, | |
1559 | service_acache_store); | |
1560 | ||
1561 | static struct acache_orangefs_attribute acache_timeout_msecs_attribute = | |
1562 | __ATTR(timeout_msecs, | |
1563 | 0664, | |
1564 | service_acache_show, | |
1565 | service_acache_store); | |
1566 | ||
1567 | static struct attribute *acache_orangefs_default_attrs[] = { | |
1568 | &acache_hard_limit_attribute.attr, | |
1569 | &acache_reclaim_percent_attribute.attr, | |
1570 | &acache_soft_limit_attribute.attr, | |
1571 | &acache_timeout_msecs_attribute.attr, | |
1572 | NULL, | |
1573 | }; | |
1574 | ||
1575 | static struct kobj_type acache_orangefs_ktype = { | |
1576 | .sysfs_ops = &acache_orangefs_sysfs_ops, | |
1577 | .release = acache_orangefs_release, | |
1578 | .default_attrs = acache_orangefs_default_attrs, | |
1579 | }; | |
1580 | ||
1581 | static struct capcache_orangefs_attribute capcache_hard_limit_attribute = | |
1582 | __ATTR(hard_limit, | |
1583 | 0664, | |
1584 | service_capcache_show, | |
1585 | service_capcache_store); | |
1586 | ||
1587 | static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute = | |
1588 | __ATTR(reclaim_percentage, | |
1589 | 0664, | |
1590 | service_capcache_show, | |
1591 | service_capcache_store); | |
1592 | ||
1593 | static struct capcache_orangefs_attribute capcache_soft_limit_attribute = | |
1594 | __ATTR(soft_limit, | |
1595 | 0664, | |
1596 | service_capcache_show, | |
1597 | service_capcache_store); | |
1598 | ||
1599 | static struct capcache_orangefs_attribute capcache_timeout_secs_attribute = | |
1600 | __ATTR(timeout_secs, | |
1601 | 0664, | |
1602 | service_capcache_show, | |
1603 | service_capcache_store); | |
1604 | ||
1605 | static struct attribute *capcache_orangefs_default_attrs[] = { | |
1606 | &capcache_hard_limit_attribute.attr, | |
1607 | &capcache_reclaim_percent_attribute.attr, | |
1608 | &capcache_soft_limit_attribute.attr, | |
1609 | &capcache_timeout_secs_attribute.attr, | |
1610 | NULL, | |
1611 | }; | |
1612 | ||
1613 | static struct kobj_type capcache_orangefs_ktype = { | |
1614 | .sysfs_ops = &capcache_orangefs_sysfs_ops, | |
1615 | .release = capcache_orangefs_release, | |
1616 | .default_attrs = capcache_orangefs_default_attrs, | |
1617 | }; | |
1618 | ||
1619 | static struct ccache_orangefs_attribute ccache_hard_limit_attribute = | |
1620 | __ATTR(hard_limit, | |
1621 | 0664, | |
1622 | service_ccache_show, | |
1623 | service_ccache_store); | |
1624 | ||
1625 | static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute = | |
1626 | __ATTR(reclaim_percentage, | |
1627 | 0664, | |
1628 | service_ccache_show, | |
1629 | service_ccache_store); | |
1630 | ||
1631 | static struct ccache_orangefs_attribute ccache_soft_limit_attribute = | |
1632 | __ATTR(soft_limit, | |
1633 | 0664, | |
1634 | service_ccache_show, | |
1635 | service_ccache_store); | |
1636 | ||
1637 | static struct ccache_orangefs_attribute ccache_timeout_secs_attribute = | |
1638 | __ATTR(timeout_secs, | |
1639 | 0664, | |
1640 | service_ccache_show, | |
1641 | service_ccache_store); | |
1642 | ||
1643 | static struct attribute *ccache_orangefs_default_attrs[] = { | |
1644 | &ccache_hard_limit_attribute.attr, | |
1645 | &ccache_reclaim_percent_attribute.attr, | |
1646 | &ccache_soft_limit_attribute.attr, | |
1647 | &ccache_timeout_secs_attribute.attr, | |
1648 | NULL, | |
1649 | }; | |
1650 | ||
1651 | static struct kobj_type ccache_orangefs_ktype = { | |
1652 | .sysfs_ops = &ccache_orangefs_sysfs_ops, | |
1653 | .release = ccache_orangefs_release, | |
1654 | .default_attrs = ccache_orangefs_default_attrs, | |
1655 | }; | |
1656 | ||
1657 | static struct ncache_orangefs_attribute ncache_hard_limit_attribute = | |
1658 | __ATTR(hard_limit, | |
1659 | 0664, | |
1660 | service_ncache_show, | |
1661 | service_ncache_store); | |
1662 | ||
1663 | static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute = | |
1664 | __ATTR(reclaim_percentage, | |
1665 | 0664, | |
1666 | service_ncache_show, | |
1667 | service_ncache_store); | |
1668 | ||
1669 | static struct ncache_orangefs_attribute ncache_soft_limit_attribute = | |
1670 | __ATTR(soft_limit, | |
1671 | 0664, | |
1672 | service_ncache_show, | |
1673 | service_ncache_store); | |
1674 | ||
1675 | static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute = | |
1676 | __ATTR(timeout_msecs, | |
1677 | 0664, | |
1678 | service_ncache_show, | |
1679 | service_ncache_store); | |
1680 | ||
1681 | static struct attribute *ncache_orangefs_default_attrs[] = { | |
1682 | &ncache_hard_limit_attribute.attr, | |
1683 | &ncache_reclaim_percent_attribute.attr, | |
1684 | &ncache_soft_limit_attribute.attr, | |
1685 | &ncache_timeout_msecs_attribute.attr, | |
1686 | NULL, | |
1687 | }; | |
1688 | ||
1689 | static struct kobj_type ncache_orangefs_ktype = { | |
1690 | .sysfs_ops = &ncache_orangefs_sysfs_ops, | |
1691 | .release = ncache_orangefs_release, | |
1692 | .default_attrs = ncache_orangefs_default_attrs, | |
1693 | }; | |
1694 | ||
1695 | static struct pc_orangefs_attribute pc_acache_attribute = | |
1696 | __ATTR(acache, | |
1697 | 0664, | |
1698 | service_pc_show, | |
1699 | NULL); | |
1700 | ||
1701 | static struct pc_orangefs_attribute pc_capcache_attribute = | |
1702 | __ATTR(capcache, | |
1703 | 0664, | |
1704 | service_pc_show, | |
1705 | NULL); | |
1706 | ||
1707 | static struct pc_orangefs_attribute pc_ncache_attribute = | |
1708 | __ATTR(ncache, | |
1709 | 0664, | |
1710 | service_pc_show, | |
1711 | NULL); | |
1712 | ||
1713 | static struct attribute *pc_orangefs_default_attrs[] = { | |
1714 | &pc_acache_attribute.attr, | |
1715 | &pc_capcache_attribute.attr, | |
1716 | &pc_ncache_attribute.attr, | |
1717 | NULL, | |
1718 | }; | |
1719 | ||
1720 | static struct kobj_type pc_orangefs_ktype = { | |
1721 | .sysfs_ops = &pc_orangefs_sysfs_ops, | |
1722 | .release = pc_orangefs_release, | |
1723 | .default_attrs = pc_orangefs_default_attrs, | |
1724 | }; | |
1725 | ||
1726 | static struct stats_orangefs_attribute stats_reads_attribute = | |
1727 | __ATTR(reads, | |
1728 | 0664, | |
1729 | int_stats_show, | |
1730 | NULL); | |
1731 | ||
1732 | static struct stats_orangefs_attribute stats_writes_attribute = | |
1733 | __ATTR(writes, | |
1734 | 0664, | |
1735 | int_stats_show, | |
1736 | NULL); | |
1737 | ||
1738 | static struct attribute *stats_orangefs_default_attrs[] = { | |
1739 | &stats_reads_attribute.attr, | |
1740 | &stats_writes_attribute.attr, | |
1741 | NULL, | |
1742 | }; | |
1743 | ||
1744 | static struct kobj_type stats_orangefs_ktype = { | |
1745 | .sysfs_ops = &stats_orangefs_sysfs_ops, | |
1746 | .release = stats_orangefs_release, | |
1747 | .default_attrs = stats_orangefs_default_attrs, | |
1748 | }; | |
1749 | ||
1750 | static struct orangefs_obj *orangefs_obj; | |
1751 | static struct acache_orangefs_obj *acache_orangefs_obj; | |
1752 | static struct capcache_orangefs_obj *capcache_orangefs_obj; | |
1753 | static struct ccache_orangefs_obj *ccache_orangefs_obj; | |
1754 | static struct ncache_orangefs_obj *ncache_orangefs_obj; | |
1755 | static struct pc_orangefs_obj *pc_orangefs_obj; | |
1756 | static struct stats_orangefs_obj *stats_orangefs_obj; | |
1757 | ||
1758 | int orangefs_sysfs_init(void) | |
1759 | { | |
2180c52c | 1760 | int rc = -EINVAL; |
f7be4ee0 MM |
1761 | |
1762 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n"); | |
1763 | ||
1764 | /* create /sys/fs/orangefs. */ | |
1765 | orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL); | |
2180c52c | 1766 | if (!orangefs_obj) |
f7be4ee0 | 1767 | goto out; |
f7be4ee0 MM |
1768 | |
1769 | rc = kobject_init_and_add(&orangefs_obj->kobj, | |
1770 | &orangefs_ktype, | |
1771 | fs_kobj, | |
1772 | ORANGEFS_KOBJ_ID); | |
1773 | ||
2180c52c MM |
1774 | if (rc) |
1775 | goto ofs_obj_bail; | |
f7be4ee0 MM |
1776 | |
1777 | kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD); | |
1778 | ||
1779 | /* create /sys/fs/orangefs/acache. */ | |
1780 | acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); | |
1781 | if (!acache_orangefs_obj) { | |
1782 | rc = -EINVAL; | |
2180c52c | 1783 | goto ofs_obj_bail; |
f7be4ee0 MM |
1784 | } |
1785 | ||
1786 | rc = kobject_init_and_add(&acache_orangefs_obj->kobj, | |
1787 | &acache_orangefs_ktype, | |
1788 | &orangefs_obj->kobj, | |
1789 | ACACHE_KOBJ_ID); | |
1790 | ||
2180c52c MM |
1791 | if (rc) |
1792 | goto acache_obj_bail; | |
f7be4ee0 MM |
1793 | |
1794 | kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD); | |
1795 | ||
1796 | /* create /sys/fs/orangefs/capcache. */ | |
1797 | capcache_orangefs_obj = | |
1798 | kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL); | |
1799 | if (!capcache_orangefs_obj) { | |
1800 | rc = -EINVAL; | |
2180c52c | 1801 | goto acache_obj_bail; |
f7be4ee0 MM |
1802 | } |
1803 | ||
1804 | rc = kobject_init_and_add(&capcache_orangefs_obj->kobj, | |
1805 | &capcache_orangefs_ktype, | |
1806 | &orangefs_obj->kobj, | |
1807 | CAPCACHE_KOBJ_ID); | |
2180c52c MM |
1808 | if (rc) |
1809 | goto capcache_obj_bail; | |
f7be4ee0 MM |
1810 | |
1811 | kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD); | |
1812 | ||
1813 | /* create /sys/fs/orangefs/ccache. */ | |
1814 | ccache_orangefs_obj = | |
1815 | kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL); | |
1816 | if (!ccache_orangefs_obj) { | |
1817 | rc = -EINVAL; | |
2180c52c | 1818 | goto capcache_obj_bail; |
f7be4ee0 MM |
1819 | } |
1820 | ||
1821 | rc = kobject_init_and_add(&ccache_orangefs_obj->kobj, | |
1822 | &ccache_orangefs_ktype, | |
1823 | &orangefs_obj->kobj, | |
1824 | CCACHE_KOBJ_ID); | |
2180c52c MM |
1825 | if (rc) |
1826 | goto ccache_obj_bail; | |
f7be4ee0 MM |
1827 | |
1828 | kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD); | |
1829 | ||
1830 | /* create /sys/fs/orangefs/ncache. */ | |
1831 | ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); | |
1832 | if (!ncache_orangefs_obj) { | |
1833 | rc = -EINVAL; | |
2180c52c | 1834 | goto ccache_obj_bail; |
f7be4ee0 MM |
1835 | } |
1836 | ||
1837 | rc = kobject_init_and_add(&ncache_orangefs_obj->kobj, | |
1838 | &ncache_orangefs_ktype, | |
1839 | &orangefs_obj->kobj, | |
1840 | NCACHE_KOBJ_ID); | |
1841 | ||
2180c52c MM |
1842 | if (rc) |
1843 | goto ncache_obj_bail; | |
f7be4ee0 MM |
1844 | |
1845 | kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD); | |
1846 | ||
1847 | /* create /sys/fs/orangefs/perf_counters. */ | |
1848 | pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); | |
1849 | if (!pc_orangefs_obj) { | |
1850 | rc = -EINVAL; | |
2180c52c | 1851 | goto ncache_obj_bail; |
f7be4ee0 MM |
1852 | } |
1853 | ||
1854 | rc = kobject_init_and_add(&pc_orangefs_obj->kobj, | |
1855 | &pc_orangefs_ktype, | |
1856 | &orangefs_obj->kobj, | |
1857 | "perf_counters"); | |
1858 | ||
2180c52c MM |
1859 | if (rc) |
1860 | goto pc_obj_bail; | |
f7be4ee0 MM |
1861 | |
1862 | kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD); | |
1863 | ||
1864 | /* create /sys/fs/orangefs/stats. */ | |
1865 | stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); | |
1866 | if (!stats_orangefs_obj) { | |
1867 | rc = -EINVAL; | |
2180c52c | 1868 | goto pc_obj_bail; |
f7be4ee0 MM |
1869 | } |
1870 | ||
1871 | rc = kobject_init_and_add(&stats_orangefs_obj->kobj, | |
1872 | &stats_orangefs_ktype, | |
1873 | &orangefs_obj->kobj, | |
1874 | STATS_KOBJ_ID); | |
1875 | ||
2180c52c MM |
1876 | if (rc) |
1877 | goto stats_obj_bail; | |
f7be4ee0 MM |
1878 | |
1879 | kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD); | |
2180c52c MM |
1880 | goto out; |
1881 | ||
1882 | stats_obj_bail: | |
1883 | kobject_put(&stats_orangefs_obj->kobj); | |
1884 | ||
1885 | pc_obj_bail: | |
1886 | kobject_put(&pc_orangefs_obj->kobj); | |
1887 | ||
1888 | ncache_obj_bail: | |
1889 | kobject_put(&ncache_orangefs_obj->kobj); | |
1890 | ||
1891 | ccache_obj_bail: | |
1892 | kobject_put(&ccache_orangefs_obj->kobj); | |
1893 | ||
1894 | capcache_obj_bail: | |
1895 | kobject_put(&capcache_orangefs_obj->kobj); | |
1896 | ||
1897 | acache_obj_bail: | |
1898 | kobject_put(&acache_orangefs_obj->kobj); | |
1899 | ||
1900 | ofs_obj_bail: | |
1901 | kobject_put(&orangefs_obj->kobj); | |
f7be4ee0 MM |
1902 | out: |
1903 | return rc; | |
1904 | } | |
1905 | ||
1906 | void orangefs_sysfs_exit(void) | |
1907 | { | |
1908 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n"); | |
1909 | ||
1910 | kobject_put(&acache_orangefs_obj->kobj); | |
1911 | kobject_put(&capcache_orangefs_obj->kobj); | |
1912 | kobject_put(&ccache_orangefs_obj->kobj); | |
1913 | kobject_put(&ncache_orangefs_obj->kobj); | |
1914 | kobject_put(&pc_orangefs_obj->kobj); | |
1915 | kobject_put(&stats_orangefs_obj->kobj); | |
1916 | ||
1917 | kobject_put(&orangefs_obj->kobj); | |
1918 | } |