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 | c27889c | 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 | */ |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 148 | |
| 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, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 152 | struct orangefs_attribute *attr, |
| 153 | char *buf); |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 154 | ssize_t (*store)(struct kobject *kobj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 155 | struct orangefs_attribute *attr, |
| 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", |
Martin Brandenburg | 1d50361 | 2016-08-16 11:38:14 -0400 | [diff] [blame] | 221 | orangefs_dcache_timeout_msecs); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 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", |
Martin Brandenburg | 1d50361 | 2016-08-16 11:38:14 -0400 | [diff] [blame] | 228 | orangefs_getattr_timeout_msecs); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 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", |
Martin Brandenburg | 889d5f1 | 2016-08-15 15:33:42 -0400 | [diff] [blame] | 239 | 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", |
Martin Brandenburg | 889d5f1 | 2016-08-15 15:33:42 -0400 | [diff] [blame] | 245 | 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")) { |
Martin Brandenburg | 1d50361 | 2016-08-16 11:38:14 -0400 | [diff] [blame] | 273 | rc = kstrtoint(buf, 0, &orangefs_dcache_timeout_msecs); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 274 | goto out; |
| 275 | } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { |
Martin Brandenburg | 1d50361 | 2016-08-16 11:38:14 -0400 | [diff] [blame] | 276 | rc = kstrtoint(buf, 0, &orangefs_getattr_timeout_msecs); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 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)) { |
Martin Brandenburg | c51e012 | 2016-08-12 16:12:09 -0400 | [diff] [blame] | 328 | /* Drop unsupported requests first. */ |
| 329 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && |
Martin Brandenburg | b78b119 | 2016-09-28 14:50:46 -0400 | [diff] [blame] | 330 | (!strcmp(attr->attr.name, "readahead_count") || |
| 331 | !strcmp(attr->attr.name, "readahead_size") || |
| 332 | !strcmp(attr->attr.name, "readahead_count_size"))) { |
Martin Brandenburg | c51e012 | 2016-08-12 16:12:09 -0400 | [diff] [blame] | 333 | rc = -EINVAL; |
| 334 | goto out; |
| 335 | } |
| 336 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 337 | if (!strcmp(attr->attr.name, "perf_history_size")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 338 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 339 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 340 | else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 341 | "perf_time_interval_secs")) |
| 342 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 343 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 344 | else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 345 | "perf_counter_reset")) |
| 346 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 347 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 348 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 349 | else if (!strcmp(attr->attr.name, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 350 | "readahead_count")) |
| 351 | new_op->upcall.req.param.op = |
| 352 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; |
| 353 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 354 | else if (!strcmp(attr->attr.name, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 355 | "readahead_size")) |
| 356 | new_op->upcall.req.param.op = |
| 357 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; |
| 358 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 359 | else if (!strcmp(attr->attr.name, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 360 | "readahead_count_size")) |
| 361 | new_op->upcall.req.param.op = |
| 362 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 363 | } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) { |
| 364 | if (!strcmp(attr->attr.name, "timeout_msecs")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 365 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 366 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 367 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 368 | if (!strcmp(attr->attr.name, "hard_limit")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 369 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 370 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 371 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 372 | if (!strcmp(attr->attr.name, "soft_limit")) |
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_ACACHE_SOFT_LIMIT; |
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, "reclaim_percentage")) |
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_ACACHE_RECLAIM_PERCENTAGE; |
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 | } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) { |
| 381 | if (!strcmp(attr->attr.name, "timeout_secs")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 382 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 383 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 384 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 385 | if (!strcmp(attr->attr.name, "hard_limit")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 386 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 387 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 388 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 389 | if (!strcmp(attr->attr.name, "soft_limit")) |
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_CAPCACHE_SOFT_LIMIT; |
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, "reclaim_percentage")) |
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_CAPCACHE_RECLAIM_PERCENTAGE; |
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 | } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) { |
| 398 | if (!strcmp(attr->attr.name, "timeout_secs")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 399 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 400 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 401 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 402 | if (!strcmp(attr->attr.name, "hard_limit")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 403 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 404 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 405 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 406 | if (!strcmp(attr->attr.name, "soft_limit")) |
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_CCACHE_SOFT_LIMIT; |
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, "reclaim_percentage")) |
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_CCACHE_RECLAIM_PERCENTAGE; |
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 | } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) { |
| 415 | if (!strcmp(attr->attr.name, "timeout_msecs")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 416 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 417 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 418 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 419 | if (!strcmp(attr->attr.name, "hard_limit")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 420 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 421 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 422 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 423 | if (!strcmp(attr->attr.name, "soft_limit")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 424 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 425 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
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, "reclaim_percentage")) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 428 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 429 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
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 | } else if (!strcmp(kobj->name, PC_KOBJ_ID)) { |
| 432 | if (!strcmp(attr->attr.name, ACACHE_KOBJ_ID)) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 433 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 434 | ORANGEFS_PERF_COUNT_REQUEST_ACACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 435 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 436 | if (!strcmp(attr->attr.name, CAPCACHE_KOBJ_ID)) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 437 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 438 | ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 439 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 440 | if (!strcmp(attr->attr.name, NCACHE_KOBJ_ID)) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 441 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 442 | ORANGEFS_PERF_COUNT_REQUEST_NCACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 443 | |
| 444 | } else { |
| 445 | gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n", |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 446 | kobj->name); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 447 | rc = -EINVAL; |
| 448 | goto out; |
| 449 | } |
| 450 | |
| 451 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 452 | if (strcmp(kobj->name, PC_KOBJ_ID)) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 453 | ser_op_type = "orangefs_param"; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 454 | else |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 455 | ser_op_type = "orangefs_perf_count"; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 456 | |
| 457 | /* |
| 458 | * The service_operation will return an errno return code on |
| 459 | * error, and zero on success. |
| 460 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 461 | rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 462 | |
| 463 | out: |
| 464 | if (!rc) { |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 465 | if (strcmp(kobj->name, PC_KOBJ_ID)) { |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 466 | if (new_op->upcall.req.param.op == |
| 467 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { |
| 468 | rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", |
| 469 | (int)new_op->downcall.resp.param.u. |
| 470 | value32[0], |
| 471 | (int)new_op->downcall.resp.param.u. |
| 472 | value32[1]); |
| 473 | } else { |
| 474 | rc = scnprintf(buf, PAGE_SIZE, "%d\n", |
| 475 | (int)new_op->downcall.resp.param.u.value64); |
| 476 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 477 | } else { |
| 478 | rc = scnprintf( |
| 479 | buf, |
| 480 | PAGE_SIZE, |
| 481 | "%s", |
| 482 | new_op->downcall.resp.perf_count.buffer); |
| 483 | } |
| 484 | } |
| 485 | |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 486 | op_release(new_op); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 487 | |
| 488 | return rc; |
| 489 | |
| 490 | } |
| 491 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 492 | /* |
| 493 | * pass attribute values back to userspace with a service operation. |
| 494 | * |
| 495 | * We have to do a memory allocation, an sscanf and a service operation. |
| 496 | * And we have to evaluate what the user entered, to make sure the |
| 497 | * value is within the range supported by the attribute. So, there's |
| 498 | * a lot of return code checking and mapping going on here. |
| 499 | * |
| 500 | * We want to return 1 if we think everything went OK, and |
| 501 | * EINVAL if not. |
| 502 | */ |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 503 | static ssize_t sysfs_service_op_store(struct kobject *kobj, |
| 504 | struct orangefs_attribute *attr, const char *buf, size_t count) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 505 | { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 506 | struct orangefs_kernel_op_s *new_op = NULL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 507 | int val = 0; |
| 508 | int rc = 0; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 509 | |
| 510 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 511 | "sysfs_service_op_store: id:%s:\n", |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 512 | kobj->name); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 513 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 514 | new_op = op_alloc(ORANGEFS_VFS_OP_PARAM); |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 515 | if (!new_op) |
| 516 | return -EINVAL; /* sic */ |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 517 | |
| 518 | /* Can't do a service_operation if the client is not running... */ |
| 519 | rc = is_daemon_in_service(); |
| 520 | if (rc) { |
| 521 | pr_info("%s: Client not running :%d:\n", |
| 522 | __func__, |
| 523 | is_daemon_in_service()); |
| 524 | goto out; |
| 525 | } |
| 526 | |
| 527 | /* |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 528 | * The value we want to send back to userspace is in buf, unless this |
| 529 | * there are two parameters, which is specially handled below. |
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 | strcmp(attr->attr.name, "readahead_count_size")) { |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 533 | rc = kstrtoint(buf, 0, &val); |
| 534 | if (rc) |
| 535 | goto out; |
| 536 | } |
| 537 | |
| 538 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 539 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 540 | if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { |
Martin Brandenburg | c51e012 | 2016-08-12 16:12:09 -0400 | [diff] [blame] | 541 | /* Drop unsupported requests first. */ |
| 542 | if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) && |
Martin Brandenburg | b78b119 | 2016-09-28 14:50:46 -0400 | [diff] [blame] | 543 | (!strcmp(attr->attr.name, "readahead_count") || |
| 544 | !strcmp(attr->attr.name, "readahead_size") || |
| 545 | !strcmp(attr->attr.name, "readahead_count_size"))) { |
Martin Brandenburg | c51e012 | 2016-08-12 16:12:09 -0400 | [diff] [blame] | 546 | rc = -EINVAL; |
| 547 | goto out; |
| 548 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 549 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 550 | if (!strcmp(attr->attr.name, "perf_history_size")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 551 | if (val > 0) { |
| 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_HISTORY_SIZE; |
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, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 559 | "perf_time_interval_secs")) { |
| 560 | if (val > 0) { |
| 561 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 562 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 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, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 568 | "perf_counter_reset")) { |
| 569 | if ((val == 0) || (val == 1)) { |
| 570 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 571 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 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")) { |
| 578 | if ((val >= 0)) { |
| 579 | new_op->upcall.req.param.op = |
| 580 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; |
| 581 | } else { |
| 582 | rc = 0; |
| 583 | goto out; |
| 584 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 585 | } else if (!strcmp(attr->attr.name, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 586 | "readahead_size")) { |
| 587 | if ((val >= 0)) { |
| 588 | new_op->upcall.req.param.op = |
| 589 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; |
| 590 | } else { |
| 591 | rc = 0; |
| 592 | goto out; |
| 593 | } |
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 | "readahead_count_size")) { |
| 596 | int val1, val2; |
| 597 | rc = sscanf(buf, "%d %d", &val1, &val2); |
| 598 | if (rc < 2) { |
| 599 | rc = 0; |
| 600 | goto out; |
| 601 | } |
| 602 | if ((val1 >= 0) && (val2 >= 0)) { |
| 603 | new_op->upcall.req.param.op = |
| 604 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
| 605 | } else { |
| 606 | rc = 0; |
| 607 | goto out; |
| 608 | } |
| 609 | new_op->upcall.req.param.u.value32[0] = val1; |
| 610 | new_op->upcall.req.param.u.value32[1] = val2; |
| 611 | goto value_set; |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 612 | } else if (!strcmp(attr->attr.name, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 613 | "perf_counter_reset")) { |
| 614 | if ((val > 0)) { |
| 615 | new_op->upcall.req.param.op = |
| 616 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
| 617 | } else { |
| 618 | rc = 0; |
| 619 | goto out; |
| 620 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 621 | } |
| 622 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 623 | } else if (!strcmp(kobj->name, ACACHE_KOBJ_ID)) { |
| 624 | if (!strcmp(attr->attr.name, "hard_limit")) { |
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_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 628 | } else { |
| 629 | rc = 0; |
| 630 | goto out; |
| 631 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 632 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 633 | if (val > -1) { |
| 634 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 635 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 636 | } else { |
| 637 | rc = 0; |
| 638 | goto out; |
| 639 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 640 | } else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 641 | "reclaim_percentage")) { |
| 642 | if ((val > -1) && (val < 101)) { |
| 643 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 644 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 645 | } else { |
| 646 | rc = 0; |
| 647 | goto out; |
| 648 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 649 | } else if (!strcmp(attr->attr.name, "timeout_msecs")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 650 | if (val > -1) { |
| 651 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 652 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 653 | } else { |
| 654 | rc = 0; |
| 655 | goto out; |
| 656 | } |
| 657 | } |
| 658 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 659 | } else if (!strcmp(kobj->name, CAPCACHE_KOBJ_ID)) { |
| 660 | if (!strcmp(attr->attr.name, "hard_limit")) { |
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_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 664 | } else { |
| 665 | rc = 0; |
| 666 | goto out; |
| 667 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 668 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 669 | if (val > -1) { |
| 670 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 671 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 672 | } else { |
| 673 | rc = 0; |
| 674 | goto out; |
| 675 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 676 | } else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 677 | "reclaim_percentage")) { |
| 678 | if ((val > -1) && (val < 101)) { |
| 679 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 680 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 681 | } else { |
| 682 | rc = 0; |
| 683 | goto out; |
| 684 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 685 | } else if (!strcmp(attr->attr.name, "timeout_secs")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 686 | if (val > -1) { |
| 687 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 688 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 689 | } else { |
| 690 | rc = 0; |
| 691 | goto out; |
| 692 | } |
| 693 | } |
| 694 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 695 | } else if (!strcmp(kobj->name, CCACHE_KOBJ_ID)) { |
| 696 | if (!strcmp(attr->attr.name, "hard_limit")) { |
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_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 700 | } else { |
| 701 | rc = 0; |
| 702 | goto out; |
| 703 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 704 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 705 | if (val > -1) { |
| 706 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 707 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 708 | } else { |
| 709 | rc = 0; |
| 710 | goto out; |
| 711 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 712 | } else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 713 | "reclaim_percentage")) { |
| 714 | if ((val > -1) && (val < 101)) { |
| 715 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 716 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 717 | } else { |
| 718 | rc = 0; |
| 719 | goto out; |
| 720 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 721 | } else if (!strcmp(attr->attr.name, "timeout_secs")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 722 | if (val > -1) { |
| 723 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 724 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 725 | } else { |
| 726 | rc = 0; |
| 727 | goto out; |
| 728 | } |
| 729 | } |
| 730 | |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 731 | } else if (!strcmp(kobj->name, NCACHE_KOBJ_ID)) { |
| 732 | if (!strcmp(attr->attr.name, "hard_limit")) { |
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_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 736 | } else { |
| 737 | rc = 0; |
| 738 | goto out; |
| 739 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 740 | } else if (!strcmp(attr->attr.name, "soft_limit")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 741 | if (val > -1) { |
| 742 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 743 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 744 | } else { |
| 745 | rc = 0; |
| 746 | goto out; |
| 747 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 748 | } else if (!strcmp(attr->attr.name, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 749 | "reclaim_percentage")) { |
| 750 | if ((val > -1) && (val < 101)) { |
| 751 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 752 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 753 | } else { |
| 754 | rc = 0; |
| 755 | goto out; |
| 756 | } |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 757 | } else if (!strcmp(attr->attr.name, "timeout_msecs")) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 758 | if (val > -1) { |
| 759 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 760 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 761 | } else { |
| 762 | rc = 0; |
| 763 | goto out; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | } else { |
| 768 | gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n", |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 769 | kobj->name); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 770 | rc = -EINVAL; |
| 771 | goto out; |
| 772 | } |
| 773 | |
Martin Brandenburg | 680908e | 2016-08-02 16:33:34 -0400 | [diff] [blame] | 774 | new_op->upcall.req.param.u.value64 = val; |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 775 | value_set: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 776 | |
| 777 | /* |
| 778 | * The service_operation will return a errno return code on |
| 779 | * error, and zero on success. |
| 780 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 781 | rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 782 | |
| 783 | if (rc < 0) { |
| 784 | gossip_err("sysfs_service_op_store: service op returned:%d:\n", |
| 785 | rc); |
| 786 | rc = 0; |
| 787 | } else { |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 788 | rc = count; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | out: |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 792 | op_release(new_op); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 793 | |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 794 | if (rc == -ENOMEM || rc == 0) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 795 | rc = -EINVAL; |
| 796 | |
| 797 | return rc; |
| 798 | } |
| 799 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 800 | static struct orangefs_attribute op_timeout_secs_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 801 | __ATTR(op_timeout_secs, 0664, sysfs_int_show, sysfs_int_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 802 | |
| 803 | static struct orangefs_attribute slot_timeout_secs_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 804 | __ATTR(slot_timeout_secs, 0664, sysfs_int_show, sysfs_int_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 805 | |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 806 | static struct orangefs_attribute dcache_timeout_msecs_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 807 | __ATTR(dcache_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 808 | |
| 809 | static struct orangefs_attribute getattr_timeout_msecs_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 810 | __ATTR(getattr_timeout_msecs, 0664, sysfs_int_show, sysfs_int_store); |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 811 | |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 812 | static struct orangefs_attribute readahead_count_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 813 | __ATTR(readahead_count, 0664, sysfs_service_op_show, |
| 814 | sysfs_service_op_store); |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 815 | |
| 816 | static struct orangefs_attribute readahead_size_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 817 | __ATTR(readahead_size, 0664, sysfs_service_op_show, |
| 818 | sysfs_service_op_store); |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 819 | |
| 820 | static struct orangefs_attribute readahead_count_size_attribute = |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 821 | __ATTR(readahead_count_size, 0664, sysfs_service_op_show, |
| 822 | sysfs_service_op_store); |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 823 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 824 | static struct orangefs_attribute perf_counter_reset_attribute = |
| 825 | __ATTR(perf_counter_reset, |
| 826 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 827 | sysfs_service_op_show, |
| 828 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 829 | |
| 830 | static struct orangefs_attribute perf_history_size_attribute = |
| 831 | __ATTR(perf_history_size, |
| 832 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 833 | sysfs_service_op_show, |
| 834 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 835 | |
| 836 | static struct orangefs_attribute perf_time_interval_secs_attribute = |
| 837 | __ATTR(perf_time_interval_secs, |
| 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 | |
| 842 | static struct attribute *orangefs_default_attrs[] = { |
| 843 | &op_timeout_secs_attribute.attr, |
| 844 | &slot_timeout_secs_attribute.attr, |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 845 | &dcache_timeout_msecs_attribute.attr, |
| 846 | &getattr_timeout_msecs_attribute.attr, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 847 | &readahead_count_attribute.attr, |
| 848 | &readahead_size_attribute.attr, |
| 849 | &readahead_count_size_attribute.attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 850 | &perf_counter_reset_attribute.attr, |
| 851 | &perf_history_size_attribute.attr, |
| 852 | &perf_time_interval_secs_attribute.attr, |
| 853 | NULL, |
| 854 | }; |
| 855 | |
| 856 | static struct kobj_type orangefs_ktype = { |
| 857 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 858 | .default_attrs = orangefs_default_attrs, |
| 859 | }; |
| 860 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 861 | static struct orangefs_attribute acache_hard_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 862 | __ATTR(hard_limit, |
| 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 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 867 | static struct orangefs_attribute acache_reclaim_percent_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 868 | __ATTR(reclaim_percentage, |
| 869 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 870 | sysfs_service_op_show, |
| 871 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 872 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 873 | static struct orangefs_attribute acache_soft_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 874 | __ATTR(soft_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 acache_timeout_msecs_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 880 | __ATTR(timeout_msecs, |
| 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 | |
| 885 | static struct attribute *acache_orangefs_default_attrs[] = { |
| 886 | &acache_hard_limit_attribute.attr, |
| 887 | &acache_reclaim_percent_attribute.attr, |
| 888 | &acache_soft_limit_attribute.attr, |
| 889 | &acache_timeout_msecs_attribute.attr, |
| 890 | NULL, |
| 891 | }; |
| 892 | |
| 893 | static struct kobj_type acache_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 894 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 895 | .default_attrs = acache_orangefs_default_attrs, |
| 896 | }; |
| 897 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 898 | static struct orangefs_attribute capcache_hard_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 899 | __ATTR(hard_limit, |
| 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 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 904 | static struct orangefs_attribute capcache_reclaim_percent_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 905 | __ATTR(reclaim_percentage, |
| 906 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 907 | sysfs_service_op_show, |
| 908 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 909 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 910 | static struct orangefs_attribute capcache_soft_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 911 | __ATTR(soft_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 capcache_timeout_secs_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 917 | __ATTR(timeout_secs, |
| 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 | |
| 922 | static struct attribute *capcache_orangefs_default_attrs[] = { |
| 923 | &capcache_hard_limit_attribute.attr, |
| 924 | &capcache_reclaim_percent_attribute.attr, |
| 925 | &capcache_soft_limit_attribute.attr, |
| 926 | &capcache_timeout_secs_attribute.attr, |
| 927 | NULL, |
| 928 | }; |
| 929 | |
| 930 | static struct kobj_type capcache_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 931 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 932 | .default_attrs = capcache_orangefs_default_attrs, |
| 933 | }; |
| 934 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 935 | static struct orangefs_attribute ccache_hard_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 936 | __ATTR(hard_limit, |
| 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 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 941 | static struct orangefs_attribute ccache_reclaim_percent_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 942 | __ATTR(reclaim_percentage, |
| 943 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 944 | sysfs_service_op_show, |
| 945 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 946 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 947 | static struct orangefs_attribute ccache_soft_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 948 | __ATTR(soft_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 ccache_timeout_secs_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 954 | __ATTR(timeout_secs, |
| 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 | |
| 959 | static struct attribute *ccache_orangefs_default_attrs[] = { |
| 960 | &ccache_hard_limit_attribute.attr, |
| 961 | &ccache_reclaim_percent_attribute.attr, |
| 962 | &ccache_soft_limit_attribute.attr, |
| 963 | &ccache_timeout_secs_attribute.attr, |
| 964 | NULL, |
| 965 | }; |
| 966 | |
| 967 | static struct kobj_type ccache_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 968 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 969 | .default_attrs = ccache_orangefs_default_attrs, |
| 970 | }; |
| 971 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 972 | static struct orangefs_attribute ncache_hard_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 973 | __ATTR(hard_limit, |
| 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 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 978 | static struct orangefs_attribute ncache_reclaim_percent_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 979 | __ATTR(reclaim_percentage, |
| 980 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 981 | sysfs_service_op_show, |
| 982 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 983 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 984 | static struct orangefs_attribute ncache_soft_limit_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 985 | __ATTR(soft_limit, |
| 986 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 987 | sysfs_service_op_show, |
| 988 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 989 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 990 | static struct orangefs_attribute ncache_timeout_msecs_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 991 | __ATTR(timeout_msecs, |
| 992 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 993 | sysfs_service_op_show, |
| 994 | sysfs_service_op_store); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 995 | |
| 996 | static struct attribute *ncache_orangefs_default_attrs[] = { |
| 997 | &ncache_hard_limit_attribute.attr, |
| 998 | &ncache_reclaim_percent_attribute.attr, |
| 999 | &ncache_soft_limit_attribute.attr, |
| 1000 | &ncache_timeout_msecs_attribute.attr, |
| 1001 | NULL, |
| 1002 | }; |
| 1003 | |
| 1004 | static struct kobj_type ncache_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 1005 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1006 | .default_attrs = ncache_orangefs_default_attrs, |
| 1007 | }; |
| 1008 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 1009 | static struct orangefs_attribute pc_acache_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1010 | __ATTR(acache, |
| 1011 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 1012 | sysfs_service_op_show, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1013 | NULL); |
| 1014 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 1015 | static struct orangefs_attribute pc_capcache_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1016 | __ATTR(capcache, |
| 1017 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 1018 | sysfs_service_op_show, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1019 | NULL); |
| 1020 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 1021 | static struct orangefs_attribute pc_ncache_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1022 | __ATTR(ncache, |
| 1023 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 1024 | sysfs_service_op_show, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1025 | NULL); |
| 1026 | |
| 1027 | static struct attribute *pc_orangefs_default_attrs[] = { |
| 1028 | &pc_acache_attribute.attr, |
| 1029 | &pc_capcache_attribute.attr, |
| 1030 | &pc_ncache_attribute.attr, |
| 1031 | NULL, |
| 1032 | }; |
| 1033 | |
| 1034 | static struct kobj_type pc_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 1035 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1036 | .default_attrs = pc_orangefs_default_attrs, |
| 1037 | }; |
| 1038 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 1039 | static struct orangefs_attribute stats_reads_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1040 | __ATTR(reads, |
| 1041 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 1042 | sysfs_int_show, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1043 | NULL); |
| 1044 | |
Martin Brandenburg | 2e9f80d | 2016-08-15 14:02:39 -0400 | [diff] [blame] | 1045 | static struct orangefs_attribute stats_writes_attribute = |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1046 | __ATTR(writes, |
| 1047 | 0664, |
Martin Brandenburg | 7b0cae6 | 2016-08-15 14:51:31 -0400 | [diff] [blame] | 1048 | sysfs_int_show, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1049 | NULL); |
| 1050 | |
| 1051 | static struct attribute *stats_orangefs_default_attrs[] = { |
| 1052 | &stats_reads_attribute.attr, |
| 1053 | &stats_writes_attribute.attr, |
| 1054 | NULL, |
| 1055 | }; |
| 1056 | |
| 1057 | static struct kobj_type stats_orangefs_ktype = { |
Martin Brandenburg | 4a34366 | 2016-08-15 15:01:30 -0400 | [diff] [blame] | 1058 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1059 | .default_attrs = stats_orangefs_default_attrs, |
| 1060 | }; |
| 1061 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1062 | static struct kobject *orangefs_obj; |
| 1063 | static struct kobject *acache_orangefs_obj; |
| 1064 | static struct kobject *capcache_orangefs_obj; |
| 1065 | static struct kobject *ccache_orangefs_obj; |
| 1066 | static struct kobject *ncache_orangefs_obj; |
| 1067 | static struct kobject *pc_orangefs_obj; |
| 1068 | static struct kobject *stats_orangefs_obj; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1069 | |
| 1070 | int orangefs_sysfs_init(void) |
| 1071 | { |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1072 | int rc = -EINVAL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1073 | |
| 1074 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n"); |
| 1075 | |
| 1076 | /* create /sys/fs/orangefs. */ |
| 1077 | orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1078 | if (!orangefs_obj) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1079 | goto out; |
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 | rc = kobject_init_and_add(orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1082 | &orangefs_ktype, |
| 1083 | fs_kobj, |
| 1084 | ORANGEFS_KOBJ_ID); |
| 1085 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1086 | if (rc) |
| 1087 | goto ofs_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1088 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1089 | kobject_uevent(orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1090 | |
| 1091 | /* create /sys/fs/orangefs/acache. */ |
| 1092 | acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); |
| 1093 | if (!acache_orangefs_obj) { |
| 1094 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1095 | goto ofs_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(acache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1099 | &acache_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 | ACACHE_KOBJ_ID); |
| 1102 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1103 | if (rc) |
| 1104 | goto acache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1105 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1106 | kobject_uevent(acache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1107 | |
| 1108 | /* create /sys/fs/orangefs/capcache. */ |
| 1109 | capcache_orangefs_obj = |
| 1110 | kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL); |
| 1111 | if (!capcache_orangefs_obj) { |
| 1112 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1113 | goto acache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1114 | } |
| 1115 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1116 | rc = kobject_init_and_add(capcache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1117 | &capcache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1118 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1119 | CAPCACHE_KOBJ_ID); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1120 | if (rc) |
| 1121 | goto capcache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1122 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1123 | kobject_uevent(capcache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1124 | |
| 1125 | /* create /sys/fs/orangefs/ccache. */ |
| 1126 | ccache_orangefs_obj = |
| 1127 | kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL); |
| 1128 | if (!ccache_orangefs_obj) { |
| 1129 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1130 | goto capcache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1131 | } |
| 1132 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1133 | rc = kobject_init_and_add(ccache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1134 | &ccache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1135 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1136 | CCACHE_KOBJ_ID); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1137 | if (rc) |
| 1138 | goto ccache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1139 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1140 | kobject_uevent(ccache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1141 | |
| 1142 | /* create /sys/fs/orangefs/ncache. */ |
| 1143 | ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); |
| 1144 | if (!ncache_orangefs_obj) { |
| 1145 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1146 | goto ccache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1147 | } |
| 1148 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1149 | rc = kobject_init_and_add(ncache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1150 | &ncache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1151 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1152 | NCACHE_KOBJ_ID); |
| 1153 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1154 | if (rc) |
| 1155 | goto ncache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1156 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1157 | kobject_uevent(ncache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1158 | |
| 1159 | /* create /sys/fs/orangefs/perf_counters. */ |
| 1160 | pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); |
| 1161 | if (!pc_orangefs_obj) { |
| 1162 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1163 | goto ncache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1164 | } |
| 1165 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1166 | rc = kobject_init_and_add(pc_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1167 | &pc_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1168 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1169 | "perf_counters"); |
| 1170 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1171 | if (rc) |
| 1172 | goto pc_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1173 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1174 | kobject_uevent(pc_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1175 | |
| 1176 | /* create /sys/fs/orangefs/stats. */ |
| 1177 | stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); |
| 1178 | if (!stats_orangefs_obj) { |
| 1179 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1180 | goto pc_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1181 | } |
| 1182 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1183 | rc = kobject_init_and_add(stats_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1184 | &stats_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1185 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1186 | STATS_KOBJ_ID); |
| 1187 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1188 | if (rc) |
| 1189 | goto stats_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1190 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1191 | kobject_uevent(stats_orangefs_obj, KOBJ_ADD); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1192 | goto out; |
| 1193 | |
| 1194 | stats_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1195 | kobject_put(stats_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1196 | pc_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1197 | kobject_put(pc_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1198 | ncache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1199 | kobject_put(ncache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1200 | ccache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1201 | kobject_put(ccache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1202 | capcache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1203 | kobject_put(capcache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1204 | acache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1205 | kobject_put(acache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1206 | ofs_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1207 | kobject_put(orangefs_obj); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1208 | out: |
| 1209 | return rc; |
| 1210 | } |
| 1211 | |
| 1212 | void orangefs_sysfs_exit(void) |
| 1213 | { |
| 1214 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n"); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame] | 1215 | kobject_put(acache_orangefs_obj); |
| 1216 | kobject_put(capcache_orangefs_obj); |
| 1217 | kobject_put(ccache_orangefs_obj); |
| 1218 | kobject_put(ncache_orangefs_obj); |
| 1219 | kobject_put(pc_orangefs_obj); |
| 1220 | kobject_put(stats_orangefs_obj); |
| 1221 | kobject_put(orangefs_obj); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1222 | } |