1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2575e9461SMike Marshall /*
344348e8aSMauro Carvalho Chehab * Documentation/ABI/stable/sysfs-fs-orangefs:
4575e9461SMike Marshall *
5575e9461SMike Marshall * What: /sys/fs/orangefs/perf_counter_reset
6575e9461SMike Marshall * Date: June 2015
7575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
8575e9461SMike Marshall * Description:
9575e9461SMike Marshall * echo a 0 or a 1 into perf_counter_reset to
10575e9461SMike Marshall * reset all the counters in
11575e9461SMike Marshall * /sys/fs/orangefs/perf_counters
12575e9461SMike Marshall * except ones with PINT_PERF_PRESERVE set.
13575e9461SMike Marshall *
14575e9461SMike Marshall *
15575e9461SMike Marshall * What: /sys/fs/orangefs/perf_counters/...
16575e9461SMike Marshall * Date: Jun 2015
17575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
18575e9461SMike Marshall * Description:
19575e9461SMike Marshall * Counters and settings for various caches.
20575e9461SMike Marshall * Read only.
21575e9461SMike Marshall *
22575e9461SMike Marshall *
23575e9461SMike Marshall * What: /sys/fs/orangefs/perf_time_interval_secs
24575e9461SMike Marshall * Date: Jun 2015
25575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
26575e9461SMike Marshall * Description:
27575e9461SMike Marshall * Length of perf counter intervals in
28575e9461SMike Marshall * seconds.
29575e9461SMike Marshall *
30575e9461SMike Marshall *
31575e9461SMike Marshall * What: /sys/fs/orangefs/perf_history_size
32575e9461SMike Marshall * Date: Jun 2015
33575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
34575e9461SMike Marshall * Description:
35575e9461SMike Marshall * The perf_counters cache statistics have N, or
36575e9461SMike Marshall * perf_history_size, samples. The default is
37575e9461SMike Marshall * one.
38575e9461SMike Marshall *
39575e9461SMike Marshall * Every perf_time_interval_secs the (first)
40575e9461SMike Marshall * samples are reset.
41575e9461SMike Marshall *
42575e9461SMike Marshall * If N is greater than one, the "current" set
43575e9461SMike Marshall * of samples is reset, and the samples from the
44575e9461SMike Marshall * other N-1 intervals remain available.
45575e9461SMike Marshall *
46575e9461SMike Marshall *
47575e9461SMike Marshall * What: /sys/fs/orangefs/op_timeout_secs
48575e9461SMike Marshall * Date: Jun 2015
49575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
50575e9461SMike Marshall * Description:
51575e9461SMike Marshall * Service operation timeout in seconds.
52575e9461SMike Marshall *
53575e9461SMike Marshall *
54575e9461SMike Marshall * What: /sys/fs/orangefs/slot_timeout_secs
55575e9461SMike Marshall * Date: Jun 2015
56575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
57575e9461SMike Marshall * Description:
58575e9461SMike Marshall * "Slot" timeout in seconds. A "slot"
59575e9461SMike Marshall * is an indexed buffer in the shared
60575e9461SMike Marshall * memory segment used for communication
61575e9461SMike Marshall * between the kernel module and userspace.
62575e9461SMike Marshall * Slots are requested and waited for,
63575e9461SMike Marshall * the wait times out after slot_timeout_secs.
64575e9461SMike Marshall *
658f04e1beSMartin Brandenburg * What: /sys/fs/orangefs/cache_timeout_msecs
668f04e1beSMartin Brandenburg * Date: Mar 2018
678f04e1beSMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
688f04e1beSMartin Brandenburg * Description:
698f04e1beSMartin Brandenburg * Time in milliseconds between which
708f04e1beSMartin Brandenburg * orangefs_revalidate_mapping will invalidate the page
718f04e1beSMartin Brandenburg * cache.
728f04e1beSMartin Brandenburg *
734cd8f319SMartin Brandenburg * What: /sys/fs/orangefs/dcache_timeout_msecs
744cd8f319SMartin Brandenburg * Date: Jul 2016
754cd8f319SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
764cd8f319SMartin Brandenburg * Description:
774cd8f319SMartin Brandenburg * Time lookup is valid in milliseconds.
784cd8f319SMartin Brandenburg *
794cd8f319SMartin Brandenburg * What: /sys/fs/orangefs/getattr_timeout_msecs
804cd8f319SMartin Brandenburg * Date: Jul 2016
814cd8f319SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
824cd8f319SMartin Brandenburg * Description:
834cd8f319SMartin Brandenburg * Time getattr is valid in milliseconds.
84575e9461SMike Marshall *
854d20a756SMartin Brandenburg * What: /sys/fs/orangefs/readahead_count
864d20a756SMartin Brandenburg * Date: Aug 2016
874d20a756SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
884d20a756SMartin Brandenburg * Description:
894d20a756SMartin Brandenburg * Readahead cache buffer count.
904d20a756SMartin Brandenburg *
914d20a756SMartin Brandenburg * What: /sys/fs/orangefs/readahead_size
924d20a756SMartin Brandenburg * Date: Aug 2016
934d20a756SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
944d20a756SMartin Brandenburg * Description:
954d20a756SMartin Brandenburg * Readahead cache buffer size.
964d20a756SMartin Brandenburg *
974d20a756SMartin Brandenburg * What: /sys/fs/orangefs/readahead_count_size
984d20a756SMartin Brandenburg * Date: Aug 2016
994d20a756SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
1004d20a756SMartin Brandenburg * Description:
1014d20a756SMartin Brandenburg * Readahead cache buffer count and size.
1024d20a756SMartin Brandenburg *
10331c829f3SMartin Brandenburg * What: /sys/fs/orangefs/readahead_readcnt
10431c829f3SMartin Brandenburg * Date: Jan 2017
10531c829f3SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
10631c829f3SMartin Brandenburg * Description:
10731c829f3SMartin Brandenburg * Number of buffers (in multiples of readahead_size)
10831c829f3SMartin Brandenburg * which can be read ahead for a single file at once.
10931c829f3SMartin Brandenburg *
110575e9461SMike Marshall * What: /sys/fs/orangefs/acache/...
111575e9461SMike Marshall * Date: Jun 2015
1124cd8f319SMartin Brandenburg * Contact: Martin Brandenburg <martin@omnibond.com>
113575e9461SMike Marshall * Description:
114575e9461SMike Marshall * Attribute cache configurable settings.
115575e9461SMike Marshall *
116575e9461SMike Marshall *
117575e9461SMike Marshall * What: /sys/fs/orangefs/ncache/...
118575e9461SMike Marshall * Date: Jun 2015
119575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
120575e9461SMike Marshall * Description:
121575e9461SMike Marshall * Name cache configurable settings.
122575e9461SMike Marshall *
123575e9461SMike Marshall *
124575e9461SMike Marshall * What: /sys/fs/orangefs/capcache/...
125575e9461SMike Marshall * Date: Jun 2015
126575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
127575e9461SMike Marshall * Description:
128575e9461SMike Marshall * Capability cache configurable settings.
129575e9461SMike Marshall *
130575e9461SMike Marshall *
131575e9461SMike Marshall * What: /sys/fs/orangefs/ccache/...
132575e9461SMike Marshall * Date: Jun 2015
133575e9461SMike Marshall * Contact: Mike Marshall <hubcap@omnibond.com>
134575e9461SMike Marshall * Description:
135575e9461SMike Marshall * Credential cache configurable settings.
136575e9461SMike Marshall *
137575e9461SMike Marshall */
138575e9461SMike Marshall
139575e9461SMike Marshall #include <linux/fs.h>
140575e9461SMike Marshall #include <linux/kobject.h>
141575e9461SMike Marshall #include <linux/string.h>
142575e9461SMike Marshall #include <linux/sysfs.h>
143575e9461SMike Marshall #include <linux/module.h>
144575e9461SMike Marshall #include <linux/init.h>
145575e9461SMike Marshall
146575e9461SMike Marshall #include "protocol.h"
147575e9461SMike Marshall #include "orangefs-kernel.h"
148575e9461SMike Marshall #include "orangefs-sysfs.h"
149575e9461SMike Marshall
150575e9461SMike Marshall #define ORANGEFS_KOBJ_ID "orangefs"
151575e9461SMike Marshall #define ACACHE_KOBJ_ID "acache"
152575e9461SMike Marshall #define CAPCACHE_KOBJ_ID "capcache"
153575e9461SMike Marshall #define CCACHE_KOBJ_ID "ccache"
154575e9461SMike Marshall #define NCACHE_KOBJ_ID "ncache"
155575e9461SMike Marshall #define PC_KOBJ_ID "pc"
156575e9461SMike Marshall #define STATS_KOBJ_ID "stats"
157575e9461SMike Marshall
158c27889cdSMartin Brandenburg /*
159c27889cdSMartin Brandenburg * Every item calls orangefs_attr_show and orangefs_attr_store through
160c27889cdSMartin Brandenburg * orangefs_sysfs_ops. They look at the orangefs_attributes further below to
161c27889cdSMartin Brandenburg * call one of sysfs_int_show, sysfs_int_store, sysfs_service_op_show, or
162c27889cdSMartin Brandenburg * sysfs_service_op_store.
163c27889cdSMartin Brandenburg */
164575e9461SMike Marshall
165575e9461SMike Marshall struct orangefs_attribute {
166575e9461SMike Marshall struct attribute attr;
1677b0cae60SMartin Brandenburg ssize_t (*show)(struct kobject *kobj,
168575e9461SMike Marshall struct orangefs_attribute *attr,
169575e9461SMike Marshall char *buf);
1707b0cae60SMartin Brandenburg ssize_t (*store)(struct kobject *kobj,
171575e9461SMike Marshall struct orangefs_attribute *attr,
172575e9461SMike Marshall const char *buf,
173575e9461SMike Marshall size_t count);
174575e9461SMike Marshall };
175575e9461SMike Marshall
orangefs_attr_show(struct kobject * kobj,struct attribute * attr,char * buf)176575e9461SMike Marshall static ssize_t orangefs_attr_show(struct kobject *kobj,
177575e9461SMike Marshall struct attribute *attr,
178575e9461SMike Marshall char *buf)
179575e9461SMike Marshall {
180575e9461SMike Marshall struct orangefs_attribute *attribute;
181575e9461SMike Marshall
182575e9461SMike Marshall attribute = container_of(attr, struct orangefs_attribute, attr);
1834a343664SMartin Brandenburg if (!attribute->show)
1844a343664SMartin Brandenburg return -EIO;
1854a343664SMartin Brandenburg return attribute->show(kobj, attribute, buf);
186575e9461SMike Marshall }
187575e9461SMike Marshall
orangefs_attr_store(struct kobject * kobj,struct attribute * attr,const char * buf,size_t len)188575e9461SMike Marshall static ssize_t orangefs_attr_store(struct kobject *kobj,
189575e9461SMike Marshall struct attribute *attr,
190575e9461SMike Marshall const char *buf,
191575e9461SMike Marshall size_t len)
192575e9461SMike Marshall {
193575e9461SMike Marshall struct orangefs_attribute *attribute;
194575e9461SMike Marshall
1954a343664SMartin Brandenburg if (!strcmp(kobj->name, PC_KOBJ_ID) ||
1964a343664SMartin Brandenburg !strcmp(kobj->name, STATS_KOBJ_ID))
1974a343664SMartin Brandenburg return -EPERM;
198575e9461SMike Marshall
199575e9461SMike Marshall attribute = container_of(attr, struct orangefs_attribute, attr);
2004a343664SMartin Brandenburg if (!attribute->store)
2014a343664SMartin Brandenburg return -EIO;
2024a343664SMartin Brandenburg return attribute->store(kobj, attribute, buf, len);
203575e9461SMike Marshall }
204575e9461SMike Marshall
205575e9461SMike Marshall static const struct sysfs_ops orangefs_sysfs_ops = {
206575e9461SMike Marshall .show = orangefs_attr_show,
207575e9461SMike Marshall .store = orangefs_attr_store,
208575e9461SMike Marshall };
209575e9461SMike Marshall
sysfs_int_show(struct kobject * kobj,struct orangefs_attribute * attr,char * buf)2107b0cae60SMartin Brandenburg static ssize_t sysfs_int_show(struct kobject *kobj,
2117b0cae60SMartin Brandenburg struct orangefs_attribute *attr, char *buf)
212575e9461SMike Marshall {
213575e9461SMike Marshall int rc = -EIO;
214575e9461SMike Marshall
2157b0cae60SMartin Brandenburg gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n",
2167b0cae60SMartin Brandenburg kobj->name);
217575e9461SMike Marshall
2187b0cae60SMartin Brandenburg if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
2197b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "op_timeout_secs")) {
220575e9461SMike Marshall rc = scnprintf(buf,
221575e9461SMike Marshall PAGE_SIZE,
222575e9461SMike Marshall "%d\n",
223575e9461SMike Marshall op_timeout_secs);
224575e9461SMike Marshall goto out;
2257b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
226575e9461SMike Marshall "slot_timeout_secs")) {
227575e9461SMike Marshall rc = scnprintf(buf,
228575e9461SMike Marshall PAGE_SIZE,
229575e9461SMike Marshall "%d\n",
230575e9461SMike Marshall slot_timeout_secs);
231575e9461SMike Marshall goto out;
2327b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
2338f04e1beSMartin Brandenburg "cache_timeout_msecs")) {
2348f04e1beSMartin Brandenburg rc = scnprintf(buf,
2358f04e1beSMartin Brandenburg PAGE_SIZE,
2368f04e1beSMartin Brandenburg "%d\n",
2378f04e1beSMartin Brandenburg orangefs_cache_timeout_msecs);
2388f04e1beSMartin Brandenburg goto out;
2398f04e1beSMartin Brandenburg } else if (!strcmp(attr->attr.name,
2404cd8f319SMartin Brandenburg "dcache_timeout_msecs")) {
2414cd8f319SMartin Brandenburg rc = scnprintf(buf,
2424cd8f319SMartin Brandenburg PAGE_SIZE,
2434cd8f319SMartin Brandenburg "%d\n",
2441d503617SMartin Brandenburg orangefs_dcache_timeout_msecs);
2454cd8f319SMartin Brandenburg goto out;
2467b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
2474cd8f319SMartin Brandenburg "getattr_timeout_msecs")) {
2484cd8f319SMartin Brandenburg rc = scnprintf(buf,
2494cd8f319SMartin Brandenburg PAGE_SIZE,
2504cd8f319SMartin Brandenburg "%d\n",
2511d503617SMartin Brandenburg orangefs_getattr_timeout_msecs);
2524cd8f319SMartin Brandenburg goto out;
253575e9461SMike Marshall } else {
254575e9461SMike Marshall goto out;
255575e9461SMike Marshall }
256575e9461SMike Marshall
2577b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) {
2587b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "reads")) {
259575e9461SMike Marshall rc = scnprintf(buf,
260575e9461SMike Marshall PAGE_SIZE,
261575e9461SMike Marshall "%lu\n",
262889d5f1bSMartin Brandenburg orangefs_stats.reads);
263575e9461SMike Marshall goto out;
2647b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "writes")) {
265575e9461SMike Marshall rc = scnprintf(buf,
266575e9461SMike Marshall PAGE_SIZE,
267575e9461SMike Marshall "%lu\n",
268889d5f1bSMartin Brandenburg orangefs_stats.writes);
269575e9461SMike Marshall goto out;
270575e9461SMike Marshall } else {
271575e9461SMike Marshall goto out;
272575e9461SMike Marshall }
273575e9461SMike Marshall }
274575e9461SMike Marshall
275575e9461SMike Marshall out:
276575e9461SMike Marshall
277575e9461SMike Marshall return rc;
278575e9461SMike Marshall }
279575e9461SMike Marshall
sysfs_int_store(struct kobject * kobj,struct orangefs_attribute * attr,const char * buf,size_t count)2807b0cae60SMartin Brandenburg static ssize_t sysfs_int_store(struct kobject *kobj,
2817b0cae60SMartin Brandenburg struct orangefs_attribute *attr, const char *buf, size_t count)
282575e9461SMike Marshall {
283575e9461SMike Marshall int rc = 0;
284575e9461SMike Marshall
285575e9461SMike Marshall gossip_debug(GOSSIP_SYSFS_DEBUG,
2867b0cae60SMartin Brandenburg "sysfs_int_store: start attr->attr.name:%s: buf:%s:\n",
287575e9461SMike Marshall attr->attr.name, buf);
288575e9461SMike Marshall
289575e9461SMike Marshall if (!strcmp(attr->attr.name, "op_timeout_secs")) {
290575e9461SMike Marshall rc = kstrtoint(buf, 0, &op_timeout_secs);
291575e9461SMike Marshall goto out;
292575e9461SMike Marshall } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) {
293575e9461SMike Marshall rc = kstrtoint(buf, 0, &slot_timeout_secs);
294575e9461SMike Marshall goto out;
2958f04e1beSMartin Brandenburg } else if (!strcmp(attr->attr.name, "cache_timeout_msecs")) {
2968f04e1beSMartin Brandenburg rc = kstrtoint(buf, 0, &orangefs_cache_timeout_msecs);
2978f04e1beSMartin Brandenburg goto out;
2984cd8f319SMartin Brandenburg } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) {
2991d503617SMartin Brandenburg rc = kstrtoint(buf, 0, &orangefs_dcache_timeout_msecs);
3004cd8f319SMartin Brandenburg goto out;
3014cd8f319SMartin Brandenburg } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) {
3021d503617SMartin Brandenburg rc = kstrtoint(buf, 0, &orangefs_getattr_timeout_msecs);
3034cd8f319SMartin Brandenburg goto out;
304575e9461SMike Marshall } else {
305575e9461SMike Marshall goto out;
306575e9461SMike Marshall }
307575e9461SMike Marshall
308575e9461SMike Marshall out:
309575e9461SMike Marshall if (rc)
310575e9461SMike Marshall rc = -EINVAL;
311575e9461SMike Marshall else
312575e9461SMike Marshall rc = count;
313575e9461SMike Marshall
314575e9461SMike Marshall return rc;
315575e9461SMike Marshall }
316575e9461SMike Marshall
317575e9461SMike Marshall /*
318575e9461SMike Marshall * obtain attribute values from userspace with a service operation.
319575e9461SMike Marshall */
sysfs_service_op_show(struct kobject * kobj,struct orangefs_attribute * attr,char * buf)3207b0cae60SMartin Brandenburg static ssize_t sysfs_service_op_show(struct kobject *kobj,
3217b0cae60SMartin Brandenburg struct orangefs_attribute *attr, char *buf)
322575e9461SMike Marshall {
323575e9461SMike Marshall struct orangefs_kernel_op_s *new_op = NULL;
324575e9461SMike Marshall int rc = 0;
325575e9461SMike Marshall char *ser_op_type = NULL;
326575e9461SMike Marshall __u32 op_alloc_type;
327575e9461SMike Marshall
328575e9461SMike Marshall gossip_debug(GOSSIP_SYSFS_DEBUG,
329575e9461SMike Marshall "sysfs_service_op_show: id:%s:\n",
3307b0cae60SMartin Brandenburg kobj->name);
331575e9461SMike Marshall
3327b0cae60SMartin Brandenburg if (strcmp(kobj->name, PC_KOBJ_ID))
333575e9461SMike Marshall op_alloc_type = ORANGEFS_VFS_OP_PARAM;
334575e9461SMike Marshall else
335575e9461SMike Marshall op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT;
336575e9461SMike Marshall
337575e9461SMike Marshall new_op = op_alloc(op_alloc_type);
338ed42fe05SAl Viro if (!new_op)
339ed42fe05SAl Viro return -ENOMEM;
340575e9461SMike Marshall
341575e9461SMike Marshall /* Can't do a service_operation if the client is not running... */
342575e9461SMike Marshall rc = is_daemon_in_service();
343575e9461SMike Marshall if (rc) {
3442978d873SColin Ian King pr_info_ratelimited("%s: Client not running :%d:\n",
345575e9461SMike Marshall __func__,
346575e9461SMike Marshall is_daemon_in_service());
347575e9461SMike Marshall goto out;
348575e9461SMike Marshall }
349575e9461SMike Marshall
3507b0cae60SMartin Brandenburg if (strcmp(kobj->name, PC_KOBJ_ID))
351575e9461SMike Marshall new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET;
352575e9461SMike Marshall
3537b0cae60SMartin Brandenburg if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
354c51e0129SMartin Brandenburg /* Drop unsupported requests first. */
355c51e0129SMartin Brandenburg if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
356b78b1198SMartin Brandenburg (!strcmp(attr->attr.name, "readahead_count") ||
357b78b1198SMartin Brandenburg !strcmp(attr->attr.name, "readahead_size") ||
35831c829f3SMartin Brandenburg !strcmp(attr->attr.name, "readahead_count_size") ||
35931c829f3SMartin Brandenburg !strcmp(attr->attr.name, "readahead_readcnt"))) {
360c51e0129SMartin Brandenburg rc = -EINVAL;
361c51e0129SMartin Brandenburg goto out;
362c51e0129SMartin Brandenburg }
363c51e0129SMartin Brandenburg
3647b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "perf_history_size"))
365575e9461SMike Marshall new_op->upcall.req.param.op =
366575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
3677b0cae60SMartin Brandenburg else if (!strcmp(attr->attr.name,
368575e9461SMike Marshall "perf_time_interval_secs"))
369575e9461SMike Marshall new_op->upcall.req.param.op =
370575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
3717b0cae60SMartin Brandenburg else if (!strcmp(attr->attr.name,
372575e9461SMike Marshall "perf_counter_reset"))
373575e9461SMike Marshall new_op->upcall.req.param.op =
374575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
375575e9461SMike Marshall
3767b0cae60SMartin Brandenburg else if (!strcmp(attr->attr.name,
3774d20a756SMartin Brandenburg "readahead_count"))
3784d20a756SMartin Brandenburg new_op->upcall.req.param.op =
3794d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
3804d20a756SMartin Brandenburg
3817b0cae60SMartin Brandenburg else if (!strcmp(attr->attr.name,
3824d20a756SMartin Brandenburg "readahead_size"))
3834d20a756SMartin Brandenburg new_op->upcall.req.param.op =
3844d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
3854d20a756SMartin Brandenburg
3867b0cae60SMartin Brandenburg else if (!strcmp(attr->attr.name,
3874d20a756SMartin Brandenburg "readahead_count_size"))
3884d20a756SMartin Brandenburg new_op->upcall.req.param.op =
3894d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
39031c829f3SMartin Brandenburg
39131c829f3SMartin Brandenburg else if (!strcmp(attr->attr.name,
39231c829f3SMartin Brandenburg "readahead_readcnt"))
39331c829f3SMartin Brandenburg new_op->upcall.req.param.op =
39431c829f3SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT;
3957b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
3967b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "timeout_msecs"))
397575e9461SMike Marshall new_op->upcall.req.param.op =
398575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
399575e9461SMike Marshall
4007b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit"))
401575e9461SMike Marshall new_op->upcall.req.param.op =
402575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
403575e9461SMike Marshall
4047b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "soft_limit"))
405575e9461SMike Marshall new_op->upcall.req.param.op =
406575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
407575e9461SMike Marshall
4087b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "reclaim_percentage"))
409575e9461SMike Marshall new_op->upcall.req.param.op =
410575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
411575e9461SMike Marshall
4127b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
4137b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "timeout_secs"))
414575e9461SMike Marshall new_op->upcall.req.param.op =
415575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
416575e9461SMike Marshall
4177b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit"))
418575e9461SMike Marshall new_op->upcall.req.param.op =
419575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
420575e9461SMike Marshall
4217b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "soft_limit"))
422575e9461SMike Marshall new_op->upcall.req.param.op =
423575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
424575e9461SMike Marshall
4257b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "reclaim_percentage"))
426575e9461SMike Marshall new_op->upcall.req.param.op =
427575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
428575e9461SMike Marshall
4297b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
4307b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "timeout_secs"))
431575e9461SMike Marshall new_op->upcall.req.param.op =
432575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
433575e9461SMike Marshall
4347b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit"))
435575e9461SMike Marshall new_op->upcall.req.param.op =
436575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
437575e9461SMike Marshall
4387b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "soft_limit"))
439575e9461SMike Marshall new_op->upcall.req.param.op =
440575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
441575e9461SMike Marshall
4427b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "reclaim_percentage"))
443575e9461SMike Marshall new_op->upcall.req.param.op =
444575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
445575e9461SMike Marshall
4467b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
4477b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "timeout_msecs"))
448575e9461SMike Marshall new_op->upcall.req.param.op =
449575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
450575e9461SMike Marshall
4517b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit"))
452575e9461SMike Marshall new_op->upcall.req.param.op =
453575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
454575e9461SMike Marshall
4557b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "soft_limit"))
456575e9461SMike Marshall new_op->upcall.req.param.op =
457575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
458575e9461SMike Marshall
4597b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "reclaim_percentage"))
460575e9461SMike Marshall new_op->upcall.req.param.op =
461575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
462575e9461SMike Marshall
4637b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, PC_KOBJ_ID)) {
4647b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID))
465575e9461SMike Marshall new_op->upcall.req.perf_count.type =
466575e9461SMike Marshall ORANGEFS_PERF_COUNT_REQUEST_ACACHE;
467575e9461SMike Marshall
4687b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID))
469575e9461SMike Marshall new_op->upcall.req.perf_count.type =
470575e9461SMike Marshall ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE;
471575e9461SMike Marshall
4727b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID))
473575e9461SMike Marshall new_op->upcall.req.perf_count.type =
474575e9461SMike Marshall ORANGEFS_PERF_COUNT_REQUEST_NCACHE;
475575e9461SMike Marshall
476575e9461SMike Marshall } else {
477575e9461SMike Marshall gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n",
4787b0cae60SMartin Brandenburg kobj->name);
479575e9461SMike Marshall rc = -EINVAL;
480575e9461SMike Marshall goto out;
481575e9461SMike Marshall }
482575e9461SMike Marshall
483575e9461SMike Marshall
4847b0cae60SMartin Brandenburg if (strcmp(kobj->name, PC_KOBJ_ID))
485575e9461SMike Marshall ser_op_type = "orangefs_param";
486575e9461SMike Marshall else
487575e9461SMike Marshall ser_op_type = "orangefs_perf_count";
488575e9461SMike Marshall
489575e9461SMike Marshall /*
490575e9461SMike Marshall * The service_operation will return an errno return code on
491575e9461SMike Marshall * error, and zero on success.
492575e9461SMike Marshall */
493575e9461SMike Marshall rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE);
494575e9461SMike Marshall
495575e9461SMike Marshall out:
496575e9461SMike Marshall if (!rc) {
4977b0cae60SMartin Brandenburg if (strcmp(kobj->name, PC_KOBJ_ID)) {
4984d20a756SMartin Brandenburg if (new_op->upcall.req.param.op ==
4994d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) {
5004d20a756SMartin Brandenburg rc = scnprintf(buf, PAGE_SIZE, "%d %d\n",
5014d20a756SMartin Brandenburg (int)new_op->downcall.resp.param.u.
5024d20a756SMartin Brandenburg value32[0],
5034d20a756SMartin Brandenburg (int)new_op->downcall.resp.param.u.
5044d20a756SMartin Brandenburg value32[1]);
5054d20a756SMartin Brandenburg } else {
506680908e5SMartin Brandenburg rc = scnprintf(buf, PAGE_SIZE, "%d\n",
507680908e5SMartin Brandenburg (int)new_op->downcall.resp.param.u.value64);
5084d20a756SMartin Brandenburg }
509575e9461SMike Marshall } else {
510575e9461SMike Marshall rc = scnprintf(
511575e9461SMike Marshall buf,
512575e9461SMike Marshall PAGE_SIZE,
513575e9461SMike Marshall "%s",
514575e9461SMike Marshall new_op->downcall.resp.perf_count.buffer);
515575e9461SMike Marshall }
516575e9461SMike Marshall }
517575e9461SMike Marshall
518575e9461SMike Marshall op_release(new_op);
519575e9461SMike Marshall
520575e9461SMike Marshall return rc;
521575e9461SMike Marshall
522575e9461SMike Marshall }
523575e9461SMike Marshall
524575e9461SMike Marshall /*
525575e9461SMike Marshall * pass attribute values back to userspace with a service operation.
526575e9461SMike Marshall *
527575e9461SMike Marshall * We have to do a memory allocation, an sscanf and a service operation.
528575e9461SMike Marshall * And we have to evaluate what the user entered, to make sure the
529575e9461SMike Marshall * value is within the range supported by the attribute. So, there's
530575e9461SMike Marshall * a lot of return code checking and mapping going on here.
531575e9461SMike Marshall *
532575e9461SMike Marshall * We want to return 1 if we think everything went OK, and
533575e9461SMike Marshall * EINVAL if not.
534575e9461SMike Marshall */
sysfs_service_op_store(struct kobject * kobj,struct orangefs_attribute * attr,const char * buf,size_t count)5357b0cae60SMartin Brandenburg static ssize_t sysfs_service_op_store(struct kobject *kobj,
5367b0cae60SMartin Brandenburg struct orangefs_attribute *attr, const char *buf, size_t count)
537575e9461SMike Marshall {
538575e9461SMike Marshall struct orangefs_kernel_op_s *new_op = NULL;
539575e9461SMike Marshall int val = 0;
540575e9461SMike Marshall int rc = 0;
541575e9461SMike Marshall
542575e9461SMike Marshall gossip_debug(GOSSIP_SYSFS_DEBUG,
543575e9461SMike Marshall "sysfs_service_op_store: id:%s:\n",
5447b0cae60SMartin Brandenburg kobj->name);
545575e9461SMike Marshall
546575e9461SMike Marshall new_op = op_alloc(ORANGEFS_VFS_OP_PARAM);
547ed42fe05SAl Viro if (!new_op)
548ed42fe05SAl Viro return -EINVAL; /* sic */
549575e9461SMike Marshall
550575e9461SMike Marshall /* Can't do a service_operation if the client is not running... */
551575e9461SMike Marshall rc = is_daemon_in_service();
552575e9461SMike Marshall if (rc) {
553575e9461SMike Marshall pr_info("%s: Client not running :%d:\n",
554575e9461SMike Marshall __func__,
555575e9461SMike Marshall is_daemon_in_service());
556575e9461SMike Marshall goto out;
557575e9461SMike Marshall }
558575e9461SMike Marshall
559575e9461SMike Marshall /*
5604d20a756SMartin Brandenburg * The value we want to send back to userspace is in buf, unless this
5614d20a756SMartin Brandenburg * there are two parameters, which is specially handled below.
562575e9461SMike Marshall */
5637b0cae60SMartin Brandenburg if (strcmp(kobj->name, ORANGEFS_KOBJ_ID) ||
5647b0cae60SMartin Brandenburg strcmp(attr->attr.name, "readahead_count_size")) {
565575e9461SMike Marshall rc = kstrtoint(buf, 0, &val);
566575e9461SMike Marshall if (rc)
567575e9461SMike Marshall goto out;
5684d20a756SMartin Brandenburg }
5694d20a756SMartin Brandenburg
5704d20a756SMartin Brandenburg new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET;
571575e9461SMike Marshall
5727b0cae60SMartin Brandenburg if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) {
573c51e0129SMartin Brandenburg /* Drop unsupported requests first. */
574c51e0129SMartin Brandenburg if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
575b78b1198SMartin Brandenburg (!strcmp(attr->attr.name, "readahead_count") ||
576b78b1198SMartin Brandenburg !strcmp(attr->attr.name, "readahead_size") ||
57731c829f3SMartin Brandenburg !strcmp(attr->attr.name, "readahead_count_size") ||
57831c829f3SMartin Brandenburg !strcmp(attr->attr.name, "readahead_readcnt"))) {
579c51e0129SMartin Brandenburg rc = -EINVAL;
580c51e0129SMartin Brandenburg goto out;
581c51e0129SMartin Brandenburg }
582575e9461SMike Marshall
5837b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "perf_history_size")) {
584575e9461SMike Marshall if (val > 0) {
585575e9461SMike Marshall new_op->upcall.req.param.op =
586575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
587575e9461SMike Marshall } else {
588575e9461SMike Marshall rc = 0;
589575e9461SMike Marshall goto out;
590575e9461SMike Marshall }
5917b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
592575e9461SMike Marshall "perf_time_interval_secs")) {
593575e9461SMike Marshall if (val > 0) {
594575e9461SMike Marshall new_op->upcall.req.param.op =
595575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS;
596575e9461SMike Marshall } else {
597575e9461SMike Marshall rc = 0;
598575e9461SMike Marshall goto out;
599575e9461SMike Marshall }
6007b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
601575e9461SMike Marshall "perf_counter_reset")) {
602575e9461SMike Marshall if ((val == 0) || (val == 1)) {
603575e9461SMike Marshall new_op->upcall.req.param.op =
604575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_PERF_RESET;
605575e9461SMike Marshall } else {
606575e9461SMike Marshall rc = 0;
607575e9461SMike Marshall goto out;
608575e9461SMike Marshall }
6097b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
6104d20a756SMartin Brandenburg "readahead_count")) {
6114d20a756SMartin Brandenburg if ((val >= 0)) {
6124d20a756SMartin Brandenburg new_op->upcall.req.param.op =
6134d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT;
6144d20a756SMartin Brandenburg } else {
6154d20a756SMartin Brandenburg rc = 0;
6164d20a756SMartin Brandenburg goto out;
6174d20a756SMartin Brandenburg }
6187b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
6194d20a756SMartin Brandenburg "readahead_size")) {
6204d20a756SMartin Brandenburg if ((val >= 0)) {
6214d20a756SMartin Brandenburg new_op->upcall.req.param.op =
6224d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE;
6234d20a756SMartin Brandenburg } else {
6244d20a756SMartin Brandenburg rc = 0;
6254d20a756SMartin Brandenburg goto out;
6264d20a756SMartin Brandenburg }
6277b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
6284d20a756SMartin Brandenburg "readahead_count_size")) {
6294d20a756SMartin Brandenburg int val1, val2;
6304d20a756SMartin Brandenburg rc = sscanf(buf, "%d %d", &val1, &val2);
6314d20a756SMartin Brandenburg if (rc < 2) {
6324d20a756SMartin Brandenburg rc = 0;
6334d20a756SMartin Brandenburg goto out;
6344d20a756SMartin Brandenburg }
6354d20a756SMartin Brandenburg if ((val1 >= 0) && (val2 >= 0)) {
6364d20a756SMartin Brandenburg new_op->upcall.req.param.op =
6374d20a756SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE;
6384d20a756SMartin Brandenburg } else {
6394d20a756SMartin Brandenburg rc = 0;
6404d20a756SMartin Brandenburg goto out;
6414d20a756SMartin Brandenburg }
6424d20a756SMartin Brandenburg new_op->upcall.req.param.u.value32[0] = val1;
6434d20a756SMartin Brandenburg new_op->upcall.req.param.u.value32[1] = val2;
6444d20a756SMartin Brandenburg goto value_set;
64531c829f3SMartin Brandenburg } else if (!strcmp(attr->attr.name,
64631c829f3SMartin Brandenburg "readahead_readcnt")) {
64731c829f3SMartin Brandenburg if ((val >= 0)) {
64831c829f3SMartin Brandenburg new_op->upcall.req.param.op =
64931c829f3SMartin Brandenburg ORANGEFS_PARAM_REQUEST_OP_READAHEAD_READCNT;
65031c829f3SMartin Brandenburg } else {
65131c829f3SMartin Brandenburg rc = 0;
65231c829f3SMartin Brandenburg goto out;
65331c829f3SMartin Brandenburg }
654575e9461SMike Marshall }
655575e9461SMike Marshall
6567b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) {
6577b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit")) {
658575e9461SMike Marshall if (val > -1) {
659575e9461SMike Marshall new_op->upcall.req.param.op =
660575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT;
661575e9461SMike Marshall } else {
662575e9461SMike Marshall rc = 0;
663575e9461SMike Marshall goto out;
664575e9461SMike Marshall }
6657b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "soft_limit")) {
666575e9461SMike Marshall if (val > -1) {
667575e9461SMike Marshall new_op->upcall.req.param.op =
668575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT;
669575e9461SMike Marshall } else {
670575e9461SMike Marshall rc = 0;
671575e9461SMike Marshall goto out;
672575e9461SMike Marshall }
6737b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
674575e9461SMike Marshall "reclaim_percentage")) {
675575e9461SMike Marshall if ((val > -1) && (val < 101)) {
676575e9461SMike Marshall new_op->upcall.req.param.op =
677575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE;
678575e9461SMike Marshall } else {
679575e9461SMike Marshall rc = 0;
680575e9461SMike Marshall goto out;
681575e9461SMike Marshall }
6827b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
683575e9461SMike Marshall if (val > -1) {
684575e9461SMike Marshall new_op->upcall.req.param.op =
685575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS;
686575e9461SMike Marshall } else {
687575e9461SMike Marshall rc = 0;
688575e9461SMike Marshall goto out;
689575e9461SMike Marshall }
690575e9461SMike Marshall }
691575e9461SMike Marshall
6927b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) {
6937b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit")) {
694575e9461SMike Marshall if (val > -1) {
695575e9461SMike Marshall new_op->upcall.req.param.op =
696575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT;
697575e9461SMike Marshall } else {
698575e9461SMike Marshall rc = 0;
699575e9461SMike Marshall goto out;
700575e9461SMike Marshall }
7017b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "soft_limit")) {
702575e9461SMike Marshall if (val > -1) {
703575e9461SMike Marshall new_op->upcall.req.param.op =
704575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT;
705575e9461SMike Marshall } else {
706575e9461SMike Marshall rc = 0;
707575e9461SMike Marshall goto out;
708575e9461SMike Marshall }
7097b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
710575e9461SMike Marshall "reclaim_percentage")) {
711575e9461SMike Marshall if ((val > -1) && (val < 101)) {
712575e9461SMike Marshall new_op->upcall.req.param.op =
713575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE;
714575e9461SMike Marshall } else {
715575e9461SMike Marshall rc = 0;
716575e9461SMike Marshall goto out;
717575e9461SMike Marshall }
7187b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "timeout_secs")) {
719575e9461SMike Marshall if (val > -1) {
720575e9461SMike Marshall new_op->upcall.req.param.op =
721575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS;
722575e9461SMike Marshall } else {
723575e9461SMike Marshall rc = 0;
724575e9461SMike Marshall goto out;
725575e9461SMike Marshall }
726575e9461SMike Marshall }
727575e9461SMike Marshall
7287b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) {
7297b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit")) {
730575e9461SMike Marshall if (val > -1) {
731575e9461SMike Marshall new_op->upcall.req.param.op =
732575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT;
733575e9461SMike Marshall } else {
734575e9461SMike Marshall rc = 0;
735575e9461SMike Marshall goto out;
736575e9461SMike Marshall }
7377b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "soft_limit")) {
738575e9461SMike Marshall if (val > -1) {
739575e9461SMike Marshall new_op->upcall.req.param.op =
740575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT;
741575e9461SMike Marshall } else {
742575e9461SMike Marshall rc = 0;
743575e9461SMike Marshall goto out;
744575e9461SMike Marshall }
7457b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
746575e9461SMike Marshall "reclaim_percentage")) {
747575e9461SMike Marshall if ((val > -1) && (val < 101)) {
748575e9461SMike Marshall new_op->upcall.req.param.op =
749575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE;
750575e9461SMike Marshall } else {
751575e9461SMike Marshall rc = 0;
752575e9461SMike Marshall goto out;
753575e9461SMike Marshall }
7547b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "timeout_secs")) {
755575e9461SMike Marshall if (val > -1) {
756575e9461SMike Marshall new_op->upcall.req.param.op =
757575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS;
758575e9461SMike Marshall } else {
759575e9461SMike Marshall rc = 0;
760575e9461SMike Marshall goto out;
761575e9461SMike Marshall }
762575e9461SMike Marshall }
763575e9461SMike Marshall
7647b0cae60SMartin Brandenburg } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) {
7657b0cae60SMartin Brandenburg if (!strcmp(attr->attr.name, "hard_limit")) {
766575e9461SMike Marshall if (val > -1) {
767575e9461SMike Marshall new_op->upcall.req.param.op =
768575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT;
769575e9461SMike Marshall } else {
770575e9461SMike Marshall rc = 0;
771575e9461SMike Marshall goto out;
772575e9461SMike Marshall }
7737b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "soft_limit")) {
774575e9461SMike Marshall if (val > -1) {
775575e9461SMike Marshall new_op->upcall.req.param.op =
776575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT;
777575e9461SMike Marshall } else {
778575e9461SMike Marshall rc = 0;
779575e9461SMike Marshall goto out;
780575e9461SMike Marshall }
7817b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name,
782575e9461SMike Marshall "reclaim_percentage")) {
783575e9461SMike Marshall if ((val > -1) && (val < 101)) {
784575e9461SMike Marshall new_op->upcall.req.param.op =
785575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE;
786575e9461SMike Marshall } else {
787575e9461SMike Marshall rc = 0;
788575e9461SMike Marshall goto out;
789575e9461SMike Marshall }
7907b0cae60SMartin Brandenburg } else if (!strcmp(attr->attr.name, "timeout_msecs")) {
791575e9461SMike Marshall if (val > -1) {
792575e9461SMike Marshall new_op->upcall.req.param.op =
793575e9461SMike Marshall ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS;
794575e9461SMike Marshall } else {
795575e9461SMike Marshall rc = 0;
796575e9461SMike Marshall goto out;
797575e9461SMike Marshall }
798575e9461SMike Marshall }
799575e9461SMike Marshall
800575e9461SMike Marshall } else {
801575e9461SMike Marshall gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n",
8027b0cae60SMartin Brandenburg kobj->name);
803575e9461SMike Marshall rc = -EINVAL;
804575e9461SMike Marshall goto out;
805575e9461SMike Marshall }
806575e9461SMike Marshall
807680908e5SMartin Brandenburg new_op->upcall.req.param.u.value64 = val;
8084d20a756SMartin Brandenburg value_set:
809575e9461SMike Marshall
810575e9461SMike Marshall /*
811575e9461SMike Marshall * The service_operation will return a errno return code on
812575e9461SMike Marshall * error, and zero on success.
813575e9461SMike Marshall */
814575e9461SMike Marshall rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE);
815575e9461SMike Marshall
816575e9461SMike Marshall if (rc < 0) {
817575e9461SMike Marshall gossip_err("sysfs_service_op_store: service op returned:%d:\n",
818575e9461SMike Marshall rc);
819575e9461SMike Marshall rc = 0;
820575e9461SMike Marshall } else {
8217b0cae60SMartin Brandenburg rc = count;
822575e9461SMike Marshall }
823575e9461SMike Marshall
824575e9461SMike Marshall out:
825575e9461SMike Marshall op_release(new_op);
826575e9461SMike Marshall
827ed42fe05SAl Viro if (rc == -ENOMEM || rc == 0)
828575e9461SMike Marshall rc = -EINVAL;
829575e9461SMike Marshall
830575e9461SMike Marshall return rc;
831575e9461SMike Marshall }
832575e9461SMike Marshall
833575e9461SMike Marshall static struct orangefs_attribute op_timeout_secs_attribute =
8347b0cae60SMartin Brandenburg __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
835575e9461SMike Marshall
836575e9461SMike Marshall static struct orangefs_attribute slot_timeout_secs_attribute =
8377b0cae60SMartin Brandenburg __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store);
838575e9461SMike Marshall
8398f04e1beSMartin Brandenburg static struct orangefs_attribute cache_timeout_msecs_attribute =
8408f04e1beSMartin Brandenburg __ATTR(cache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
8418f04e1beSMartin Brandenburg
8424cd8f319SMartin Brandenburg static struct orangefs_attribute dcache_timeout_msecs_attribute =
8437b0cae60SMartin Brandenburg __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
8444cd8f319SMartin Brandenburg
8454cd8f319SMartin Brandenburg static struct orangefs_attribute getattr_timeout_msecs_attribute =
8467b0cae60SMartin Brandenburg __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store);
8474cd8f319SMartin Brandenburg
8484d20a756SMartin Brandenburg static struct orangefs_attribute readahead_count_attribute =
8497b0cae60SMartin Brandenburg __ATTR(readahead_count, 0664, sysfs_service_op_show,
8507b0cae60SMartin Brandenburg sysfs_service_op_store);
8514d20a756SMartin Brandenburg
8524d20a756SMartin Brandenburg static struct orangefs_attribute readahead_size_attribute =
8537b0cae60SMartin Brandenburg __ATTR(readahead_size, 0664, sysfs_service_op_show,
8547b0cae60SMartin Brandenburg sysfs_service_op_store);
8554d20a756SMartin Brandenburg
8564d20a756SMartin Brandenburg static struct orangefs_attribute readahead_count_size_attribute =
8577b0cae60SMartin Brandenburg __ATTR(readahead_count_size, 0664, sysfs_service_op_show,
8587b0cae60SMartin Brandenburg sysfs_service_op_store);
8594d20a756SMartin Brandenburg
86031c829f3SMartin Brandenburg static struct orangefs_attribute readahead_readcnt_attribute =
86131c829f3SMartin Brandenburg __ATTR(readahead_readcnt, 0664, sysfs_service_op_show,
86231c829f3SMartin Brandenburg sysfs_service_op_store);
86331c829f3SMartin Brandenburg
864575e9461SMike Marshall static struct orangefs_attribute perf_counter_reset_attribute =
865575e9461SMike Marshall __ATTR(perf_counter_reset,
866575e9461SMike Marshall 0664,
8677b0cae60SMartin Brandenburg sysfs_service_op_show,
8687b0cae60SMartin Brandenburg sysfs_service_op_store);
869575e9461SMike Marshall
870575e9461SMike Marshall static struct orangefs_attribute perf_history_size_attribute =
871575e9461SMike Marshall __ATTR(perf_history_size,
872575e9461SMike Marshall 0664,
8737b0cae60SMartin Brandenburg sysfs_service_op_show,
8747b0cae60SMartin Brandenburg sysfs_service_op_store);
875575e9461SMike Marshall
876575e9461SMike Marshall static struct orangefs_attribute perf_time_interval_secs_attribute =
877575e9461SMike Marshall __ATTR(perf_time_interval_secs,
878575e9461SMike Marshall 0664,
8797b0cae60SMartin Brandenburg sysfs_service_op_show,
8807b0cae60SMartin Brandenburg sysfs_service_op_store);
881575e9461SMike Marshall
882575e9461SMike Marshall static struct attribute *orangefs_default_attrs[] = {
883575e9461SMike Marshall &op_timeout_secs_attribute.attr,
884575e9461SMike Marshall &slot_timeout_secs_attribute.attr,
8858f04e1beSMartin Brandenburg &cache_timeout_msecs_attribute.attr,
8864cd8f319SMartin Brandenburg &dcache_timeout_msecs_attribute.attr,
8874cd8f319SMartin Brandenburg &getattr_timeout_msecs_attribute.attr,
8884d20a756SMartin Brandenburg &readahead_count_attribute.attr,
8894d20a756SMartin Brandenburg &readahead_size_attribute.attr,
8904d20a756SMartin Brandenburg &readahead_count_size_attribute.attr,
89131c829f3SMartin Brandenburg &readahead_readcnt_attribute.attr,
892575e9461SMike Marshall &perf_counter_reset_attribute.attr,
893575e9461SMike Marshall &perf_history_size_attribute.attr,
894575e9461SMike Marshall &perf_time_interval_secs_attribute.attr,
895575e9461SMike Marshall NULL,
896575e9461SMike Marshall };
897063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(orangefs_default);
898575e9461SMike Marshall
8991f2c0e8aSZhang Xiaoxu static struct kobject *orangefs_obj;
9001f2c0e8aSZhang Xiaoxu
orangefs_obj_release(struct kobject * kobj)9011f2c0e8aSZhang Xiaoxu static void orangefs_obj_release(struct kobject *kobj)
9021f2c0e8aSZhang Xiaoxu {
9031f2c0e8aSZhang Xiaoxu kfree(orangefs_obj);
9041f2c0e8aSZhang Xiaoxu orangefs_obj = NULL;
9051f2c0e8aSZhang Xiaoxu }
9061f2c0e8aSZhang Xiaoxu
907*96319dacSHuang Xiaojia static const struct kobj_type orangefs_ktype = {
908575e9461SMike Marshall .sysfs_ops = &orangefs_sysfs_ops,
909063e458cSGreg Kroah-Hartman .default_groups = orangefs_default_groups,
9101f2c0e8aSZhang Xiaoxu .release = orangefs_obj_release,
911575e9461SMike Marshall };
912575e9461SMike Marshall
9132e9f80daSMartin Brandenburg static struct orangefs_attribute acache_hard_limit_attribute =
914575e9461SMike Marshall __ATTR(hard_limit,
915575e9461SMike Marshall 0664,
9167b0cae60SMartin Brandenburg sysfs_service_op_show,
9177b0cae60SMartin Brandenburg sysfs_service_op_store);
918575e9461SMike Marshall
9192e9f80daSMartin Brandenburg static struct orangefs_attribute acache_reclaim_percent_attribute =
920575e9461SMike Marshall __ATTR(reclaim_percentage,
921575e9461SMike Marshall 0664,
9227b0cae60SMartin Brandenburg sysfs_service_op_show,
9237b0cae60SMartin Brandenburg sysfs_service_op_store);
924575e9461SMike Marshall
9252e9f80daSMartin Brandenburg static struct orangefs_attribute acache_soft_limit_attribute =
926575e9461SMike Marshall __ATTR(soft_limit,
927575e9461SMike Marshall 0664,
9287b0cae60SMartin Brandenburg sysfs_service_op_show,
9297b0cae60SMartin Brandenburg sysfs_service_op_store);
930575e9461SMike Marshall
9312e9f80daSMartin Brandenburg static struct orangefs_attribute acache_timeout_msecs_attribute =
932575e9461SMike Marshall __ATTR(timeout_msecs,
933575e9461SMike Marshall 0664,
9347b0cae60SMartin Brandenburg sysfs_service_op_show,
9357b0cae60SMartin Brandenburg sysfs_service_op_store);
936575e9461SMike Marshall
937575e9461SMike Marshall static struct attribute *acache_orangefs_default_attrs[] = {
938575e9461SMike Marshall &acache_hard_limit_attribute.attr,
939575e9461SMike Marshall &acache_reclaim_percent_attribute.attr,
940575e9461SMike Marshall &acache_soft_limit_attribute.attr,
941575e9461SMike Marshall &acache_timeout_msecs_attribute.attr,
942575e9461SMike Marshall NULL,
943575e9461SMike Marshall };
944063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(acache_orangefs_default);
945575e9461SMike Marshall
9461f2c0e8aSZhang Xiaoxu static struct kobject *acache_orangefs_obj;
9471f2c0e8aSZhang Xiaoxu
acache_orangefs_obj_release(struct kobject * kobj)9481f2c0e8aSZhang Xiaoxu static void acache_orangefs_obj_release(struct kobject *kobj)
9491f2c0e8aSZhang Xiaoxu {
9501f2c0e8aSZhang Xiaoxu kfree(acache_orangefs_obj);
9511f2c0e8aSZhang Xiaoxu acache_orangefs_obj = NULL;
9521f2c0e8aSZhang Xiaoxu }
9531f2c0e8aSZhang Xiaoxu
954*96319dacSHuang Xiaojia static const struct kobj_type acache_orangefs_ktype = {
9554a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
956063e458cSGreg Kroah-Hartman .default_groups = acache_orangefs_default_groups,
9571f2c0e8aSZhang Xiaoxu .release = acache_orangefs_obj_release,
958575e9461SMike Marshall };
959575e9461SMike Marshall
9602e9f80daSMartin Brandenburg static struct orangefs_attribute capcache_hard_limit_attribute =
961575e9461SMike Marshall __ATTR(hard_limit,
962575e9461SMike Marshall 0664,
9637b0cae60SMartin Brandenburg sysfs_service_op_show,
9647b0cae60SMartin Brandenburg sysfs_service_op_store);
965575e9461SMike Marshall
9662e9f80daSMartin Brandenburg static struct orangefs_attribute capcache_reclaim_percent_attribute =
967575e9461SMike Marshall __ATTR(reclaim_percentage,
968575e9461SMike Marshall 0664,
9697b0cae60SMartin Brandenburg sysfs_service_op_show,
9707b0cae60SMartin Brandenburg sysfs_service_op_store);
971575e9461SMike Marshall
9722e9f80daSMartin Brandenburg static struct orangefs_attribute capcache_soft_limit_attribute =
973575e9461SMike Marshall __ATTR(soft_limit,
974575e9461SMike Marshall 0664,
9757b0cae60SMartin Brandenburg sysfs_service_op_show,
9767b0cae60SMartin Brandenburg sysfs_service_op_store);
977575e9461SMike Marshall
9782e9f80daSMartin Brandenburg static struct orangefs_attribute capcache_timeout_secs_attribute =
979575e9461SMike Marshall __ATTR(timeout_secs,
980575e9461SMike Marshall 0664,
9817b0cae60SMartin Brandenburg sysfs_service_op_show,
9827b0cae60SMartin Brandenburg sysfs_service_op_store);
983575e9461SMike Marshall
984575e9461SMike Marshall static struct attribute *capcache_orangefs_default_attrs[] = {
985575e9461SMike Marshall &capcache_hard_limit_attribute.attr,
986575e9461SMike Marshall &capcache_reclaim_percent_attribute.attr,
987575e9461SMike Marshall &capcache_soft_limit_attribute.attr,
988575e9461SMike Marshall &capcache_timeout_secs_attribute.attr,
989575e9461SMike Marshall NULL,
990575e9461SMike Marshall };
991063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(capcache_orangefs_default);
992575e9461SMike Marshall
9931f2c0e8aSZhang Xiaoxu static struct kobject *capcache_orangefs_obj;
9941f2c0e8aSZhang Xiaoxu
capcache_orangefs_obj_release(struct kobject * kobj)9951f2c0e8aSZhang Xiaoxu static void capcache_orangefs_obj_release(struct kobject *kobj)
9961f2c0e8aSZhang Xiaoxu {
9971f2c0e8aSZhang Xiaoxu kfree(capcache_orangefs_obj);
9981f2c0e8aSZhang Xiaoxu capcache_orangefs_obj = NULL;
9991f2c0e8aSZhang Xiaoxu }
10001f2c0e8aSZhang Xiaoxu
1001*96319dacSHuang Xiaojia static const struct kobj_type capcache_orangefs_ktype = {
10024a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
1003063e458cSGreg Kroah-Hartman .default_groups = capcache_orangefs_default_groups,
10041f2c0e8aSZhang Xiaoxu .release = capcache_orangefs_obj_release,
1005575e9461SMike Marshall };
1006575e9461SMike Marshall
10072e9f80daSMartin Brandenburg static struct orangefs_attribute ccache_hard_limit_attribute =
1008575e9461SMike Marshall __ATTR(hard_limit,
1009575e9461SMike Marshall 0664,
10107b0cae60SMartin Brandenburg sysfs_service_op_show,
10117b0cae60SMartin Brandenburg sysfs_service_op_store);
1012575e9461SMike Marshall
10132e9f80daSMartin Brandenburg static struct orangefs_attribute ccache_reclaim_percent_attribute =
1014575e9461SMike Marshall __ATTR(reclaim_percentage,
1015575e9461SMike Marshall 0664,
10167b0cae60SMartin Brandenburg sysfs_service_op_show,
10177b0cae60SMartin Brandenburg sysfs_service_op_store);
1018575e9461SMike Marshall
10192e9f80daSMartin Brandenburg static struct orangefs_attribute ccache_soft_limit_attribute =
1020575e9461SMike Marshall __ATTR(soft_limit,
1021575e9461SMike Marshall 0664,
10227b0cae60SMartin Brandenburg sysfs_service_op_show,
10237b0cae60SMartin Brandenburg sysfs_service_op_store);
1024575e9461SMike Marshall
10252e9f80daSMartin Brandenburg static struct orangefs_attribute ccache_timeout_secs_attribute =
1026575e9461SMike Marshall __ATTR(timeout_secs,
1027575e9461SMike Marshall 0664,
10287b0cae60SMartin Brandenburg sysfs_service_op_show,
10297b0cae60SMartin Brandenburg sysfs_service_op_store);
1030575e9461SMike Marshall
1031575e9461SMike Marshall static struct attribute *ccache_orangefs_default_attrs[] = {
1032575e9461SMike Marshall &ccache_hard_limit_attribute.attr,
1033575e9461SMike Marshall &ccache_reclaim_percent_attribute.attr,
1034575e9461SMike Marshall &ccache_soft_limit_attribute.attr,
1035575e9461SMike Marshall &ccache_timeout_secs_attribute.attr,
1036575e9461SMike Marshall NULL,
1037575e9461SMike Marshall };
1038063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(ccache_orangefs_default);
1039575e9461SMike Marshall
10401f2c0e8aSZhang Xiaoxu static struct kobject *ccache_orangefs_obj;
10411f2c0e8aSZhang Xiaoxu
ccache_orangefs_obj_release(struct kobject * kobj)10421f2c0e8aSZhang Xiaoxu static void ccache_orangefs_obj_release(struct kobject *kobj)
10431f2c0e8aSZhang Xiaoxu {
10441f2c0e8aSZhang Xiaoxu kfree(ccache_orangefs_obj);
10451f2c0e8aSZhang Xiaoxu ccache_orangefs_obj = NULL;
10461f2c0e8aSZhang Xiaoxu }
10471f2c0e8aSZhang Xiaoxu
1048*96319dacSHuang Xiaojia static const struct kobj_type ccache_orangefs_ktype = {
10494a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
1050063e458cSGreg Kroah-Hartman .default_groups = ccache_orangefs_default_groups,
10511f2c0e8aSZhang Xiaoxu .release = ccache_orangefs_obj_release,
1052575e9461SMike Marshall };
1053575e9461SMike Marshall
10542e9f80daSMartin Brandenburg static struct orangefs_attribute ncache_hard_limit_attribute =
1055575e9461SMike Marshall __ATTR(hard_limit,
1056575e9461SMike Marshall 0664,
10577b0cae60SMartin Brandenburg sysfs_service_op_show,
10587b0cae60SMartin Brandenburg sysfs_service_op_store);
1059575e9461SMike Marshall
10602e9f80daSMartin Brandenburg static struct orangefs_attribute ncache_reclaim_percent_attribute =
1061575e9461SMike Marshall __ATTR(reclaim_percentage,
1062575e9461SMike Marshall 0664,
10637b0cae60SMartin Brandenburg sysfs_service_op_show,
10647b0cae60SMartin Brandenburg sysfs_service_op_store);
1065575e9461SMike Marshall
10662e9f80daSMartin Brandenburg static struct orangefs_attribute ncache_soft_limit_attribute =
1067575e9461SMike Marshall __ATTR(soft_limit,
1068575e9461SMike Marshall 0664,
10697b0cae60SMartin Brandenburg sysfs_service_op_show,
10707b0cae60SMartin Brandenburg sysfs_service_op_store);
1071575e9461SMike Marshall
10722e9f80daSMartin Brandenburg static struct orangefs_attribute ncache_timeout_msecs_attribute =
1073575e9461SMike Marshall __ATTR(timeout_msecs,
1074575e9461SMike Marshall 0664,
10757b0cae60SMartin Brandenburg sysfs_service_op_show,
10767b0cae60SMartin Brandenburg sysfs_service_op_store);
1077575e9461SMike Marshall
1078575e9461SMike Marshall static struct attribute *ncache_orangefs_default_attrs[] = {
1079575e9461SMike Marshall &ncache_hard_limit_attribute.attr,
1080575e9461SMike Marshall &ncache_reclaim_percent_attribute.attr,
1081575e9461SMike Marshall &ncache_soft_limit_attribute.attr,
1082575e9461SMike Marshall &ncache_timeout_msecs_attribute.attr,
1083575e9461SMike Marshall NULL,
1084575e9461SMike Marshall };
1085063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(ncache_orangefs_default);
1086575e9461SMike Marshall
10871f2c0e8aSZhang Xiaoxu static struct kobject *ncache_orangefs_obj;
10881f2c0e8aSZhang Xiaoxu
ncache_orangefs_obj_release(struct kobject * kobj)10891f2c0e8aSZhang Xiaoxu static void ncache_orangefs_obj_release(struct kobject *kobj)
10901f2c0e8aSZhang Xiaoxu {
10911f2c0e8aSZhang Xiaoxu kfree(ncache_orangefs_obj);
10921f2c0e8aSZhang Xiaoxu ncache_orangefs_obj = NULL;
10931f2c0e8aSZhang Xiaoxu }
10941f2c0e8aSZhang Xiaoxu
1095*96319dacSHuang Xiaojia static const struct kobj_type ncache_orangefs_ktype = {
10964a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
1097063e458cSGreg Kroah-Hartman .default_groups = ncache_orangefs_default_groups,
10981f2c0e8aSZhang Xiaoxu .release = ncache_orangefs_obj_release,
1099575e9461SMike Marshall };
1100575e9461SMike Marshall
11012e9f80daSMartin Brandenburg static struct orangefs_attribute pc_acache_attribute =
1102575e9461SMike Marshall __ATTR(acache,
1103575e9461SMike Marshall 0664,
11047b0cae60SMartin Brandenburg sysfs_service_op_show,
1105575e9461SMike Marshall NULL);
1106575e9461SMike Marshall
11072e9f80daSMartin Brandenburg static struct orangefs_attribute pc_capcache_attribute =
1108575e9461SMike Marshall __ATTR(capcache,
1109575e9461SMike Marshall 0664,
11107b0cae60SMartin Brandenburg sysfs_service_op_show,
1111575e9461SMike Marshall NULL);
1112575e9461SMike Marshall
11132e9f80daSMartin Brandenburg static struct orangefs_attribute pc_ncache_attribute =
1114575e9461SMike Marshall __ATTR(ncache,
1115575e9461SMike Marshall 0664,
11167b0cae60SMartin Brandenburg sysfs_service_op_show,
1117575e9461SMike Marshall NULL);
1118575e9461SMike Marshall
1119575e9461SMike Marshall static struct attribute *pc_orangefs_default_attrs[] = {
1120575e9461SMike Marshall &pc_acache_attribute.attr,
1121575e9461SMike Marshall &pc_capcache_attribute.attr,
1122575e9461SMike Marshall &pc_ncache_attribute.attr,
1123575e9461SMike Marshall NULL,
1124575e9461SMike Marshall };
1125063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(pc_orangefs_default);
1126575e9461SMike Marshall
11271f2c0e8aSZhang Xiaoxu static struct kobject *pc_orangefs_obj;
11281f2c0e8aSZhang Xiaoxu
pc_orangefs_obj_release(struct kobject * kobj)11291f2c0e8aSZhang Xiaoxu static void pc_orangefs_obj_release(struct kobject *kobj)
11301f2c0e8aSZhang Xiaoxu {
11311f2c0e8aSZhang Xiaoxu kfree(pc_orangefs_obj);
11321f2c0e8aSZhang Xiaoxu pc_orangefs_obj = NULL;
11331f2c0e8aSZhang Xiaoxu }
11341f2c0e8aSZhang Xiaoxu
1135*96319dacSHuang Xiaojia static const struct kobj_type pc_orangefs_ktype = {
11364a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
1137063e458cSGreg Kroah-Hartman .default_groups = pc_orangefs_default_groups,
11381f2c0e8aSZhang Xiaoxu .release = pc_orangefs_obj_release,
1139575e9461SMike Marshall };
1140575e9461SMike Marshall
11412e9f80daSMartin Brandenburg static struct orangefs_attribute stats_reads_attribute =
1142575e9461SMike Marshall __ATTR(reads,
1143575e9461SMike Marshall 0664,
11447b0cae60SMartin Brandenburg sysfs_int_show,
1145575e9461SMike Marshall NULL);
1146575e9461SMike Marshall
11472e9f80daSMartin Brandenburg static struct orangefs_attribute stats_writes_attribute =
1148575e9461SMike Marshall __ATTR(writes,
1149575e9461SMike Marshall 0664,
11507b0cae60SMartin Brandenburg sysfs_int_show,
1151575e9461SMike Marshall NULL);
1152575e9461SMike Marshall
1153575e9461SMike Marshall static struct attribute *stats_orangefs_default_attrs[] = {
1154575e9461SMike Marshall &stats_reads_attribute.attr,
1155575e9461SMike Marshall &stats_writes_attribute.attr,
1156575e9461SMike Marshall NULL,
1157575e9461SMike Marshall };
1158063e458cSGreg Kroah-Hartman ATTRIBUTE_GROUPS(stats_orangefs_default);
1159575e9461SMike Marshall
11601f2c0e8aSZhang Xiaoxu static struct kobject *stats_orangefs_obj;
11611f2c0e8aSZhang Xiaoxu
stats_orangefs_obj_release(struct kobject * kobj)11621f2c0e8aSZhang Xiaoxu static void stats_orangefs_obj_release(struct kobject *kobj)
11631f2c0e8aSZhang Xiaoxu {
11641f2c0e8aSZhang Xiaoxu kfree(stats_orangefs_obj);
11651f2c0e8aSZhang Xiaoxu stats_orangefs_obj = NULL;
11661f2c0e8aSZhang Xiaoxu }
11671f2c0e8aSZhang Xiaoxu
1168*96319dacSHuang Xiaojia static const struct kobj_type stats_orangefs_ktype = {
11694a343664SMartin Brandenburg .sysfs_ops = &orangefs_sysfs_ops,
1170063e458cSGreg Kroah-Hartman .default_groups = stats_orangefs_default_groups,
11711f2c0e8aSZhang Xiaoxu .release = stats_orangefs_obj_release,
1172575e9461SMike Marshall };
1173575e9461SMike Marshall
orangefs_sysfs_init(void)1174575e9461SMike Marshall int orangefs_sysfs_init(void)
1175575e9461SMike Marshall {
11762180c52cSMike Marshall int rc = -EINVAL;
1177575e9461SMike Marshall
1178575e9461SMike Marshall gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1179575e9461SMike Marshall
1180575e9461SMike Marshall /* create /sys/fs/orangefs. */
1181575e9461SMike Marshall orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
11822180c52cSMike Marshall if (!orangefs_obj)
1183575e9461SMike Marshall goto out;
1184575e9461SMike Marshall
1185dc3012a7SMartin Brandenburg rc = kobject_init_and_add(orangefs_obj,
1186575e9461SMike Marshall &orangefs_ktype,
1187575e9461SMike Marshall fs_kobj,
1188575e9461SMike Marshall ORANGEFS_KOBJ_ID);
1189575e9461SMike Marshall
11902180c52cSMike Marshall if (rc)
11912180c52cSMike Marshall goto ofs_obj_bail;
1192575e9461SMike Marshall
1193dc3012a7SMartin Brandenburg kobject_uevent(orangefs_obj, KOBJ_ADD);
1194575e9461SMike Marshall
1195575e9461SMike Marshall /* create /sys/fs/orangefs/acache. */
1196575e9461SMike Marshall acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1197575e9461SMike Marshall if (!acache_orangefs_obj) {
1198575e9461SMike Marshall rc = -EINVAL;
11992180c52cSMike Marshall goto ofs_obj_bail;
1200575e9461SMike Marshall }
1201575e9461SMike Marshall
1202dc3012a7SMartin Brandenburg rc = kobject_init_and_add(acache_orangefs_obj,
1203575e9461SMike Marshall &acache_orangefs_ktype,
1204dc3012a7SMartin Brandenburg orangefs_obj,
1205575e9461SMike Marshall ACACHE_KOBJ_ID);
1206575e9461SMike Marshall
12072180c52cSMike Marshall if (rc)
12082180c52cSMike Marshall goto acache_obj_bail;
1209575e9461SMike Marshall
1210dc3012a7SMartin Brandenburg kobject_uevent(acache_orangefs_obj, KOBJ_ADD);
1211575e9461SMike Marshall
1212575e9461SMike Marshall /* create /sys/fs/orangefs/capcache. */
1213575e9461SMike Marshall capcache_orangefs_obj =
1214575e9461SMike Marshall kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1215575e9461SMike Marshall if (!capcache_orangefs_obj) {
1216575e9461SMike Marshall rc = -EINVAL;
12172180c52cSMike Marshall goto acache_obj_bail;
1218575e9461SMike Marshall }
1219575e9461SMike Marshall
1220dc3012a7SMartin Brandenburg rc = kobject_init_and_add(capcache_orangefs_obj,
1221575e9461SMike Marshall &capcache_orangefs_ktype,
1222dc3012a7SMartin Brandenburg orangefs_obj,
1223575e9461SMike Marshall CAPCACHE_KOBJ_ID);
12242180c52cSMike Marshall if (rc)
12252180c52cSMike Marshall goto capcache_obj_bail;
1226575e9461SMike Marshall
1227dc3012a7SMartin Brandenburg kobject_uevent(capcache_orangefs_obj, KOBJ_ADD);
1228575e9461SMike Marshall
1229575e9461SMike Marshall /* create /sys/fs/orangefs/ccache. */
1230575e9461SMike Marshall ccache_orangefs_obj =
1231575e9461SMike Marshall kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1232575e9461SMike Marshall if (!ccache_orangefs_obj) {
1233575e9461SMike Marshall rc = -EINVAL;
12342180c52cSMike Marshall goto capcache_obj_bail;
1235575e9461SMike Marshall }
1236575e9461SMike Marshall
1237dc3012a7SMartin Brandenburg rc = kobject_init_and_add(ccache_orangefs_obj,
1238575e9461SMike Marshall &ccache_orangefs_ktype,
1239dc3012a7SMartin Brandenburg orangefs_obj,
1240575e9461SMike Marshall CCACHE_KOBJ_ID);
12412180c52cSMike Marshall if (rc)
12422180c52cSMike Marshall goto ccache_obj_bail;
1243575e9461SMike Marshall
1244dc3012a7SMartin Brandenburg kobject_uevent(ccache_orangefs_obj, KOBJ_ADD);
1245575e9461SMike Marshall
1246575e9461SMike Marshall /* create /sys/fs/orangefs/ncache. */
1247575e9461SMike Marshall ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1248575e9461SMike Marshall if (!ncache_orangefs_obj) {
1249575e9461SMike Marshall rc = -EINVAL;
12502180c52cSMike Marshall goto ccache_obj_bail;
1251575e9461SMike Marshall }
1252575e9461SMike Marshall
1253dc3012a7SMartin Brandenburg rc = kobject_init_and_add(ncache_orangefs_obj,
1254575e9461SMike Marshall &ncache_orangefs_ktype,
1255dc3012a7SMartin Brandenburg orangefs_obj,
1256575e9461SMike Marshall NCACHE_KOBJ_ID);
1257575e9461SMike Marshall
12582180c52cSMike Marshall if (rc)
12592180c52cSMike Marshall goto ncache_obj_bail;
1260575e9461SMike Marshall
1261dc3012a7SMartin Brandenburg kobject_uevent(ncache_orangefs_obj, KOBJ_ADD);
1262575e9461SMike Marshall
1263575e9461SMike Marshall /* create /sys/fs/orangefs/perf_counters. */
1264575e9461SMike Marshall pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1265575e9461SMike Marshall if (!pc_orangefs_obj) {
1266575e9461SMike Marshall rc = -EINVAL;
12672180c52cSMike Marshall goto ncache_obj_bail;
1268575e9461SMike Marshall }
1269575e9461SMike Marshall
1270dc3012a7SMartin Brandenburg rc = kobject_init_and_add(pc_orangefs_obj,
1271575e9461SMike Marshall &pc_orangefs_ktype,
1272dc3012a7SMartin Brandenburg orangefs_obj,
1273575e9461SMike Marshall "perf_counters");
1274575e9461SMike Marshall
12752180c52cSMike Marshall if (rc)
12762180c52cSMike Marshall goto pc_obj_bail;
1277575e9461SMike Marshall
1278dc3012a7SMartin Brandenburg kobject_uevent(pc_orangefs_obj, KOBJ_ADD);
1279575e9461SMike Marshall
1280575e9461SMike Marshall /* create /sys/fs/orangefs/stats. */
1281575e9461SMike Marshall stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1282575e9461SMike Marshall if (!stats_orangefs_obj) {
1283575e9461SMike Marshall rc = -EINVAL;
12842180c52cSMike Marshall goto pc_obj_bail;
1285575e9461SMike Marshall }
1286575e9461SMike Marshall
1287dc3012a7SMartin Brandenburg rc = kobject_init_and_add(stats_orangefs_obj,
1288575e9461SMike Marshall &stats_orangefs_ktype,
1289dc3012a7SMartin Brandenburg orangefs_obj,
1290575e9461SMike Marshall STATS_KOBJ_ID);
1291575e9461SMike Marshall
12922180c52cSMike Marshall if (rc)
12932180c52cSMike Marshall goto stats_obj_bail;
1294575e9461SMike Marshall
1295dc3012a7SMartin Brandenburg kobject_uevent(stats_orangefs_obj, KOBJ_ADD);
12962180c52cSMike Marshall goto out;
12972180c52cSMike Marshall
12982180c52cSMike Marshall stats_obj_bail:
1299dc3012a7SMartin Brandenburg kobject_put(stats_orangefs_obj);
13002180c52cSMike Marshall pc_obj_bail:
1301dc3012a7SMartin Brandenburg kobject_put(pc_orangefs_obj);
13022180c52cSMike Marshall ncache_obj_bail:
1303dc3012a7SMartin Brandenburg kobject_put(ncache_orangefs_obj);
13042180c52cSMike Marshall ccache_obj_bail:
1305dc3012a7SMartin Brandenburg kobject_put(ccache_orangefs_obj);
13062180c52cSMike Marshall capcache_obj_bail:
1307dc3012a7SMartin Brandenburg kobject_put(capcache_orangefs_obj);
13082180c52cSMike Marshall acache_obj_bail:
1309dc3012a7SMartin Brandenburg kobject_put(acache_orangefs_obj);
13102180c52cSMike Marshall ofs_obj_bail:
1311dc3012a7SMartin Brandenburg kobject_put(orangefs_obj);
1312575e9461SMike Marshall out:
1313575e9461SMike Marshall return rc;
1314575e9461SMike Marshall }
1315575e9461SMike Marshall
orangefs_sysfs_exit(void)1316575e9461SMike Marshall void orangefs_sysfs_exit(void)
1317575e9461SMike Marshall {
1318575e9461SMike Marshall gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n");
1319dc3012a7SMartin Brandenburg kobject_put(acache_orangefs_obj);
1320dc3012a7SMartin Brandenburg kobject_put(capcache_orangefs_obj);
1321dc3012a7SMartin Brandenburg kobject_put(ccache_orangefs_obj);
1322dc3012a7SMartin Brandenburg kobject_put(ncache_orangefs_obj);
1323dc3012a7SMartin Brandenburg kobject_put(pc_orangefs_obj);
1324dc3012a7SMartin Brandenburg kobject_put(stats_orangefs_obj);
1325dc3012a7SMartin Brandenburg kobject_put(orangefs_obj);
1326575e9461SMike Marshall }
1327