orangefs-sysfs.c 32 KB

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