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