sysfs.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * sysfs.c - sysfs support implementation.
  4. *
  5. * Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation.
  6. * Copyright (C) 2014 HGST, Inc., a Western Digital Company.
  7. *
  8. * Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>
  9. */
  10. #include <linux/kobject.h>
  11. #include "nilfs.h"
  12. #include "mdt.h"
  13. #include "sufile.h"
  14. #include "cpfile.h"
  15. #include "sysfs.h"
  16. /* /sys/fs/<nilfs>/ */
  17. static struct kset *nilfs_kset;
  18. #define NILFS_SHOW_TIME(time_t_val, buf) ({ \
  19. struct tm res; \
  20. int count = 0; \
  21. time64_to_tm(time_t_val, 0, &res); \
  22. res.tm_year += 1900; \
  23. res.tm_mon += 1; \
  24. count = scnprintf(buf, PAGE_SIZE, \
  25. "%ld-%.2d-%.2d %.2d:%.2d:%.2d\n", \
  26. res.tm_year, res.tm_mon, res.tm_mday, \
  27. res.tm_hour, res.tm_min, res.tm_sec);\
  28. count; \
  29. })
  30. #define NILFS_DEV_INT_GROUP_OPS(name, parent_name) \
  31. static ssize_t nilfs_##name##_attr_show(struct kobject *kobj, \
  32. struct attribute *attr, char *buf) \
  33. { \
  34. struct the_nilfs *nilfs = container_of(kobj->parent, \
  35. struct the_nilfs, \
  36. ns_##parent_name##_kobj); \
  37. struct nilfs_##name##_attr *a = container_of(attr, \
  38. struct nilfs_##name##_attr, \
  39. attr); \
  40. return a->show ? a->show(a, nilfs, buf) : 0; \
  41. } \
  42. static ssize_t nilfs_##name##_attr_store(struct kobject *kobj, \
  43. struct attribute *attr, \
  44. const char *buf, size_t len) \
  45. { \
  46. struct the_nilfs *nilfs = container_of(kobj->parent, \
  47. struct the_nilfs, \
  48. ns_##parent_name##_kobj); \
  49. struct nilfs_##name##_attr *a = container_of(attr, \
  50. struct nilfs_##name##_attr, \
  51. attr); \
  52. return a->store ? a->store(a, nilfs, buf, len) : 0; \
  53. } \
  54. static const struct sysfs_ops nilfs_##name##_attr_ops = { \
  55. .show = nilfs_##name##_attr_show, \
  56. .store = nilfs_##name##_attr_store, \
  57. }
  58. #define NILFS_DEV_INT_GROUP_TYPE(name, parent_name) \
  59. static void nilfs_##name##_attr_release(struct kobject *kobj) \
  60. { \
  61. struct nilfs_sysfs_##parent_name##_subgroups *subgroups; \
  62. struct the_nilfs *nilfs = container_of(kobj->parent, \
  63. struct the_nilfs, \
  64. ns_##parent_name##_kobj); \
  65. subgroups = nilfs->ns_##parent_name##_subgroups; \
  66. complete(&subgroups->sg_##name##_kobj_unregister); \
  67. } \
  68. static struct kobj_type nilfs_##name##_ktype = { \
  69. .default_attrs = nilfs_##name##_attrs, \
  70. .sysfs_ops = &nilfs_##name##_attr_ops, \
  71. .release = nilfs_##name##_attr_release, \
  72. }
  73. #define NILFS_DEV_INT_GROUP_FNS(name, parent_name) \
  74. static int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
  75. { \
  76. struct kobject *parent; \
  77. struct kobject *kobj; \
  78. struct completion *kobj_unregister; \
  79. struct nilfs_sysfs_##parent_name##_subgroups *subgroups; \
  80. int err; \
  81. subgroups = nilfs->ns_##parent_name##_subgroups; \
  82. kobj = &subgroups->sg_##name##_kobj; \
  83. kobj_unregister = &subgroups->sg_##name##_kobj_unregister; \
  84. parent = &nilfs->ns_##parent_name##_kobj; \
  85. kobj->kset = nilfs_kset; \
  86. init_completion(kobj_unregister); \
  87. err = kobject_init_and_add(kobj, &nilfs_##name##_ktype, parent, \
  88. #name); \
  89. if (err) \
  90. return err; \
  91. return 0; \
  92. } \
  93. static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
  94. { \
  95. kobject_del(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \
  96. }
  97. /************************************************************************
  98. * NILFS snapshot attrs *
  99. ************************************************************************/
  100. static ssize_t
  101. nilfs_snapshot_inodes_count_show(struct nilfs_snapshot_attr *attr,
  102. struct nilfs_root *root, char *buf)
  103. {
  104. return snprintf(buf, PAGE_SIZE, "%llu\n",
  105. (unsigned long long)atomic64_read(&root->inodes_count));
  106. }
  107. static ssize_t
  108. nilfs_snapshot_blocks_count_show(struct nilfs_snapshot_attr *attr,
  109. struct nilfs_root *root, char *buf)
  110. {
  111. return snprintf(buf, PAGE_SIZE, "%llu\n",
  112. (unsigned long long)atomic64_read(&root->blocks_count));
  113. }
  114. static const char snapshot_readme_str[] =
  115. "The group contains details about mounted snapshot.\n\n"
  116. "(1) inodes_count\n\tshow number of inodes for snapshot.\n\n"
  117. "(2) blocks_count\n\tshow number of blocks for snapshot.\n\n";
  118. static ssize_t
  119. nilfs_snapshot_README_show(struct nilfs_snapshot_attr *attr,
  120. struct nilfs_root *root, char *buf)
  121. {
  122. return snprintf(buf, PAGE_SIZE, snapshot_readme_str);
  123. }
  124. NILFS_SNAPSHOT_RO_ATTR(inodes_count);
  125. NILFS_SNAPSHOT_RO_ATTR(blocks_count);
  126. NILFS_SNAPSHOT_RO_ATTR(README);
  127. static struct attribute *nilfs_snapshot_attrs[] = {
  128. NILFS_SNAPSHOT_ATTR_LIST(inodes_count),
  129. NILFS_SNAPSHOT_ATTR_LIST(blocks_count),
  130. NILFS_SNAPSHOT_ATTR_LIST(README),
  131. NULL,
  132. };
  133. static ssize_t nilfs_snapshot_attr_show(struct kobject *kobj,
  134. struct attribute *attr, char *buf)
  135. {
  136. struct nilfs_root *root =
  137. container_of(kobj, struct nilfs_root, snapshot_kobj);
  138. struct nilfs_snapshot_attr *a =
  139. container_of(attr, struct nilfs_snapshot_attr, attr);
  140. return a->show ? a->show(a, root, buf) : 0;
  141. }
  142. static ssize_t nilfs_snapshot_attr_store(struct kobject *kobj,
  143. struct attribute *attr,
  144. const char *buf, size_t len)
  145. {
  146. struct nilfs_root *root =
  147. container_of(kobj, struct nilfs_root, snapshot_kobj);
  148. struct nilfs_snapshot_attr *a =
  149. container_of(attr, struct nilfs_snapshot_attr, attr);
  150. return a->store ? a->store(a, root, buf, len) : 0;
  151. }
  152. static void nilfs_snapshot_attr_release(struct kobject *kobj)
  153. {
  154. struct nilfs_root *root = container_of(kobj, struct nilfs_root,
  155. snapshot_kobj);
  156. complete(&root->snapshot_kobj_unregister);
  157. }
  158. static const struct sysfs_ops nilfs_snapshot_attr_ops = {
  159. .show = nilfs_snapshot_attr_show,
  160. .store = nilfs_snapshot_attr_store,
  161. };
  162. static struct kobj_type nilfs_snapshot_ktype = {
  163. .default_attrs = nilfs_snapshot_attrs,
  164. .sysfs_ops = &nilfs_snapshot_attr_ops,
  165. .release = nilfs_snapshot_attr_release,
  166. };
  167. int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)
  168. {
  169. struct the_nilfs *nilfs;
  170. struct kobject *parent;
  171. int err;
  172. nilfs = root->nilfs;
  173. parent = &nilfs->ns_dev_subgroups->sg_mounted_snapshots_kobj;
  174. root->snapshot_kobj.kset = nilfs_kset;
  175. init_completion(&root->snapshot_kobj_unregister);
  176. if (root->cno == NILFS_CPTREE_CURRENT_CNO) {
  177. err = kobject_init_and_add(&root->snapshot_kobj,
  178. &nilfs_snapshot_ktype,
  179. &nilfs->ns_dev_kobj,
  180. "current_checkpoint");
  181. } else {
  182. err = kobject_init_and_add(&root->snapshot_kobj,
  183. &nilfs_snapshot_ktype,
  184. parent,
  185. "%llu", root->cno);
  186. }
  187. if (err)
  188. return err;
  189. return 0;
  190. }
  191. void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *root)
  192. {
  193. kobject_del(&root->snapshot_kobj);
  194. }
  195. /************************************************************************
  196. * NILFS mounted snapshots attrs *
  197. ************************************************************************/
  198. static const char mounted_snapshots_readme_str[] =
  199. "The mounted_snapshots group contains group for\n"
  200. "every mounted snapshot.\n";
  201. static ssize_t
  202. nilfs_mounted_snapshots_README_show(struct nilfs_mounted_snapshots_attr *attr,
  203. struct the_nilfs *nilfs, char *buf)
  204. {
  205. return snprintf(buf, PAGE_SIZE, mounted_snapshots_readme_str);
  206. }
  207. NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(README);
  208. static struct attribute *nilfs_mounted_snapshots_attrs[] = {
  209. NILFS_MOUNTED_SNAPSHOTS_ATTR_LIST(README),
  210. NULL,
  211. };
  212. NILFS_DEV_INT_GROUP_OPS(mounted_snapshots, dev);
  213. NILFS_DEV_INT_GROUP_TYPE(mounted_snapshots, dev);
  214. NILFS_DEV_INT_GROUP_FNS(mounted_snapshots, dev);
  215. /************************************************************************
  216. * NILFS checkpoints attrs *
  217. ************************************************************************/
  218. static ssize_t
  219. nilfs_checkpoints_checkpoints_number_show(struct nilfs_checkpoints_attr *attr,
  220. struct the_nilfs *nilfs,
  221. char *buf)
  222. {
  223. __u64 ncheckpoints;
  224. struct nilfs_cpstat cpstat;
  225. int err;
  226. down_read(&nilfs->ns_segctor_sem);
  227. err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat);
  228. up_read(&nilfs->ns_segctor_sem);
  229. if (err < 0) {
  230. nilfs_msg(nilfs->ns_sb, KERN_ERR,
  231. "unable to get checkpoint stat: err=%d", err);
  232. return err;
  233. }
  234. ncheckpoints = cpstat.cs_ncps;
  235. return snprintf(buf, PAGE_SIZE, "%llu\n", ncheckpoints);
  236. }
  237. static ssize_t
  238. nilfs_checkpoints_snapshots_number_show(struct nilfs_checkpoints_attr *attr,
  239. struct the_nilfs *nilfs,
  240. char *buf)
  241. {
  242. __u64 nsnapshots;
  243. struct nilfs_cpstat cpstat;
  244. int err;
  245. down_read(&nilfs->ns_segctor_sem);
  246. err = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat);
  247. up_read(&nilfs->ns_segctor_sem);
  248. if (err < 0) {
  249. nilfs_msg(nilfs->ns_sb, KERN_ERR,
  250. "unable to get checkpoint stat: err=%d", err);
  251. return err;
  252. }
  253. nsnapshots = cpstat.cs_nsss;
  254. return snprintf(buf, PAGE_SIZE, "%llu\n", nsnapshots);
  255. }
  256. static ssize_t
  257. nilfs_checkpoints_last_seg_checkpoint_show(struct nilfs_checkpoints_attr *attr,
  258. struct the_nilfs *nilfs,
  259. char *buf)
  260. {
  261. __u64 last_cno;
  262. spin_lock(&nilfs->ns_last_segment_lock);
  263. last_cno = nilfs->ns_last_cno;
  264. spin_unlock(&nilfs->ns_last_segment_lock);
  265. return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno);
  266. }
  267. static ssize_t
  268. nilfs_checkpoints_next_checkpoint_show(struct nilfs_checkpoints_attr *attr,
  269. struct the_nilfs *nilfs,
  270. char *buf)
  271. {
  272. __u64 cno;
  273. down_read(&nilfs->ns_segctor_sem);
  274. cno = nilfs->ns_cno;
  275. up_read(&nilfs->ns_segctor_sem);
  276. return snprintf(buf, PAGE_SIZE, "%llu\n", cno);
  277. }
  278. static const char checkpoints_readme_str[] =
  279. "The checkpoints group contains attributes that describe\n"
  280. "details about volume's checkpoints.\n\n"
  281. "(1) checkpoints_number\n\tshow number of checkpoints on volume.\n\n"
  282. "(2) snapshots_number\n\tshow number of snapshots on volume.\n\n"
  283. "(3) last_seg_checkpoint\n"
  284. "\tshow checkpoint number of the latest segment.\n\n"
  285. "(4) next_checkpoint\n\tshow next checkpoint number.\n\n";
  286. static ssize_t
  287. nilfs_checkpoints_README_show(struct nilfs_checkpoints_attr *attr,
  288. struct the_nilfs *nilfs, char *buf)
  289. {
  290. return snprintf(buf, PAGE_SIZE, checkpoints_readme_str);
  291. }
  292. NILFS_CHECKPOINTS_RO_ATTR(checkpoints_number);
  293. NILFS_CHECKPOINTS_RO_ATTR(snapshots_number);
  294. NILFS_CHECKPOINTS_RO_ATTR(last_seg_checkpoint);
  295. NILFS_CHECKPOINTS_RO_ATTR(next_checkpoint);
  296. NILFS_CHECKPOINTS_RO_ATTR(README);
  297. static struct attribute *nilfs_checkpoints_attrs[] = {
  298. NILFS_CHECKPOINTS_ATTR_LIST(checkpoints_number),
  299. NILFS_CHECKPOINTS_ATTR_LIST(snapshots_number),
  300. NILFS_CHECKPOINTS_ATTR_LIST(last_seg_checkpoint),
  301. NILFS_CHECKPOINTS_ATTR_LIST(next_checkpoint),
  302. NILFS_CHECKPOINTS_ATTR_LIST(README),
  303. NULL,
  304. };
  305. NILFS_DEV_INT_GROUP_OPS(checkpoints, dev);
  306. NILFS_DEV_INT_GROUP_TYPE(checkpoints, dev);
  307. NILFS_DEV_INT_GROUP_FNS(checkpoints, dev);
  308. /************************************************************************
  309. * NILFS segments attrs *
  310. ************************************************************************/
  311. static ssize_t
  312. nilfs_segments_segments_number_show(struct nilfs_segments_attr *attr,
  313. struct the_nilfs *nilfs,
  314. char *buf)
  315. {
  316. return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_nsegments);
  317. }
  318. static ssize_t
  319. nilfs_segments_blocks_per_segment_show(struct nilfs_segments_attr *attr,
  320. struct the_nilfs *nilfs,
  321. char *buf)
  322. {
  323. return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_blocks_per_segment);
  324. }
  325. static ssize_t
  326. nilfs_segments_clean_segments_show(struct nilfs_segments_attr *attr,
  327. struct the_nilfs *nilfs,
  328. char *buf)
  329. {
  330. unsigned long ncleansegs;
  331. down_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem);
  332. ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile);
  333. up_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem);
  334. return snprintf(buf, PAGE_SIZE, "%lu\n", ncleansegs);
  335. }
  336. static ssize_t
  337. nilfs_segments_dirty_segments_show(struct nilfs_segments_attr *attr,
  338. struct the_nilfs *nilfs,
  339. char *buf)
  340. {
  341. struct nilfs_sustat sustat;
  342. int err;
  343. down_read(&nilfs->ns_segctor_sem);
  344. err = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat);
  345. up_read(&nilfs->ns_segctor_sem);
  346. if (err < 0) {
  347. nilfs_msg(nilfs->ns_sb, KERN_ERR,
  348. "unable to get segment stat: err=%d", err);
  349. return err;
  350. }
  351. return snprintf(buf, PAGE_SIZE, "%llu\n", sustat.ss_ndirtysegs);
  352. }
  353. static const char segments_readme_str[] =
  354. "The segments group contains attributes that describe\n"
  355. "details about volume's segments.\n\n"
  356. "(1) segments_number\n\tshow number of segments on volume.\n\n"
  357. "(2) blocks_per_segment\n\tshow number of blocks in segment.\n\n"
  358. "(3) clean_segments\n\tshow count of clean segments.\n\n"
  359. "(4) dirty_segments\n\tshow count of dirty segments.\n\n";
  360. static ssize_t
  361. nilfs_segments_README_show(struct nilfs_segments_attr *attr,
  362. struct the_nilfs *nilfs,
  363. char *buf)
  364. {
  365. return snprintf(buf, PAGE_SIZE, segments_readme_str);
  366. }
  367. NILFS_SEGMENTS_RO_ATTR(segments_number);
  368. NILFS_SEGMENTS_RO_ATTR(blocks_per_segment);
  369. NILFS_SEGMENTS_RO_ATTR(clean_segments);
  370. NILFS_SEGMENTS_RO_ATTR(dirty_segments);
  371. NILFS_SEGMENTS_RO_ATTR(README);
  372. static struct attribute *nilfs_segments_attrs[] = {
  373. NILFS_SEGMENTS_ATTR_LIST(segments_number),
  374. NILFS_SEGMENTS_ATTR_LIST(blocks_per_segment),
  375. NILFS_SEGMENTS_ATTR_LIST(clean_segments),
  376. NILFS_SEGMENTS_ATTR_LIST(dirty_segments),
  377. NILFS_SEGMENTS_ATTR_LIST(README),
  378. NULL,
  379. };
  380. NILFS_DEV_INT_GROUP_OPS(segments, dev);
  381. NILFS_DEV_INT_GROUP_TYPE(segments, dev);
  382. NILFS_DEV_INT_GROUP_FNS(segments, dev);
  383. /************************************************************************
  384. * NILFS segctor attrs *
  385. ************************************************************************/
  386. static ssize_t
  387. nilfs_segctor_last_pseg_block_show(struct nilfs_segctor_attr *attr,
  388. struct the_nilfs *nilfs,
  389. char *buf)
  390. {
  391. sector_t last_pseg;
  392. spin_lock(&nilfs->ns_last_segment_lock);
  393. last_pseg = nilfs->ns_last_pseg;
  394. spin_unlock(&nilfs->ns_last_segment_lock);
  395. return snprintf(buf, PAGE_SIZE, "%llu\n",
  396. (unsigned long long)last_pseg);
  397. }
  398. static ssize_t
  399. nilfs_segctor_last_seg_sequence_show(struct nilfs_segctor_attr *attr,
  400. struct the_nilfs *nilfs,
  401. char *buf)
  402. {
  403. u64 last_seq;
  404. spin_lock(&nilfs->ns_last_segment_lock);
  405. last_seq = nilfs->ns_last_seq;
  406. spin_unlock(&nilfs->ns_last_segment_lock);
  407. return snprintf(buf, PAGE_SIZE, "%llu\n", last_seq);
  408. }
  409. static ssize_t
  410. nilfs_segctor_last_seg_checkpoint_show(struct nilfs_segctor_attr *attr,
  411. struct the_nilfs *nilfs,
  412. char *buf)
  413. {
  414. __u64 last_cno;
  415. spin_lock(&nilfs->ns_last_segment_lock);
  416. last_cno = nilfs->ns_last_cno;
  417. spin_unlock(&nilfs->ns_last_segment_lock);
  418. return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno);
  419. }
  420. static ssize_t
  421. nilfs_segctor_current_seg_sequence_show(struct nilfs_segctor_attr *attr,
  422. struct the_nilfs *nilfs,
  423. char *buf)
  424. {
  425. u64 seg_seq;
  426. down_read(&nilfs->ns_segctor_sem);
  427. seg_seq = nilfs->ns_seg_seq;
  428. up_read(&nilfs->ns_segctor_sem);
  429. return snprintf(buf, PAGE_SIZE, "%llu\n", seg_seq);
  430. }
  431. static ssize_t
  432. nilfs_segctor_current_last_full_seg_show(struct nilfs_segctor_attr *attr,
  433. struct the_nilfs *nilfs,
  434. char *buf)
  435. {
  436. __u64 segnum;
  437. down_read(&nilfs->ns_segctor_sem);
  438. segnum = nilfs->ns_segnum;
  439. up_read(&nilfs->ns_segctor_sem);
  440. return snprintf(buf, PAGE_SIZE, "%llu\n", segnum);
  441. }
  442. static ssize_t
  443. nilfs_segctor_next_full_seg_show(struct nilfs_segctor_attr *attr,
  444. struct the_nilfs *nilfs,
  445. char *buf)
  446. {
  447. __u64 nextnum;
  448. down_read(&nilfs->ns_segctor_sem);
  449. nextnum = nilfs->ns_nextnum;
  450. up_read(&nilfs->ns_segctor_sem);
  451. return snprintf(buf, PAGE_SIZE, "%llu\n", nextnum);
  452. }
  453. static ssize_t
  454. nilfs_segctor_next_pseg_offset_show(struct nilfs_segctor_attr *attr,
  455. struct the_nilfs *nilfs,
  456. char *buf)
  457. {
  458. unsigned long pseg_offset;
  459. down_read(&nilfs->ns_segctor_sem);
  460. pseg_offset = nilfs->ns_pseg_offset;
  461. up_read(&nilfs->ns_segctor_sem);
  462. return snprintf(buf, PAGE_SIZE, "%lu\n", pseg_offset);
  463. }
  464. static ssize_t
  465. nilfs_segctor_next_checkpoint_show(struct nilfs_segctor_attr *attr,
  466. struct the_nilfs *nilfs,
  467. char *buf)
  468. {
  469. __u64 cno;
  470. down_read(&nilfs->ns_segctor_sem);
  471. cno = nilfs->ns_cno;
  472. up_read(&nilfs->ns_segctor_sem);
  473. return snprintf(buf, PAGE_SIZE, "%llu\n", cno);
  474. }
  475. static ssize_t
  476. nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr,
  477. struct the_nilfs *nilfs,
  478. char *buf)
  479. {
  480. time64_t ctime;
  481. down_read(&nilfs->ns_segctor_sem);
  482. ctime = nilfs->ns_ctime;
  483. up_read(&nilfs->ns_segctor_sem);
  484. return NILFS_SHOW_TIME(ctime, buf);
  485. }
  486. static ssize_t
  487. nilfs_segctor_last_seg_write_time_secs_show(struct nilfs_segctor_attr *attr,
  488. struct the_nilfs *nilfs,
  489. char *buf)
  490. {
  491. time64_t ctime;
  492. down_read(&nilfs->ns_segctor_sem);
  493. ctime = nilfs->ns_ctime;
  494. up_read(&nilfs->ns_segctor_sem);
  495. return snprintf(buf, PAGE_SIZE, "%llu\n", ctime);
  496. }
  497. static ssize_t
  498. nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr,
  499. struct the_nilfs *nilfs,
  500. char *buf)
  501. {
  502. time64_t nongc_ctime;
  503. down_read(&nilfs->ns_segctor_sem);
  504. nongc_ctime = nilfs->ns_nongc_ctime;
  505. up_read(&nilfs->ns_segctor_sem);
  506. return NILFS_SHOW_TIME(nongc_ctime, buf);
  507. }
  508. static ssize_t
  509. nilfs_segctor_last_nongc_write_time_secs_show(struct nilfs_segctor_attr *attr,
  510. struct the_nilfs *nilfs,
  511. char *buf)
  512. {
  513. time64_t nongc_ctime;
  514. down_read(&nilfs->ns_segctor_sem);
  515. nongc_ctime = nilfs->ns_nongc_ctime;
  516. up_read(&nilfs->ns_segctor_sem);
  517. return snprintf(buf, PAGE_SIZE, "%llu\n", nongc_ctime);
  518. }
  519. static ssize_t
  520. nilfs_segctor_dirty_data_blocks_count_show(struct nilfs_segctor_attr *attr,
  521. struct the_nilfs *nilfs,
  522. char *buf)
  523. {
  524. u32 ndirtyblks;
  525. down_read(&nilfs->ns_segctor_sem);
  526. ndirtyblks = atomic_read(&nilfs->ns_ndirtyblks);
  527. up_read(&nilfs->ns_segctor_sem);
  528. return snprintf(buf, PAGE_SIZE, "%u\n", ndirtyblks);
  529. }
  530. static const char segctor_readme_str[] =
  531. "The segctor group contains attributes that describe\n"
  532. "segctor thread activity details.\n\n"
  533. "(1) last_pseg_block\n"
  534. "\tshow start block number of the latest segment.\n\n"
  535. "(2) last_seg_sequence\n"
  536. "\tshow sequence value of the latest segment.\n\n"
  537. "(3) last_seg_checkpoint\n"
  538. "\tshow checkpoint number of the latest segment.\n\n"
  539. "(4) current_seg_sequence\n\tshow segment sequence counter.\n\n"
  540. "(5) current_last_full_seg\n"
  541. "\tshow index number of the latest full segment.\n\n"
  542. "(6) next_full_seg\n"
  543. "\tshow index number of the full segment index to be used next.\n\n"
  544. "(7) next_pseg_offset\n"
  545. "\tshow offset of next partial segment in the current full segment.\n\n"
  546. "(8) next_checkpoint\n\tshow next checkpoint number.\n\n"
  547. "(9) last_seg_write_time\n"
  548. "\tshow write time of the last segment in human-readable format.\n\n"
  549. "(10) last_seg_write_time_secs\n"
  550. "\tshow write time of the last segment in seconds.\n\n"
  551. "(11) last_nongc_write_time\n"
  552. "\tshow write time of the last segment not for cleaner operation "
  553. "in human-readable format.\n\n"
  554. "(12) last_nongc_write_time_secs\n"
  555. "\tshow write time of the last segment not for cleaner operation "
  556. "in seconds.\n\n"
  557. "(13) dirty_data_blocks_count\n"
  558. "\tshow number of dirty data blocks.\n\n";
  559. static ssize_t
  560. nilfs_segctor_README_show(struct nilfs_segctor_attr *attr,
  561. struct the_nilfs *nilfs, char *buf)
  562. {
  563. return snprintf(buf, PAGE_SIZE, segctor_readme_str);
  564. }
  565. NILFS_SEGCTOR_RO_ATTR(last_pseg_block);
  566. NILFS_SEGCTOR_RO_ATTR(last_seg_sequence);
  567. NILFS_SEGCTOR_RO_ATTR(last_seg_checkpoint);
  568. NILFS_SEGCTOR_RO_ATTR(current_seg_sequence);
  569. NILFS_SEGCTOR_RO_ATTR(current_last_full_seg);
  570. NILFS_SEGCTOR_RO_ATTR(next_full_seg);
  571. NILFS_SEGCTOR_RO_ATTR(next_pseg_offset);
  572. NILFS_SEGCTOR_RO_ATTR(next_checkpoint);
  573. NILFS_SEGCTOR_RO_ATTR(last_seg_write_time);
  574. NILFS_SEGCTOR_RO_ATTR(last_seg_write_time_secs);
  575. NILFS_SEGCTOR_RO_ATTR(last_nongc_write_time);
  576. NILFS_SEGCTOR_RO_ATTR(last_nongc_write_time_secs);
  577. NILFS_SEGCTOR_RO_ATTR(dirty_data_blocks_count);
  578. NILFS_SEGCTOR_RO_ATTR(README);
  579. static struct attribute *nilfs_segctor_attrs[] = {
  580. NILFS_SEGCTOR_ATTR_LIST(last_pseg_block),
  581. NILFS_SEGCTOR_ATTR_LIST(last_seg_sequence),
  582. NILFS_SEGCTOR_ATTR_LIST(last_seg_checkpoint),
  583. NILFS_SEGCTOR_ATTR_LIST(current_seg_sequence),
  584. NILFS_SEGCTOR_ATTR_LIST(current_last_full_seg),
  585. NILFS_SEGCTOR_ATTR_LIST(next_full_seg),
  586. NILFS_SEGCTOR_ATTR_LIST(next_pseg_offset),
  587. NILFS_SEGCTOR_ATTR_LIST(next_checkpoint),
  588. NILFS_SEGCTOR_ATTR_LIST(last_seg_write_time),
  589. NILFS_SEGCTOR_ATTR_LIST(last_seg_write_time_secs),
  590. NILFS_SEGCTOR_ATTR_LIST(last_nongc_write_time),
  591. NILFS_SEGCTOR_ATTR_LIST(last_nongc_write_time_secs),
  592. NILFS_SEGCTOR_ATTR_LIST(dirty_data_blocks_count),
  593. NILFS_SEGCTOR_ATTR_LIST(README),
  594. NULL,
  595. };
  596. NILFS_DEV_INT_GROUP_OPS(segctor, dev);
  597. NILFS_DEV_INT_GROUP_TYPE(segctor, dev);
  598. NILFS_DEV_INT_GROUP_FNS(segctor, dev);
  599. /************************************************************************
  600. * NILFS superblock attrs *
  601. ************************************************************************/
  602. static ssize_t
  603. nilfs_superblock_sb_write_time_show(struct nilfs_superblock_attr *attr,
  604. struct the_nilfs *nilfs,
  605. char *buf)
  606. {
  607. time64_t sbwtime;
  608. down_read(&nilfs->ns_sem);
  609. sbwtime = nilfs->ns_sbwtime;
  610. up_read(&nilfs->ns_sem);
  611. return NILFS_SHOW_TIME(sbwtime, buf);
  612. }
  613. static ssize_t
  614. nilfs_superblock_sb_write_time_secs_show(struct nilfs_superblock_attr *attr,
  615. struct the_nilfs *nilfs,
  616. char *buf)
  617. {
  618. time64_t sbwtime;
  619. down_read(&nilfs->ns_sem);
  620. sbwtime = nilfs->ns_sbwtime;
  621. up_read(&nilfs->ns_sem);
  622. return snprintf(buf, PAGE_SIZE, "%llu\n", sbwtime);
  623. }
  624. static ssize_t
  625. nilfs_superblock_sb_write_count_show(struct nilfs_superblock_attr *attr,
  626. struct the_nilfs *nilfs,
  627. char *buf)
  628. {
  629. unsigned int sbwcount;
  630. down_read(&nilfs->ns_sem);
  631. sbwcount = nilfs->ns_sbwcount;
  632. up_read(&nilfs->ns_sem);
  633. return snprintf(buf, PAGE_SIZE, "%u\n", sbwcount);
  634. }
  635. static ssize_t
  636. nilfs_superblock_sb_update_frequency_show(struct nilfs_superblock_attr *attr,
  637. struct the_nilfs *nilfs,
  638. char *buf)
  639. {
  640. unsigned int sb_update_freq;
  641. down_read(&nilfs->ns_sem);
  642. sb_update_freq = nilfs->ns_sb_update_freq;
  643. up_read(&nilfs->ns_sem);
  644. return snprintf(buf, PAGE_SIZE, "%u\n", sb_update_freq);
  645. }
  646. static ssize_t
  647. nilfs_superblock_sb_update_frequency_store(struct nilfs_superblock_attr *attr,
  648. struct the_nilfs *nilfs,
  649. const char *buf, size_t count)
  650. {
  651. unsigned int val;
  652. int err;
  653. err = kstrtouint(skip_spaces(buf), 0, &val);
  654. if (err) {
  655. nilfs_msg(nilfs->ns_sb, KERN_ERR,
  656. "unable to convert string: err=%d", err);
  657. return err;
  658. }
  659. if (val < NILFS_SB_FREQ) {
  660. val = NILFS_SB_FREQ;
  661. nilfs_msg(nilfs->ns_sb, KERN_WARNING,
  662. "superblock update frequency cannot be lesser than 10 seconds");
  663. }
  664. down_write(&nilfs->ns_sem);
  665. nilfs->ns_sb_update_freq = val;
  666. up_write(&nilfs->ns_sem);
  667. return count;
  668. }
  669. static const char sb_readme_str[] =
  670. "The superblock group contains attributes that describe\n"
  671. "superblock's details.\n\n"
  672. "(1) sb_write_time\n\tshow previous write time of super block "
  673. "in human-readable format.\n\n"
  674. "(2) sb_write_time_secs\n\tshow previous write time of super block "
  675. "in seconds.\n\n"
  676. "(3) sb_write_count\n\tshow write count of super block.\n\n"
  677. "(4) sb_update_frequency\n"
  678. "\tshow/set interval of periodical update of superblock (in seconds).\n\n"
  679. "\tYou can set preferable frequency of superblock update by command:\n\n"
  680. "\t'echo <val> > /sys/fs/<nilfs>/<dev>/superblock/sb_update_frequency'\n";
  681. static ssize_t
  682. nilfs_superblock_README_show(struct nilfs_superblock_attr *attr,
  683. struct the_nilfs *nilfs, char *buf)
  684. {
  685. return snprintf(buf, PAGE_SIZE, sb_readme_str);
  686. }
  687. NILFS_SUPERBLOCK_RO_ATTR(sb_write_time);
  688. NILFS_SUPERBLOCK_RO_ATTR(sb_write_time_secs);
  689. NILFS_SUPERBLOCK_RO_ATTR(sb_write_count);
  690. NILFS_SUPERBLOCK_RW_ATTR(sb_update_frequency);
  691. NILFS_SUPERBLOCK_RO_ATTR(README);
  692. static struct attribute *nilfs_superblock_attrs[] = {
  693. NILFS_SUPERBLOCK_ATTR_LIST(sb_write_time),
  694. NILFS_SUPERBLOCK_ATTR_LIST(sb_write_time_secs),
  695. NILFS_SUPERBLOCK_ATTR_LIST(sb_write_count),
  696. NILFS_SUPERBLOCK_ATTR_LIST(sb_update_frequency),
  697. NILFS_SUPERBLOCK_ATTR_LIST(README),
  698. NULL,
  699. };
  700. NILFS_DEV_INT_GROUP_OPS(superblock, dev);
  701. NILFS_DEV_INT_GROUP_TYPE(superblock, dev);
  702. NILFS_DEV_INT_GROUP_FNS(superblock, dev);
  703. /************************************************************************
  704. * NILFS device attrs *
  705. ************************************************************************/
  706. static
  707. ssize_t nilfs_dev_revision_show(struct nilfs_dev_attr *attr,
  708. struct the_nilfs *nilfs,
  709. char *buf)
  710. {
  711. struct nilfs_super_block **sbp = nilfs->ns_sbp;
  712. u32 major = le32_to_cpu(sbp[0]->s_rev_level);
  713. u16 minor = le16_to_cpu(sbp[0]->s_minor_rev_level);
  714. return snprintf(buf, PAGE_SIZE, "%d.%d\n", major, minor);
  715. }
  716. static
  717. ssize_t nilfs_dev_blocksize_show(struct nilfs_dev_attr *attr,
  718. struct the_nilfs *nilfs,
  719. char *buf)
  720. {
  721. return snprintf(buf, PAGE_SIZE, "%u\n", nilfs->ns_blocksize);
  722. }
  723. static
  724. ssize_t nilfs_dev_device_size_show(struct nilfs_dev_attr *attr,
  725. struct the_nilfs *nilfs,
  726. char *buf)
  727. {
  728. struct nilfs_super_block **sbp = nilfs->ns_sbp;
  729. u64 dev_size = le64_to_cpu(sbp[0]->s_dev_size);
  730. return snprintf(buf, PAGE_SIZE, "%llu\n", dev_size);
  731. }
  732. static
  733. ssize_t nilfs_dev_free_blocks_show(struct nilfs_dev_attr *attr,
  734. struct the_nilfs *nilfs,
  735. char *buf)
  736. {
  737. sector_t free_blocks = 0;
  738. nilfs_count_free_blocks(nilfs, &free_blocks);
  739. return snprintf(buf, PAGE_SIZE, "%llu\n",
  740. (unsigned long long)free_blocks);
  741. }
  742. static
  743. ssize_t nilfs_dev_uuid_show(struct nilfs_dev_attr *attr,
  744. struct the_nilfs *nilfs,
  745. char *buf)
  746. {
  747. struct nilfs_super_block **sbp = nilfs->ns_sbp;
  748. return snprintf(buf, PAGE_SIZE, "%pUb\n", sbp[0]->s_uuid);
  749. }
  750. static
  751. ssize_t nilfs_dev_volume_name_show(struct nilfs_dev_attr *attr,
  752. struct the_nilfs *nilfs,
  753. char *buf)
  754. {
  755. struct nilfs_super_block **sbp = nilfs->ns_sbp;
  756. return scnprintf(buf, sizeof(sbp[0]->s_volume_name), "%s\n",
  757. sbp[0]->s_volume_name);
  758. }
  759. static const char dev_readme_str[] =
  760. "The <device> group contains attributes that describe file system\n"
  761. "partition's details.\n\n"
  762. "(1) revision\n\tshow NILFS file system revision.\n\n"
  763. "(2) blocksize\n\tshow volume block size in bytes.\n\n"
  764. "(3) device_size\n\tshow volume size in bytes.\n\n"
  765. "(4) free_blocks\n\tshow count of free blocks on volume.\n\n"
  766. "(5) uuid\n\tshow volume's UUID.\n\n"
  767. "(6) volume_name\n\tshow volume's name.\n\n";
  768. static ssize_t nilfs_dev_README_show(struct nilfs_dev_attr *attr,
  769. struct the_nilfs *nilfs,
  770. char *buf)
  771. {
  772. return snprintf(buf, PAGE_SIZE, dev_readme_str);
  773. }
  774. NILFS_DEV_RO_ATTR(revision);
  775. NILFS_DEV_RO_ATTR(blocksize);
  776. NILFS_DEV_RO_ATTR(device_size);
  777. NILFS_DEV_RO_ATTR(free_blocks);
  778. NILFS_DEV_RO_ATTR(uuid);
  779. NILFS_DEV_RO_ATTR(volume_name);
  780. NILFS_DEV_RO_ATTR(README);
  781. static struct attribute *nilfs_dev_attrs[] = {
  782. NILFS_DEV_ATTR_LIST(revision),
  783. NILFS_DEV_ATTR_LIST(blocksize),
  784. NILFS_DEV_ATTR_LIST(device_size),
  785. NILFS_DEV_ATTR_LIST(free_blocks),
  786. NILFS_DEV_ATTR_LIST(uuid),
  787. NILFS_DEV_ATTR_LIST(volume_name),
  788. NILFS_DEV_ATTR_LIST(README),
  789. NULL,
  790. };
  791. static ssize_t nilfs_dev_attr_show(struct kobject *kobj,
  792. struct attribute *attr, char *buf)
  793. {
  794. struct the_nilfs *nilfs = container_of(kobj, struct the_nilfs,
  795. ns_dev_kobj);
  796. struct nilfs_dev_attr *a = container_of(attr, struct nilfs_dev_attr,
  797. attr);
  798. return a->show ? a->show(a, nilfs, buf) : 0;
  799. }
  800. static ssize_t nilfs_dev_attr_store(struct kobject *kobj,
  801. struct attribute *attr,
  802. const char *buf, size_t len)
  803. {
  804. struct the_nilfs *nilfs = container_of(kobj, struct the_nilfs,
  805. ns_dev_kobj);
  806. struct nilfs_dev_attr *a = container_of(attr, struct nilfs_dev_attr,
  807. attr);
  808. return a->store ? a->store(a, nilfs, buf, len) : 0;
  809. }
  810. static void nilfs_dev_attr_release(struct kobject *kobj)
  811. {
  812. struct the_nilfs *nilfs = container_of(kobj, struct the_nilfs,
  813. ns_dev_kobj);
  814. complete(&nilfs->ns_dev_kobj_unregister);
  815. }
  816. static const struct sysfs_ops nilfs_dev_attr_ops = {
  817. .show = nilfs_dev_attr_show,
  818. .store = nilfs_dev_attr_store,
  819. };
  820. static struct kobj_type nilfs_dev_ktype = {
  821. .default_attrs = nilfs_dev_attrs,
  822. .sysfs_ops = &nilfs_dev_attr_ops,
  823. .release = nilfs_dev_attr_release,
  824. };
  825. int nilfs_sysfs_create_device_group(struct super_block *sb)
  826. {
  827. struct the_nilfs *nilfs = sb->s_fs_info;
  828. size_t devgrp_size = sizeof(struct nilfs_sysfs_dev_subgroups);
  829. int err;
  830. nilfs->ns_dev_subgroups = kzalloc(devgrp_size, GFP_KERNEL);
  831. if (unlikely(!nilfs->ns_dev_subgroups)) {
  832. err = -ENOMEM;
  833. nilfs_msg(sb, KERN_ERR,
  834. "unable to allocate memory for device group");
  835. goto failed_create_device_group;
  836. }
  837. nilfs->ns_dev_kobj.kset = nilfs_kset;
  838. init_completion(&nilfs->ns_dev_kobj_unregister);
  839. err = kobject_init_and_add(&nilfs->ns_dev_kobj, &nilfs_dev_ktype, NULL,
  840. "%s", sb->s_id);
  841. if (err)
  842. goto free_dev_subgroups;
  843. err = nilfs_sysfs_create_mounted_snapshots_group(nilfs);
  844. if (err)
  845. goto cleanup_dev_kobject;
  846. err = nilfs_sysfs_create_checkpoints_group(nilfs);
  847. if (err)
  848. goto delete_mounted_snapshots_group;
  849. err = nilfs_sysfs_create_segments_group(nilfs);
  850. if (err)
  851. goto delete_checkpoints_group;
  852. err = nilfs_sysfs_create_superblock_group(nilfs);
  853. if (err)
  854. goto delete_segments_group;
  855. err = nilfs_sysfs_create_segctor_group(nilfs);
  856. if (err)
  857. goto delete_superblock_group;
  858. return 0;
  859. delete_superblock_group:
  860. nilfs_sysfs_delete_superblock_group(nilfs);
  861. delete_segments_group:
  862. nilfs_sysfs_delete_segments_group(nilfs);
  863. delete_checkpoints_group:
  864. nilfs_sysfs_delete_checkpoints_group(nilfs);
  865. delete_mounted_snapshots_group:
  866. nilfs_sysfs_delete_mounted_snapshots_group(nilfs);
  867. cleanup_dev_kobject:
  868. kobject_del(&nilfs->ns_dev_kobj);
  869. free_dev_subgroups:
  870. kfree(nilfs->ns_dev_subgroups);
  871. failed_create_device_group:
  872. return err;
  873. }
  874. void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs)
  875. {
  876. nilfs_sysfs_delete_mounted_snapshots_group(nilfs);
  877. nilfs_sysfs_delete_checkpoints_group(nilfs);
  878. nilfs_sysfs_delete_segments_group(nilfs);
  879. nilfs_sysfs_delete_superblock_group(nilfs);
  880. nilfs_sysfs_delete_segctor_group(nilfs);
  881. kobject_del(&nilfs->ns_dev_kobj);
  882. kfree(nilfs->ns_dev_subgroups);
  883. }
  884. /************************************************************************
  885. * NILFS feature attrs *
  886. ************************************************************************/
  887. static ssize_t nilfs_feature_revision_show(struct kobject *kobj,
  888. struct attribute *attr, char *buf)
  889. {
  890. return snprintf(buf, PAGE_SIZE, "%d.%d\n",
  891. NILFS_CURRENT_REV, NILFS_MINOR_REV);
  892. }
  893. static const char features_readme_str[] =
  894. "The features group contains attributes that describe NILFS file\n"
  895. "system driver features.\n\n"
  896. "(1) revision\n\tshow current revision of NILFS file system driver.\n";
  897. static ssize_t nilfs_feature_README_show(struct kobject *kobj,
  898. struct attribute *attr,
  899. char *buf)
  900. {
  901. return snprintf(buf, PAGE_SIZE, features_readme_str);
  902. }
  903. NILFS_FEATURE_RO_ATTR(revision);
  904. NILFS_FEATURE_RO_ATTR(README);
  905. static struct attribute *nilfs_feature_attrs[] = {
  906. NILFS_FEATURE_ATTR_LIST(revision),
  907. NILFS_FEATURE_ATTR_LIST(README),
  908. NULL,
  909. };
  910. static const struct attribute_group nilfs_feature_attr_group = {
  911. .name = "features",
  912. .attrs = nilfs_feature_attrs,
  913. };
  914. int __init nilfs_sysfs_init(void)
  915. {
  916. int err;
  917. nilfs_kset = kset_create_and_add(NILFS_ROOT_GROUP_NAME, NULL, fs_kobj);
  918. if (!nilfs_kset) {
  919. err = -ENOMEM;
  920. nilfs_msg(NULL, KERN_ERR,
  921. "unable to create sysfs entry: err=%d", err);
  922. goto failed_sysfs_init;
  923. }
  924. err = sysfs_create_group(&nilfs_kset->kobj, &nilfs_feature_attr_group);
  925. if (unlikely(err)) {
  926. nilfs_msg(NULL, KERN_ERR,
  927. "unable to create feature group: err=%d", err);
  928. goto cleanup_sysfs_init;
  929. }
  930. return 0;
  931. cleanup_sysfs_init:
  932. kset_unregister(nilfs_kset);
  933. failed_sysfs_init:
  934. return err;
  935. }
  936. void nilfs_sysfs_exit(void)
  937. {
  938. sysfs_remove_group(&nilfs_kset->kobj, &nilfs_feature_attr_group);
  939. kset_unregister(nilfs_kset);
  940. }