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