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