f2fs.h 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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. unsigned int n_dirty_dirs; /* # of dir inodes */
  328. /* basic file system units */
  329. unsigned int log_sectors_per_block; /* log2 sectors per block */
  330. unsigned int log_blocksize; /* log2 block size */
  331. unsigned int blocksize; /* block size */
  332. unsigned int root_ino_num; /* root inode number*/
  333. unsigned int node_ino_num; /* node inode number*/
  334. unsigned int meta_ino_num; /* meta inode number*/
  335. unsigned int log_blocks_per_seg; /* log2 blocks per segment */
  336. unsigned int blocks_per_seg; /* blocks per segment */
  337. unsigned int segs_per_sec; /* segments per section */
  338. unsigned int secs_per_zone; /* sections per zone */
  339. unsigned int total_sections; /* total section count */
  340. unsigned int total_node_count; /* total node block count */
  341. unsigned int total_valid_node_count; /* valid node block count */
  342. unsigned int total_valid_inode_count; /* valid inode count */
  343. int active_logs; /* # of active logs */
  344. block_t user_block_count; /* # of user blocks */
  345. block_t total_valid_block_count; /* # of valid blocks */
  346. block_t alloc_valid_block_count; /* # of allocated blocks */
  347. block_t last_valid_block_count; /* for recovery */
  348. u32 s_next_generation; /* for NFS support */
  349. atomic_t nr_pages[NR_COUNT_TYPE]; /* # of pages, see count_type */
  350. struct f2fs_mount_info mount_opt; /* mount options */
  351. /* for cleaning operations */
  352. struct mutex gc_mutex; /* mutex for GC */
  353. struct f2fs_gc_kthread *gc_thread; /* GC thread */
  354. unsigned int cur_victim_sec; /* current victim section num */
  355. /*
  356. * for stat information.
  357. * one is for the LFS mode, and the other is for the SSR mode.
  358. */
  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. unsigned int last_victim[2]; /* last victim segment # */
  363. int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
  364. int bg_gc; /* background gc calls */
  365. spinlock_t stat_lock; /* lock for stat operations */
  366. };
  367. /*
  368. * Inline functions
  369. */
  370. static inline struct f2fs_inode_info *F2FS_I(struct inode *inode)
  371. {
  372. return container_of(inode, struct f2fs_inode_info, vfs_inode);
  373. }
  374. static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
  375. {
  376. return sb->s_fs_info;
  377. }
  378. static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
  379. {
  380. return (struct f2fs_super_block *)(sbi->raw_super);
  381. }
  382. static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
  383. {
  384. return (struct f2fs_checkpoint *)(sbi->ckpt);
  385. }
  386. static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi)
  387. {
  388. return (struct f2fs_nm_info *)(sbi->nm_info);
  389. }
  390. static inline struct f2fs_sm_info *SM_I(struct f2fs_sb_info *sbi)
  391. {
  392. return (struct f2fs_sm_info *)(sbi->sm_info);
  393. }
  394. static inline struct sit_info *SIT_I(struct f2fs_sb_info *sbi)
  395. {
  396. return (struct sit_info *)(SM_I(sbi)->sit_info);
  397. }
  398. static inline struct free_segmap_info *FREE_I(struct f2fs_sb_info *sbi)
  399. {
  400. return (struct free_segmap_info *)(SM_I(sbi)->free_info);
  401. }
  402. static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi)
  403. {
  404. return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info);
  405. }
  406. static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi)
  407. {
  408. sbi->s_dirty = 1;
  409. }
  410. static inline void F2FS_RESET_SB_DIRT(struct f2fs_sb_info *sbi)
  411. {
  412. sbi->s_dirty = 0;
  413. }
  414. static inline bool is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  415. {
  416. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  417. return ckpt_flags & f;
  418. }
  419. static inline void set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  420. {
  421. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  422. ckpt_flags |= f;
  423. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  424. }
  425. static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  426. {
  427. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  428. ckpt_flags &= (~f);
  429. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  430. }
  431. static inline void mutex_lock_all(struct f2fs_sb_info *sbi)
  432. {
  433. int i;
  434. for (i = 0; i < NR_GLOBAL_LOCKS; i++) {
  435. /*
  436. * This is the only time we take multiple fs_lock[]
  437. * instances; the order is immaterial since we
  438. * always hold cp_mutex, which serializes multiple
  439. * such operations.
  440. */
  441. mutex_lock_nest_lock(&sbi->fs_lock[i], &sbi->cp_mutex);
  442. }
  443. }
  444. static inline void mutex_unlock_all(struct f2fs_sb_info *sbi)
  445. {
  446. int i = 0;
  447. for (; i < NR_GLOBAL_LOCKS; i++)
  448. mutex_unlock(&sbi->fs_lock[i]);
  449. }
  450. static inline int mutex_lock_op(struct f2fs_sb_info *sbi)
  451. {
  452. unsigned char next_lock = sbi->next_lock_num % NR_GLOBAL_LOCKS;
  453. int i = 0;
  454. for (; i < NR_GLOBAL_LOCKS; i++)
  455. if (mutex_trylock(&sbi->fs_lock[i]))
  456. return i;
  457. mutex_lock(&sbi->fs_lock[next_lock]);
  458. sbi->next_lock_num++;
  459. return next_lock;
  460. }
  461. static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, int ilock)
  462. {
  463. if (ilock < 0)
  464. return;
  465. BUG_ON(ilock >= NR_GLOBAL_LOCKS);
  466. mutex_unlock(&sbi->fs_lock[ilock]);
  467. }
  468. /*
  469. * Check whether the given nid is within node id range.
  470. */
  471. static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
  472. {
  473. WARN_ON((nid >= NM_I(sbi)->max_nid));
  474. if (nid >= NM_I(sbi)->max_nid)
  475. return -EINVAL;
  476. return 0;
  477. }
  478. #define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
  479. /*
  480. * Check whether the inode has blocks or not
  481. */
  482. static inline int F2FS_HAS_BLOCKS(struct inode *inode)
  483. {
  484. if (F2FS_I(inode)->i_xattr_nid)
  485. return (inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS + 1);
  486. else
  487. return (inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS);
  488. }
  489. static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
  490. struct inode *inode, blkcnt_t count)
  491. {
  492. block_t valid_block_count;
  493. spin_lock(&sbi->stat_lock);
  494. valid_block_count =
  495. sbi->total_valid_block_count + (block_t)count;
  496. if (valid_block_count > sbi->user_block_count) {
  497. spin_unlock(&sbi->stat_lock);
  498. return false;
  499. }
  500. inode->i_blocks += count;
  501. sbi->total_valid_block_count = valid_block_count;
  502. sbi->alloc_valid_block_count += (block_t)count;
  503. spin_unlock(&sbi->stat_lock);
  504. return true;
  505. }
  506. static inline int dec_valid_block_count(struct f2fs_sb_info *sbi,
  507. struct inode *inode,
  508. blkcnt_t count)
  509. {
  510. spin_lock(&sbi->stat_lock);
  511. BUG_ON(sbi->total_valid_block_count < (block_t) count);
  512. BUG_ON(inode->i_blocks < count);
  513. inode->i_blocks -= count;
  514. sbi->total_valid_block_count -= (block_t)count;
  515. spin_unlock(&sbi->stat_lock);
  516. return 0;
  517. }
  518. static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
  519. {
  520. atomic_inc(&sbi->nr_pages[count_type]);
  521. F2FS_SET_SB_DIRT(sbi);
  522. }
  523. static inline void inode_inc_dirty_dents(struct inode *inode)
  524. {
  525. atomic_inc(&F2FS_I(inode)->dirty_dents);
  526. }
  527. static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
  528. {
  529. atomic_dec(&sbi->nr_pages[count_type]);
  530. }
  531. static inline void inode_dec_dirty_dents(struct inode *inode)
  532. {
  533. atomic_dec(&F2FS_I(inode)->dirty_dents);
  534. }
  535. static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
  536. {
  537. return atomic_read(&sbi->nr_pages[count_type]);
  538. }
  539. static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
  540. {
  541. unsigned int pages_per_sec = sbi->segs_per_sec *
  542. (1 << sbi->log_blocks_per_seg);
  543. return ((get_pages(sbi, block_type) + pages_per_sec - 1)
  544. >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
  545. }
  546. static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
  547. {
  548. block_t ret;
  549. spin_lock(&sbi->stat_lock);
  550. ret = sbi->total_valid_block_count;
  551. spin_unlock(&sbi->stat_lock);
  552. return ret;
  553. }
  554. static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag)
  555. {
  556. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  557. /* return NAT or SIT bitmap */
  558. if (flag == NAT_BITMAP)
  559. return le32_to_cpu(ckpt->nat_ver_bitmap_bytesize);
  560. else if (flag == SIT_BITMAP)
  561. return le32_to_cpu(ckpt->sit_ver_bitmap_bytesize);
  562. return 0;
  563. }
  564. static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
  565. {
  566. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  567. int offset = (flag == NAT_BITMAP) ?
  568. le32_to_cpu(ckpt->sit_ver_bitmap_bytesize) : 0;
  569. return &ckpt->sit_nat_version_bitmap + offset;
  570. }
  571. static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi)
  572. {
  573. block_t start_addr;
  574. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  575. unsigned long long ckpt_version = le64_to_cpu(ckpt->checkpoint_ver);
  576. start_addr = le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr);
  577. /*
  578. * odd numbered checkpoint should at cp segment 0
  579. * and even segent must be at cp segment 1
  580. */
  581. if (!(ckpt_version & 1))
  582. start_addr += sbi->blocks_per_seg;
  583. return start_addr;
  584. }
  585. static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
  586. {
  587. return le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
  588. }
  589. static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
  590. struct inode *inode,
  591. unsigned int count)
  592. {
  593. block_t valid_block_count;
  594. unsigned int valid_node_count;
  595. spin_lock(&sbi->stat_lock);
  596. valid_block_count = sbi->total_valid_block_count + (block_t)count;
  597. sbi->alloc_valid_block_count += (block_t)count;
  598. valid_node_count = sbi->total_valid_node_count + count;
  599. if (valid_block_count > sbi->user_block_count) {
  600. spin_unlock(&sbi->stat_lock);
  601. return false;
  602. }
  603. if (valid_node_count > sbi->total_node_count) {
  604. spin_unlock(&sbi->stat_lock);
  605. return false;
  606. }
  607. if (inode)
  608. inode->i_blocks += count;
  609. sbi->total_valid_node_count = valid_node_count;
  610. sbi->total_valid_block_count = valid_block_count;
  611. spin_unlock(&sbi->stat_lock);
  612. return true;
  613. }
  614. static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
  615. struct inode *inode,
  616. unsigned int count)
  617. {
  618. spin_lock(&sbi->stat_lock);
  619. BUG_ON(sbi->total_valid_block_count < count);
  620. BUG_ON(sbi->total_valid_node_count < count);
  621. BUG_ON(inode->i_blocks < count);
  622. inode->i_blocks -= count;
  623. sbi->total_valid_node_count -= count;
  624. sbi->total_valid_block_count -= (block_t)count;
  625. spin_unlock(&sbi->stat_lock);
  626. }
  627. static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
  628. {
  629. unsigned int ret;
  630. spin_lock(&sbi->stat_lock);
  631. ret = sbi->total_valid_node_count;
  632. spin_unlock(&sbi->stat_lock);
  633. return ret;
  634. }
  635. static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi)
  636. {
  637. spin_lock(&sbi->stat_lock);
  638. BUG_ON(sbi->total_valid_inode_count == sbi->total_node_count);
  639. sbi->total_valid_inode_count++;
  640. spin_unlock(&sbi->stat_lock);
  641. }
  642. static inline int dec_valid_inode_count(struct f2fs_sb_info *sbi)
  643. {
  644. spin_lock(&sbi->stat_lock);
  645. BUG_ON(!sbi->total_valid_inode_count);
  646. sbi->total_valid_inode_count--;
  647. spin_unlock(&sbi->stat_lock);
  648. return 0;
  649. }
  650. static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
  651. {
  652. unsigned int ret;
  653. spin_lock(&sbi->stat_lock);
  654. ret = sbi->total_valid_inode_count;
  655. spin_unlock(&sbi->stat_lock);
  656. return ret;
  657. }
  658. static inline void f2fs_put_page(struct page *page, int unlock)
  659. {
  660. if (!page || IS_ERR(page))
  661. return;
  662. if (unlock) {
  663. BUG_ON(!PageLocked(page));
  664. unlock_page(page);
  665. }
  666. page_cache_release(page);
  667. }
  668. static inline void f2fs_put_dnode(struct dnode_of_data *dn)
  669. {
  670. if (dn->node_page)
  671. f2fs_put_page(dn->node_page, 1);
  672. if (dn->inode_page && dn->node_page != dn->inode_page)
  673. f2fs_put_page(dn->inode_page, 0);
  674. dn->node_page = NULL;
  675. dn->inode_page = NULL;
  676. }
  677. static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name,
  678. size_t size, void (*ctor)(void *))
  679. {
  680. return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, ctor);
  681. }
  682. #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino)
  683. static inline bool IS_INODE(struct page *page)
  684. {
  685. struct f2fs_node *p = (struct f2fs_node *)page_address(page);
  686. return RAW_IS_INODE(p);
  687. }
  688. static inline __le32 *blkaddr_in_node(struct f2fs_node *node)
  689. {
  690. return RAW_IS_INODE(node) ? node->i.i_addr : node->dn.addr;
  691. }
  692. static inline block_t datablock_addr(struct page *node_page,
  693. unsigned int offset)
  694. {
  695. struct f2fs_node *raw_node;
  696. __le32 *addr_array;
  697. raw_node = (struct f2fs_node *)page_address(node_page);
  698. addr_array = blkaddr_in_node(raw_node);
  699. return le32_to_cpu(addr_array[offset]);
  700. }
  701. static inline int f2fs_test_bit(unsigned int nr, char *addr)
  702. {
  703. int mask;
  704. addr += (nr >> 3);
  705. mask = 1 << (7 - (nr & 0x07));
  706. return mask & *addr;
  707. }
  708. static inline int f2fs_set_bit(unsigned int nr, char *addr)
  709. {
  710. int mask;
  711. int ret;
  712. addr += (nr >> 3);
  713. mask = 1 << (7 - (nr & 0x07));
  714. ret = mask & *addr;
  715. *addr |= mask;
  716. return ret;
  717. }
  718. static inline int f2fs_clear_bit(unsigned int nr, char *addr)
  719. {
  720. int mask;
  721. int ret;
  722. addr += (nr >> 3);
  723. mask = 1 << (7 - (nr & 0x07));
  724. ret = mask & *addr;
  725. *addr &= ~mask;
  726. return ret;
  727. }
  728. /* used for f2fs_inode_info->flags */
  729. enum {
  730. FI_NEW_INODE, /* indicate newly allocated inode */
  731. FI_INC_LINK, /* need to increment i_nlink */
  732. FI_ACL_MODE, /* indicate acl mode */
  733. FI_NO_ALLOC, /* should not allocate any blocks */
  734. FI_DELAY_IPUT, /* used for the recovery */
  735. };
  736. static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
  737. {
  738. set_bit(flag, &fi->flags);
  739. }
  740. static inline int is_inode_flag_set(struct f2fs_inode_info *fi, int flag)
  741. {
  742. return test_bit(flag, &fi->flags);
  743. }
  744. static inline void clear_inode_flag(struct f2fs_inode_info *fi, int flag)
  745. {
  746. clear_bit(flag, &fi->flags);
  747. }
  748. static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
  749. {
  750. fi->i_acl_mode = mode;
  751. set_inode_flag(fi, FI_ACL_MODE);
  752. }
  753. static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
  754. {
  755. if (is_inode_flag_set(fi, FI_ACL_MODE)) {
  756. clear_inode_flag(fi, FI_ACL_MODE);
  757. return 1;
  758. }
  759. return 0;
  760. }
  761. static inline int f2fs_readonly(struct super_block *sb)
  762. {
  763. return sb->s_flags & MS_RDONLY;
  764. }
  765. /*
  766. * file.c
  767. */
  768. int f2fs_sync_file(struct file *, loff_t, loff_t, int);
  769. void truncate_data_blocks(struct dnode_of_data *);
  770. void f2fs_truncate(struct inode *);
  771. int f2fs_setattr(struct dentry *, struct iattr *);
  772. int truncate_hole(struct inode *, pgoff_t, pgoff_t);
  773. int truncate_data_blocks_range(struct dnode_of_data *, int);
  774. long f2fs_ioctl(struct file *, unsigned int, unsigned long);
  775. long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
  776. /*
  777. * inode.c
  778. */
  779. void f2fs_set_inode_flags(struct inode *);
  780. struct inode *f2fs_iget(struct super_block *, unsigned long);
  781. void update_inode(struct inode *, struct page *);
  782. int update_inode_page(struct inode *);
  783. int f2fs_write_inode(struct inode *, struct writeback_control *);
  784. void f2fs_evict_inode(struct inode *);
  785. /*
  786. * namei.c
  787. */
  788. struct dentry *f2fs_get_parent(struct dentry *child);
  789. /*
  790. * dir.c
  791. */
  792. struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
  793. struct page **);
  794. struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
  795. ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
  796. void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
  797. struct page *, struct inode *);
  798. int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
  799. void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
  800. int f2fs_make_empty(struct inode *, struct inode *);
  801. bool f2fs_empty_dir(struct inode *);
  802. static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
  803. {
  804. return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
  805. inode);
  806. }
  807. /*
  808. * super.c
  809. */
  810. int f2fs_sync_fs(struct super_block *, int);
  811. extern __printf(3, 4)
  812. void f2fs_msg(struct super_block *, const char *, const char *, ...);
  813. /*
  814. * hash.c
  815. */
  816. f2fs_hash_t f2fs_dentry_hash(const char *, size_t);
  817. /*
  818. * node.c
  819. */
  820. struct dnode_of_data;
  821. struct node_info;
  822. int is_checkpointed_node(struct f2fs_sb_info *, nid_t);
  823. void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
  824. int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
  825. int truncate_inode_blocks(struct inode *, pgoff_t);
  826. int remove_inode_page(struct inode *);
  827. struct page *new_inode_page(struct inode *, const struct qstr *);
  828. struct page *new_node_page(struct dnode_of_data *, unsigned int);
  829. void ra_node_page(struct f2fs_sb_info *, nid_t);
  830. struct page *get_node_page(struct f2fs_sb_info *, pgoff_t);
  831. struct page *get_node_page_ra(struct page *, int);
  832. void sync_inode_page(struct dnode_of_data *);
  833. int sync_node_pages(struct f2fs_sb_info *, nid_t, struct writeback_control *);
  834. bool alloc_nid(struct f2fs_sb_info *, nid_t *);
  835. void alloc_nid_done(struct f2fs_sb_info *, nid_t);
  836. void alloc_nid_failed(struct f2fs_sb_info *, nid_t);
  837. void recover_node_page(struct f2fs_sb_info *, struct page *,
  838. struct f2fs_summary *, struct node_info *, block_t);
  839. int recover_inode_page(struct f2fs_sb_info *, struct page *);
  840. int restore_node_summary(struct f2fs_sb_info *, unsigned int,
  841. struct f2fs_summary_block *);
  842. void flush_nat_entries(struct f2fs_sb_info *);
  843. int build_node_manager(struct f2fs_sb_info *);
  844. void destroy_node_manager(struct f2fs_sb_info *);
  845. int __init create_node_manager_caches(void);
  846. void destroy_node_manager_caches(void);
  847. /*
  848. * segment.c
  849. */
  850. void f2fs_balance_fs(struct f2fs_sb_info *);
  851. void invalidate_blocks(struct f2fs_sb_info *, block_t);
  852. void locate_dirty_segment(struct f2fs_sb_info *, unsigned int);
  853. void clear_prefree_segments(struct f2fs_sb_info *);
  854. int npages_for_summary_flush(struct f2fs_sb_info *);
  855. void allocate_new_segments(struct f2fs_sb_info *);
  856. struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
  857. struct bio *f2fs_bio_alloc(struct block_device *, int);
  858. void f2fs_submit_bio(struct f2fs_sb_info *, enum page_type, bool sync);
  859. void write_meta_page(struct f2fs_sb_info *, struct page *);
  860. void write_node_page(struct f2fs_sb_info *, struct page *, unsigned int,
  861. block_t, block_t *);
  862. void write_data_page(struct inode *, struct page *, struct dnode_of_data*,
  863. block_t, block_t *);
  864. void rewrite_data_page(struct f2fs_sb_info *, struct page *, block_t);
  865. void recover_data_page(struct f2fs_sb_info *, struct page *,
  866. struct f2fs_summary *, block_t, block_t);
  867. void rewrite_node_page(struct f2fs_sb_info *, struct page *,
  868. struct f2fs_summary *, block_t, block_t);
  869. void write_data_summaries(struct f2fs_sb_info *, block_t);
  870. void write_node_summaries(struct f2fs_sb_info *, block_t);
  871. int lookup_journal_in_cursum(struct f2fs_summary_block *,
  872. int, unsigned int, int);
  873. void flush_sit_entries(struct f2fs_sb_info *);
  874. int build_segment_manager(struct f2fs_sb_info *);
  875. void destroy_segment_manager(struct f2fs_sb_info *);
  876. /*
  877. * checkpoint.c
  878. */
  879. struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
  880. struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
  881. long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
  882. int check_orphan_space(struct f2fs_sb_info *);
  883. void add_orphan_inode(struct f2fs_sb_info *, nid_t);
  884. void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
  885. int recover_orphan_inodes(struct f2fs_sb_info *);
  886. int get_valid_checkpoint(struct f2fs_sb_info *);
  887. void set_dirty_dir_page(struct inode *, struct page *);
  888. void remove_dirty_dir_inode(struct inode *);
  889. struct inode *check_dirty_dir_inode(struct f2fs_sb_info *, nid_t);
  890. void sync_dirty_dir_inodes(struct f2fs_sb_info *);
  891. void write_checkpoint(struct f2fs_sb_info *, bool);
  892. void init_orphan_info(struct f2fs_sb_info *);
  893. int __init create_checkpoint_caches(void);
  894. void destroy_checkpoint_caches(void);
  895. /*
  896. * data.c
  897. */
  898. int reserve_new_block(struct dnode_of_data *);
  899. void update_extent_cache(block_t, struct dnode_of_data *);
  900. struct page *find_data_page(struct inode *, pgoff_t, bool);
  901. struct page *get_lock_data_page(struct inode *, pgoff_t);
  902. struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
  903. int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
  904. int do_write_data_page(struct page *);
  905. /*
  906. * gc.c
  907. */
  908. int start_gc_thread(struct f2fs_sb_info *);
  909. void stop_gc_thread(struct f2fs_sb_info *);
  910. block_t start_bidx_of_node(unsigned int);
  911. int f2fs_gc(struct f2fs_sb_info *);
  912. void build_gc_manager(struct f2fs_sb_info *);
  913. int __init create_gc_caches(void);
  914. void destroy_gc_caches(void);
  915. /*
  916. * recovery.c
  917. */
  918. int recover_fsync_data(struct f2fs_sb_info *);
  919. bool space_for_roll_forward(struct f2fs_sb_info *);
  920. /*
  921. * debug.c
  922. */
  923. #ifdef CONFIG_F2FS_STAT_FS
  924. struct f2fs_stat_info {
  925. struct list_head stat_list;
  926. struct f2fs_sb_info *sbi;
  927. struct mutex stat_lock;
  928. int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs;
  929. int main_area_segs, main_area_sections, main_area_zones;
  930. int hit_ext, total_ext;
  931. int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
  932. int nats, sits, fnids;
  933. int total_count, utilization;
  934. int bg_gc;
  935. unsigned int valid_count, valid_node_count, valid_inode_count;
  936. unsigned int bimodal, avg_vblocks;
  937. int util_free, util_valid, util_invalid;
  938. int rsvd_segs, overp_segs;
  939. int dirty_count, node_pages, meta_pages;
  940. int prefree_count, call_count;
  941. int tot_segs, node_segs, data_segs, free_segs, free_secs;
  942. int tot_blks, data_blks, node_blks;
  943. int curseg[NR_CURSEG_TYPE];
  944. int cursec[NR_CURSEG_TYPE];
  945. int curzone[NR_CURSEG_TYPE];
  946. unsigned int segment_count[2];
  947. unsigned int block_count[2];
  948. unsigned base_mem, cache_mem;
  949. };
  950. #define stat_inc_call_count(si) ((si)->call_count++)
  951. #define stat_inc_seg_count(sbi, type) \
  952. do { \
  953. struct f2fs_stat_info *si = sbi->stat_info; \
  954. (si)->tot_segs++; \
  955. if (type == SUM_TYPE_DATA) \
  956. si->data_segs++; \
  957. else \
  958. si->node_segs++; \
  959. } while (0)
  960. #define stat_inc_tot_blk_count(si, blks) \
  961. (si->tot_blks += (blks))
  962. #define stat_inc_data_blk_count(sbi, blks) \
  963. do { \
  964. struct f2fs_stat_info *si = sbi->stat_info; \
  965. stat_inc_tot_blk_count(si, blks); \
  966. si->data_blks += (blks); \
  967. } while (0)
  968. #define stat_inc_node_blk_count(sbi, blks) \
  969. do { \
  970. struct f2fs_stat_info *si = sbi->stat_info; \
  971. stat_inc_tot_blk_count(si, blks); \
  972. si->node_blks += (blks); \
  973. } while (0)
  974. int f2fs_build_stats(struct f2fs_sb_info *);
  975. void f2fs_destroy_stats(struct f2fs_sb_info *);
  976. void __init f2fs_create_root_stats(void);
  977. void f2fs_destroy_root_stats(void);
  978. #else
  979. #define stat_inc_call_count(si)
  980. #define stat_inc_seg_count(si, type)
  981. #define stat_inc_tot_blk_count(si, blks)
  982. #define stat_inc_data_blk_count(si, blks)
  983. #define stat_inc_node_blk_count(sbi, blks)
  984. static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
  985. static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
  986. static inline void __init f2fs_create_root_stats(void) { }
  987. static inline void f2fs_destroy_root_stats(void) { }
  988. #endif
  989. extern const struct file_operations f2fs_dir_operations;
  990. extern const struct file_operations f2fs_file_operations;
  991. extern const struct inode_operations f2fs_file_inode_operations;
  992. extern const struct address_space_operations f2fs_dblock_aops;
  993. extern const struct address_space_operations f2fs_node_aops;
  994. extern const struct address_space_operations f2fs_meta_aops;
  995. extern const struct inode_operations f2fs_dir_inode_operations;
  996. extern const struct inode_operations f2fs_symlink_inode_operations;
  997. extern const struct inode_operations f2fs_special_inode_operations;
  998. #endif