Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Documentation/ABI/stable/orangefs-sysfs: |
| 3 | * |
| 4 | * What: /sys/fs/orangefs/perf_counter_reset |
| 5 | * Date: June 2015 |
| 6 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 7 | * Description: |
| 8 | * echo a 0 or a 1 into perf_counter_reset to |
| 9 | * reset all the counters in |
| 10 | * /sys/fs/orangefs/perf_counters |
| 11 | * except ones with PINT_PERF_PRESERVE set. |
| 12 | * |
| 13 | * |
| 14 | * What: /sys/fs/orangefs/perf_counters/... |
| 15 | * Date: Jun 2015 |
| 16 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 17 | * Description: |
| 18 | * Counters and settings for various caches. |
| 19 | * Read only. |
| 20 | * |
| 21 | * |
| 22 | * What: /sys/fs/orangefs/perf_time_interval_secs |
| 23 | * Date: Jun 2015 |
| 24 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 25 | * Description: |
| 26 | * Length of perf counter intervals in |
| 27 | * seconds. |
| 28 | * |
| 29 | * |
| 30 | * What: /sys/fs/orangefs/perf_history_size |
| 31 | * Date: Jun 2015 |
| 32 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 33 | * Description: |
| 34 | * The perf_counters cache statistics have N, or |
| 35 | * perf_history_size, samples. The default is |
| 36 | * one. |
| 37 | * |
| 38 | * Every perf_time_interval_secs the (first) |
| 39 | * samples are reset. |
| 40 | * |
| 41 | * If N is greater than one, the "current" set |
| 42 | * of samples is reset, and the samples from the |
| 43 | * other N-1 intervals remain available. |
| 44 | * |
| 45 | * |
| 46 | * What: /sys/fs/orangefs/op_timeout_secs |
| 47 | * Date: Jun 2015 |
| 48 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 49 | * Description: |
| 50 | * Service operation timeout in seconds. |
| 51 | * |
| 52 | * |
| 53 | * What: /sys/fs/orangefs/slot_timeout_secs |
| 54 | * Date: Jun 2015 |
| 55 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 56 | * Description: |
| 57 | * "Slot" timeout in seconds. A "slot" |
| 58 | * is an indexed buffer in the shared |
| 59 | * memory segment used for communication |
| 60 | * between the kernel module and userspace. |
| 61 | * Slots are requested and waited for, |
| 62 | * the wait times out after slot_timeout_secs. |
| 63 | * |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 64 | * What: /sys/fs/orangefs/dcache_timeout_msecs |
| 65 | * Date: Jul 2016 |
| 66 | * Contact: Martin Brandenburg <martin@omnibond.com> |
| 67 | * Description: |
| 68 | * Time lookup is valid in milliseconds. |
| 69 | * |
| 70 | * What: /sys/fs/orangefs/getattr_timeout_msecs |
| 71 | * Date: Jul 2016 |
| 72 | * Contact: Martin Brandenburg <martin@omnibond.com> |
| 73 | * Description: |
| 74 | * Time getattr is valid in milliseconds. |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 75 | * |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 76 | * What: /sys/fs/orangefs/readahead_count |
| 77 | * Date: Aug 2016 |
| 78 | * Contact: Martin Brandenburg <martin@omnibond.com> |
| 79 | * Description: |
| 80 | * Readahead cache buffer count. |
| 81 | * |
| 82 | * What: /sys/fs/orangefs/readahead_size |
| 83 | * Date: Aug 2016 |
| 84 | * Contact: Martin Brandenburg <martin@omnibond.com> |
| 85 | * Description: |
| 86 | * Readahead cache buffer size. |
| 87 | * |
| 88 | * What: /sys/fs/orangefs/readahead_count_size |
| 89 | * Date: Aug 2016 |
| 90 | * Contact: Martin Brandenburg <martin@omnibond.com> |
| 91 | * Description: |
| 92 | * Readahead cache buffer count and size. |
| 93 | * |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 94 | * What: /sys/fs/orangefs/acache/... |
| 95 | * Date: Jun 2015 |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 96 | * Contact: Martin Brandenburg <martin@omnibond.com> |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 97 | * Description: |
| 98 | * Attribute cache configurable settings. |
| 99 | * |
| 100 | * |
| 101 | * What: /sys/fs/orangefs/ncache/... |
| 102 | * Date: Jun 2015 |
| 103 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 104 | * Description: |
| 105 | * Name cache configurable settings. |
| 106 | * |
| 107 | * |
| 108 | * What: /sys/fs/orangefs/capcache/... |
| 109 | * Date: Jun 2015 |
| 110 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 111 | * Description: |
| 112 | * Capability cache configurable settings. |
| 113 | * |
| 114 | * |
| 115 | * What: /sys/fs/orangefs/ccache/... |
| 116 | * Date: Jun 2015 |
| 117 | * Contact: Mike Marshall <hubcap@omnibond.com> |
| 118 | * Description: |
| 119 | * Credential cache configurable settings. |
| 120 | * |
| 121 | */ |
| 122 | |
| 123 | #include <linux/fs.h> |
| 124 | #include <linux/kobject.h> |
| 125 | #include <linux/string.h> |
| 126 | #include <linux/sysfs.h> |
| 127 | #include <linux/module.h> |
| 128 | #include <linux/init.h> |
| 129 | |
| 130 | #include "protocol.h" |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 131 | #include "orangefs-kernel.h" |
| 132 | #include "orangefs-sysfs.h" |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 133 | |
| 134 | #define ORANGEFS_KOBJ_ID "orangefs" |
| 135 | #define ACACHE_KOBJ_ID "acache" |
| 136 | #define CAPCACHE_KOBJ_ID "capcache" |
| 137 | #define CCACHE_KOBJ_ID "ccache" |
| 138 | #define NCACHE_KOBJ_ID "ncache" |
| 139 | #define PC_KOBJ_ID "pc" |
| 140 | #define STATS_KOBJ_ID "stats" |
| 141 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 142 | struct orangefs_attribute { |
| 143 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 144 | ssize_t (*show)(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 145 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 146 | ssize_t (*store)(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 147 | const char *buf, |
| 148 | size_t count); |
| 149 | }; |
| 150 | |
| 151 | struct acache_orangefs_attribute { |
| 152 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 153 | ssize_t (*show)(struct acache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 154 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 155 | ssize_t (*store)(struct acache_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 | |
| 160 | struct capcache_orangefs_attribute { |
| 161 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 162 | ssize_t (*show)(struct capcache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 163 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 164 | ssize_t (*store)(struct capcache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 165 | const char *buf, |
| 166 | size_t count); |
| 167 | }; |
| 168 | |
| 169 | struct ccache_orangefs_attribute { |
| 170 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 171 | ssize_t (*show)(struct ccache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 172 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 173 | ssize_t (*store)(struct ccache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 174 | const char *buf, |
| 175 | size_t count); |
| 176 | }; |
| 177 | |
| 178 | struct ncache_orangefs_attribute { |
| 179 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 180 | ssize_t (*show)(struct ncache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 181 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 182 | ssize_t (*store)(struct ncache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 183 | const char *buf, |
| 184 | size_t count); |
| 185 | }; |
| 186 | |
| 187 | struct pc_orangefs_attribute { |
| 188 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 189 | ssize_t (*show)(struct pc_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 190 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 191 | ssize_t (*store)(struct pc_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 192 | const char *buf, |
| 193 | size_t count); |
| 194 | }; |
| 195 | |
| 196 | struct stats_orangefs_attribute { |
| 197 | struct attribute attr; |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 198 | ssize_t (*show)(struct stats_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 199 | char *buf); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 200 | ssize_t (*store)(struct stats_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 201 | const char *buf, |
| 202 | size_t count); |
| 203 | }; |
| 204 | |
| 205 | static ssize_t orangefs_attr_show(struct kobject *kobj, |
| 206 | struct attribute *attr, |
| 207 | char *buf) |
| 208 | { |
| 209 | struct orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 210 | int rc; |
| 211 | |
| 212 | attribute = container_of(attr, struct orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 213 | |
| 214 | if (!attribute->show) { |
| 215 | rc = -EIO; |
| 216 | goto out; |
| 217 | } |
| 218 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 219 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 220 | |
| 221 | out: |
| 222 | return rc; |
| 223 | } |
| 224 | |
| 225 | static ssize_t orangefs_attr_store(struct kobject *kobj, |
| 226 | struct attribute *attr, |
| 227 | const char *buf, |
| 228 | size_t len) |
| 229 | { |
| 230 | struct orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 231 | int rc; |
| 232 | |
| 233 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 234 | "orangefs_attr_store: start\n"); |
| 235 | |
| 236 | attribute = container_of(attr, struct orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 237 | |
| 238 | if (!attribute->store) { |
| 239 | rc = -EIO; |
| 240 | goto out; |
| 241 | } |
| 242 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 243 | rc = attribute->store(attribute, buf, len); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 244 | |
| 245 | out: |
| 246 | return rc; |
| 247 | } |
| 248 | |
| 249 | static const struct sysfs_ops orangefs_sysfs_ops = { |
| 250 | .show = orangefs_attr_show, |
| 251 | .store = orangefs_attr_store, |
| 252 | }; |
| 253 | |
| 254 | static ssize_t acache_orangefs_attr_show(struct kobject *kobj, |
| 255 | struct attribute *attr, |
| 256 | char *buf) |
| 257 | { |
| 258 | struct acache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 259 | int rc; |
| 260 | |
| 261 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 262 | |
| 263 | if (!attribute->show) { |
| 264 | rc = -EIO; |
| 265 | goto out; |
| 266 | } |
| 267 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 268 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 269 | |
| 270 | out: |
| 271 | return rc; |
| 272 | } |
| 273 | |
| 274 | static ssize_t acache_orangefs_attr_store(struct kobject *kobj, |
| 275 | struct attribute *attr, |
| 276 | const char *buf, |
| 277 | size_t len) |
| 278 | { |
| 279 | struct acache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 280 | int rc; |
| 281 | |
| 282 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 283 | "acache_orangefs_attr_store: start\n"); |
| 284 | |
| 285 | attribute = container_of(attr, struct acache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 286 | |
| 287 | if (!attribute->store) { |
| 288 | rc = -EIO; |
| 289 | goto out; |
| 290 | } |
| 291 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 292 | rc = attribute->store(attribute, buf, len); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 293 | |
| 294 | out: |
| 295 | return rc; |
| 296 | } |
| 297 | |
| 298 | static const struct sysfs_ops acache_orangefs_sysfs_ops = { |
| 299 | .show = acache_orangefs_attr_show, |
| 300 | .store = acache_orangefs_attr_store, |
| 301 | }; |
| 302 | |
| 303 | static ssize_t capcache_orangefs_attr_show(struct kobject *kobj, |
| 304 | struct attribute *attr, |
| 305 | char *buf) |
| 306 | { |
| 307 | struct capcache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 308 | int rc; |
| 309 | |
| 310 | attribute = |
| 311 | container_of(attr, struct capcache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 312 | |
| 313 | if (!attribute->show) { |
| 314 | rc = -EIO; |
| 315 | goto out; |
| 316 | } |
| 317 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 318 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 319 | |
| 320 | out: |
| 321 | return rc; |
| 322 | } |
| 323 | |
| 324 | static ssize_t capcache_orangefs_attr_store(struct kobject *kobj, |
| 325 | struct attribute *attr, |
| 326 | const char *buf, |
| 327 | size_t len) |
| 328 | { |
| 329 | struct capcache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 330 | int rc; |
| 331 | |
| 332 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 333 | "capcache_orangefs_attr_store: start\n"); |
| 334 | |
| 335 | attribute = |
| 336 | container_of(attr, struct capcache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 337 | |
| 338 | if (!attribute->store) { |
| 339 | rc = -EIO; |
| 340 | goto out; |
| 341 | } |
| 342 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 343 | rc = attribute->store(attribute, buf, len); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 344 | |
| 345 | out: |
| 346 | return rc; |
| 347 | } |
| 348 | |
| 349 | static const struct sysfs_ops capcache_orangefs_sysfs_ops = { |
| 350 | .show = capcache_orangefs_attr_show, |
| 351 | .store = capcache_orangefs_attr_store, |
| 352 | }; |
| 353 | |
| 354 | static ssize_t ccache_orangefs_attr_show(struct kobject *kobj, |
| 355 | struct attribute *attr, |
| 356 | char *buf) |
| 357 | { |
| 358 | struct ccache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 359 | int rc; |
| 360 | |
| 361 | attribute = |
| 362 | container_of(attr, struct ccache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 363 | |
| 364 | if (!attribute->show) { |
| 365 | rc = -EIO; |
| 366 | goto out; |
| 367 | } |
| 368 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 369 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 370 | |
| 371 | out: |
| 372 | return rc; |
| 373 | } |
| 374 | |
| 375 | static ssize_t ccache_orangefs_attr_store(struct kobject *kobj, |
| 376 | struct attribute *attr, |
| 377 | const char *buf, |
| 378 | size_t len) |
| 379 | { |
| 380 | struct ccache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 381 | int rc; |
| 382 | |
| 383 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 384 | "ccache_orangefs_attr_store: start\n"); |
| 385 | |
| 386 | attribute = |
| 387 | container_of(attr, struct ccache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 388 | |
| 389 | if (!attribute->store) { |
| 390 | rc = -EIO; |
| 391 | goto out; |
| 392 | } |
| 393 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 394 | rc = attribute->store(attribute, buf, len); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 395 | |
| 396 | out: |
| 397 | return rc; |
| 398 | } |
| 399 | |
| 400 | static const struct sysfs_ops ccache_orangefs_sysfs_ops = { |
| 401 | .show = ccache_orangefs_attr_show, |
| 402 | .store = ccache_orangefs_attr_store, |
| 403 | }; |
| 404 | |
| 405 | static ssize_t ncache_orangefs_attr_show(struct kobject *kobj, |
| 406 | struct attribute *attr, |
| 407 | char *buf) |
| 408 | { |
| 409 | struct ncache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 410 | int rc; |
| 411 | |
| 412 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 413 | |
| 414 | if (!attribute->show) { |
| 415 | rc = -EIO; |
| 416 | goto out; |
| 417 | } |
| 418 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 419 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 420 | |
| 421 | out: |
| 422 | return rc; |
| 423 | } |
| 424 | |
| 425 | static ssize_t ncache_orangefs_attr_store(struct kobject *kobj, |
| 426 | struct attribute *attr, |
| 427 | const char *buf, |
| 428 | size_t len) |
| 429 | { |
| 430 | struct ncache_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 431 | int rc; |
| 432 | |
| 433 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 434 | "ncache_orangefs_attr_store: start\n"); |
| 435 | |
| 436 | attribute = container_of(attr, struct ncache_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 437 | |
| 438 | if (!attribute->store) { |
| 439 | rc = -EIO; |
| 440 | goto out; |
| 441 | } |
| 442 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 443 | rc = attribute->store(attribute, buf, len); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 444 | |
| 445 | out: |
| 446 | return rc; |
| 447 | } |
| 448 | |
| 449 | static const struct sysfs_ops ncache_orangefs_sysfs_ops = { |
| 450 | .show = ncache_orangefs_attr_show, |
| 451 | .store = ncache_orangefs_attr_store, |
| 452 | }; |
| 453 | |
| 454 | static ssize_t pc_orangefs_attr_show(struct kobject *kobj, |
| 455 | struct attribute *attr, |
| 456 | char *buf) |
| 457 | { |
| 458 | struct pc_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 459 | int rc; |
| 460 | |
| 461 | attribute = container_of(attr, struct pc_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 462 | |
| 463 | if (!attribute->show) { |
| 464 | rc = -EIO; |
| 465 | goto out; |
| 466 | } |
| 467 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 468 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 469 | |
| 470 | out: |
| 471 | return rc; |
| 472 | } |
| 473 | |
| 474 | static const struct sysfs_ops pc_orangefs_sysfs_ops = { |
| 475 | .show = pc_orangefs_attr_show, |
| 476 | }; |
| 477 | |
| 478 | static ssize_t stats_orangefs_attr_show(struct kobject *kobj, |
| 479 | struct attribute *attr, |
| 480 | char *buf) |
| 481 | { |
| 482 | struct stats_orangefs_attribute *attribute; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 483 | int rc; |
| 484 | |
| 485 | attribute = container_of(attr, struct stats_orangefs_attribute, attr); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 486 | |
| 487 | if (!attribute->show) { |
| 488 | rc = -EIO; |
| 489 | goto out; |
| 490 | } |
| 491 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 492 | rc = attribute->show(attribute, buf); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 493 | |
| 494 | out: |
| 495 | return rc; |
| 496 | } |
| 497 | |
| 498 | static const struct sysfs_ops stats_orangefs_sysfs_ops = { |
| 499 | .show = stats_orangefs_attr_show, |
| 500 | }; |
| 501 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 502 | static ssize_t sysfs_int_show(char *kobj_id, char *buf, void *attr) |
| 503 | { |
| 504 | int rc = -EIO; |
| 505 | struct orangefs_attribute *orangefs_attr; |
| 506 | struct stats_orangefs_attribute *stats_orangefs_attr; |
| 507 | |
| 508 | gossip_debug(GOSSIP_SYSFS_DEBUG, "sysfs_int_show: id:%s:\n", kobj_id); |
| 509 | |
| 510 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { |
| 511 | orangefs_attr = (struct orangefs_attribute *)attr; |
| 512 | |
| 513 | if (!strcmp(orangefs_attr->attr.name, "op_timeout_secs")) { |
| 514 | rc = scnprintf(buf, |
| 515 | PAGE_SIZE, |
| 516 | "%d\n", |
| 517 | op_timeout_secs); |
| 518 | goto out; |
| 519 | } else if (!strcmp(orangefs_attr->attr.name, |
| 520 | "slot_timeout_secs")) { |
| 521 | rc = scnprintf(buf, |
| 522 | PAGE_SIZE, |
| 523 | "%d\n", |
| 524 | slot_timeout_secs); |
| 525 | goto out; |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 526 | } else if (!strcmp(orangefs_attr->attr.name, |
| 527 | "dcache_timeout_msecs")) { |
| 528 | rc = scnprintf(buf, |
| 529 | PAGE_SIZE, |
| 530 | "%d\n", |
| 531 | dcache_timeout_msecs); |
| 532 | goto out; |
| 533 | } else if (!strcmp(orangefs_attr->attr.name, |
| 534 | "getattr_timeout_msecs")) { |
| 535 | rc = scnprintf(buf, |
| 536 | PAGE_SIZE, |
| 537 | "%d\n", |
| 538 | getattr_timeout_msecs); |
| 539 | goto out; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 540 | } else { |
| 541 | goto out; |
| 542 | } |
| 543 | |
| 544 | } else if (!strcmp(kobj_id, STATS_KOBJ_ID)) { |
| 545 | stats_orangefs_attr = (struct stats_orangefs_attribute *)attr; |
| 546 | |
| 547 | if (!strcmp(stats_orangefs_attr->attr.name, "reads")) { |
| 548 | rc = scnprintf(buf, |
| 549 | PAGE_SIZE, |
| 550 | "%lu\n", |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 551 | g_orangefs_stats.reads); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 552 | goto out; |
| 553 | } else if (!strcmp(stats_orangefs_attr->attr.name, "writes")) { |
| 554 | rc = scnprintf(buf, |
| 555 | PAGE_SIZE, |
| 556 | "%lu\n", |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 557 | g_orangefs_stats.writes); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 558 | goto out; |
| 559 | } else { |
| 560 | goto out; |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | out: |
| 565 | |
| 566 | return rc; |
| 567 | } |
| 568 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 569 | static ssize_t int_orangefs_show(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 570 | char *buf) |
| 571 | { |
| 572 | int rc; |
| 573 | |
| 574 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 575 | "int_orangefs_show:start attr->attr.name:%s:\n", |
| 576 | attr->attr.name); |
| 577 | |
| 578 | rc = sysfs_int_show(ORANGEFS_KOBJ_ID, buf, (void *) attr); |
| 579 | |
| 580 | return rc; |
| 581 | } |
| 582 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 583 | static ssize_t int_stats_show(struct stats_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 584 | char *buf) |
| 585 | { |
| 586 | int rc; |
| 587 | |
| 588 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 589 | "int_stats_show:start attr->attr.name:%s:\n", |
| 590 | attr->attr.name); |
| 591 | |
| 592 | rc = sysfs_int_show(STATS_KOBJ_ID, buf, (void *) attr); |
| 593 | |
| 594 | return rc; |
| 595 | } |
| 596 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 597 | static ssize_t int_store(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 598 | const char *buf, |
| 599 | size_t count) |
| 600 | { |
| 601 | int rc = 0; |
| 602 | |
| 603 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 604 | "int_store: start attr->attr.name:%s: buf:%s:\n", |
| 605 | attr->attr.name, buf); |
| 606 | |
| 607 | if (!strcmp(attr->attr.name, "op_timeout_secs")) { |
| 608 | rc = kstrtoint(buf, 0, &op_timeout_secs); |
| 609 | goto out; |
| 610 | } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) { |
| 611 | rc = kstrtoint(buf, 0, &slot_timeout_secs); |
| 612 | goto out; |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 613 | } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) { |
| 614 | rc = kstrtoint(buf, 0, &dcache_timeout_msecs); |
| 615 | goto out; |
| 616 | } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { |
| 617 | rc = kstrtoint(buf, 0, &getattr_timeout_msecs); |
| 618 | goto out; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 619 | } else { |
| 620 | goto out; |
| 621 | } |
| 622 | |
| 623 | out: |
| 624 | if (rc) |
| 625 | rc = -EINVAL; |
| 626 | else |
| 627 | rc = count; |
| 628 | |
| 629 | return rc; |
| 630 | } |
| 631 | |
| 632 | /* |
| 633 | * obtain attribute values from userspace with a service operation. |
| 634 | */ |
Mike Marshall | 84d0215 | 2015-07-28 13:27:51 -0400 | [diff] [blame] | 635 | static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 636 | { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 637 | struct orangefs_kernel_op_s *new_op = NULL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 638 | int rc = 0; |
| 639 | char *ser_op_type = NULL; |
| 640 | struct orangefs_attribute *orangefs_attr; |
| 641 | struct acache_orangefs_attribute *acache_attr; |
| 642 | struct capcache_orangefs_attribute *capcache_attr; |
| 643 | struct ccache_orangefs_attribute *ccache_attr; |
| 644 | struct ncache_orangefs_attribute *ncache_attr; |
| 645 | struct pc_orangefs_attribute *pc_attr; |
| 646 | __u32 op_alloc_type; |
| 647 | |
| 648 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 649 | "sysfs_service_op_show: id:%s:\n", |
| 650 | kobj_id); |
| 651 | |
| 652 | if (strcmp(kobj_id, PC_KOBJ_ID)) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 653 | op_alloc_type = ORANGEFS_VFS_OP_PARAM; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 654 | else |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 655 | op_alloc_type = ORANGEFS_VFS_OP_PERF_COUNT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 656 | |
| 657 | new_op = op_alloc(op_alloc_type); |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 658 | if (!new_op) |
| 659 | return -ENOMEM; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 660 | |
| 661 | /* Can't do a service_operation if the client is not running... */ |
| 662 | rc = is_daemon_in_service(); |
| 663 | if (rc) { |
| 664 | pr_info("%s: Client not running :%d:\n", |
| 665 | __func__, |
| 666 | is_daemon_in_service()); |
| 667 | goto out; |
| 668 | } |
| 669 | |
| 670 | if (strcmp(kobj_id, PC_KOBJ_ID)) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 671 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_GET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 672 | |
| 673 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { |
| 674 | orangefs_attr = (struct orangefs_attribute *)attr; |
| 675 | |
| 676 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) |
| 677 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 678 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 679 | else if (!strcmp(orangefs_attr->attr.name, |
| 680 | "perf_time_interval_secs")) |
| 681 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 682 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 683 | else if (!strcmp(orangefs_attr->attr.name, |
| 684 | "perf_counter_reset")) |
| 685 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 686 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 687 | |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 688 | else if (!strcmp(orangefs_attr->attr.name, |
| 689 | "readahead_count")) |
| 690 | new_op->upcall.req.param.op = |
| 691 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; |
| 692 | |
| 693 | else if (!strcmp(orangefs_attr->attr.name, |
| 694 | "readahead_size")) |
| 695 | new_op->upcall.req.param.op = |
| 696 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; |
| 697 | |
| 698 | else if (!strcmp(orangefs_attr->attr.name, |
| 699 | "readahead_count_size")) |
| 700 | new_op->upcall.req.param.op = |
| 701 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 702 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { |
| 703 | acache_attr = (struct acache_orangefs_attribute *)attr; |
| 704 | |
| 705 | if (!strcmp(acache_attr->attr.name, "timeout_msecs")) |
| 706 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 707 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 708 | |
| 709 | if (!strcmp(acache_attr->attr.name, "hard_limit")) |
| 710 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 711 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 712 | |
| 713 | if (!strcmp(acache_attr->attr.name, "soft_limit")) |
| 714 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 715 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 716 | |
| 717 | if (!strcmp(acache_attr->attr.name, "reclaim_percentage")) |
| 718 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 719 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 720 | |
| 721 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { |
| 722 | capcache_attr = (struct capcache_orangefs_attribute *)attr; |
| 723 | |
| 724 | if (!strcmp(capcache_attr->attr.name, "timeout_secs")) |
| 725 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 726 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 727 | |
| 728 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) |
| 729 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 730 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 731 | |
| 732 | if (!strcmp(capcache_attr->attr.name, "soft_limit")) |
| 733 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 734 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 735 | |
| 736 | if (!strcmp(capcache_attr->attr.name, "reclaim_percentage")) |
| 737 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 738 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 739 | |
| 740 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { |
| 741 | ccache_attr = (struct ccache_orangefs_attribute *)attr; |
| 742 | |
| 743 | if (!strcmp(ccache_attr->attr.name, "timeout_secs")) |
| 744 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 745 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 746 | |
| 747 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) |
| 748 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 749 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 750 | |
| 751 | if (!strcmp(ccache_attr->attr.name, "soft_limit")) |
| 752 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 753 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 754 | |
| 755 | if (!strcmp(ccache_attr->attr.name, "reclaim_percentage")) |
| 756 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 757 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 758 | |
| 759 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { |
| 760 | ncache_attr = (struct ncache_orangefs_attribute *)attr; |
| 761 | |
| 762 | if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) |
| 763 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 764 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 765 | |
| 766 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) |
| 767 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 768 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 769 | |
| 770 | if (!strcmp(ncache_attr->attr.name, "soft_limit")) |
| 771 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 772 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 773 | |
| 774 | if (!strcmp(ncache_attr->attr.name, "reclaim_percentage")) |
| 775 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 776 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 777 | |
| 778 | } else if (!strcmp(kobj_id, PC_KOBJ_ID)) { |
| 779 | pc_attr = (struct pc_orangefs_attribute *)attr; |
| 780 | |
| 781 | if (!strcmp(pc_attr->attr.name, ACACHE_KOBJ_ID)) |
| 782 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 783 | ORANGEFS_PERF_COUNT_REQUEST_ACACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 784 | |
| 785 | if (!strcmp(pc_attr->attr.name, CAPCACHE_KOBJ_ID)) |
| 786 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 787 | ORANGEFS_PERF_COUNT_REQUEST_CAPCACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 788 | |
| 789 | if (!strcmp(pc_attr->attr.name, NCACHE_KOBJ_ID)) |
| 790 | new_op->upcall.req.perf_count.type = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 791 | ORANGEFS_PERF_COUNT_REQUEST_NCACHE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 792 | |
| 793 | } else { |
| 794 | gossip_err("sysfs_service_op_show: unknown kobj_id:%s:\n", |
| 795 | kobj_id); |
| 796 | rc = -EINVAL; |
| 797 | goto out; |
| 798 | } |
| 799 | |
| 800 | |
| 801 | if (strcmp(kobj_id, PC_KOBJ_ID)) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 802 | ser_op_type = "orangefs_param"; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 803 | else |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 804 | ser_op_type = "orangefs_perf_count"; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 805 | |
| 806 | /* |
| 807 | * The service_operation will return an errno return code on |
| 808 | * error, and zero on success. |
| 809 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 810 | rc = service_operation(new_op, ser_op_type, ORANGEFS_OP_INTERRUPTIBLE); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 811 | |
| 812 | out: |
| 813 | if (!rc) { |
| 814 | if (strcmp(kobj_id, PC_KOBJ_ID)) { |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 815 | if (new_op->upcall.req.param.op == |
| 816 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { |
| 817 | rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", |
| 818 | (int)new_op->downcall.resp.param.u. |
| 819 | value32[0], |
| 820 | (int)new_op->downcall.resp.param.u. |
| 821 | value32[1]); |
| 822 | } else { |
| 823 | rc = scnprintf(buf, PAGE_SIZE, "%d\n", |
| 824 | (int)new_op->downcall.resp.param.u.value64); |
| 825 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 826 | } else { |
| 827 | rc = scnprintf( |
| 828 | buf, |
| 829 | PAGE_SIZE, |
| 830 | "%s", |
| 831 | new_op->downcall.resp.perf_count.buffer); |
| 832 | } |
| 833 | } |
| 834 | |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 835 | op_release(new_op); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 836 | |
| 837 | return rc; |
| 838 | |
| 839 | } |
| 840 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 841 | static ssize_t service_orangefs_show(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 842 | char *buf) |
| 843 | { |
| 844 | int rc = 0; |
| 845 | |
| 846 | rc = sysfs_service_op_show(ORANGEFS_KOBJ_ID, buf, (void *)attr); |
| 847 | |
| 848 | return rc; |
| 849 | } |
| 850 | |
| 851 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 852 | service_acache_show(struct acache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 853 | char *buf) |
| 854 | { |
| 855 | int rc = 0; |
| 856 | |
| 857 | rc = sysfs_service_op_show(ACACHE_KOBJ_ID, buf, (void *)attr); |
| 858 | |
| 859 | return rc; |
| 860 | } |
| 861 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 862 | static ssize_t service_capcache_show(struct capcache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 863 | char *buf) |
| 864 | { |
| 865 | int rc = 0; |
| 866 | |
| 867 | rc = sysfs_service_op_show(CAPCACHE_KOBJ_ID, buf, (void *)attr); |
| 868 | |
| 869 | return rc; |
| 870 | } |
| 871 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 872 | static ssize_t service_ccache_show(struct ccache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 873 | char *buf) |
| 874 | { |
| 875 | int rc = 0; |
| 876 | |
| 877 | rc = sysfs_service_op_show(CCACHE_KOBJ_ID, buf, (void *)attr); |
| 878 | |
| 879 | return rc; |
| 880 | } |
| 881 | |
| 882 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 883 | service_ncache_show(struct ncache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 884 | char *buf) |
| 885 | { |
| 886 | int rc = 0; |
| 887 | |
| 888 | rc = sysfs_service_op_show(NCACHE_KOBJ_ID, buf, (void *)attr); |
| 889 | |
| 890 | return rc; |
| 891 | } |
| 892 | |
| 893 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 894 | service_pc_show(struct pc_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 895 | char *buf) |
| 896 | { |
| 897 | int rc = 0; |
| 898 | |
| 899 | rc = sysfs_service_op_show(PC_KOBJ_ID, buf, (void *)attr); |
| 900 | |
| 901 | return rc; |
| 902 | } |
| 903 | |
| 904 | /* |
| 905 | * pass attribute values back to userspace with a service operation. |
| 906 | * |
| 907 | * We have to do a memory allocation, an sscanf and a service operation. |
| 908 | * And we have to evaluate what the user entered, to make sure the |
| 909 | * value is within the range supported by the attribute. So, there's |
| 910 | * a lot of return code checking and mapping going on here. |
| 911 | * |
| 912 | * We want to return 1 if we think everything went OK, and |
| 913 | * EINVAL if not. |
| 914 | */ |
Mike Marshall | 84d0215 | 2015-07-28 13:27:51 -0400 | [diff] [blame] | 915 | static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 916 | { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 917 | struct orangefs_kernel_op_s *new_op = NULL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 918 | int val = 0; |
| 919 | int rc = 0; |
| 920 | struct orangefs_attribute *orangefs_attr; |
| 921 | struct acache_orangefs_attribute *acache_attr; |
| 922 | struct capcache_orangefs_attribute *capcache_attr; |
| 923 | struct ccache_orangefs_attribute *ccache_attr; |
| 924 | struct ncache_orangefs_attribute *ncache_attr; |
| 925 | |
| 926 | gossip_debug(GOSSIP_SYSFS_DEBUG, |
| 927 | "sysfs_service_op_store: id:%s:\n", |
| 928 | kobj_id); |
| 929 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 930 | new_op = op_alloc(ORANGEFS_VFS_OP_PARAM); |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 931 | if (!new_op) |
| 932 | return -EINVAL; /* sic */ |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 933 | |
| 934 | /* Can't do a service_operation if the client is not running... */ |
| 935 | rc = is_daemon_in_service(); |
| 936 | if (rc) { |
| 937 | pr_info("%s: Client not running :%d:\n", |
| 938 | __func__, |
| 939 | is_daemon_in_service()); |
| 940 | goto out; |
| 941 | } |
| 942 | |
| 943 | /* |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 944 | * The value we want to send back to userspace is in buf, unless this |
| 945 | * there are two parameters, which is specially handled below. |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 946 | */ |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 947 | if (strcmp(kobj_id, ORANGEFS_KOBJ_ID) || |
| 948 | strcmp(((struct orangefs_attribute *)attr)->attr.name, |
| 949 | "readahead_count_size")) { |
| 950 | rc = kstrtoint(buf, 0, &val); |
| 951 | if (rc) |
| 952 | goto out; |
| 953 | } |
| 954 | |
| 955 | new_op->upcall.req.param.type = ORANGEFS_PARAM_REQUEST_SET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 956 | |
| 957 | if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) { |
| 958 | orangefs_attr = (struct orangefs_attribute *)attr; |
| 959 | |
| 960 | if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) { |
| 961 | if (val > 0) { |
| 962 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 963 | ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 964 | } else { |
| 965 | rc = 0; |
| 966 | goto out; |
| 967 | } |
| 968 | } else if (!strcmp(orangefs_attr->attr.name, |
| 969 | "perf_time_interval_secs")) { |
| 970 | if (val > 0) { |
| 971 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 972 | ORANGEFS_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 973 | } else { |
| 974 | rc = 0; |
| 975 | goto out; |
| 976 | } |
| 977 | } else if (!strcmp(orangefs_attr->attr.name, |
| 978 | "perf_counter_reset")) { |
| 979 | if ((val == 0) || (val == 1)) { |
| 980 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 981 | ORANGEFS_PARAM_REQUEST_OP_PERF_RESET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 982 | } else { |
| 983 | rc = 0; |
| 984 | goto out; |
| 985 | } |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 986 | } else if (!strcmp(orangefs_attr->attr.name, |
| 987 | "readahead_count")) { |
| 988 | if ((val >= 0)) { |
| 989 | new_op->upcall.req.param.op = |
| 990 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT; |
| 991 | } else { |
| 992 | rc = 0; |
| 993 | goto out; |
| 994 | } |
| 995 | } else if (!strcmp(orangefs_attr->attr.name, |
| 996 | "readahead_size")) { |
| 997 | if ((val >= 0)) { |
| 998 | new_op->upcall.req.param.op = |
| 999 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_SIZE; |
| 1000 | } else { |
| 1001 | rc = 0; |
| 1002 | goto out; |
| 1003 | } |
| 1004 | } else if (!strcmp(orangefs_attr->attr.name, |
| 1005 | "readahead_count_size")) { |
| 1006 | int val1, val2; |
| 1007 | rc = sscanf(buf, "%d %d", &val1, &val2); |
| 1008 | if (rc < 2) { |
| 1009 | rc = 0; |
| 1010 | goto out; |
| 1011 | } |
| 1012 | if ((val1 >= 0) && (val2 >= 0)) { |
| 1013 | new_op->upcall.req.param.op = |
| 1014 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
| 1015 | } else { |
| 1016 | rc = 0; |
| 1017 | goto out; |
| 1018 | } |
| 1019 | new_op->upcall.req.param.u.value32[0] = val1; |
| 1020 | new_op->upcall.req.param.u.value32[1] = val2; |
| 1021 | goto value_set; |
| 1022 | } else if (!strcmp(orangefs_attr->attr.name, |
| 1023 | "perf_counter_reset")) { |
| 1024 | if ((val > 0)) { |
| 1025 | new_op->upcall.req.param.op = |
| 1026 | ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE; |
| 1027 | } else { |
| 1028 | rc = 0; |
| 1029 | goto out; |
| 1030 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | } else if (!strcmp(kobj_id, ACACHE_KOBJ_ID)) { |
| 1034 | acache_attr = (struct acache_orangefs_attribute *)attr; |
| 1035 | |
| 1036 | if (!strcmp(acache_attr->attr.name, "hard_limit")) { |
| 1037 | if (val > -1) { |
| 1038 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1039 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1040 | } else { |
| 1041 | rc = 0; |
| 1042 | goto out; |
| 1043 | } |
| 1044 | } else if (!strcmp(acache_attr->attr.name, "soft_limit")) { |
| 1045 | if (val > -1) { |
| 1046 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1047 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1048 | } else { |
| 1049 | rc = 0; |
| 1050 | goto out; |
| 1051 | } |
| 1052 | } else if (!strcmp(acache_attr->attr.name, |
| 1053 | "reclaim_percentage")) { |
| 1054 | if ((val > -1) && (val < 101)) { |
| 1055 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1056 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1057 | } else { |
| 1058 | rc = 0; |
| 1059 | goto out; |
| 1060 | } |
| 1061 | } else if (!strcmp(acache_attr->attr.name, "timeout_msecs")) { |
| 1062 | if (val > -1) { |
| 1063 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1064 | ORANGEFS_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1065 | } else { |
| 1066 | rc = 0; |
| 1067 | goto out; |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | } else if (!strcmp(kobj_id, CAPCACHE_KOBJ_ID)) { |
| 1072 | capcache_attr = (struct capcache_orangefs_attribute *)attr; |
| 1073 | |
| 1074 | if (!strcmp(capcache_attr->attr.name, "hard_limit")) { |
| 1075 | if (val > -1) { |
| 1076 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1077 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1078 | } else { |
| 1079 | rc = 0; |
| 1080 | goto out; |
| 1081 | } |
| 1082 | } else if (!strcmp(capcache_attr->attr.name, "soft_limit")) { |
| 1083 | if (val > -1) { |
| 1084 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1085 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1086 | } else { |
| 1087 | rc = 0; |
| 1088 | goto out; |
| 1089 | } |
| 1090 | } else if (!strcmp(capcache_attr->attr.name, |
| 1091 | "reclaim_percentage")) { |
| 1092 | if ((val > -1) && (val < 101)) { |
| 1093 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1094 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1095 | } else { |
| 1096 | rc = 0; |
| 1097 | goto out; |
| 1098 | } |
| 1099 | } else if (!strcmp(capcache_attr->attr.name, "timeout_secs")) { |
| 1100 | if (val > -1) { |
| 1101 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1102 | ORANGEFS_PARAM_REQUEST_OP_CAPCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1103 | } else { |
| 1104 | rc = 0; |
| 1105 | goto out; |
| 1106 | } |
| 1107 | } |
| 1108 | |
| 1109 | } else if (!strcmp(kobj_id, CCACHE_KOBJ_ID)) { |
| 1110 | ccache_attr = (struct ccache_orangefs_attribute *)attr; |
| 1111 | |
| 1112 | if (!strcmp(ccache_attr->attr.name, "hard_limit")) { |
| 1113 | if (val > -1) { |
| 1114 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1115 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1116 | } else { |
| 1117 | rc = 0; |
| 1118 | goto out; |
| 1119 | } |
| 1120 | } else if (!strcmp(ccache_attr->attr.name, "soft_limit")) { |
| 1121 | if (val > -1) { |
| 1122 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1123 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1124 | } else { |
| 1125 | rc = 0; |
| 1126 | goto out; |
| 1127 | } |
| 1128 | } else if (!strcmp(ccache_attr->attr.name, |
| 1129 | "reclaim_percentage")) { |
| 1130 | if ((val > -1) && (val < 101)) { |
| 1131 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1132 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1133 | } else { |
| 1134 | rc = 0; |
| 1135 | goto out; |
| 1136 | } |
| 1137 | } else if (!strcmp(ccache_attr->attr.name, "timeout_secs")) { |
| 1138 | if (val > -1) { |
| 1139 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1140 | ORANGEFS_PARAM_REQUEST_OP_CCACHE_TIMEOUT_SECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1141 | } else { |
| 1142 | rc = 0; |
| 1143 | goto out; |
| 1144 | } |
| 1145 | } |
| 1146 | |
| 1147 | } else if (!strcmp(kobj_id, NCACHE_KOBJ_ID)) { |
| 1148 | ncache_attr = (struct ncache_orangefs_attribute *)attr; |
| 1149 | |
| 1150 | if (!strcmp(ncache_attr->attr.name, "hard_limit")) { |
| 1151 | if (val > -1) { |
| 1152 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1153 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1154 | } else { |
| 1155 | rc = 0; |
| 1156 | goto out; |
| 1157 | } |
| 1158 | } else if (!strcmp(ncache_attr->attr.name, "soft_limit")) { |
| 1159 | if (val > -1) { |
| 1160 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1161 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1162 | } else { |
| 1163 | rc = 0; |
| 1164 | goto out; |
| 1165 | } |
| 1166 | } else if (!strcmp(ncache_attr->attr.name, |
| 1167 | "reclaim_percentage")) { |
| 1168 | if ((val > -1) && (val < 101)) { |
| 1169 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1170 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1171 | } else { |
| 1172 | rc = 0; |
| 1173 | goto out; |
| 1174 | } |
| 1175 | } else if (!strcmp(ncache_attr->attr.name, "timeout_msecs")) { |
| 1176 | if (val > -1) { |
| 1177 | new_op->upcall.req.param.op = |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1178 | ORANGEFS_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1179 | } else { |
| 1180 | rc = 0; |
| 1181 | goto out; |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | } else { |
| 1186 | gossip_err("sysfs_service_op_store: unknown kobj_id:%s:\n", |
| 1187 | kobj_id); |
| 1188 | rc = -EINVAL; |
| 1189 | goto out; |
| 1190 | } |
| 1191 | |
Martin Brandenburg | 680908e | 2016-08-02 16:33:34 -0400 | [diff] [blame] | 1192 | new_op->upcall.req.param.u.value64 = val; |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 1193 | value_set: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1194 | |
| 1195 | /* |
| 1196 | * The service_operation will return a errno return code on |
| 1197 | * error, and zero on success. |
| 1198 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 1199 | rc = service_operation(new_op, "orangefs_param", ORANGEFS_OP_INTERRUPTIBLE); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1200 | |
| 1201 | if (rc < 0) { |
| 1202 | gossip_err("sysfs_service_op_store: service op returned:%d:\n", |
| 1203 | rc); |
| 1204 | rc = 0; |
| 1205 | } else { |
| 1206 | rc = 1; |
| 1207 | } |
| 1208 | |
| 1209 | out: |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 1210 | op_release(new_op); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1211 | |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 1212 | if (rc == -ENOMEM || rc == 0) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1213 | rc = -EINVAL; |
| 1214 | |
| 1215 | return rc; |
| 1216 | } |
| 1217 | |
| 1218 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1219 | service_orangefs_store(struct orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1220 | const char *buf, |
| 1221 | size_t count) |
| 1222 | { |
| 1223 | int rc = 0; |
| 1224 | |
| 1225 | rc = sysfs_service_op_store(ORANGEFS_KOBJ_ID, buf, (void *) attr); |
| 1226 | |
| 1227 | /* rc should have an errno value if the service_op went bad. */ |
| 1228 | if (rc == 1) |
| 1229 | rc = count; |
| 1230 | |
| 1231 | return rc; |
| 1232 | } |
| 1233 | |
| 1234 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1235 | service_acache_store(struct acache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1236 | const char *buf, |
| 1237 | size_t count) |
| 1238 | { |
| 1239 | int rc = 0; |
| 1240 | |
| 1241 | rc = sysfs_service_op_store(ACACHE_KOBJ_ID, buf, (void *) attr); |
| 1242 | |
| 1243 | /* rc should have an errno value if the service_op went bad. */ |
| 1244 | if (rc == 1) |
| 1245 | rc = count; |
| 1246 | |
| 1247 | return rc; |
| 1248 | } |
| 1249 | |
| 1250 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1251 | service_capcache_store(struct capcache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1252 | const char *buf, |
| 1253 | size_t count) |
| 1254 | { |
| 1255 | int rc = 0; |
| 1256 | |
| 1257 | rc = sysfs_service_op_store(CAPCACHE_KOBJ_ID, buf, (void *) attr); |
| 1258 | |
| 1259 | /* rc should have an errno value if the service_op went bad. */ |
| 1260 | if (rc == 1) |
| 1261 | rc = count; |
| 1262 | |
| 1263 | return rc; |
| 1264 | } |
| 1265 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1266 | static ssize_t service_ccache_store(struct ccache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1267 | const char *buf, |
| 1268 | size_t count) |
| 1269 | { |
| 1270 | int rc = 0; |
| 1271 | |
| 1272 | rc = sysfs_service_op_store(CCACHE_KOBJ_ID, buf, (void *) attr); |
| 1273 | |
| 1274 | /* rc should have an errno value if the service_op went bad. */ |
| 1275 | if (rc == 1) |
| 1276 | rc = count; |
| 1277 | |
| 1278 | return rc; |
| 1279 | } |
| 1280 | |
| 1281 | static ssize_t |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1282 | service_ncache_store(struct ncache_orangefs_attribute *attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1283 | const char *buf, |
| 1284 | size_t count) |
| 1285 | { |
| 1286 | int rc = 0; |
| 1287 | |
| 1288 | rc = sysfs_service_op_store(NCACHE_KOBJ_ID, buf, (void *) attr); |
| 1289 | |
| 1290 | /* rc should have an errno value if the service_op went bad. */ |
| 1291 | if (rc == 1) |
| 1292 | rc = count; |
| 1293 | |
| 1294 | return rc; |
| 1295 | } |
| 1296 | |
| 1297 | static struct orangefs_attribute op_timeout_secs_attribute = |
| 1298 | __ATTR(op_timeout_secs, 0664, int_orangefs_show, int_store); |
| 1299 | |
| 1300 | static struct orangefs_attribute slot_timeout_secs_attribute = |
| 1301 | __ATTR(slot_timeout_secs, 0664, int_orangefs_show, int_store); |
| 1302 | |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 1303 | static struct orangefs_attribute dcache_timeout_msecs_attribute = |
| 1304 | __ATTR(dcache_timeout_msecs, 0664, int_orangefs_show, int_store); |
| 1305 | |
| 1306 | static struct orangefs_attribute getattr_timeout_msecs_attribute = |
| 1307 | __ATTR(getattr_timeout_msecs, 0664, int_orangefs_show, int_store); |
| 1308 | |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 1309 | static struct orangefs_attribute readahead_count_attribute = |
| 1310 | __ATTR(readahead_count, 0664, service_orangefs_show, |
| 1311 | service_orangefs_store); |
| 1312 | |
| 1313 | static struct orangefs_attribute readahead_size_attribute = |
| 1314 | __ATTR(readahead_size, 0664, service_orangefs_show, |
| 1315 | service_orangefs_store); |
| 1316 | |
| 1317 | static struct orangefs_attribute readahead_count_size_attribute = |
| 1318 | __ATTR(readahead_count_size, 0664, service_orangefs_show, |
| 1319 | service_orangefs_store); |
| 1320 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1321 | static struct orangefs_attribute perf_counter_reset_attribute = |
| 1322 | __ATTR(perf_counter_reset, |
| 1323 | 0664, |
| 1324 | service_orangefs_show, |
| 1325 | service_orangefs_store); |
| 1326 | |
| 1327 | static struct orangefs_attribute perf_history_size_attribute = |
| 1328 | __ATTR(perf_history_size, |
| 1329 | 0664, |
| 1330 | service_orangefs_show, |
| 1331 | service_orangefs_store); |
| 1332 | |
| 1333 | static struct orangefs_attribute perf_time_interval_secs_attribute = |
| 1334 | __ATTR(perf_time_interval_secs, |
| 1335 | 0664, |
| 1336 | service_orangefs_show, |
| 1337 | service_orangefs_store); |
| 1338 | |
| 1339 | static struct attribute *orangefs_default_attrs[] = { |
| 1340 | &op_timeout_secs_attribute.attr, |
| 1341 | &slot_timeout_secs_attribute.attr, |
Martin Brandenburg | 4cd8f31 | 2016-07-25 13:58:24 -0400 | [diff] [blame] | 1342 | &dcache_timeout_msecs_attribute.attr, |
| 1343 | &getattr_timeout_msecs_attribute.attr, |
Martin Brandenburg | 4d20a75 | 2016-08-03 13:47:28 -0400 | [diff] [blame] | 1344 | &readahead_count_attribute.attr, |
| 1345 | &readahead_size_attribute.attr, |
| 1346 | &readahead_count_size_attribute.attr, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1347 | &perf_counter_reset_attribute.attr, |
| 1348 | &perf_history_size_attribute.attr, |
| 1349 | &perf_time_interval_secs_attribute.attr, |
| 1350 | NULL, |
| 1351 | }; |
| 1352 | |
| 1353 | static struct kobj_type orangefs_ktype = { |
| 1354 | .sysfs_ops = &orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1355 | .default_attrs = orangefs_default_attrs, |
| 1356 | }; |
| 1357 | |
| 1358 | static struct acache_orangefs_attribute acache_hard_limit_attribute = |
| 1359 | __ATTR(hard_limit, |
| 1360 | 0664, |
| 1361 | service_acache_show, |
| 1362 | service_acache_store); |
| 1363 | |
| 1364 | static struct acache_orangefs_attribute acache_reclaim_percent_attribute = |
| 1365 | __ATTR(reclaim_percentage, |
| 1366 | 0664, |
| 1367 | service_acache_show, |
| 1368 | service_acache_store); |
| 1369 | |
| 1370 | static struct acache_orangefs_attribute acache_soft_limit_attribute = |
| 1371 | __ATTR(soft_limit, |
| 1372 | 0664, |
| 1373 | service_acache_show, |
| 1374 | service_acache_store); |
| 1375 | |
| 1376 | static struct acache_orangefs_attribute acache_timeout_msecs_attribute = |
| 1377 | __ATTR(timeout_msecs, |
| 1378 | 0664, |
| 1379 | service_acache_show, |
| 1380 | service_acache_store); |
| 1381 | |
| 1382 | static struct attribute *acache_orangefs_default_attrs[] = { |
| 1383 | &acache_hard_limit_attribute.attr, |
| 1384 | &acache_reclaim_percent_attribute.attr, |
| 1385 | &acache_soft_limit_attribute.attr, |
| 1386 | &acache_timeout_msecs_attribute.attr, |
| 1387 | NULL, |
| 1388 | }; |
| 1389 | |
| 1390 | static struct kobj_type acache_orangefs_ktype = { |
| 1391 | .sysfs_ops = &acache_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1392 | .default_attrs = acache_orangefs_default_attrs, |
| 1393 | }; |
| 1394 | |
| 1395 | static struct capcache_orangefs_attribute capcache_hard_limit_attribute = |
| 1396 | __ATTR(hard_limit, |
| 1397 | 0664, |
| 1398 | service_capcache_show, |
| 1399 | service_capcache_store); |
| 1400 | |
| 1401 | static struct capcache_orangefs_attribute capcache_reclaim_percent_attribute = |
| 1402 | __ATTR(reclaim_percentage, |
| 1403 | 0664, |
| 1404 | service_capcache_show, |
| 1405 | service_capcache_store); |
| 1406 | |
| 1407 | static struct capcache_orangefs_attribute capcache_soft_limit_attribute = |
| 1408 | __ATTR(soft_limit, |
| 1409 | 0664, |
| 1410 | service_capcache_show, |
| 1411 | service_capcache_store); |
| 1412 | |
| 1413 | static struct capcache_orangefs_attribute capcache_timeout_secs_attribute = |
| 1414 | __ATTR(timeout_secs, |
| 1415 | 0664, |
| 1416 | service_capcache_show, |
| 1417 | service_capcache_store); |
| 1418 | |
| 1419 | static struct attribute *capcache_orangefs_default_attrs[] = { |
| 1420 | &capcache_hard_limit_attribute.attr, |
| 1421 | &capcache_reclaim_percent_attribute.attr, |
| 1422 | &capcache_soft_limit_attribute.attr, |
| 1423 | &capcache_timeout_secs_attribute.attr, |
| 1424 | NULL, |
| 1425 | }; |
| 1426 | |
| 1427 | static struct kobj_type capcache_orangefs_ktype = { |
| 1428 | .sysfs_ops = &capcache_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1429 | .default_attrs = capcache_orangefs_default_attrs, |
| 1430 | }; |
| 1431 | |
| 1432 | static struct ccache_orangefs_attribute ccache_hard_limit_attribute = |
| 1433 | __ATTR(hard_limit, |
| 1434 | 0664, |
| 1435 | service_ccache_show, |
| 1436 | service_ccache_store); |
| 1437 | |
| 1438 | static struct ccache_orangefs_attribute ccache_reclaim_percent_attribute = |
| 1439 | __ATTR(reclaim_percentage, |
| 1440 | 0664, |
| 1441 | service_ccache_show, |
| 1442 | service_ccache_store); |
| 1443 | |
| 1444 | static struct ccache_orangefs_attribute ccache_soft_limit_attribute = |
| 1445 | __ATTR(soft_limit, |
| 1446 | 0664, |
| 1447 | service_ccache_show, |
| 1448 | service_ccache_store); |
| 1449 | |
| 1450 | static struct ccache_orangefs_attribute ccache_timeout_secs_attribute = |
| 1451 | __ATTR(timeout_secs, |
| 1452 | 0664, |
| 1453 | service_ccache_show, |
| 1454 | service_ccache_store); |
| 1455 | |
| 1456 | static struct attribute *ccache_orangefs_default_attrs[] = { |
| 1457 | &ccache_hard_limit_attribute.attr, |
| 1458 | &ccache_reclaim_percent_attribute.attr, |
| 1459 | &ccache_soft_limit_attribute.attr, |
| 1460 | &ccache_timeout_secs_attribute.attr, |
| 1461 | NULL, |
| 1462 | }; |
| 1463 | |
| 1464 | static struct kobj_type ccache_orangefs_ktype = { |
| 1465 | .sysfs_ops = &ccache_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1466 | .default_attrs = ccache_orangefs_default_attrs, |
| 1467 | }; |
| 1468 | |
| 1469 | static struct ncache_orangefs_attribute ncache_hard_limit_attribute = |
| 1470 | __ATTR(hard_limit, |
| 1471 | 0664, |
| 1472 | service_ncache_show, |
| 1473 | service_ncache_store); |
| 1474 | |
| 1475 | static struct ncache_orangefs_attribute ncache_reclaim_percent_attribute = |
| 1476 | __ATTR(reclaim_percentage, |
| 1477 | 0664, |
| 1478 | service_ncache_show, |
| 1479 | service_ncache_store); |
| 1480 | |
| 1481 | static struct ncache_orangefs_attribute ncache_soft_limit_attribute = |
| 1482 | __ATTR(soft_limit, |
| 1483 | 0664, |
| 1484 | service_ncache_show, |
| 1485 | service_ncache_store); |
| 1486 | |
| 1487 | static struct ncache_orangefs_attribute ncache_timeout_msecs_attribute = |
| 1488 | __ATTR(timeout_msecs, |
| 1489 | 0664, |
| 1490 | service_ncache_show, |
| 1491 | service_ncache_store); |
| 1492 | |
| 1493 | static struct attribute *ncache_orangefs_default_attrs[] = { |
| 1494 | &ncache_hard_limit_attribute.attr, |
| 1495 | &ncache_reclaim_percent_attribute.attr, |
| 1496 | &ncache_soft_limit_attribute.attr, |
| 1497 | &ncache_timeout_msecs_attribute.attr, |
| 1498 | NULL, |
| 1499 | }; |
| 1500 | |
| 1501 | static struct kobj_type ncache_orangefs_ktype = { |
| 1502 | .sysfs_ops = &ncache_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1503 | .default_attrs = ncache_orangefs_default_attrs, |
| 1504 | }; |
| 1505 | |
| 1506 | static struct pc_orangefs_attribute pc_acache_attribute = |
| 1507 | __ATTR(acache, |
| 1508 | 0664, |
| 1509 | service_pc_show, |
| 1510 | NULL); |
| 1511 | |
| 1512 | static struct pc_orangefs_attribute pc_capcache_attribute = |
| 1513 | __ATTR(capcache, |
| 1514 | 0664, |
| 1515 | service_pc_show, |
| 1516 | NULL); |
| 1517 | |
| 1518 | static struct pc_orangefs_attribute pc_ncache_attribute = |
| 1519 | __ATTR(ncache, |
| 1520 | 0664, |
| 1521 | service_pc_show, |
| 1522 | NULL); |
| 1523 | |
| 1524 | static struct attribute *pc_orangefs_default_attrs[] = { |
| 1525 | &pc_acache_attribute.attr, |
| 1526 | &pc_capcache_attribute.attr, |
| 1527 | &pc_ncache_attribute.attr, |
| 1528 | NULL, |
| 1529 | }; |
| 1530 | |
| 1531 | static struct kobj_type pc_orangefs_ktype = { |
| 1532 | .sysfs_ops = &pc_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1533 | .default_attrs = pc_orangefs_default_attrs, |
| 1534 | }; |
| 1535 | |
| 1536 | static struct stats_orangefs_attribute stats_reads_attribute = |
| 1537 | __ATTR(reads, |
| 1538 | 0664, |
| 1539 | int_stats_show, |
| 1540 | NULL); |
| 1541 | |
| 1542 | static struct stats_orangefs_attribute stats_writes_attribute = |
| 1543 | __ATTR(writes, |
| 1544 | 0664, |
| 1545 | int_stats_show, |
| 1546 | NULL); |
| 1547 | |
| 1548 | static struct attribute *stats_orangefs_default_attrs[] = { |
| 1549 | &stats_reads_attribute.attr, |
| 1550 | &stats_writes_attribute.attr, |
| 1551 | NULL, |
| 1552 | }; |
| 1553 | |
| 1554 | static struct kobj_type stats_orangefs_ktype = { |
| 1555 | .sysfs_ops = &stats_orangefs_sysfs_ops, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1556 | .default_attrs = stats_orangefs_default_attrs, |
| 1557 | }; |
| 1558 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1559 | static struct kobject *orangefs_obj; |
| 1560 | static struct kobject *acache_orangefs_obj; |
| 1561 | static struct kobject *capcache_orangefs_obj; |
| 1562 | static struct kobject *ccache_orangefs_obj; |
| 1563 | static struct kobject *ncache_orangefs_obj; |
| 1564 | static struct kobject *pc_orangefs_obj; |
| 1565 | static struct kobject *stats_orangefs_obj; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1566 | |
| 1567 | int orangefs_sysfs_init(void) |
| 1568 | { |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1569 | int rc = -EINVAL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1570 | |
| 1571 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n"); |
| 1572 | |
| 1573 | /* create /sys/fs/orangefs. */ |
| 1574 | orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1575 | if (!orangefs_obj) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1576 | goto out; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1577 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1578 | rc = kobject_init_and_add(orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1579 | &orangefs_ktype, |
| 1580 | fs_kobj, |
| 1581 | ORANGEFS_KOBJ_ID); |
| 1582 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1583 | if (rc) |
| 1584 | goto ofs_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1585 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1586 | kobject_uevent(orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1587 | |
| 1588 | /* create /sys/fs/orangefs/acache. */ |
| 1589 | acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); |
| 1590 | if (!acache_orangefs_obj) { |
| 1591 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1592 | goto ofs_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1593 | } |
| 1594 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1595 | rc = kobject_init_and_add(acache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1596 | &acache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1597 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1598 | ACACHE_KOBJ_ID); |
| 1599 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1600 | if (rc) |
| 1601 | goto acache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1602 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1603 | kobject_uevent(acache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1604 | |
| 1605 | /* create /sys/fs/orangefs/capcache. */ |
| 1606 | capcache_orangefs_obj = |
| 1607 | kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL); |
| 1608 | if (!capcache_orangefs_obj) { |
| 1609 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1610 | goto acache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1611 | } |
| 1612 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1613 | rc = kobject_init_and_add(capcache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1614 | &capcache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1615 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1616 | CAPCACHE_KOBJ_ID); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1617 | if (rc) |
| 1618 | goto capcache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1619 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1620 | kobject_uevent(capcache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1621 | |
| 1622 | /* create /sys/fs/orangefs/ccache. */ |
| 1623 | ccache_orangefs_obj = |
| 1624 | kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL); |
| 1625 | if (!ccache_orangefs_obj) { |
| 1626 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1627 | goto capcache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1628 | } |
| 1629 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1630 | rc = kobject_init_and_add(ccache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1631 | &ccache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1632 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1633 | CCACHE_KOBJ_ID); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1634 | if (rc) |
| 1635 | goto ccache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1636 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1637 | kobject_uevent(ccache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1638 | |
| 1639 | /* create /sys/fs/orangefs/ncache. */ |
| 1640 | ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); |
| 1641 | if (!ncache_orangefs_obj) { |
| 1642 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1643 | goto ccache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1644 | } |
| 1645 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1646 | rc = kobject_init_and_add(ncache_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1647 | &ncache_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1648 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1649 | NCACHE_KOBJ_ID); |
| 1650 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1651 | if (rc) |
| 1652 | goto ncache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1653 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1654 | kobject_uevent(ncache_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1655 | |
| 1656 | /* create /sys/fs/orangefs/perf_counters. */ |
| 1657 | pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); |
| 1658 | if (!pc_orangefs_obj) { |
| 1659 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1660 | goto ncache_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1661 | } |
| 1662 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1663 | rc = kobject_init_and_add(pc_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1664 | &pc_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1665 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1666 | "perf_counters"); |
| 1667 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1668 | if (rc) |
| 1669 | goto pc_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1670 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1671 | kobject_uevent(pc_orangefs_obj, KOBJ_ADD); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1672 | |
| 1673 | /* create /sys/fs/orangefs/stats. */ |
| 1674 | stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); |
| 1675 | if (!stats_orangefs_obj) { |
| 1676 | rc = -EINVAL; |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1677 | goto pc_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1678 | } |
| 1679 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1680 | rc = kobject_init_and_add(stats_orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1681 | &stats_orangefs_ktype, |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1682 | orangefs_obj, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1683 | STATS_KOBJ_ID); |
| 1684 | |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1685 | if (rc) |
| 1686 | goto stats_obj_bail; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1687 | |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1688 | kobject_uevent(stats_orangefs_obj, KOBJ_ADD); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1689 | goto out; |
| 1690 | |
| 1691 | stats_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1692 | kobject_put(stats_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1693 | pc_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1694 | kobject_put(pc_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1695 | ncache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1696 | kobject_put(ncache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1697 | ccache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1698 | kobject_put(ccache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1699 | capcache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1700 | kobject_put(capcache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1701 | acache_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1702 | kobject_put(acache_orangefs_obj); |
Mike Marshall | 2180c52 | 2016-03-14 15:30:39 -0400 | [diff] [blame] | 1703 | ofs_obj_bail: |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1704 | kobject_put(orangefs_obj); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1705 | out: |
| 1706 | return rc; |
| 1707 | } |
| 1708 | |
| 1709 | void orangefs_sysfs_exit(void) |
| 1710 | { |
| 1711 | gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_exit: start\n"); |
Martin Brandenburg | dc3012a | 2016-08-15 13:28:51 -0400 | [diff] [blame^] | 1712 | kobject_put(acache_orangefs_obj); |
| 1713 | kobject_put(capcache_orangefs_obj); |
| 1714 | kobject_put(ccache_orangefs_obj); |
| 1715 | kobject_put(ncache_orangefs_obj); |
| 1716 | kobject_put(pc_orangefs_obj); |
| 1717 | kobject_put(stats_orangefs_obj); |
| 1718 | kobject_put(orangefs_obj); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 1719 | } |