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