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