f2fs.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. /*
  2. * fs/f2fs/f2fs.h
  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. #ifndef _LINUX_F2FS_H
  12. #define _LINUX_F2FS_H
  13. #include <linux/types.h>
  14. #include <linux/page-flags.h>
  15. #include <linux/buffer_head.h>
  16. #include <linux/slab.h>
  17. #include <linux/crc32.h>
  18. #include <linux/magic.h>
  19. /*
  20. * For mount options
  21. */
  22. #define F2FS_MOUNT_BG_GC 0x00000001
  23. #define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002
  24. #define F2FS_MOUNT_DISCARD 0x00000004
  25. #define F2FS_MOUNT_NOHEAP 0x00000008
  26. #define F2FS_MOUNT_XATTR_USER 0x00000010
  27. #define F2FS_MOUNT_POSIX_ACL 0x00000020
  28. #define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000040
  29. #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
  30. #define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
  31. #define test_opt(sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option)
  32. #define ver_after(a, b) (typecheck(unsigned long long, a) && \
  33. typecheck(unsigned long long, b) && \
  34. ((long long)((a) - (b)) > 0))
  35. typedef u32 block_t; /*
  36. * should not change u32, since it is the on-disk block
  37. * address format, __le32.
  38. */
  39. typedef u32 nid_t;
  40. struct f2fs_mount_info {
  41. unsigned int opt;
  42. };
  43. static inline __u32 f2fs_crc32(void *buff, size_t len)
  44. {
  45. return crc32_le(F2FS_SUPER_MAGIC, buff, len);
  46. }
  47. static inline bool f2fs_crc_valid(__u32 blk_crc, void *buff, size_t buff_size)
  48. {
  49. return f2fs_crc32(buff, buff_size) == blk_crc;
  50. }
  51. /*
  52. * For checkpoint manager
  53. */
  54. enum {
  55. NAT_BITMAP,
  56. SIT_BITMAP
  57. };
  58. /* for the list of orphan inodes */
  59. struct orphan_inode_entry {
  60. struct list_head list; /* list head */
  61. nid_t ino; /* inode number */
  62. };
  63. /* for the list of directory inodes */
  64. struct dir_inode_entry {
  65. struct list_head list; /* list head */
  66. struct inode *inode; /* vfs inode pointer */
  67. };
  68. /* for the list of fsync inodes, used only during recovery */
  69. struct fsync_inode_entry {
  70. struct list_head list; /* list head */
  71. struct inode *inode; /* vfs inode pointer */
  72. block_t blkaddr; /* block address locating the last inode */
  73. };
  74. #define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats))
  75. #define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits))
  76. #define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne)
  77. #define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid)
  78. #define sit_in_journal(sum, i) (sum->sit_j.entries[i].se)
  79. #define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno)
  80. static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i)
  81. {
  82. int before = nats_in_cursum(rs);
  83. rs->n_nats = cpu_to_le16(before + i);
  84. return before;
  85. }
  86. static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
  87. {
  88. int before = sits_in_cursum(rs);
  89. rs->n_sits = cpu_to_le16(before + i);
  90. return before;
  91. }
  92. /*
  93. * ioctl commands
  94. */
  95. #define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
  96. #define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
  97. #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  98. /*
  99. * ioctl commands in 32 bit emulation
  100. */
  101. #define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
  102. #define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
  103. #endif
  104. /*
  105. * For INODE and NODE manager
  106. */
  107. #define XATTR_NODE_OFFSET (-1) /*
  108. * store xattrs to one node block per
  109. * file keeping -1 as its node offset to
  110. * distinguish from index node blocks.
  111. */
  112. enum {
  113. ALLOC_NODE, /* allocate a new node page if needed */
  114. LOOKUP_NODE, /* look up a node without readahead */
  115. LOOKUP_NODE_RA, /*
  116. * look up a node with readahead called
  117. * by get_datablock_ro.
  118. */
  119. };
  120. #define F2FS_LINK_MAX 32000 /* maximum link count per file */
  121. /* for in-memory extent cache entry */
  122. struct extent_info {
  123. rwlock_t ext_lock; /* rwlock for consistency */
  124. unsigned int fofs; /* start offset in a file */
  125. u32 blk_addr; /* start block address of the extent */
  126. unsigned int len; /* length of the extent */
  127. };
  128. /*
  129. * i_advise uses FADVISE_XXX_BIT. We can add additional hints later.
  130. */
  131. #define FADVISE_COLD_BIT 0x01
  132. #define FADVISE_CP_BIT 0x02
  133. struct f2fs_inode_info {
  134. struct inode vfs_inode; /* serve a vfs inode */
  135. unsigned long i_flags; /* keep an inode flags for ioctl */
  136. unsigned char i_advise; /* use to give file attribute hints */
  137. unsigned int i_current_depth; /* use only in directory structure */
  138. unsigned int i_pino; /* parent inode number */
  139. umode_t i_acl_mode; /* keep file acl mode temporarily */
  140. /* Use below internally in f2fs*/
  141. unsigned long flags; /* use to pass per-file flags */
  142. atomic_t dirty_dents; /* # of dirty dentry pages */
  143. f2fs_hash_t chash; /* hash value of given file name */
  144. unsigned int clevel; /* maximum level of given file name */
  145. nid_t i_xattr_nid; /* node id that contains xattrs */
  146. struct extent_info ext; /* in-memory extent cache entry */
  147. };
  148. static inline void get_extent_info(struct extent_info *ext,
  149. struct f2fs_extent i_ext)
  150. {
  151. write_lock(&ext->ext_lock);
  152. ext->fofs = le32_to_cpu(i_ext.fofs);
  153. ext->blk_addr = le32_to_cpu(i_ext.blk_addr);
  154. ext->len = le32_to_cpu(i_ext.len);
  155. write_unlock(&ext->ext_lock);
  156. }
  157. static inline void set_raw_extent(struct extent_info *ext,
  158. struct f2fs_extent *i_ext)
  159. {
  160. read_lock(&ext->ext_lock);
  161. i_ext->fofs = cpu_to_le32(ext->fofs);
  162. i_ext->blk_addr = cpu_to_le32(ext->blk_addr);
  163. i_ext->len = cpu_to_le32(ext->len);
  164. read_unlock(&ext->ext_lock);
  165. }
  166. struct f2fs_nm_info {
  167. block_t nat_blkaddr; /* base disk address of NAT */
  168. nid_t max_nid; /* maximum possible node ids */
  169. nid_t next_scan_nid; /* the next nid to be scanned */
  170. /* NAT cache management */
  171. struct radix_tree_root nat_root;/* root of the nat entry cache */
  172. rwlock_t nat_tree_lock; /* protect nat_tree_lock */
  173. unsigned int nat_cnt; /* the # of cached nat entries */
  174. struct list_head nat_entries; /* cached nat entry list (clean) */
  175. struct list_head dirty_nat_entries; /* cached nat entry list (dirty) */
  176. /* free node ids management */
  177. struct list_head free_nid_list; /* a list for free nids */
  178. spinlock_t free_nid_list_lock; /* protect free nid list */
  179. unsigned int fcnt; /* the number of free node id */
  180. struct mutex build_lock; /* lock for build free nids */
  181. /* for checkpoint */
  182. char *nat_bitmap; /* NAT bitmap pointer */
  183. int bitmap_size; /* bitmap size */
  184. };
  185. /*
  186. * this structure is used as one of function parameters.
  187. * all the information are dedicated to a given direct node block determined
  188. * by the data offset in a file.
  189. */
  190. struct dnode_of_data {
  191. struct inode *inode; /* vfs inode pointer */
  192. struct page *inode_page; /* its inode page, NULL is possible */
  193. struct page *node_page; /* cached direct node page */
  194. nid_t nid; /* node id of the direct node block */
  195. unsigned int ofs_in_node; /* data offset in the node page */
  196. bool inode_page_locked; /* inode page is locked or not */
  197. block_t data_blkaddr; /* block address of the node block */
  198. };
  199. static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,
  200. struct page *ipage, struct page *npage, nid_t nid)
  201. {
  202. memset(dn, 0, sizeof(*dn));
  203. dn->inode = inode;
  204. dn->inode_page = ipage;
  205. dn->node_page = npage;
  206. dn->nid = nid;
  207. }
  208. /*
  209. * For SIT manager
  210. *
  211. * By default, there are 6 active log areas across the whole main area.
  212. * When considering hot and cold data separation to reduce cleaning overhead,
  213. * we split 3 for data logs and 3 for node logs as hot, warm, and cold types,
  214. * respectively.
  215. * In the current design, you should not change the numbers intentionally.
  216. * Instead, as a mount option such as active_logs=x, you can use 2, 4, and 6
  217. * logs individually according to the underlying devices. (default: 6)
  218. * Just in case, on-disk layout covers maximum 16 logs that consist of 8 for
  219. * data and 8 for node logs.
  220. */
  221. #define NR_CURSEG_DATA_TYPE (3)
  222. #define NR_CURSEG_NODE_TYPE (3)
  223. #define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE)
  224. enum {
  225. CURSEG_HOT_DATA = 0, /* directory entry blocks */
  226. CURSEG_WARM_DATA, /* data blocks */
  227. CURSEG_COLD_DATA, /* multimedia or GCed data blocks */
  228. CURSEG_HOT_NODE, /* direct node blocks of directory files */
  229. CURSEG_WARM_NODE, /* direct node blocks of normal files */
  230. CURSEG_COLD_NODE, /* indirect node blocks */
  231. NO_CHECK_TYPE
  232. };
  233. struct f2fs_sm_info {
  234. struct sit_info *sit_info; /* whole segment information */
  235. struct free_segmap_info *free_info; /* free segment information */
  236. struct dirty_seglist_info *dirty_info; /* dirty segment information */
  237. struct curseg_info *curseg_array; /* active segment information */
  238. struct list_head wblist_head; /* list of under-writeback pages */
  239. spinlock_t wblist_lock; /* lock for checkpoint */
  240. block_t seg0_blkaddr; /* block address of 0'th segment */
  241. block_t main_blkaddr; /* start block address of main area */
  242. block_t ssa_blkaddr; /* start block address of SSA area */
  243. unsigned int segment_count; /* total # of segments */
  244. unsigned int main_segments; /* # of segments in main area */
  245. unsigned int reserved_segments; /* # of reserved segments */
  246. unsigned int ovp_segments; /* # of overprovision segments */
  247. };
  248. /*
  249. * For directory operation
  250. */
  251. #define NODE_DIR1_BLOCK (ADDRS_PER_INODE + 1)
  252. #define NODE_DIR2_BLOCK (ADDRS_PER_INODE + 2)
  253. #define NODE_IND1_BLOCK (ADDRS_PER_INODE + 3)
  254. #define NODE_IND2_BLOCK (ADDRS_PER_INODE + 4)
  255. #define NODE_DIND_BLOCK (ADDRS_PER_INODE + 5)
  256. /*
  257. * For superblock
  258. */
  259. /*
  260. * COUNT_TYPE for monitoring
  261. *
  262. * f2fs monitors the number of several block types such as on-writeback,
  263. * dirty dentry blocks, dirty node blocks, and dirty meta blocks.
  264. */
  265. enum count_type {
  266. F2FS_WRITEBACK,
  267. F2FS_DIRTY_DENTS,
  268. F2FS_DIRTY_NODES,
  269. F2FS_DIRTY_META,
  270. NR_COUNT_TYPE,
  271. };
  272. /*
  273. * Uses as sbi->fs_lock[NR_GLOBAL_LOCKS].
  274. * The checkpoint procedure blocks all the locks in this fs_lock array.
  275. * Some FS operations grab free locks, and if there is no free lock,
  276. * then wait to grab a lock in a round-robin manner.
  277. */
  278. #define NR_GLOBAL_LOCKS 8
  279. /*
  280. * The below are the page types of bios used in submti_bio().
  281. * The available types are:
  282. * DATA User data pages. It operates as async mode.
  283. * NODE Node pages. It operates as async mode.
  284. * META FS metadata pages such as SIT, NAT, CP.
  285. * NR_PAGE_TYPE The number of page types.
  286. * META_FLUSH Make sure the previous pages are written
  287. * with waiting the bio's completion
  288. * ... Only can be used with META.
  289. */
  290. enum page_type {
  291. DATA,
  292. NODE,
  293. META,
  294. NR_PAGE_TYPE,
  295. META_FLUSH,
  296. };
  297. struct f2fs_sb_info {
  298. struct super_block *sb; /* pointer to VFS super block */
  299. struct buffer_head *raw_super_buf; /* buffer head of raw sb */
  300. struct f2fs_super_block *raw_super; /* raw super block pointer */
  301. int s_dirty; /* dirty flag for checkpoint */
  302. /* for node-related operations */
  303. struct f2fs_nm_info *nm_info; /* node manager */
  304. struct inode *node_inode; /* cache node blocks */
  305. /* for segment-related operations */
  306. struct f2fs_sm_info *sm_info; /* segment manager */
  307. struct bio *bio[NR_PAGE_TYPE]; /* bios to merge */
  308. sector_t last_block_in_bio[NR_PAGE_TYPE]; /* last block number */
  309. struct rw_semaphore bio_sem; /* IO semaphore */
  310. /* for checkpoint */
  311. struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
  312. struct inode *meta_inode; /* cache meta blocks */
  313. struct mutex cp_mutex; /* checkpoint procedure lock */
  314. struct mutex fs_lock[NR_GLOBAL_LOCKS]; /* blocking FS operations */
  315. struct mutex node_write; /* locking node writes */
  316. struct mutex writepages; /* mutex for writepages() */
  317. unsigned char next_lock_num; /* round-robin global locks */
  318. int por_doing; /* recovery is doing or not */
  319. int on_build_free_nids; /* build_free_nids is doing */
  320. /* for orphan inode management */
  321. struct list_head orphan_inode_list; /* orphan inode list */
  322. struct mutex orphan_inode_mutex; /* for orphan inode list */
  323. unsigned int n_orphans; /* # of orphan inodes */
  324. /* for directory inode management */
  325. struct list_head dir_inode_list; /* dir inode list */
  326. spinlock_t dir_inode_lock; /* for dir inode list lock */
  327. /* basic file system units */
  328. unsigned int log_sectors_per_block; /* log2 sectors per block */
  329. unsigned int log_blocksize; /* log2 block size */
  330. unsigned int blocksize; /* block size */
  331. unsigned int root_ino_num; /* root inode number*/
  332. unsigned int node_ino_num; /* node inode number*/
  333. unsigned int meta_ino_num; /* meta inode number*/
  334. unsigned int log_blocks_per_seg; /* log2 blocks per segment */
  335. unsigned int blocks_per_seg; /* blocks per segment */
  336. unsigned int segs_per_sec; /* segments per section */
  337. unsigned int secs_per_zone; /* sections per zone */
  338. unsigned int total_sections; /* total section count */
  339. unsigned int total_node_count; /* total node block count */
  340. unsigned int total_valid_node_count; /* valid node block count */
  341. unsigned int total_valid_inode_count; /* valid inode count */
  342. int active_logs; /* # of active logs */
  343. block_t user_block_count; /* # of user blocks */
  344. block_t total_valid_block_count; /* # of valid blocks */
  345. block_t alloc_valid_block_count; /* # of allocated blocks */
  346. block_t last_valid_block_count; /* for recovery */
  347. u32 s_next_generation; /* for NFS support */
  348. atomic_t nr_pages[NR_COUNT_TYPE]; /* # of pages, see count_type */
  349. struct f2fs_mount_info mount_opt; /* mount options */
  350. /* for cleaning operations */
  351. struct mutex gc_mutex; /* mutex for GC */
  352. struct f2fs_gc_kthread *gc_thread; /* GC thread */
  353. unsigned int cur_victim_sec; /* current victim section num */
  354. /*
  355. * for stat information.
  356. * one is for the LFS mode, and the other is for the SSR mode.
  357. */
  358. #ifdef CONFIG_F2FS_STAT_FS
  359. struct f2fs_stat_info *stat_info; /* FS status information */
  360. unsigned int segment_count[2]; /* # of allocated segments */
  361. unsigned int block_count[2]; /* # of allocated blocks */
  362. int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
  363. int bg_gc; /* background gc calls */
  364. unsigned int n_dirty_dirs; /* # of dir inodes */
  365. #endif
  366. unsigned int last_victim[2]; /* last victim segment # */
  367. spinlock_t stat_lock; /* lock for stat operations */
  368. };
  369. /*
  370. * Inline functions
  371. */
  372. static inline struct f2fs_inode_info *F2FS_I(struct inode *inode)
  373. {
  374. return container_of(inode, struct f2fs_inode_info, vfs_inode);
  375. }
  376. static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
  377. {
  378. return sb->s_fs_info;
  379. }
  380. static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
  381. {
  382. return (struct f2fs_super_block *)(sbi->raw_super);
  383. }
  384. static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
  385. {
  386. return (struct f2fs_checkpoint *)(sbi->ckpt);
  387. }
  388. static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi)
  389. {
  390. return (struct f2fs_nm_info *)(sbi->nm_info);
  391. }
  392. static inline struct f2fs_sm_info *SM_I(struct f2fs_sb_info *sbi)
  393. {
  394. return (struct f2fs_sm_info *)(sbi->sm_info);
  395. }
  396. static inline struct sit_info *SIT_I(struct f2fs_sb_info *sbi)
  397. {
  398. return (struct sit_info *)(SM_I(sbi)->sit_info);
  399. }
  400. static inline struct free_segmap_info *FREE_I(struct f2fs_sb_info *sbi)
  401. {
  402. return (struct free_segmap_info *)(SM_I(sbi)->free_info);
  403. }
  404. static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi)
  405. {
  406. return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info);
  407. }
  408. static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi)
  409. {
  410. sbi->s_dirty = 1;
  411. }
  412. static inline void F2FS_RESET_SB_DIRT(struct f2fs_sb_info *sbi)
  413. {
  414. sbi->s_dirty = 0;
  415. }
  416. static inline bool is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  417. {
  418. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  419. return ckpt_flags & f;
  420. }
  421. static inline void set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  422. {
  423. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  424. ckpt_flags |= f;
  425. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  426. }
  427. static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  428. {
  429. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  430. ckpt_flags &= (~f);
  431. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  432. }
  433. static inline void mutex_lock_all(struct f2fs_sb_info *sbi)
  434. {
  435. int i;
  436. for (i = 0; i < NR_GLOBAL_LOCKS; i++) {
  437. /*
  438. * This is the only time we take multiple fs_lock[]
  439. * instances; the order is immaterial since we
  440. * always hold cp_mutex, which serializes multiple
  441. * such operations.
  442. */
  443. mutex_lock_nest_lock(&sbi->fs_lock[i], &sbi->cp_mutex);
  444. }
  445. }
  446. static inline void mutex_unlock_all(struct f2fs_sb_info *sbi)
  447. {
  448. int i = 0;
  449. for (; i < NR_GLOBAL_LOCKS; i++)
  450. mutex_unlock(&sbi->fs_lock[i]);
  451. }
  452. static inline int mutex_lock_op(struct f2fs_sb_info *sbi)
  453. {
  454. unsigned char next_lock = sbi->next_lock_num % NR_GLOBAL_LOCKS;
  455. int i = 0;
  456. for (; i < NR_GLOBAL_LOCKS; i++)
  457. if (mutex_trylock(&sbi->fs_lock[i]))
  458. return i;
  459. mutex_lock(&sbi->fs_lock[next_lock]);
  460. sbi->next_lock_num++;
  461. return next_lock;
  462. }
  463. static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, int ilock)
  464. {
  465. if (ilock < 0)
  466. return;
  467. BUG_ON(ilock >= NR_GLOBAL_LOCKS);
  468. mutex_unlock(&sbi->fs_lock[ilock]);
  469. }
  470. /*
  471. * Check whether the given nid is within node id range.
  472. */
  473. static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
  474. {
  475. WARN_ON((nid >= NM_I(sbi)->max_nid));
  476. if (nid >= NM_I(sbi)->max_nid)
  477. return -EINVAL;
  478. return 0;
  479. }
  480. #define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
  481. /*
  482. * Check whether the inode has blocks or not
  483. */
  484. static inline int F2FS_HAS_BLOCKS(struct inode *inode)
  485. {
  486. if (F2FS_I(inode)->i_xattr_nid)
  487. return (inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS + 1);
  488. else
  489. return (inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS);
  490. }
  491. static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
  492. struct inode *inode, blkcnt_t count)
  493. {
  494. block_t valid_block_count;
  495. spin_lock(&sbi->stat_lock);
  496. valid_block_count =
  497. sbi->total_valid_block_count + (block_t)count;
  498. if (valid_block_count > sbi->user_block_count) {
  499. spin_unlock(&sbi->stat_lock);
  500. return false;
  501. }
  502. inode->i_blocks += count;
  503. sbi->total_valid_block_count = valid_block_count;
  504. sbi->alloc_valid_block_count += (block_t)count;
  505. spin_unlock(&sbi->stat_lock);
  506. return true;
  507. }
  508. static inline int dec_valid_block_count(struct f2fs_sb_info *sbi,
  509. struct inode *inode,
  510. blkcnt_t count)
  511. {
  512. spin_lock(&sbi->stat_lock);
  513. BUG_ON(sbi->total_valid_block_count < (block_t) count);
  514. BUG_ON(inode->i_blocks < count);
  515. inode->i_blocks -= count;
  516. sbi->total_valid_block_count -= (block_t)count;
  517. spin_unlock(&sbi->stat_lock);
  518. return 0;
  519. }
  520. static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
  521. {
  522. atomic_inc(&sbi->nr_pages[count_type]);
  523. F2FS_SET_SB_DIRT(sbi);
  524. }
  525. static inline void inode_inc_dirty_dents(struct inode *inode)
  526. {
  527. atomic_inc(&F2FS_I(inode)->dirty_dents);
  528. }
  529. static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
  530. {
  531. atomic_dec(&sbi->nr_pages[count_type]);
  532. }
  533. static inline void inode_dec_dirty_dents(struct inode *inode)
  534. {
  535. atomic_dec(&F2FS_I(inode)->dirty_dents);
  536. }
  537. static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
  538. {
  539. return atomic_read(&sbi->nr_pages[count_type]);
  540. }
  541. static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
  542. {
  543. unsigned int pages_per_sec = sbi->segs_per_sec *
  544. (1 << sbi->log_blocks_per_seg);
  545. return ((get_pages(sbi, block_type) + pages_per_sec - 1)
  546. >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
  547. }
  548. static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
  549. {
  550. block_t ret;
  551. spin_lock(&sbi->stat_lock);
  552. ret = sbi->total_valid_block_count;
  553. spin_unlock(&sbi->stat_lock);
  554. return ret;
  555. }
  556. static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag)
  557. {
  558. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  559. /* return NAT or SIT bitmap */
  560. if (flag == NAT_BITMAP)
  561. return le32_to_cpu(ckpt->nat_ver_bitmap_bytesize);
  562. else if (flag == SIT_BITMAP)
  563. return le32_to_cpu(ckpt->sit_ver_bitmap_bytesize);
  564. return 0;
  565. }
  566. static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
  567. {
  568. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  569. int offset = (flag == NAT_BITMAP) ?
  570. le32_to_cpu(ckpt->sit_ver_bitmap_bytesize) : 0;
  571. return &ckpt->sit_nat_version_bitmap + offset;
  572. }
  573. static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi)
  574. {
  575. block_t start_addr;
  576. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  577. unsigned long long ckpt_version = le64_to_cpu(ckpt->checkpoint_ver);
  578. start_addr = le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr);
  579. /*
  580. * odd numbered checkpoint should at cp segment 0
  581. * and even segent must be at cp segment 1
  582. */
  583. if (!(ckpt_version & 1))
  584. start_addr += sbi->blocks_per_seg;
  585. return start_addr;
  586. }
  587. static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
  588. {
  589. return le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
  590. }
  591. static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
  592. struct inode *inode,
  593. unsigned int count)
  594. {
  595. block_t valid_block_count;
  596. unsigned int valid_node_count;
  597. spin_lock(&sbi->stat_lock);
  598. valid_block_count = sbi->total_valid_block_count + (block_t)count;
  599. sbi->alloc_valid_block_count += (block_t)count;
  600. valid_node_count = sbi->total_valid_node_count + count;
  601. if (valid_block_count > sbi->user_block_count) {
  602. spin_unlock(&sbi->stat_lock);
  603. return false;
  604. }
  605. if (valid_node_count > sbi->total_node_count) {
  606. spin_unlock(&sbi->stat_lock);
  607. return false;
  608. }
  609. if (inode)
  610. inode->i_blocks += count;
  611. sbi->total_valid_node_count = valid_node_count;
  612. sbi->total_valid_block_count = valid_block_count;
  613. spin_unlock(&sbi->stat_lock);
  614. return true;
  615. }
  616. static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
  617. struct inode *inode,
  618. unsigned int count)
  619. {
  620. spin_lock(&sbi->stat_lock);
  621. BUG_ON(sbi->total_valid_block_count < count);
  622. BUG_ON(sbi->total_valid_node_count < count);
  623. BUG_ON(inode->i_blocks < count);
  624. inode->i_blocks -= count;
  625. sbi->total_valid_node_count -= count;
  626. sbi->total_valid_block_count -= (block_t)count;
  627. spin_unlock(&sbi->stat_lock);
  628. }
  629. static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
  630. {
  631. unsigned int ret;
  632. spin_lock(&sbi->stat_lock);
  633. ret = sbi->total_valid_node_count;
  634. spin_unlock(&sbi->stat_lock);
  635. return ret;
  636. }
  637. static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi)
  638. {
  639. spin_lock(&sbi->stat_lock);
  640. BUG_ON(sbi->total_valid_inode_count == sbi->total_node_count);
  641. sbi->total_valid_inode_count++;
  642. spin_unlock(&sbi->stat_lock);
  643. }
  644. static inline int dec_valid_inode_count(struct f2fs_sb_info *sbi)
  645. {
  646. spin_lock(&sbi->stat_lock);
  647. BUG_ON(!sbi->total_valid_inode_count);
  648. sbi->total_valid_inode_count--;
  649. spin_unlock(&sbi->stat_lock);
  650. return 0;
  651. }
  652. static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
  653. {
  654. unsigned int ret;
  655. spin_lock(&sbi->stat_lock);
  656. ret = sbi->total_valid_inode_count;
  657. spin_unlock(&sbi->stat_lock);
  658. return ret;
  659. }
  660. static inline void f2fs_put_page(struct page *page, int unlock)
  661. {
  662. if (!page || IS_ERR(page))
  663. return;
  664. if (unlock) {
  665. BUG_ON(!PageLocked(page));
  666. unlock_page(page);
  667. }
  668. page_cache_release(page);
  669. }
  670. static inline void f2fs_put_dnode(struct dnode_of_data *dn)
  671. {
  672. if (dn->node_page)
  673. f2fs_put_page(dn->node_page, 1);
  674. if (dn->inode_page && dn->node_page != dn->inode_page)
  675. f2fs_put_page(dn->inode_page, 0);
  676. dn->node_page = NULL;
  677. dn->inode_page = NULL;
  678. }
  679. static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name,
  680. size_t size, void (*ctor)(void *))
  681. {
  682. return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, ctor);
  683. }
  684. #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino)
  685. static inline bool IS_INODE(struct page *page)
  686. {
  687. struct f2fs_node *p = (struct f2fs_node *)page_address(page);
  688. return RAW_IS_INODE(p);
  689. }
  690. static inline __le32 *blkaddr_in_node(struct f2fs_node *node)
  691. {
  692. return RAW_IS_INODE(node) ? node->i.i_addr : node->dn.addr;
  693. }
  694. static inline block_t datablock_addr(struct page *node_page,
  695. unsigned int offset)
  696. {
  697. struct f2fs_node *raw_node;
  698. __le32 *addr_array;
  699. raw_node = (struct f2fs_node *)page_address(node_page);
  700. addr_array = blkaddr_in_node(raw_node);
  701. return le32_to_cpu(addr_array[offset]);
  702. }
  703. static inline int f2fs_test_bit(unsigned int nr, char *addr)
  704. {
  705. int mask;
  706. addr += (nr >> 3);
  707. mask = 1 << (7 - (nr & 0x07));
  708. return mask & *addr;
  709. }
  710. static inline int f2fs_set_bit(unsigned int nr, char *addr)
  711. {
  712. int mask;
  713. int ret;
  714. addr += (nr >> 3);
  715. mask = 1 << (7 - (nr & 0x07));
  716. ret = mask & *addr;
  717. *addr |= mask;
  718. return ret;
  719. }
  720. static inline int f2fs_clear_bit(unsigned int nr, char *addr)
  721. {
  722. int mask;
  723. int ret;
  724. addr += (nr >> 3);
  725. mask = 1 << (7 - (nr & 0x07));
  726. ret = mask & *addr;
  727. *addr &= ~mask;
  728. return ret;
  729. }
  730. /* used for f2fs_inode_info->flags */
  731. enum {
  732. FI_NEW_INODE, /* indicate newly allocated inode */
  733. FI_INC_LINK, /* need to increment i_nlink */
  734. FI_ACL_MODE, /* indicate acl mode */
  735. FI_NO_ALLOC, /* should not allocate any blocks */
  736. FI_DELAY_IPUT, /* used for the recovery */
  737. };
  738. static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
  739. {
  740. set_bit(flag, &fi->flags);
  741. }
  742. static inline int is_inode_flag_set(struct f2fs_inode_info *fi, int flag)
  743. {
  744. return test_bit(flag, &fi->flags);
  745. }
  746. static inline void clear_inode_flag(struct f2fs_inode_info *fi, int flag)
  747. {
  748. clear_bit(flag, &fi->flags);
  749. }
  750. static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
  751. {
  752. fi->i_acl_mode = mode;
  753. set_inode_flag(fi, FI_ACL_MODE);
  754. }
  755. static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
  756. {
  757. if (is_inode_flag_set(fi, FI_ACL_MODE)) {
  758. clear_inode_flag(fi, FI_ACL_MODE);
  759. return 1;
  760. }
  761. return 0;
  762. }
  763. static inline int f2fs_readonly(struct super_block *sb)
  764. {
  765. return sb->s_flags & MS_RDONLY;
  766. }
  767. /*
  768. * file.c
  769. */
  770. int f2fs_sync_file(struct file *, loff_t, loff_t, int);
  771. void truncate_data_blocks(struct dnode_of_data *);
  772. void f2fs_truncate(struct inode *);
  773. int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  774. int f2fs_setattr(struct dentry *, struct iattr *);
  775. int truncate_hole(struct inode *, pgoff_t, pgoff_t);
  776. int truncate_data_blocks_range(struct dnode_of_data *, int);
  777. long f2fs_ioctl(struct file *, unsigned int, unsigned long);
  778. long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
  779. /*
  780. * inode.c
  781. */
  782. void f2fs_set_inode_flags(struct inode *);
  783. struct inode *f2fs_iget(struct super_block *, unsigned long);
  784. void update_inode(struct inode *, struct page *);
  785. int update_inode_page(struct inode *);
  786. int f2fs_write_inode(struct inode *, struct writeback_control *);
  787. void f2fs_evict_inode(struct inode *);
  788. /*
  789. * namei.c
  790. */
  791. struct dentry *f2fs_get_parent(struct dentry *child);
  792. /*
  793. * dir.c
  794. */
  795. struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
  796. struct page **);
  797. struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
  798. ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
  799. void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
  800. struct page *, struct inode *);
  801. int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
  802. void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
  803. int f2fs_make_empty(struct inode *, struct inode *);
  804. bool f2fs_empty_dir(struct inode *);
  805. static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
  806. {
  807. return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
  808. inode);
  809. }
  810. /*
  811. * super.c
  812. */
  813. int f2fs_sync_fs(struct super_block *, int);
  814. extern __printf(3, 4)
  815. void f2fs_msg(struct super_block *, const char *, const char *, ...);
  816. /*
  817. * hash.c
  818. */
  819. f2fs_hash_t f2fs_dentry_hash(const char *, size_t);
  820. /*
  821. * node.c
  822. */
  823. struct dnode_of_data;
  824. struct node_info;
  825. int is_checkpointed_node(struct f2fs_sb_info *, nid_t);
  826. void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
  827. int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
  828. int truncate_inode_blocks(struct inode *, pgoff_t);
  829. int remove_inode_page(struct inode *);
  830. struct page *new_inode_page(struct inode *, const struct qstr *);
  831. struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *);
  832. void ra_node_page(struct f2fs_sb_info *, nid_t);
  833. struct page *get_node_page(struct f2fs_sb_info *, pgoff_t);
  834. struct page *get_node_page_ra(struct page *, int);
  835. void sync_inode_page(struct dnode_of_data *);
  836. int sync_node_pages(struct f2fs_sb_info *, nid_t, struct writeback_control *);
  837. bool alloc_nid(struct f2fs_sb_info *, nid_t *);
  838. void alloc_nid_done(struct f2fs_sb_info *, nid_t);
  839. void alloc_nid_failed(struct f2fs_sb_info *, nid_t);
  840. void recover_node_page(struct f2fs_sb_info *, struct page *,
  841. struct f2fs_summary *, struct node_info *, block_t);
  842. int recover_inode_page(struct f2fs_sb_info *, struct page *);
  843. int restore_node_summary(struct f2fs_sb_info *, unsigned int,
  844. struct f2fs_summary_block *);
  845. void flush_nat_entries(struct f2fs_sb_info *);
  846. int build_node_manager(struct f2fs_sb_info *);
  847. void destroy_node_manager(struct f2fs_sb_info *);
  848. int __init create_node_manager_caches(void);
  849. void destroy_node_manager_caches(void);
  850. /*
  851. * segment.c
  852. */
  853. void f2fs_balance_fs(struct f2fs_sb_info *);
  854. void invalidate_blocks(struct f2fs_sb_info *, block_t);
  855. void locate_dirty_segment(struct f2fs_sb_info *, unsigned int);
  856. void clear_prefree_segments(struct f2fs_sb_info *);
  857. int npages_for_summary_flush(struct f2fs_sb_info *);
  858. void allocate_new_segments(struct f2fs_sb_info *);
  859. struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
  860. struct bio *f2fs_bio_alloc(struct block_device *, int);
  861. void f2fs_submit_bio(struct f2fs_sb_info *, enum page_type, bool sync);
  862. void write_meta_page(struct f2fs_sb_info *, struct page *);
  863. void write_node_page(struct f2fs_sb_info *, struct page *, unsigned int,
  864. block_t, block_t *);
  865. void write_data_page(struct inode *, struct page *, struct dnode_of_data*,
  866. block_t, block_t *);
  867. void rewrite_data_page(struct f2fs_sb_info *, struct page *, block_t);
  868. void recover_data_page(struct f2fs_sb_info *, struct page *,
  869. struct f2fs_summary *, block_t, block_t);
  870. void rewrite_node_page(struct f2fs_sb_info *, struct page *,
  871. struct f2fs_summary *, block_t, block_t);
  872. void write_data_summaries(struct f2fs_sb_info *, block_t);
  873. void write_node_summaries(struct f2fs_sb_info *, block_t);
  874. int lookup_journal_in_cursum(struct f2fs_summary_block *,
  875. int, unsigned int, int);
  876. void flush_sit_entries(struct f2fs_sb_info *);
  877. int build_segment_manager(struct f2fs_sb_info *);
  878. void destroy_segment_manager(struct f2fs_sb_info *);
  879. /*
  880. * checkpoint.c
  881. */
  882. struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
  883. struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
  884. long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
  885. int check_orphan_space(struct f2fs_sb_info *);
  886. void add_orphan_inode(struct f2fs_sb_info *, nid_t);
  887. void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
  888. int recover_orphan_inodes(struct f2fs_sb_info *);
  889. int get_valid_checkpoint(struct f2fs_sb_info *);
  890. void set_dirty_dir_page(struct inode *, struct page *);
  891. void add_dirty_dir_inode(struct inode *);
  892. void remove_dirty_dir_inode(struct inode *);
  893. struct inode *check_dirty_dir_inode(struct f2fs_sb_info *, nid_t);
  894. void sync_dirty_dir_inodes(struct f2fs_sb_info *);
  895. void write_checkpoint(struct f2fs_sb_info *, bool);
  896. void init_orphan_info(struct f2fs_sb_info *);
  897. int __init create_checkpoint_caches(void);
  898. void destroy_checkpoint_caches(void);
  899. /*
  900. * data.c
  901. */
  902. int reserve_new_block(struct dnode_of_data *);
  903. void update_extent_cache(block_t, struct dnode_of_data *);
  904. struct page *find_data_page(struct inode *, pgoff_t, bool);
  905. struct page *get_lock_data_page(struct inode *, pgoff_t);
  906. struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
  907. int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
  908. int do_write_data_page(struct page *);
  909. /*
  910. * gc.c
  911. */
  912. int start_gc_thread(struct f2fs_sb_info *);
  913. void stop_gc_thread(struct f2fs_sb_info *);
  914. block_t start_bidx_of_node(unsigned int);
  915. int f2fs_gc(struct f2fs_sb_info *);
  916. void build_gc_manager(struct f2fs_sb_info *);
  917. int __init create_gc_caches(void);
  918. void destroy_gc_caches(void);
  919. /*
  920. * recovery.c
  921. */
  922. int recover_fsync_data(struct f2fs_sb_info *);
  923. bool space_for_roll_forward(struct f2fs_sb_info *);
  924. /*
  925. * debug.c
  926. */
  927. #ifdef CONFIG_F2FS_STAT_FS
  928. struct f2fs_stat_info {
  929. struct list_head stat_list;
  930. struct f2fs_sb_info *sbi;
  931. struct mutex stat_lock;
  932. int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs;
  933. int main_area_segs, main_area_sections, main_area_zones;
  934. int hit_ext, total_ext;
  935. int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
  936. int nats, sits, fnids;
  937. int total_count, utilization;
  938. int bg_gc;
  939. unsigned int valid_count, valid_node_count, valid_inode_count;
  940. unsigned int bimodal, avg_vblocks;
  941. int util_free, util_valid, util_invalid;
  942. int rsvd_segs, overp_segs;
  943. int dirty_count, node_pages, meta_pages;
  944. int prefree_count, call_count;
  945. int tot_segs, node_segs, data_segs, free_segs, free_secs;
  946. int tot_blks, data_blks, node_blks;
  947. int curseg[NR_CURSEG_TYPE];
  948. int cursec[NR_CURSEG_TYPE];
  949. int curzone[NR_CURSEG_TYPE];
  950. unsigned int segment_count[2];
  951. unsigned int block_count[2];
  952. unsigned base_mem, cache_mem;
  953. };
  954. #define stat_inc_call_count(si) ((si)->call_count++)
  955. #define stat_inc_seg_count(sbi, type) \
  956. do { \
  957. struct f2fs_stat_info *si = sbi->stat_info; \
  958. (si)->tot_segs++; \
  959. if (type == SUM_TYPE_DATA) \
  960. si->data_segs++; \
  961. else \
  962. si->node_segs++; \
  963. } while (0)
  964. #define stat_inc_tot_blk_count(si, blks) \
  965. (si->tot_blks += (blks))
  966. #define stat_inc_data_blk_count(sbi, blks) \
  967. do { \
  968. struct f2fs_stat_info *si = sbi->stat_info; \
  969. stat_inc_tot_blk_count(si, blks); \
  970. si->data_blks += (blks); \
  971. } while (0)
  972. #define stat_inc_node_blk_count(sbi, blks) \
  973. do { \
  974. struct f2fs_stat_info *si = sbi->stat_info; \
  975. stat_inc_tot_blk_count(si, blks); \
  976. si->node_blks += (blks); \
  977. } while (0)
  978. int f2fs_build_stats(struct f2fs_sb_info *);
  979. void f2fs_destroy_stats(struct f2fs_sb_info *);
  980. void __init f2fs_create_root_stats(void);
  981. void f2fs_destroy_root_stats(void);
  982. #else
  983. #define stat_inc_call_count(si)
  984. #define stat_inc_seg_count(si, type)
  985. #define stat_inc_tot_blk_count(si, blks)
  986. #define stat_inc_data_blk_count(si, blks)
  987. #define stat_inc_node_blk_count(sbi, blks)
  988. static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
  989. static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
  990. static inline void __init f2fs_create_root_stats(void) { }
  991. static inline void f2fs_destroy_root_stats(void) { }
  992. #endif
  993. extern const struct file_operations f2fs_dir_operations;
  994. extern const struct file_operations f2fs_file_operations;
  995. extern const struct inode_operations f2fs_file_inode_operations;
  996. extern const struct address_space_operations f2fs_dblock_aops;
  997. extern const struct address_space_operations f2fs_node_aops;
  998. extern const struct address_space_operations f2fs_meta_aops;
  999. extern const struct inode_operations f2fs_dir_inode_operations;
  1000. extern const struct inode_operations f2fs_symlink_inode_operations;
  1001. extern const struct inode_operations f2fs_special_inode_operations;
  1002. #endif