orangefs-sysfs.c 32 KB

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