super.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /*
  2. * fs/f2fs/super.c
  3. *
  4. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com/
  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 version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/fs.h>
  14. #include <linux/statfs.h>
  15. #include <linux/proc_fs.h>
  16. #include <linux/buffer_head.h>
  17. #include <linux/backing-dev.h>
  18. #include <linux/kthread.h>
  19. #include <linux/parser.h>
  20. #include <linux/mount.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/random.h>
  23. #include <linux/exportfs.h>
  24. #include <linux/f2fs_fs.h>
  25. #include "f2fs.h"
  26. #include "node.h"
  27. #include "xattr.h"
  28. static struct kmem_cache *f2fs_inode_cachep;
  29. enum {
  30. Opt_gc_background_off,
  31. Opt_disable_roll_forward,
  32. Opt_discard,
  33. Opt_noheap,
  34. Opt_nouser_xattr,
  35. Opt_noacl,
  36. Opt_active_logs,
  37. Opt_disable_ext_identify,
  38. Opt_err,
  39. };
  40. static match_table_t f2fs_tokens = {
  41. {Opt_gc_background_off, "background_gc_off"},
  42. {Opt_disable_roll_forward, "disable_roll_forward"},
  43. {Opt_discard, "discard"},
  44. {Opt_noheap, "no_heap"},
  45. {Opt_nouser_xattr, "nouser_xattr"},
  46. {Opt_noacl, "noacl"},
  47. {Opt_active_logs, "active_logs=%u"},
  48. {Opt_disable_ext_identify, "disable_ext_identify"},
  49. {Opt_err, NULL},
  50. };
  51. static void init_once(void *foo)
  52. {
  53. struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;
  54. inode_init_once(&fi->vfs_inode);
  55. }
  56. static struct inode *f2fs_alloc_inode(struct super_block *sb)
  57. {
  58. struct f2fs_inode_info *fi;
  59. fi = kmem_cache_alloc(f2fs_inode_cachep, GFP_NOFS | __GFP_ZERO);
  60. if (!fi)
  61. return NULL;
  62. init_once((void *) fi);
  63. /* Initilize f2fs-specific inode info */
  64. fi->vfs_inode.i_version = 1;
  65. atomic_set(&fi->dirty_dents, 0);
  66. fi->i_current_depth = 1;
  67. fi->i_advise = 0;
  68. rwlock_init(&fi->ext.ext_lock);
  69. set_inode_flag(fi, FI_NEW_INODE);
  70. return &fi->vfs_inode;
  71. }
  72. static void f2fs_i_callback(struct rcu_head *head)
  73. {
  74. struct inode *inode = container_of(head, struct inode, i_rcu);
  75. kmem_cache_free(f2fs_inode_cachep, F2FS_I(inode));
  76. }
  77. static void f2fs_destroy_inode(struct inode *inode)
  78. {
  79. call_rcu(&inode->i_rcu, f2fs_i_callback);
  80. }
  81. static void f2fs_put_super(struct super_block *sb)
  82. {
  83. struct f2fs_sb_info *sbi = F2FS_SB(sb);
  84. f2fs_destroy_stats(sbi);
  85. stop_gc_thread(sbi);
  86. write_checkpoint(sbi, false, true);
  87. iput(sbi->node_inode);
  88. iput(sbi->meta_inode);
  89. /* destroy f2fs internal modules */
  90. destroy_node_manager(sbi);
  91. destroy_segment_manager(sbi);
  92. kfree(sbi->ckpt);
  93. sb->s_fs_info = NULL;
  94. brelse(sbi->raw_super_buf);
  95. kfree(sbi);
  96. }
  97. int f2fs_sync_fs(struct super_block *sb, int sync)
  98. {
  99. struct f2fs_sb_info *sbi = F2FS_SB(sb);
  100. if (!sbi->s_dirty && !get_pages(sbi, F2FS_DIRTY_NODES))
  101. return 0;
  102. if (sync)
  103. write_checkpoint(sbi, false, false);
  104. return 0;
  105. }
  106. static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
  107. {
  108. struct super_block *sb = dentry->d_sb;
  109. struct f2fs_sb_info *sbi = F2FS_SB(sb);
  110. u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
  111. block_t total_count, user_block_count, start_count, ovp_count;
  112. total_count = le64_to_cpu(sbi->raw_super->block_count);
  113. user_block_count = sbi->user_block_count;
  114. start_count = le32_to_cpu(sbi->raw_super->segment0_blkaddr);
  115. ovp_count = SM_I(sbi)->ovp_segments << sbi->log_blocks_per_seg;
  116. buf->f_type = F2FS_SUPER_MAGIC;
  117. buf->f_bsize = sbi->blocksize;
  118. buf->f_blocks = total_count - start_count;
  119. buf->f_bfree = buf->f_blocks - valid_user_blocks(sbi) - ovp_count;
  120. buf->f_bavail = user_block_count - valid_user_blocks(sbi);
  121. buf->f_files = sbi->total_node_count;
  122. buf->f_ffree = sbi->total_node_count - valid_inode_count(sbi);
  123. buf->f_namelen = F2FS_MAX_NAME_LEN;
  124. buf->f_fsid.val[0] = (u32)id;
  125. buf->f_fsid.val[1] = (u32)(id >> 32);
  126. return 0;
  127. }
  128. static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
  129. {
  130. struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb);
  131. if (test_opt(sbi, BG_GC))
  132. seq_puts(seq, ",background_gc_on");
  133. else
  134. seq_puts(seq, ",background_gc_off");
  135. if (test_opt(sbi, DISABLE_ROLL_FORWARD))
  136. seq_puts(seq, ",disable_roll_forward");
  137. if (test_opt(sbi, DISCARD))
  138. seq_puts(seq, ",discard");
  139. if (test_opt(sbi, NOHEAP))
  140. seq_puts(seq, ",no_heap_alloc");
  141. #ifdef CONFIG_F2FS_FS_XATTR
  142. if (test_opt(sbi, XATTR_USER))
  143. seq_puts(seq, ",user_xattr");
  144. else
  145. seq_puts(seq, ",nouser_xattr");
  146. #endif
  147. #ifdef CONFIG_F2FS_FS_POSIX_ACL
  148. if (test_opt(sbi, POSIX_ACL))
  149. seq_puts(seq, ",acl");
  150. else
  151. seq_puts(seq, ",noacl");
  152. #endif
  153. if (test_opt(sbi, DISABLE_EXT_IDENTIFY))
  154. seq_puts(seq, ",disable_ext_indentify");
  155. seq_printf(seq, ",active_logs=%u", sbi->active_logs);
  156. return 0;
  157. }
  158. static struct super_operations f2fs_sops = {
  159. .alloc_inode = f2fs_alloc_inode,
  160. .destroy_inode = f2fs_destroy_inode,
  161. .write_inode = f2fs_write_inode,
  162. .show_options = f2fs_show_options,
  163. .evict_inode = f2fs_evict_inode,
  164. .put_super = f2fs_put_super,
  165. .sync_fs = f2fs_sync_fs,
  166. .statfs = f2fs_statfs,
  167. };
  168. static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
  169. u64 ino, u32 generation)
  170. {
  171. struct f2fs_sb_info *sbi = F2FS_SB(sb);
  172. struct inode *inode;
  173. if (ino < F2FS_ROOT_INO(sbi))
  174. return ERR_PTR(-ESTALE);
  175. /*
  176. * f2fs_iget isn't quite right if the inode is currently unallocated!
  177. * However f2fs_iget currently does appropriate checks to handle stale
  178. * inodes so everything is OK.
  179. */
  180. inode = f2fs_iget(sb, ino);
  181. if (IS_ERR(inode))
  182. return ERR_CAST(inode);
  183. if (generation && inode->i_generation != generation) {
  184. /* we didn't find the right inode.. */
  185. iput(inode);
  186. return ERR_PTR(-ESTALE);
  187. }
  188. return inode;
  189. }
  190. static struct dentry *f2fs_fh_to_dentry(struct super_block *sb, struct fid *fid,
  191. int fh_len, int fh_type)
  192. {
  193. return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
  194. f2fs_nfs_get_inode);
  195. }
  196. static struct dentry *f2fs_fh_to_parent(struct super_block *sb, struct fid *fid,
  197. int fh_len, int fh_type)
  198. {
  199. return generic_fh_to_parent(sb, fid, fh_len, fh_type,
  200. f2fs_nfs_get_inode);
  201. }
  202. static const struct export_operations f2fs_export_ops = {
  203. .fh_to_dentry = f2fs_fh_to_dentry,
  204. .fh_to_parent = f2fs_fh_to_parent,
  205. .get_parent = f2fs_get_parent,
  206. };
  207. static int parse_options(struct f2fs_sb_info *sbi, char *options)
  208. {
  209. substring_t args[MAX_OPT_ARGS];
  210. char *p;
  211. int arg = 0;
  212. if (!options)
  213. return 0;
  214. while ((p = strsep(&options, ",")) != NULL) {
  215. int token;
  216. if (!*p)
  217. continue;
  218. /*
  219. * Initialize args struct so we know whether arg was
  220. * found; some options take optional arguments.
  221. */
  222. args[0].to = args[0].from = NULL;
  223. token = match_token(p, f2fs_tokens, args);
  224. switch (token) {
  225. case Opt_gc_background_off:
  226. clear_opt(sbi, BG_GC);
  227. break;
  228. case Opt_disable_roll_forward:
  229. set_opt(sbi, DISABLE_ROLL_FORWARD);
  230. break;
  231. case Opt_discard:
  232. set_opt(sbi, DISCARD);
  233. break;
  234. case Opt_noheap:
  235. set_opt(sbi, NOHEAP);
  236. break;
  237. #ifdef CONFIG_F2FS_FS_XATTR
  238. case Opt_nouser_xattr:
  239. clear_opt(sbi, XATTR_USER);
  240. break;
  241. #else
  242. case Opt_nouser_xattr:
  243. pr_info("nouser_xattr options not supported\n");
  244. break;
  245. #endif
  246. #ifdef CONFIG_F2FS_FS_POSIX_ACL
  247. case Opt_noacl:
  248. clear_opt(sbi, POSIX_ACL);
  249. break;
  250. #else
  251. case Opt_noacl:
  252. pr_info("noacl options not supported\n");
  253. break;
  254. #endif
  255. case Opt_active_logs:
  256. if (args->from && match_int(args, &arg))
  257. return -EINVAL;
  258. if (arg != 2 && arg != 4 && arg != NR_CURSEG_TYPE)
  259. return -EINVAL;
  260. sbi->active_logs = arg;
  261. break;
  262. case Opt_disable_ext_identify:
  263. set_opt(sbi, DISABLE_EXT_IDENTIFY);
  264. break;
  265. default:
  266. pr_err("Unrecognized mount option \"%s\" or missing value\n",
  267. p);
  268. return -EINVAL;
  269. }
  270. }
  271. return 0;
  272. }
  273. static loff_t max_file_size(unsigned bits)
  274. {
  275. loff_t result = ADDRS_PER_INODE;
  276. loff_t leaf_count = ADDRS_PER_BLOCK;
  277. /* two direct node blocks */
  278. result += (leaf_count * 2);
  279. /* two indirect node blocks */
  280. leaf_count *= NIDS_PER_BLOCK;
  281. result += (leaf_count * 2);
  282. /* one double indirect node block */
  283. leaf_count *= NIDS_PER_BLOCK;
  284. result += leaf_count;
  285. result <<= bits;
  286. return result;
  287. }
  288. static int sanity_check_raw_super(struct f2fs_super_block *raw_super)
  289. {
  290. unsigned int blocksize;
  291. if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic))
  292. return 1;
  293. /* Currently, support only 4KB block size */
  294. blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);
  295. if (blocksize != PAGE_CACHE_SIZE)
  296. return 1;
  297. if (le32_to_cpu(raw_super->log_sectorsize) !=
  298. F2FS_LOG_SECTOR_SIZE)
  299. return 1;
  300. if (le32_to_cpu(raw_super->log_sectors_per_block) !=
  301. F2FS_LOG_SECTORS_PER_BLOCK)
  302. return 1;
  303. return 0;
  304. }
  305. static int sanity_check_ckpt(struct f2fs_super_block *raw_super,
  306. struct f2fs_checkpoint *ckpt)
  307. {
  308. unsigned int total, fsmeta;
  309. total = le32_to_cpu(raw_super->segment_count);
  310. fsmeta = le32_to_cpu(raw_super->segment_count_ckpt);
  311. fsmeta += le32_to_cpu(raw_super->segment_count_sit);
  312. fsmeta += le32_to_cpu(raw_super->segment_count_nat);
  313. fsmeta += le32_to_cpu(ckpt->rsvd_segment_count);
  314. fsmeta += le32_to_cpu(raw_super->segment_count_ssa);
  315. if (fsmeta >= total)
  316. return 1;
  317. return 0;
  318. }
  319. static void init_sb_info(struct f2fs_sb_info *sbi)
  320. {
  321. struct f2fs_super_block *raw_super = sbi->raw_super;
  322. int i;
  323. sbi->log_sectors_per_block =
  324. le32_to_cpu(raw_super->log_sectors_per_block);
  325. sbi->log_blocksize = le32_to_cpu(raw_super->log_blocksize);
  326. sbi->blocksize = 1 << sbi->log_blocksize;
  327. sbi->log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
  328. sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg;
  329. sbi->segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
  330. sbi->secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
  331. sbi->total_sections = le32_to_cpu(raw_super->section_count);
  332. sbi->total_node_count =
  333. (le32_to_cpu(raw_super->segment_count_nat) / 2)
  334. * sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK;
  335. sbi->root_ino_num = le32_to_cpu(raw_super->root_ino);
  336. sbi->node_ino_num = le32_to_cpu(raw_super->node_ino);
  337. sbi->meta_ino_num = le32_to_cpu(raw_super->meta_ino);
  338. for (i = 0; i < NR_COUNT_TYPE; i++)
  339. atomic_set(&sbi->nr_pages[i], 0);
  340. }
  341. static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
  342. {
  343. struct f2fs_sb_info *sbi;
  344. struct f2fs_super_block *raw_super;
  345. struct buffer_head *raw_super_buf;
  346. struct inode *root;
  347. long err = -EINVAL;
  348. int i;
  349. /* allocate memory for f2fs-specific super block info */
  350. sbi = kzalloc(sizeof(struct f2fs_sb_info), GFP_KERNEL);
  351. if (!sbi)
  352. return -ENOMEM;
  353. /* set a temporary block size */
  354. if (!sb_set_blocksize(sb, F2FS_BLKSIZE))
  355. goto free_sbi;
  356. /* read f2fs raw super block */
  357. raw_super_buf = sb_bread(sb, 0);
  358. if (!raw_super_buf) {
  359. err = -EIO;
  360. goto free_sbi;
  361. }
  362. raw_super = (struct f2fs_super_block *)
  363. ((char *)raw_super_buf->b_data + F2FS_SUPER_OFFSET);
  364. /* init some FS parameters */
  365. sbi->active_logs = NR_CURSEG_TYPE;
  366. set_opt(sbi, BG_GC);
  367. #ifdef CONFIG_F2FS_FS_XATTR
  368. set_opt(sbi, XATTR_USER);
  369. #endif
  370. #ifdef CONFIG_F2FS_FS_POSIX_ACL
  371. set_opt(sbi, POSIX_ACL);
  372. #endif
  373. /* parse mount options */
  374. if (parse_options(sbi, (char *)data))
  375. goto free_sb_buf;
  376. /* sanity checking of raw super */
  377. if (sanity_check_raw_super(raw_super))
  378. goto free_sb_buf;
  379. sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));
  380. sb->s_max_links = F2FS_LINK_MAX;
  381. get_random_bytes(&sbi->s_next_generation, sizeof(u32));
  382. sb->s_op = &f2fs_sops;
  383. sb->s_xattr = f2fs_xattr_handlers;
  384. sb->s_export_op = &f2fs_export_ops;
  385. sb->s_magic = F2FS_SUPER_MAGIC;
  386. sb->s_fs_info = sbi;
  387. sb->s_time_gran = 1;
  388. sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
  389. (test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
  390. memcpy(sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
  391. /* init f2fs-specific super block info */
  392. sbi->sb = sb;
  393. sbi->raw_super = raw_super;
  394. sbi->raw_super_buf = raw_super_buf;
  395. mutex_init(&sbi->gc_mutex);
  396. mutex_init(&sbi->write_inode);
  397. mutex_init(&sbi->writepages);
  398. mutex_init(&sbi->cp_mutex);
  399. for (i = 0; i < NR_LOCK_TYPE; i++)
  400. mutex_init(&sbi->fs_lock[i]);
  401. sbi->por_doing = 0;
  402. spin_lock_init(&sbi->stat_lock);
  403. init_rwsem(&sbi->bio_sem);
  404. init_sb_info(sbi);
  405. /* get an inode for meta space */
  406. sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
  407. if (IS_ERR(sbi->meta_inode)) {
  408. err = PTR_ERR(sbi->meta_inode);
  409. goto free_sb_buf;
  410. }
  411. err = get_valid_checkpoint(sbi);
  412. if (err)
  413. goto free_meta_inode;
  414. /* sanity checking of checkpoint */
  415. err = -EINVAL;
  416. if (sanity_check_ckpt(raw_super, sbi->ckpt))
  417. goto free_cp;
  418. sbi->total_valid_node_count =
  419. le32_to_cpu(sbi->ckpt->valid_node_count);
  420. sbi->total_valid_inode_count =
  421. le32_to_cpu(sbi->ckpt->valid_inode_count);
  422. sbi->user_block_count = le64_to_cpu(sbi->ckpt->user_block_count);
  423. sbi->total_valid_block_count =
  424. le64_to_cpu(sbi->ckpt->valid_block_count);
  425. sbi->last_valid_block_count = sbi->total_valid_block_count;
  426. sbi->alloc_valid_block_count = 0;
  427. INIT_LIST_HEAD(&sbi->dir_inode_list);
  428. spin_lock_init(&sbi->dir_inode_lock);
  429. /* init super block */
  430. if (!sb_set_blocksize(sb, sbi->blocksize))
  431. goto free_cp;
  432. init_orphan_info(sbi);
  433. /* setup f2fs internal modules */
  434. err = build_segment_manager(sbi);
  435. if (err)
  436. goto free_sm;
  437. err = build_node_manager(sbi);
  438. if (err)
  439. goto free_nm;
  440. build_gc_manager(sbi);
  441. /* get an inode for node space */
  442. sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
  443. if (IS_ERR(sbi->node_inode)) {
  444. err = PTR_ERR(sbi->node_inode);
  445. goto free_nm;
  446. }
  447. /* if there are nt orphan nodes free them */
  448. err = -EINVAL;
  449. if (recover_orphan_inodes(sbi))
  450. goto free_node_inode;
  451. /* read root inode and dentry */
  452. root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
  453. if (IS_ERR(root)) {
  454. err = PTR_ERR(root);
  455. goto free_node_inode;
  456. }
  457. if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size)
  458. goto free_root_inode;
  459. sb->s_root = d_make_root(root); /* allocate root dentry */
  460. if (!sb->s_root) {
  461. err = -ENOMEM;
  462. goto free_root_inode;
  463. }
  464. /* recover fsynced data */
  465. if (!test_opt(sbi, DISABLE_ROLL_FORWARD))
  466. recover_fsync_data(sbi);
  467. /* After POR, we can run background GC thread */
  468. err = start_gc_thread(sbi);
  469. if (err)
  470. goto fail;
  471. err = f2fs_build_stats(sbi);
  472. if (err)
  473. goto fail;
  474. return 0;
  475. fail:
  476. stop_gc_thread(sbi);
  477. free_root_inode:
  478. dput(sb->s_root);
  479. sb->s_root = NULL;
  480. free_node_inode:
  481. iput(sbi->node_inode);
  482. free_nm:
  483. destroy_node_manager(sbi);
  484. free_sm:
  485. destroy_segment_manager(sbi);
  486. free_cp:
  487. kfree(sbi->ckpt);
  488. free_meta_inode:
  489. make_bad_inode(sbi->meta_inode);
  490. iput(sbi->meta_inode);
  491. free_sb_buf:
  492. brelse(raw_super_buf);
  493. free_sbi:
  494. kfree(sbi);
  495. return err;
  496. }
  497. static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
  498. const char *dev_name, void *data)
  499. {
  500. return mount_bdev(fs_type, flags, dev_name, data, f2fs_fill_super);
  501. }
  502. static struct file_system_type f2fs_fs_type = {
  503. .owner = THIS_MODULE,
  504. .name = "f2fs",
  505. .mount = f2fs_mount,
  506. .kill_sb = kill_block_super,
  507. .fs_flags = FS_REQUIRES_DEV,
  508. };
  509. static int init_inodecache(void)
  510. {
  511. f2fs_inode_cachep = f2fs_kmem_cache_create("f2fs_inode_cache",
  512. sizeof(struct f2fs_inode_info), NULL);
  513. if (f2fs_inode_cachep == NULL)
  514. return -ENOMEM;
  515. return 0;
  516. }
  517. static void destroy_inodecache(void)
  518. {
  519. /*
  520. * Make sure all delayed rcu free inodes are flushed before we
  521. * destroy cache.
  522. */
  523. rcu_barrier();
  524. kmem_cache_destroy(f2fs_inode_cachep);
  525. }
  526. static int __init init_f2fs_fs(void)
  527. {
  528. int err;
  529. err = init_inodecache();
  530. if (err)
  531. goto fail;
  532. err = create_node_manager_caches();
  533. if (err)
  534. goto fail;
  535. err = create_gc_caches();
  536. if (err)
  537. goto fail;
  538. err = create_checkpoint_caches();
  539. if (err)
  540. goto fail;
  541. return register_filesystem(&f2fs_fs_type);
  542. fail:
  543. return err;
  544. }
  545. static void __exit exit_f2fs_fs(void)
  546. {
  547. destroy_root_stats();
  548. unregister_filesystem(&f2fs_fs_type);
  549. destroy_checkpoint_caches();
  550. destroy_gc_caches();
  551. destroy_node_manager_caches();
  552. destroy_inodecache();
  553. }
  554. module_init(init_f2fs_fs)
  555. module_exit(exit_f2fs_fs)
  556. MODULE_AUTHOR("Samsung Electronics's Praesto Team");
  557. MODULE_DESCRIPTION("Flash Friendly File System");
  558. MODULE_LICENSE("GPL");