super.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. /*
  2. * fs/logfs/super.c
  3. *
  4. * As should be obvious for Linux kernel code, license is GPLv2
  5. *
  6. * Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
  7. *
  8. * Generally contains mount/umount code and also serves as a dump area for
  9. * any functions that don't fit elsewhere and neither justify a file of their
  10. * own.
  11. */
  12. #include "logfs.h"
  13. #include <linux/bio.h>
  14. #include <linux/slab.h>
  15. #include <linux/blkdev.h>
  16. #include <linux/module.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/statfs.h>
  19. #include <linux/buffer_head.h>
  20. static DEFINE_MUTEX(emergency_mutex);
  21. static struct page *emergency_page;
  22. struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index)
  23. {
  24. filler_t *filler = (filler_t *)mapping->a_ops->readpage;
  25. struct page *page;
  26. int err;
  27. page = read_cache_page(mapping, index, filler, NULL);
  28. if (page)
  29. return page;
  30. /* No more pages available, switch to emergency page */
  31. printk(KERN_INFO"Logfs: Using emergency page\n");
  32. mutex_lock(&emergency_mutex);
  33. err = filler(NULL, emergency_page);
  34. if (err) {
  35. mutex_unlock(&emergency_mutex);
  36. printk(KERN_EMERG"Logfs: Error reading emergency page\n");
  37. return ERR_PTR(err);
  38. }
  39. return emergency_page;
  40. }
  41. void emergency_read_end(struct page *page)
  42. {
  43. if (page == emergency_page)
  44. mutex_unlock(&emergency_mutex);
  45. else
  46. page_cache_release(page);
  47. }
  48. static void dump_segfile(struct super_block *sb)
  49. {
  50. struct logfs_super *super = logfs_super(sb);
  51. struct logfs_segment_entry se;
  52. u32 segno;
  53. for (segno = 0; segno < super->s_no_segs; segno++) {
  54. logfs_get_segment_entry(sb, segno, &se);
  55. printk("%3x: %6x %8x", segno, be32_to_cpu(se.ec_level),
  56. be32_to_cpu(se.valid));
  57. if (++segno < super->s_no_segs) {
  58. logfs_get_segment_entry(sb, segno, &se);
  59. printk(" %6x %8x", be32_to_cpu(se.ec_level),
  60. be32_to_cpu(se.valid));
  61. }
  62. if (++segno < super->s_no_segs) {
  63. logfs_get_segment_entry(sb, segno, &se);
  64. printk(" %6x %8x", be32_to_cpu(se.ec_level),
  65. be32_to_cpu(se.valid));
  66. }
  67. if (++segno < super->s_no_segs) {
  68. logfs_get_segment_entry(sb, segno, &se);
  69. printk(" %6x %8x", be32_to_cpu(se.ec_level),
  70. be32_to_cpu(se.valid));
  71. }
  72. printk("\n");
  73. }
  74. }
  75. /*
  76. * logfs_crash_dump - dump debug information to device
  77. *
  78. * The LogFS superblock only occupies part of a segment. This function will
  79. * write as much debug information as it can gather into the spare space.
  80. */
  81. void logfs_crash_dump(struct super_block *sb)
  82. {
  83. dump_segfile(sb);
  84. }
  85. /*
  86. * FIXME: There should be a reserve for root, similar to ext2.
  87. */
  88. int logfs_statfs(struct dentry *dentry, struct kstatfs *stats)
  89. {
  90. struct super_block *sb = dentry->d_sb;
  91. struct logfs_super *super = logfs_super(sb);
  92. stats->f_type = LOGFS_MAGIC_U32;
  93. stats->f_bsize = sb->s_blocksize;
  94. stats->f_blocks = super->s_size >> LOGFS_BLOCK_BITS >> 3;
  95. stats->f_bfree = super->s_free_bytes >> sb->s_blocksize_bits;
  96. stats->f_bavail = super->s_free_bytes >> sb->s_blocksize_bits;
  97. stats->f_files = 0;
  98. stats->f_ffree = 0;
  99. stats->f_namelen = LOGFS_MAX_NAMELEN;
  100. return 0;
  101. }
  102. static int logfs_sb_set(struct super_block *sb, void *_super)
  103. {
  104. struct logfs_super *super = _super;
  105. sb->s_fs_info = super;
  106. sb->s_mtd = super->s_mtd;
  107. sb->s_bdev = super->s_bdev;
  108. #ifdef CONFIG_BLOCK
  109. if (sb->s_bdev)
  110. sb->s_bdi = &bdev_get_queue(sb->s_bdev)->backing_dev_info;
  111. #endif
  112. #ifdef CONFIG_MTD
  113. if (sb->s_mtd)
  114. sb->s_bdi = sb->s_mtd->backing_dev_info;
  115. #endif
  116. return 0;
  117. }
  118. static int logfs_sb_test(struct super_block *sb, void *_super)
  119. {
  120. struct logfs_super *super = _super;
  121. struct mtd_info *mtd = super->s_mtd;
  122. if (mtd && sb->s_mtd == mtd)
  123. return 1;
  124. if (super->s_bdev && sb->s_bdev == super->s_bdev)
  125. return 1;
  126. return 0;
  127. }
  128. static void set_segment_header(struct logfs_segment_header *sh, u8 type,
  129. u8 level, u32 segno, u32 ec)
  130. {
  131. sh->pad = 0;
  132. sh->type = type;
  133. sh->level = level;
  134. sh->segno = cpu_to_be32(segno);
  135. sh->ec = cpu_to_be32(ec);
  136. sh->gec = cpu_to_be64(segno);
  137. sh->crc = logfs_crc32(sh, LOGFS_SEGMENT_HEADERSIZE, 4);
  138. }
  139. static void logfs_write_ds(struct super_block *sb, struct logfs_disk_super *ds,
  140. u32 segno, u32 ec)
  141. {
  142. struct logfs_super *super = logfs_super(sb);
  143. struct logfs_segment_header *sh = &ds->ds_sh;
  144. int i;
  145. memset(ds, 0, sizeof(*ds));
  146. set_segment_header(sh, SEG_SUPER, 0, segno, ec);
  147. ds->ds_ifile_levels = super->s_ifile_levels;
  148. ds->ds_iblock_levels = super->s_iblock_levels;
  149. ds->ds_data_levels = super->s_data_levels; /* XXX: Remove */
  150. ds->ds_segment_shift = super->s_segshift;
  151. ds->ds_block_shift = sb->s_blocksize_bits;
  152. ds->ds_write_shift = super->s_writeshift;
  153. ds->ds_filesystem_size = cpu_to_be64(super->s_size);
  154. ds->ds_segment_size = cpu_to_be32(super->s_segsize);
  155. ds->ds_bad_seg_reserve = cpu_to_be32(super->s_bad_seg_reserve);
  156. ds->ds_feature_incompat = cpu_to_be64(super->s_feature_incompat);
  157. ds->ds_feature_ro_compat= cpu_to_be64(super->s_feature_ro_compat);
  158. ds->ds_feature_compat = cpu_to_be64(super->s_feature_compat);
  159. ds->ds_feature_flags = cpu_to_be64(super->s_feature_flags);
  160. ds->ds_root_reserve = cpu_to_be64(super->s_root_reserve);
  161. ds->ds_speed_reserve = cpu_to_be64(super->s_speed_reserve);
  162. journal_for_each(i)
  163. ds->ds_journal_seg[i] = cpu_to_be32(super->s_journal_seg[i]);
  164. ds->ds_magic = cpu_to_be64(LOGFS_MAGIC);
  165. ds->ds_crc = logfs_crc32(ds, sizeof(*ds),
  166. LOGFS_SEGMENT_HEADERSIZE + 12);
  167. }
  168. static int write_one_sb(struct super_block *sb,
  169. struct page *(*find_sb)(struct super_block *sb, u64 *ofs))
  170. {
  171. struct logfs_super *super = logfs_super(sb);
  172. struct logfs_disk_super *ds;
  173. struct logfs_segment_entry se;
  174. struct page *page;
  175. u64 ofs;
  176. u32 ec, segno;
  177. int err;
  178. page = find_sb(sb, &ofs);
  179. if (!page)
  180. return -EIO;
  181. ds = page_address(page);
  182. segno = seg_no(sb, ofs);
  183. logfs_get_segment_entry(sb, segno, &se);
  184. ec = be32_to_cpu(se.ec_level) >> 4;
  185. ec++;
  186. logfs_set_segment_erased(sb, segno, ec, 0);
  187. logfs_write_ds(sb, ds, segno, ec);
  188. err = super->s_devops->write_sb(sb, page);
  189. page_cache_release(page);
  190. return err;
  191. }
  192. int logfs_write_sb(struct super_block *sb)
  193. {
  194. struct logfs_super *super = logfs_super(sb);
  195. int err;
  196. /* First superblock */
  197. err = write_one_sb(sb, super->s_devops->find_first_sb);
  198. if (err)
  199. return err;
  200. /* Last superblock */
  201. err = write_one_sb(sb, super->s_devops->find_last_sb);
  202. if (err)
  203. return err;
  204. return 0;
  205. }
  206. static int ds_cmp(const void *ds0, const void *ds1)
  207. {
  208. size_t len = sizeof(struct logfs_disk_super);
  209. /* We know the segment headers differ, so ignore them */
  210. len -= LOGFS_SEGMENT_HEADERSIZE;
  211. ds0 += LOGFS_SEGMENT_HEADERSIZE;
  212. ds1 += LOGFS_SEGMENT_HEADERSIZE;
  213. return memcmp(ds0, ds1, len);
  214. }
  215. static int logfs_recover_sb(struct super_block *sb)
  216. {
  217. struct logfs_super *super = logfs_super(sb);
  218. struct logfs_disk_super _ds0, *ds0 = &_ds0;
  219. struct logfs_disk_super _ds1, *ds1 = &_ds1;
  220. int err, valid0, valid1;
  221. /* read first superblock */
  222. err = wbuf_read(sb, super->s_sb_ofs[0], sizeof(*ds0), ds0);
  223. if (err)
  224. return err;
  225. /* read last superblock */
  226. err = wbuf_read(sb, super->s_sb_ofs[1], sizeof(*ds1), ds1);
  227. if (err)
  228. return err;
  229. valid0 = logfs_check_ds(ds0) == 0;
  230. valid1 = logfs_check_ds(ds1) == 0;
  231. if (!valid0 && valid1) {
  232. printk(KERN_INFO"First superblock is invalid - fixing.\n");
  233. return write_one_sb(sb, super->s_devops->find_first_sb);
  234. }
  235. if (valid0 && !valid1) {
  236. printk(KERN_INFO"Last superblock is invalid - fixing.\n");
  237. return write_one_sb(sb, super->s_devops->find_last_sb);
  238. }
  239. if (valid0 && valid1 && ds_cmp(ds0, ds1)) {
  240. printk(KERN_INFO"Superblocks don't match - fixing.\n");
  241. return logfs_write_sb(sb);
  242. }
  243. /* If neither is valid now, something's wrong. Didn't we properly
  244. * check them before?!? */
  245. BUG_ON(!valid0 && !valid1);
  246. return 0;
  247. }
  248. static int logfs_make_writeable(struct super_block *sb)
  249. {
  250. int err;
  251. err = logfs_open_segfile(sb);
  252. if (err)
  253. return err;
  254. /* Repair any broken superblock copies */
  255. err = logfs_recover_sb(sb);
  256. if (err)
  257. return err;
  258. /* Check areas for trailing unaccounted data */
  259. err = logfs_check_areas(sb);
  260. if (err)
  261. return err;
  262. /* Do one GC pass before any data gets dirtied */
  263. logfs_gc_pass(sb);
  264. /* after all initializations are done, replay the journal
  265. * for rw-mounts, if necessary */
  266. err = logfs_replay_journal(sb);
  267. if (err)
  268. return err;
  269. return 0;
  270. }
  271. static int logfs_get_sb_final(struct super_block *sb)
  272. {
  273. struct logfs_super *super = logfs_super(sb);
  274. struct inode *rootdir;
  275. int err;
  276. /* root dir */
  277. rootdir = logfs_iget(sb, LOGFS_INO_ROOT);
  278. if (IS_ERR(rootdir))
  279. goto fail;
  280. sb->s_root = d_make_root(rootdir);
  281. if (!sb->s_root)
  282. goto fail;
  283. /* at that point we know that ->put_super() will be called */
  284. super->s_erase_page = alloc_pages(GFP_KERNEL, 0);
  285. if (!super->s_erase_page)
  286. return -ENOMEM;
  287. memset(page_address(super->s_erase_page), 0xFF, PAGE_SIZE);
  288. /* FIXME: check for read-only mounts */
  289. err = logfs_make_writeable(sb);
  290. if (err) {
  291. __free_page(super->s_erase_page);
  292. return err;
  293. }
  294. log_super("LogFS: Finished mounting\n");
  295. return 0;
  296. fail:
  297. iput(super->s_master_inode);
  298. iput(super->s_segfile_inode);
  299. iput(super->s_mapping_inode);
  300. return -EIO;
  301. }
  302. int logfs_check_ds(struct logfs_disk_super *ds)
  303. {
  304. struct logfs_segment_header *sh = &ds->ds_sh;
  305. if (ds->ds_magic != cpu_to_be64(LOGFS_MAGIC))
  306. return -EINVAL;
  307. if (sh->crc != logfs_crc32(sh, LOGFS_SEGMENT_HEADERSIZE, 4))
  308. return -EINVAL;
  309. if (ds->ds_crc != logfs_crc32(ds, sizeof(*ds),
  310. LOGFS_SEGMENT_HEADERSIZE + 12))
  311. return -EINVAL;
  312. return 0;
  313. }
  314. static struct page *find_super_block(struct super_block *sb)
  315. {
  316. struct logfs_super *super = logfs_super(sb);
  317. struct page *first, *last;
  318. first = super->s_devops->find_first_sb(sb, &super->s_sb_ofs[0]);
  319. if (!first || IS_ERR(first))
  320. return NULL;
  321. last = super->s_devops->find_last_sb(sb, &super->s_sb_ofs[1]);
  322. if (!last || IS_ERR(last)) {
  323. page_cache_release(first);
  324. return NULL;
  325. }
  326. if (!logfs_check_ds(page_address(first))) {
  327. page_cache_release(last);
  328. return first;
  329. }
  330. /* First one didn't work, try the second superblock */
  331. if (!logfs_check_ds(page_address(last))) {
  332. page_cache_release(first);
  333. return last;
  334. }
  335. /* Neither worked, sorry folks */
  336. page_cache_release(first);
  337. page_cache_release(last);
  338. return NULL;
  339. }
  340. static int __logfs_read_sb(struct super_block *sb)
  341. {
  342. struct logfs_super *super = logfs_super(sb);
  343. struct page *page;
  344. struct logfs_disk_super *ds;
  345. int i;
  346. page = find_super_block(sb);
  347. if (!page)
  348. return -EINVAL;
  349. ds = page_address(page);
  350. super->s_size = be64_to_cpu(ds->ds_filesystem_size);
  351. super->s_root_reserve = be64_to_cpu(ds->ds_root_reserve);
  352. super->s_speed_reserve = be64_to_cpu(ds->ds_speed_reserve);
  353. super->s_bad_seg_reserve = be32_to_cpu(ds->ds_bad_seg_reserve);
  354. super->s_segsize = 1 << ds->ds_segment_shift;
  355. super->s_segmask = (1 << ds->ds_segment_shift) - 1;
  356. super->s_segshift = ds->ds_segment_shift;
  357. sb->s_blocksize = 1 << ds->ds_block_shift;
  358. sb->s_blocksize_bits = ds->ds_block_shift;
  359. super->s_writesize = 1 << ds->ds_write_shift;
  360. super->s_writeshift = ds->ds_write_shift;
  361. super->s_no_segs = super->s_size >> super->s_segshift;
  362. super->s_no_blocks = super->s_segsize >> sb->s_blocksize_bits;
  363. super->s_feature_incompat = be64_to_cpu(ds->ds_feature_incompat);
  364. super->s_feature_ro_compat = be64_to_cpu(ds->ds_feature_ro_compat);
  365. super->s_feature_compat = be64_to_cpu(ds->ds_feature_compat);
  366. super->s_feature_flags = be64_to_cpu(ds->ds_feature_flags);
  367. journal_for_each(i)
  368. super->s_journal_seg[i] = be32_to_cpu(ds->ds_journal_seg[i]);
  369. super->s_ifile_levels = ds->ds_ifile_levels;
  370. super->s_iblock_levels = ds->ds_iblock_levels;
  371. super->s_data_levels = ds->ds_data_levels;
  372. super->s_total_levels = super->s_ifile_levels + super->s_iblock_levels
  373. + super->s_data_levels;
  374. page_cache_release(page);
  375. return 0;
  376. }
  377. static int logfs_read_sb(struct super_block *sb, int read_only)
  378. {
  379. struct logfs_super *super = logfs_super(sb);
  380. int ret;
  381. super->s_btree_pool = mempool_create(32, btree_alloc, btree_free, NULL);
  382. if (!super->s_btree_pool)
  383. return -ENOMEM;
  384. btree_init_mempool64(&super->s_shadow_tree.new, super->s_btree_pool);
  385. btree_init_mempool64(&super->s_shadow_tree.old, super->s_btree_pool);
  386. btree_init_mempool32(&super->s_shadow_tree.segment_map,
  387. super->s_btree_pool);
  388. ret = logfs_init_mapping(sb);
  389. if (ret)
  390. return ret;
  391. ret = __logfs_read_sb(sb);
  392. if (ret)
  393. return ret;
  394. if (super->s_feature_incompat & ~LOGFS_FEATURES_INCOMPAT)
  395. return -EIO;
  396. if ((super->s_feature_ro_compat & ~LOGFS_FEATURES_RO_COMPAT) &&
  397. !read_only)
  398. return -EIO;
  399. ret = logfs_init_rw(sb);
  400. if (ret)
  401. return ret;
  402. ret = logfs_init_areas(sb);
  403. if (ret)
  404. return ret;
  405. ret = logfs_init_gc(sb);
  406. if (ret)
  407. return ret;
  408. ret = logfs_init_journal(sb);
  409. if (ret)
  410. return ret;
  411. return 0;
  412. }
  413. static void logfs_kill_sb(struct super_block *sb)
  414. {
  415. struct logfs_super *super = logfs_super(sb);
  416. log_super("LogFS: Start unmounting\n");
  417. /* Alias entries slow down mount, so evict as many as possible */
  418. sync_filesystem(sb);
  419. logfs_write_anchor(sb);
  420. free_areas(sb);
  421. /*
  422. * From this point on alias entries are simply dropped - and any
  423. * writes to the object store are considered bugs.
  424. */
  425. log_super("LogFS: Now in shutdown\n");
  426. generic_shutdown_super(sb);
  427. super->s_flags |= LOGFS_SB_FLAG_SHUTDOWN;
  428. BUG_ON(super->s_dirty_used_bytes || super->s_dirty_free_bytes);
  429. logfs_cleanup_gc(sb);
  430. logfs_cleanup_journal(sb);
  431. logfs_cleanup_areas(sb);
  432. logfs_cleanup_rw(sb);
  433. if (super->s_erase_page)
  434. __free_page(super->s_erase_page);
  435. super->s_devops->put_device(super);
  436. logfs_mempool_destroy(super->s_btree_pool);
  437. logfs_mempool_destroy(super->s_alias_pool);
  438. kfree(super);
  439. log_super("LogFS: Finished unmounting\n");
  440. }
  441. static struct dentry *logfs_get_sb_device(struct logfs_super *super,
  442. struct file_system_type *type, int flags)
  443. {
  444. struct super_block *sb;
  445. int err = -ENOMEM;
  446. static int mount_count;
  447. log_super("LogFS: Start mount %x\n", mount_count++);
  448. err = -EINVAL;
  449. sb = sget(type, logfs_sb_test, logfs_sb_set, flags | MS_NOATIME, super);
  450. if (IS_ERR(sb)) {
  451. super->s_devops->put_device(super);
  452. kfree(super);
  453. return ERR_CAST(sb);
  454. }
  455. if (sb->s_root) {
  456. /* Device is already in use */
  457. super->s_devops->put_device(super);
  458. kfree(super);
  459. return dget(sb->s_root);
  460. }
  461. /*
  462. * sb->s_maxbytes is limited to 8TB. On 32bit systems, the page cache
  463. * only covers 16TB and the upper 8TB are used for indirect blocks.
  464. * On 64bit system we could bump up the limit, but that would make
  465. * the filesystem incompatible with 32bit systems.
  466. */
  467. sb->s_maxbytes = (1ull << 43) - 1;
  468. sb->s_max_links = LOGFS_LINK_MAX;
  469. sb->s_op = &logfs_super_operations;
  470. err = logfs_read_sb(sb, sb->s_flags & MS_RDONLY);
  471. if (err)
  472. goto err1;
  473. sb->s_flags |= MS_ACTIVE;
  474. err = logfs_get_sb_final(sb);
  475. if (err) {
  476. deactivate_locked_super(sb);
  477. return ERR_PTR(err);
  478. }
  479. return dget(sb->s_root);
  480. err1:
  481. /* no ->s_root, no ->put_super() */
  482. iput(super->s_master_inode);
  483. iput(super->s_segfile_inode);
  484. iput(super->s_mapping_inode);
  485. deactivate_locked_super(sb);
  486. return ERR_PTR(err);
  487. }
  488. static struct dentry *logfs_mount(struct file_system_type *type, int flags,
  489. const char *devname, void *data)
  490. {
  491. ulong mtdnr;
  492. struct logfs_super *super;
  493. int err;
  494. super = kzalloc(sizeof(*super), GFP_KERNEL);
  495. if (!super)
  496. return ERR_PTR(-ENOMEM);
  497. mutex_init(&super->s_dirop_mutex);
  498. mutex_init(&super->s_object_alias_mutex);
  499. INIT_LIST_HEAD(&super->s_freeing_list);
  500. if (!devname)
  501. err = logfs_get_sb_bdev(super, type, devname);
  502. else if (strncmp(devname, "mtd", 3))
  503. err = logfs_get_sb_bdev(super, type, devname);
  504. else {
  505. char *garbage;
  506. mtdnr = simple_strtoul(devname+3, &garbage, 0);
  507. if (*garbage)
  508. err = -EINVAL;
  509. else
  510. err = logfs_get_sb_mtd(super, mtdnr);
  511. }
  512. if (err) {
  513. kfree(super);
  514. return ERR_PTR(err);
  515. }
  516. return logfs_get_sb_device(super, type, flags);
  517. }
  518. static struct file_system_type logfs_fs_type = {
  519. .owner = THIS_MODULE,
  520. .name = "logfs",
  521. .mount = logfs_mount,
  522. .kill_sb = logfs_kill_sb,
  523. .fs_flags = FS_REQUIRES_DEV,
  524. };
  525. MODULE_ALIAS_FS("logfs");
  526. static int __init logfs_init(void)
  527. {
  528. int ret;
  529. emergency_page = alloc_pages(GFP_KERNEL, 0);
  530. if (!emergency_page)
  531. return -ENOMEM;
  532. ret = logfs_compr_init();
  533. if (ret)
  534. goto out1;
  535. ret = logfs_init_inode_cache();
  536. if (ret)
  537. goto out2;
  538. ret = register_filesystem(&logfs_fs_type);
  539. if (!ret)
  540. return 0;
  541. logfs_destroy_inode_cache();
  542. out2:
  543. logfs_compr_exit();
  544. out1:
  545. __free_pages(emergency_page, 0);
  546. return ret;
  547. }
  548. static void __exit logfs_exit(void)
  549. {
  550. unregister_filesystem(&logfs_fs_type);
  551. logfs_destroy_inode_cache();
  552. logfs_compr_exit();
  553. __free_pages(emergency_page, 0);
  554. }
  555. module_init(logfs_init);
  556. module_exit(logfs_exit);
  557. MODULE_LICENSE("GPL v2");
  558. MODULE_AUTHOR("Joern Engel <joern@logfs.org>");
  559. MODULE_DESCRIPTION("scalable flash filesystem");