sysfs.c 32 KB

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