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