f2fs.h 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643
  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. #include <linux/kobject.h>
  20. #include <linux/sched.h>
  21. #ifdef CONFIG_F2FS_CHECK_FS
  22. #define f2fs_bug_on(sbi, condition) BUG_ON(condition)
  23. #define f2fs_down_write(x, y) down_write_nest_lock(x, y)
  24. #else
  25. #define f2fs_bug_on(sbi, condition) \
  26. do { \
  27. if (unlikely(condition)) { \
  28. WARN_ON(1); \
  29. sbi->need_fsck = true; \
  30. } \
  31. } while (0)
  32. #define f2fs_down_write(x, y) down_write(x)
  33. #endif
  34. /*
  35. * For mount options
  36. */
  37. #define F2FS_MOUNT_BG_GC 0x00000001
  38. #define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002
  39. #define F2FS_MOUNT_DISCARD 0x00000004
  40. #define F2FS_MOUNT_NOHEAP 0x00000008
  41. #define F2FS_MOUNT_XATTR_USER 0x00000010
  42. #define F2FS_MOUNT_POSIX_ACL 0x00000020
  43. #define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000040
  44. #define F2FS_MOUNT_INLINE_XATTR 0x00000080
  45. #define F2FS_MOUNT_INLINE_DATA 0x00000100
  46. #define F2FS_MOUNT_INLINE_DENTRY 0x00000200
  47. #define F2FS_MOUNT_FLUSH_MERGE 0x00000400
  48. #define F2FS_MOUNT_NOBARRIER 0x00000800
  49. #define F2FS_MOUNT_FASTBOOT 0x00001000
  50. #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
  51. #define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
  52. #define test_opt(sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option)
  53. #define ver_after(a, b) (typecheck(unsigned long long, a) && \
  54. typecheck(unsigned long long, b) && \
  55. ((long long)((a) - (b)) > 0))
  56. typedef u32 block_t; /*
  57. * should not change u32, since it is the on-disk block
  58. * address format, __le32.
  59. */
  60. typedef u32 nid_t;
  61. struct f2fs_mount_info {
  62. unsigned int opt;
  63. };
  64. #define CRCPOLY_LE 0xedb88320
  65. static inline __u32 f2fs_crc32(void *buf, size_t len)
  66. {
  67. unsigned char *p = (unsigned char *)buf;
  68. __u32 crc = F2FS_SUPER_MAGIC;
  69. int i;
  70. while (len--) {
  71. crc ^= *p++;
  72. for (i = 0; i < 8; i++)
  73. crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
  74. }
  75. return crc;
  76. }
  77. static inline bool f2fs_crc_valid(__u32 blk_crc, void *buf, size_t buf_size)
  78. {
  79. return f2fs_crc32(buf, buf_size) == blk_crc;
  80. }
  81. /*
  82. * For checkpoint manager
  83. */
  84. enum {
  85. NAT_BITMAP,
  86. SIT_BITMAP
  87. };
  88. enum {
  89. CP_UMOUNT,
  90. CP_SYNC,
  91. CP_DISCARD,
  92. };
  93. struct cp_control {
  94. int reason;
  95. __u64 trim_start;
  96. __u64 trim_end;
  97. __u64 trim_minlen;
  98. __u64 trimmed;
  99. };
  100. /*
  101. * For CP/NAT/SIT/SSA readahead
  102. */
  103. enum {
  104. META_CP,
  105. META_NAT,
  106. META_SIT,
  107. META_SSA,
  108. META_POR,
  109. };
  110. /* for the list of ino */
  111. enum {
  112. ORPHAN_INO, /* for orphan ino list */
  113. APPEND_INO, /* for append ino list */
  114. UPDATE_INO, /* for update ino list */
  115. MAX_INO_ENTRY, /* max. list */
  116. };
  117. struct ino_entry {
  118. struct list_head list; /* list head */
  119. nid_t ino; /* inode number */
  120. };
  121. /* for the list of directory inodes */
  122. struct dir_inode_entry {
  123. struct list_head list; /* list head */
  124. struct inode *inode; /* vfs inode pointer */
  125. };
  126. /* for the list of blockaddresses to be discarded */
  127. struct discard_entry {
  128. struct list_head list; /* list head */
  129. block_t blkaddr; /* block address to be discarded */
  130. int len; /* # of consecutive blocks of the discard */
  131. };
  132. /* for the list of fsync inodes, used only during recovery */
  133. struct fsync_inode_entry {
  134. struct list_head list; /* list head */
  135. struct inode *inode; /* vfs inode pointer */
  136. block_t blkaddr; /* block address locating the last fsync */
  137. block_t last_dentry; /* block address locating the last dentry */
  138. block_t last_inode; /* block address locating the last inode */
  139. };
  140. #define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats))
  141. #define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits))
  142. #define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne)
  143. #define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid)
  144. #define sit_in_journal(sum, i) (sum->sit_j.entries[i].se)
  145. #define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno)
  146. #define MAX_NAT_JENTRIES(sum) (NAT_JOURNAL_ENTRIES - nats_in_cursum(sum))
  147. #define MAX_SIT_JENTRIES(sum) (SIT_JOURNAL_ENTRIES - sits_in_cursum(sum))
  148. static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i)
  149. {
  150. int before = nats_in_cursum(rs);
  151. rs->n_nats = cpu_to_le16(before + i);
  152. return before;
  153. }
  154. static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
  155. {
  156. int before = sits_in_cursum(rs);
  157. rs->n_sits = cpu_to_le16(before + i);
  158. return before;
  159. }
  160. static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size,
  161. int type)
  162. {
  163. if (type == NAT_JOURNAL)
  164. return size <= MAX_NAT_JENTRIES(sum);
  165. return size <= MAX_SIT_JENTRIES(sum);
  166. }
  167. /*
  168. * ioctl commands
  169. */
  170. #define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
  171. #define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
  172. #define F2FS_IOCTL_MAGIC 0xf5
  173. #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
  174. #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
  175. #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
  176. #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  177. /*
  178. * ioctl commands in 32 bit emulation
  179. */
  180. #define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
  181. #define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
  182. #endif
  183. /*
  184. * For INODE and NODE manager
  185. */
  186. /* for directory operations */
  187. struct f2fs_dentry_ptr {
  188. const void *bitmap;
  189. struct f2fs_dir_entry *dentry;
  190. __u8 (*filename)[F2FS_SLOT_LEN];
  191. int max;
  192. };
  193. static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d,
  194. void *src, int type)
  195. {
  196. if (type == 1) {
  197. struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
  198. d->max = NR_DENTRY_IN_BLOCK;
  199. d->bitmap = &t->dentry_bitmap;
  200. d->dentry = t->dentry;
  201. d->filename = t->filename;
  202. } else {
  203. struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src;
  204. d->max = NR_INLINE_DENTRY;
  205. d->bitmap = &t->dentry_bitmap;
  206. d->dentry = t->dentry;
  207. d->filename = t->filename;
  208. }
  209. }
  210. /*
  211. * XATTR_NODE_OFFSET stores xattrs to one node block per file keeping -1
  212. * as its node offset to distinguish from index node blocks.
  213. * But some bits are used to mark the node block.
  214. */
  215. #define XATTR_NODE_OFFSET ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \
  216. >> OFFSET_BIT_SHIFT)
  217. enum {
  218. ALLOC_NODE, /* allocate a new node page if needed */
  219. LOOKUP_NODE, /* look up a node without readahead */
  220. LOOKUP_NODE_RA, /*
  221. * look up a node with readahead called
  222. * by get_data_block.
  223. */
  224. };
  225. #define F2FS_LINK_MAX 32000 /* maximum link count per file */
  226. #define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
  227. /* for in-memory extent cache entry */
  228. #define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */
  229. struct extent_info {
  230. rwlock_t ext_lock; /* rwlock for consistency */
  231. unsigned int fofs; /* start offset in a file */
  232. u32 blk_addr; /* start block address of the extent */
  233. unsigned int len; /* length of the extent */
  234. };
  235. /*
  236. * i_advise uses FADVISE_XXX_BIT. We can add additional hints later.
  237. */
  238. #define FADVISE_COLD_BIT 0x01
  239. #define FADVISE_LOST_PINO_BIT 0x02
  240. #define DEF_DIR_LEVEL 0
  241. struct f2fs_inode_info {
  242. struct inode vfs_inode; /* serve a vfs inode */
  243. unsigned long i_flags; /* keep an inode flags for ioctl */
  244. unsigned char i_advise; /* use to give file attribute hints */
  245. unsigned char i_dir_level; /* use for dentry level for large dir */
  246. unsigned int i_current_depth; /* use only in directory structure */
  247. unsigned int i_pino; /* parent inode number */
  248. umode_t i_acl_mode; /* keep file acl mode temporarily */
  249. /* Use below internally in f2fs*/
  250. unsigned long flags; /* use to pass per-file flags */
  251. struct rw_semaphore i_sem; /* protect fi info */
  252. atomic_t dirty_pages; /* # of dirty pages */
  253. f2fs_hash_t chash; /* hash value of given file name */
  254. unsigned int clevel; /* maximum level of given file name */
  255. nid_t i_xattr_nid; /* node id that contains xattrs */
  256. unsigned long long xattr_ver; /* cp version of xattr modification */
  257. struct extent_info ext; /* in-memory extent cache entry */
  258. struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */
  259. struct radix_tree_root inmem_root; /* radix tree for inmem pages */
  260. struct list_head inmem_pages; /* inmemory pages managed by f2fs */
  261. struct mutex inmem_lock; /* lock for inmemory pages */
  262. };
  263. static inline void get_extent_info(struct extent_info *ext,
  264. struct f2fs_extent i_ext)
  265. {
  266. write_lock(&ext->ext_lock);
  267. ext->fofs = le32_to_cpu(i_ext.fofs);
  268. ext->blk_addr = le32_to_cpu(i_ext.blk_addr);
  269. ext->len = le32_to_cpu(i_ext.len);
  270. write_unlock(&ext->ext_lock);
  271. }
  272. static inline void set_raw_extent(struct extent_info *ext,
  273. struct f2fs_extent *i_ext)
  274. {
  275. read_lock(&ext->ext_lock);
  276. i_ext->fofs = cpu_to_le32(ext->fofs);
  277. i_ext->blk_addr = cpu_to_le32(ext->blk_addr);
  278. i_ext->len = cpu_to_le32(ext->len);
  279. read_unlock(&ext->ext_lock);
  280. }
  281. struct f2fs_nm_info {
  282. block_t nat_blkaddr; /* base disk address of NAT */
  283. nid_t max_nid; /* maximum possible node ids */
  284. nid_t available_nids; /* maximum available node ids */
  285. nid_t next_scan_nid; /* the next nid to be scanned */
  286. unsigned int ram_thresh; /* control the memory footprint */
  287. /* NAT cache management */
  288. struct radix_tree_root nat_root;/* root of the nat entry cache */
  289. struct radix_tree_root nat_set_root;/* root of the nat set cache */
  290. struct rw_semaphore nat_tree_lock; /* protect nat_tree_lock */
  291. struct list_head nat_entries; /* cached nat entry list (clean) */
  292. unsigned int nat_cnt; /* the # of cached nat entries */
  293. unsigned int dirty_nat_cnt; /* total num of nat entries in set */
  294. /* free node ids management */
  295. struct radix_tree_root free_nid_root;/* root of the free_nid cache */
  296. struct list_head free_nid_list; /* a list for free nids */
  297. spinlock_t free_nid_list_lock; /* protect free nid list */
  298. unsigned int fcnt; /* the number of free node id */
  299. struct mutex build_lock; /* lock for build free nids */
  300. /* for checkpoint */
  301. char *nat_bitmap; /* NAT bitmap pointer */
  302. int bitmap_size; /* bitmap size */
  303. };
  304. /*
  305. * this structure is used as one of function parameters.
  306. * all the information are dedicated to a given direct node block determined
  307. * by the data offset in a file.
  308. */
  309. struct dnode_of_data {
  310. struct inode *inode; /* vfs inode pointer */
  311. struct page *inode_page; /* its inode page, NULL is possible */
  312. struct page *node_page; /* cached direct node page */
  313. nid_t nid; /* node id of the direct node block */
  314. unsigned int ofs_in_node; /* data offset in the node page */
  315. bool inode_page_locked; /* inode page is locked or not */
  316. block_t data_blkaddr; /* block address of the node block */
  317. };
  318. static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode,
  319. struct page *ipage, struct page *npage, nid_t nid)
  320. {
  321. memset(dn, 0, sizeof(*dn));
  322. dn->inode = inode;
  323. dn->inode_page = ipage;
  324. dn->node_page = npage;
  325. dn->nid = nid;
  326. }
  327. /*
  328. * For SIT manager
  329. *
  330. * By default, there are 6 active log areas across the whole main area.
  331. * When considering hot and cold data separation to reduce cleaning overhead,
  332. * we split 3 for data logs and 3 for node logs as hot, warm, and cold types,
  333. * respectively.
  334. * In the current design, you should not change the numbers intentionally.
  335. * Instead, as a mount option such as active_logs=x, you can use 2, 4, and 6
  336. * logs individually according to the underlying devices. (default: 6)
  337. * Just in case, on-disk layout covers maximum 16 logs that consist of 8 for
  338. * data and 8 for node logs.
  339. */
  340. #define NR_CURSEG_DATA_TYPE (3)
  341. #define NR_CURSEG_NODE_TYPE (3)
  342. #define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE)
  343. enum {
  344. CURSEG_HOT_DATA = 0, /* directory entry blocks */
  345. CURSEG_WARM_DATA, /* data blocks */
  346. CURSEG_COLD_DATA, /* multimedia or GCed data blocks */
  347. CURSEG_HOT_NODE, /* direct node blocks of directory files */
  348. CURSEG_WARM_NODE, /* direct node blocks of normal files */
  349. CURSEG_COLD_NODE, /* indirect node blocks */
  350. NO_CHECK_TYPE
  351. };
  352. struct flush_cmd {
  353. struct completion wait;
  354. struct llist_node llnode;
  355. int ret;
  356. };
  357. struct flush_cmd_control {
  358. struct task_struct *f2fs_issue_flush; /* flush thread */
  359. wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */
  360. struct llist_head issue_list; /* list for command issue */
  361. struct llist_node *dispatch_list; /* list for command dispatch */
  362. };
  363. struct f2fs_sm_info {
  364. struct sit_info *sit_info; /* whole segment information */
  365. struct free_segmap_info *free_info; /* free segment information */
  366. struct dirty_seglist_info *dirty_info; /* dirty segment information */
  367. struct curseg_info *curseg_array; /* active segment information */
  368. block_t seg0_blkaddr; /* block address of 0'th segment */
  369. block_t main_blkaddr; /* start block address of main area */
  370. block_t ssa_blkaddr; /* start block address of SSA area */
  371. unsigned int segment_count; /* total # of segments */
  372. unsigned int main_segments; /* # of segments in main area */
  373. unsigned int reserved_segments; /* # of reserved segments */
  374. unsigned int ovp_segments; /* # of overprovision segments */
  375. /* a threshold to reclaim prefree segments */
  376. unsigned int rec_prefree_segments;
  377. /* for small discard management */
  378. struct list_head discard_list; /* 4KB discard list */
  379. int nr_discards; /* # of discards in the list */
  380. int max_discards; /* max. discards to be issued */
  381. struct list_head sit_entry_set; /* sit entry set list */
  382. unsigned int ipu_policy; /* in-place-update policy */
  383. unsigned int min_ipu_util; /* in-place-update threshold */
  384. unsigned int min_fsync_blocks; /* threshold for fsync */
  385. /* for flush command control */
  386. struct flush_cmd_control *cmd_control_info;
  387. };
  388. /*
  389. * For superblock
  390. */
  391. /*
  392. * COUNT_TYPE for monitoring
  393. *
  394. * f2fs monitors the number of several block types such as on-writeback,
  395. * dirty dentry blocks, dirty node blocks, and dirty meta blocks.
  396. */
  397. enum count_type {
  398. F2FS_WRITEBACK,
  399. F2FS_DIRTY_DENTS,
  400. F2FS_DIRTY_NODES,
  401. F2FS_DIRTY_META,
  402. F2FS_INMEM_PAGES,
  403. NR_COUNT_TYPE,
  404. };
  405. /*
  406. * The below are the page types of bios used in submit_bio().
  407. * The available types are:
  408. * DATA User data pages. It operates as async mode.
  409. * NODE Node pages. It operates as async mode.
  410. * META FS metadata pages such as SIT, NAT, CP.
  411. * NR_PAGE_TYPE The number of page types.
  412. * META_FLUSH Make sure the previous pages are written
  413. * with waiting the bio's completion
  414. * ... Only can be used with META.
  415. */
  416. #define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type))
  417. enum page_type {
  418. DATA,
  419. NODE,
  420. META,
  421. NR_PAGE_TYPE,
  422. META_FLUSH,
  423. };
  424. struct f2fs_io_info {
  425. enum page_type type; /* contains DATA/NODE/META/META_FLUSH */
  426. int rw; /* contains R/RS/W/WS with REQ_META/REQ_PRIO */
  427. };
  428. #define is_read_io(rw) (((rw) & 1) == READ)
  429. struct f2fs_bio_info {
  430. struct f2fs_sb_info *sbi; /* f2fs superblock */
  431. struct bio *bio; /* bios to merge */
  432. sector_t last_block_in_bio; /* last block number */
  433. struct f2fs_io_info fio; /* store buffered io info. */
  434. struct rw_semaphore io_rwsem; /* blocking op for bio */
  435. };
  436. /* for inner inode cache management */
  437. struct inode_management {
  438. struct radix_tree_root ino_root; /* ino entry array */
  439. spinlock_t ino_lock; /* for ino entry lock */
  440. struct list_head ino_list; /* inode list head */
  441. unsigned long ino_num; /* number of entries */
  442. };
  443. struct f2fs_sb_info {
  444. struct super_block *sb; /* pointer to VFS super block */
  445. struct proc_dir_entry *s_proc; /* proc entry */
  446. struct buffer_head *raw_super_buf; /* buffer head of raw sb */
  447. struct f2fs_super_block *raw_super; /* raw super block pointer */
  448. int s_dirty; /* dirty flag for checkpoint */
  449. bool need_fsck; /* need fsck.f2fs to fix */
  450. /* for node-related operations */
  451. struct f2fs_nm_info *nm_info; /* node manager */
  452. struct inode *node_inode; /* cache node blocks */
  453. /* for segment-related operations */
  454. struct f2fs_sm_info *sm_info; /* segment manager */
  455. /* for bio operations */
  456. struct f2fs_bio_info read_io; /* for read bios */
  457. struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */
  458. /* for checkpoint */
  459. struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
  460. struct inode *meta_inode; /* cache meta blocks */
  461. struct mutex cp_mutex; /* checkpoint procedure lock */
  462. struct rw_semaphore cp_rwsem; /* blocking FS operations */
  463. struct rw_semaphore node_write; /* locking node writes */
  464. struct mutex writepages; /* mutex for writepages() */
  465. bool por_doing; /* recovery is doing or not */
  466. wait_queue_head_t cp_wait;
  467. struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */
  468. /* for orphan inode, use 0'th array */
  469. unsigned int max_orphans; /* max orphan inodes */
  470. /* for directory inode management */
  471. struct list_head dir_inode_list; /* dir inode list */
  472. spinlock_t dir_inode_lock; /* for dir inode list lock */
  473. /* basic filesystem units */
  474. unsigned int log_sectors_per_block; /* log2 sectors per block */
  475. unsigned int log_blocksize; /* log2 block size */
  476. unsigned int blocksize; /* block size */
  477. unsigned int root_ino_num; /* root inode number*/
  478. unsigned int node_ino_num; /* node inode number*/
  479. unsigned int meta_ino_num; /* meta inode number*/
  480. unsigned int log_blocks_per_seg; /* log2 blocks per segment */
  481. unsigned int blocks_per_seg; /* blocks per segment */
  482. unsigned int segs_per_sec; /* segments per section */
  483. unsigned int secs_per_zone; /* sections per zone */
  484. unsigned int total_sections; /* total section count */
  485. unsigned int total_node_count; /* total node block count */
  486. unsigned int total_valid_node_count; /* valid node block count */
  487. unsigned int total_valid_inode_count; /* valid inode count */
  488. int active_logs; /* # of active logs */
  489. int dir_level; /* directory level */
  490. block_t user_block_count; /* # of user blocks */
  491. block_t total_valid_block_count; /* # of valid blocks */
  492. block_t alloc_valid_block_count; /* # of allocated blocks */
  493. block_t last_valid_block_count; /* for recovery */
  494. u32 s_next_generation; /* for NFS support */
  495. atomic_t nr_pages[NR_COUNT_TYPE]; /* # of pages, see count_type */
  496. struct f2fs_mount_info mount_opt; /* mount options */
  497. /* for cleaning operations */
  498. struct mutex gc_mutex; /* mutex for GC */
  499. struct f2fs_gc_kthread *gc_thread; /* GC thread */
  500. unsigned int cur_victim_sec; /* current victim section num */
  501. /* maximum # of trials to find a victim segment for SSR and GC */
  502. unsigned int max_victim_search;
  503. /*
  504. * for stat information.
  505. * one is for the LFS mode, and the other is for the SSR mode.
  506. */
  507. #ifdef CONFIG_F2FS_STAT_FS
  508. struct f2fs_stat_info *stat_info; /* FS status information */
  509. unsigned int segment_count[2]; /* # of allocated segments */
  510. unsigned int block_count[2]; /* # of allocated blocks */
  511. int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
  512. atomic_t inline_inode; /* # of inline_data inodes */
  513. atomic_t inline_dir; /* # of inline_dentry inodes */
  514. int bg_gc; /* background gc calls */
  515. unsigned int n_dirty_dirs; /* # of dir inodes */
  516. #endif
  517. unsigned int last_victim[2]; /* last victim segment # */
  518. spinlock_t stat_lock; /* lock for stat operations */
  519. /* For sysfs suppport */
  520. struct kobject s_kobj;
  521. struct completion s_kobj_unregister;
  522. };
  523. /*
  524. * Inline functions
  525. */
  526. static inline struct f2fs_inode_info *F2FS_I(struct inode *inode)
  527. {
  528. return container_of(inode, struct f2fs_inode_info, vfs_inode);
  529. }
  530. static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
  531. {
  532. return sb->s_fs_info;
  533. }
  534. static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode)
  535. {
  536. return F2FS_SB(inode->i_sb);
  537. }
  538. static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping)
  539. {
  540. return F2FS_I_SB(mapping->host);
  541. }
  542. static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)
  543. {
  544. return F2FS_M_SB(page->mapping);
  545. }
  546. static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
  547. {
  548. return (struct f2fs_super_block *)(sbi->raw_super);
  549. }
  550. static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi)
  551. {
  552. return (struct f2fs_checkpoint *)(sbi->ckpt);
  553. }
  554. static inline struct f2fs_node *F2FS_NODE(struct page *page)
  555. {
  556. return (struct f2fs_node *)page_address(page);
  557. }
  558. static inline struct f2fs_inode *F2FS_INODE(struct page *page)
  559. {
  560. return &((struct f2fs_node *)page_address(page))->i;
  561. }
  562. static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi)
  563. {
  564. return (struct f2fs_nm_info *)(sbi->nm_info);
  565. }
  566. static inline struct f2fs_sm_info *SM_I(struct f2fs_sb_info *sbi)
  567. {
  568. return (struct f2fs_sm_info *)(sbi->sm_info);
  569. }
  570. static inline struct sit_info *SIT_I(struct f2fs_sb_info *sbi)
  571. {
  572. return (struct sit_info *)(SM_I(sbi)->sit_info);
  573. }
  574. static inline struct free_segmap_info *FREE_I(struct f2fs_sb_info *sbi)
  575. {
  576. return (struct free_segmap_info *)(SM_I(sbi)->free_info);
  577. }
  578. static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi)
  579. {
  580. return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info);
  581. }
  582. static inline struct address_space *META_MAPPING(struct f2fs_sb_info *sbi)
  583. {
  584. return sbi->meta_inode->i_mapping;
  585. }
  586. static inline struct address_space *NODE_MAPPING(struct f2fs_sb_info *sbi)
  587. {
  588. return sbi->node_inode->i_mapping;
  589. }
  590. static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi)
  591. {
  592. sbi->s_dirty = 1;
  593. }
  594. static inline void F2FS_RESET_SB_DIRT(struct f2fs_sb_info *sbi)
  595. {
  596. sbi->s_dirty = 0;
  597. }
  598. static inline unsigned long long cur_cp_version(struct f2fs_checkpoint *cp)
  599. {
  600. return le64_to_cpu(cp->checkpoint_ver);
  601. }
  602. static inline bool is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  603. {
  604. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  605. return ckpt_flags & f;
  606. }
  607. static inline void set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  608. {
  609. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  610. ckpt_flags |= f;
  611. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  612. }
  613. static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
  614. {
  615. unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
  616. ckpt_flags &= (~f);
  617. cp->ckpt_flags = cpu_to_le32(ckpt_flags);
  618. }
  619. static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
  620. {
  621. down_read(&sbi->cp_rwsem);
  622. }
  623. static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi)
  624. {
  625. up_read(&sbi->cp_rwsem);
  626. }
  627. static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
  628. {
  629. f2fs_down_write(&sbi->cp_rwsem, &sbi->cp_mutex);
  630. }
  631. static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
  632. {
  633. up_write(&sbi->cp_rwsem);
  634. }
  635. /*
  636. * Check whether the given nid is within node id range.
  637. */
  638. static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
  639. {
  640. if (unlikely(nid < F2FS_ROOT_INO(sbi)))
  641. return -EINVAL;
  642. if (unlikely(nid >= NM_I(sbi)->max_nid))
  643. return -EINVAL;
  644. return 0;
  645. }
  646. #define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
  647. /*
  648. * Check whether the inode has blocks or not
  649. */
  650. static inline int F2FS_HAS_BLOCKS(struct inode *inode)
  651. {
  652. if (F2FS_I(inode)->i_xattr_nid)
  653. return inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS + 1;
  654. else
  655. return inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS;
  656. }
  657. static inline bool f2fs_has_xattr_block(unsigned int ofs)
  658. {
  659. return ofs == XATTR_NODE_OFFSET;
  660. }
  661. static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
  662. struct inode *inode, blkcnt_t count)
  663. {
  664. block_t valid_block_count;
  665. spin_lock(&sbi->stat_lock);
  666. valid_block_count =
  667. sbi->total_valid_block_count + (block_t)count;
  668. if (unlikely(valid_block_count > sbi->user_block_count)) {
  669. spin_unlock(&sbi->stat_lock);
  670. return false;
  671. }
  672. inode->i_blocks += count;
  673. sbi->total_valid_block_count = valid_block_count;
  674. sbi->alloc_valid_block_count += (block_t)count;
  675. spin_unlock(&sbi->stat_lock);
  676. return true;
  677. }
  678. static inline void dec_valid_block_count(struct f2fs_sb_info *sbi,
  679. struct inode *inode,
  680. blkcnt_t count)
  681. {
  682. spin_lock(&sbi->stat_lock);
  683. f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count);
  684. f2fs_bug_on(sbi, inode->i_blocks < count);
  685. inode->i_blocks -= count;
  686. sbi->total_valid_block_count -= (block_t)count;
  687. spin_unlock(&sbi->stat_lock);
  688. }
  689. static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
  690. {
  691. atomic_inc(&sbi->nr_pages[count_type]);
  692. F2FS_SET_SB_DIRT(sbi);
  693. }
  694. static inline void inode_inc_dirty_pages(struct inode *inode)
  695. {
  696. atomic_inc(&F2FS_I(inode)->dirty_pages);
  697. if (S_ISDIR(inode->i_mode))
  698. inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
  699. }
  700. static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
  701. {
  702. atomic_dec(&sbi->nr_pages[count_type]);
  703. }
  704. static inline void inode_dec_dirty_pages(struct inode *inode)
  705. {
  706. if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode))
  707. return;
  708. atomic_dec(&F2FS_I(inode)->dirty_pages);
  709. if (S_ISDIR(inode->i_mode))
  710. dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
  711. }
  712. static inline int get_pages(struct f2fs_sb_info *sbi, int count_type)
  713. {
  714. return atomic_read(&sbi->nr_pages[count_type]);
  715. }
  716. static inline int get_dirty_pages(struct inode *inode)
  717. {
  718. return atomic_read(&F2FS_I(inode)->dirty_pages);
  719. }
  720. static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
  721. {
  722. unsigned int pages_per_sec = sbi->segs_per_sec *
  723. (1 << sbi->log_blocks_per_seg);
  724. return ((get_pages(sbi, block_type) + pages_per_sec - 1)
  725. >> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
  726. }
  727. static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
  728. {
  729. return sbi->total_valid_block_count;
  730. }
  731. static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag)
  732. {
  733. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  734. /* return NAT or SIT bitmap */
  735. if (flag == NAT_BITMAP)
  736. return le32_to_cpu(ckpt->nat_ver_bitmap_bytesize);
  737. else if (flag == SIT_BITMAP)
  738. return le32_to_cpu(ckpt->sit_ver_bitmap_bytesize);
  739. return 0;
  740. }
  741. static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
  742. {
  743. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  744. int offset;
  745. if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload) > 0) {
  746. if (flag == NAT_BITMAP)
  747. return &ckpt->sit_nat_version_bitmap;
  748. else
  749. return (unsigned char *)ckpt + F2FS_BLKSIZE;
  750. } else {
  751. offset = (flag == NAT_BITMAP) ?
  752. le32_to_cpu(ckpt->sit_ver_bitmap_bytesize) : 0;
  753. return &ckpt->sit_nat_version_bitmap + offset;
  754. }
  755. }
  756. static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi)
  757. {
  758. block_t start_addr;
  759. struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
  760. unsigned long long ckpt_version = cur_cp_version(ckpt);
  761. start_addr = le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr);
  762. /*
  763. * odd numbered checkpoint should at cp segment 0
  764. * and even segment must be at cp segment 1
  765. */
  766. if (!(ckpt_version & 1))
  767. start_addr += sbi->blocks_per_seg;
  768. return start_addr;
  769. }
  770. static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi)
  771. {
  772. return le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
  773. }
  774. static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi,
  775. struct inode *inode)
  776. {
  777. block_t valid_block_count;
  778. unsigned int valid_node_count;
  779. spin_lock(&sbi->stat_lock);
  780. valid_block_count = sbi->total_valid_block_count + 1;
  781. if (unlikely(valid_block_count > sbi->user_block_count)) {
  782. spin_unlock(&sbi->stat_lock);
  783. return false;
  784. }
  785. valid_node_count = sbi->total_valid_node_count + 1;
  786. if (unlikely(valid_node_count > sbi->total_node_count)) {
  787. spin_unlock(&sbi->stat_lock);
  788. return false;
  789. }
  790. if (inode)
  791. inode->i_blocks++;
  792. sbi->alloc_valid_block_count++;
  793. sbi->total_valid_node_count++;
  794. sbi->total_valid_block_count++;
  795. spin_unlock(&sbi->stat_lock);
  796. return true;
  797. }
  798. static inline void dec_valid_node_count(struct f2fs_sb_info *sbi,
  799. struct inode *inode)
  800. {
  801. spin_lock(&sbi->stat_lock);
  802. f2fs_bug_on(sbi, !sbi->total_valid_block_count);
  803. f2fs_bug_on(sbi, !sbi->total_valid_node_count);
  804. f2fs_bug_on(sbi, !inode->i_blocks);
  805. inode->i_blocks--;
  806. sbi->total_valid_node_count--;
  807. sbi->total_valid_block_count--;
  808. spin_unlock(&sbi->stat_lock);
  809. }
  810. static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi)
  811. {
  812. return sbi->total_valid_node_count;
  813. }
  814. static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi)
  815. {
  816. spin_lock(&sbi->stat_lock);
  817. f2fs_bug_on(sbi, sbi->total_valid_inode_count == sbi->total_node_count);
  818. sbi->total_valid_inode_count++;
  819. spin_unlock(&sbi->stat_lock);
  820. }
  821. static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi)
  822. {
  823. spin_lock(&sbi->stat_lock);
  824. f2fs_bug_on(sbi, !sbi->total_valid_inode_count);
  825. sbi->total_valid_inode_count--;
  826. spin_unlock(&sbi->stat_lock);
  827. }
  828. static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi)
  829. {
  830. return sbi->total_valid_inode_count;
  831. }
  832. static inline void f2fs_put_page(struct page *page, int unlock)
  833. {
  834. if (!page)
  835. return;
  836. if (unlock) {
  837. f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page));
  838. unlock_page(page);
  839. }
  840. page_cache_release(page);
  841. }
  842. static inline void f2fs_put_dnode(struct dnode_of_data *dn)
  843. {
  844. if (dn->node_page)
  845. f2fs_put_page(dn->node_page, 1);
  846. if (dn->inode_page && dn->node_page != dn->inode_page)
  847. f2fs_put_page(dn->inode_page, 0);
  848. dn->node_page = NULL;
  849. dn->inode_page = NULL;
  850. }
  851. static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name,
  852. size_t size)
  853. {
  854. return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, NULL);
  855. }
  856. static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep,
  857. gfp_t flags)
  858. {
  859. void *entry;
  860. retry:
  861. entry = kmem_cache_alloc(cachep, flags);
  862. if (!entry) {
  863. cond_resched();
  864. goto retry;
  865. }
  866. return entry;
  867. }
  868. static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
  869. unsigned long index, void *item)
  870. {
  871. while (radix_tree_insert(root, index, item))
  872. cond_resched();
  873. }
  874. #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino)
  875. static inline bool IS_INODE(struct page *page)
  876. {
  877. struct f2fs_node *p = F2FS_NODE(page);
  878. return RAW_IS_INODE(p);
  879. }
  880. static inline __le32 *blkaddr_in_node(struct f2fs_node *node)
  881. {
  882. return RAW_IS_INODE(node) ? node->i.i_addr : node->dn.addr;
  883. }
  884. static inline block_t datablock_addr(struct page *node_page,
  885. unsigned int offset)
  886. {
  887. struct f2fs_node *raw_node;
  888. __le32 *addr_array;
  889. raw_node = F2FS_NODE(node_page);
  890. addr_array = blkaddr_in_node(raw_node);
  891. return le32_to_cpu(addr_array[offset]);
  892. }
  893. static inline int f2fs_test_bit(unsigned int nr, char *addr)
  894. {
  895. int mask;
  896. addr += (nr >> 3);
  897. mask = 1 << (7 - (nr & 0x07));
  898. return mask & *addr;
  899. }
  900. static inline int f2fs_test_and_set_bit(unsigned int nr, char *addr)
  901. {
  902. int mask;
  903. int ret;
  904. addr += (nr >> 3);
  905. mask = 1 << (7 - (nr & 0x07));
  906. ret = mask & *addr;
  907. *addr |= mask;
  908. return ret;
  909. }
  910. static inline int f2fs_test_and_clear_bit(unsigned int nr, char *addr)
  911. {
  912. int mask;
  913. int ret;
  914. addr += (nr >> 3);
  915. mask = 1 << (7 - (nr & 0x07));
  916. ret = mask & *addr;
  917. *addr &= ~mask;
  918. return ret;
  919. }
  920. static inline void f2fs_change_bit(unsigned int nr, char *addr)
  921. {
  922. int mask;
  923. addr += (nr >> 3);
  924. mask = 1 << (7 - (nr & 0x07));
  925. *addr ^= mask;
  926. }
  927. /* used for f2fs_inode_info->flags */
  928. enum {
  929. FI_NEW_INODE, /* indicate newly allocated inode */
  930. FI_DIRTY_INODE, /* indicate inode is dirty or not */
  931. FI_DIRTY_DIR, /* indicate directory has dirty pages */
  932. FI_INC_LINK, /* need to increment i_nlink */
  933. FI_ACL_MODE, /* indicate acl mode */
  934. FI_NO_ALLOC, /* should not allocate any blocks */
  935. FI_UPDATE_DIR, /* should update inode block for consistency */
  936. FI_DELAY_IPUT, /* used for the recovery */
  937. FI_NO_EXTENT, /* not to use the extent cache */
  938. FI_INLINE_XATTR, /* used for inline xattr */
  939. FI_INLINE_DATA, /* used for inline data*/
  940. FI_INLINE_DENTRY, /* used for inline dentry */
  941. FI_APPEND_WRITE, /* inode has appended data */
  942. FI_UPDATE_WRITE, /* inode has in-place-update data */
  943. FI_NEED_IPU, /* used for ipu per file */
  944. FI_ATOMIC_FILE, /* indicate atomic file */
  945. FI_VOLATILE_FILE, /* indicate volatile file */
  946. FI_DATA_EXIST, /* indicate data exists */
  947. };
  948. static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
  949. {
  950. if (!test_bit(flag, &fi->flags))
  951. set_bit(flag, &fi->flags);
  952. }
  953. static inline int is_inode_flag_set(struct f2fs_inode_info *fi, int flag)
  954. {
  955. return test_bit(flag, &fi->flags);
  956. }
  957. static inline void clear_inode_flag(struct f2fs_inode_info *fi, int flag)
  958. {
  959. if (test_bit(flag, &fi->flags))
  960. clear_bit(flag, &fi->flags);
  961. }
  962. static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode)
  963. {
  964. fi->i_acl_mode = mode;
  965. set_inode_flag(fi, FI_ACL_MODE);
  966. }
  967. static inline void get_inline_info(struct f2fs_inode_info *fi,
  968. struct f2fs_inode *ri)
  969. {
  970. if (ri->i_inline & F2FS_INLINE_XATTR)
  971. set_inode_flag(fi, FI_INLINE_XATTR);
  972. if (ri->i_inline & F2FS_INLINE_DATA)
  973. set_inode_flag(fi, FI_INLINE_DATA);
  974. if (ri->i_inline & F2FS_INLINE_DENTRY)
  975. set_inode_flag(fi, FI_INLINE_DENTRY);
  976. if (ri->i_inline & F2FS_DATA_EXIST)
  977. set_inode_flag(fi, FI_DATA_EXIST);
  978. }
  979. static inline void set_raw_inline(struct f2fs_inode_info *fi,
  980. struct f2fs_inode *ri)
  981. {
  982. ri->i_inline = 0;
  983. if (is_inode_flag_set(fi, FI_INLINE_XATTR))
  984. ri->i_inline |= F2FS_INLINE_XATTR;
  985. if (is_inode_flag_set(fi, FI_INLINE_DATA))
  986. ri->i_inline |= F2FS_INLINE_DATA;
  987. if (is_inode_flag_set(fi, FI_INLINE_DENTRY))
  988. ri->i_inline |= F2FS_INLINE_DENTRY;
  989. if (is_inode_flag_set(fi, FI_DATA_EXIST))
  990. ri->i_inline |= F2FS_DATA_EXIST;
  991. }
  992. static inline int f2fs_has_inline_xattr(struct inode *inode)
  993. {
  994. return is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR);
  995. }
  996. static inline unsigned int addrs_per_inode(struct f2fs_inode_info *fi)
  997. {
  998. if (f2fs_has_inline_xattr(&fi->vfs_inode))
  999. return DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS;
  1000. return DEF_ADDRS_PER_INODE;
  1001. }
  1002. static inline void *inline_xattr_addr(struct page *page)
  1003. {
  1004. struct f2fs_inode *ri = F2FS_INODE(page);
  1005. return (void *)&(ri->i_addr[DEF_ADDRS_PER_INODE -
  1006. F2FS_INLINE_XATTR_ADDRS]);
  1007. }
  1008. static inline int inline_xattr_size(struct inode *inode)
  1009. {
  1010. if (f2fs_has_inline_xattr(inode))
  1011. return F2FS_INLINE_XATTR_ADDRS << 2;
  1012. else
  1013. return 0;
  1014. }
  1015. static inline int f2fs_has_inline_data(struct inode *inode)
  1016. {
  1017. return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA);
  1018. }
  1019. static inline void f2fs_clear_inline_inode(struct inode *inode)
  1020. {
  1021. clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA);
  1022. clear_inode_flag(F2FS_I(inode), FI_DATA_EXIST);
  1023. }
  1024. static inline int f2fs_exist_data(struct inode *inode)
  1025. {
  1026. return is_inode_flag_set(F2FS_I(inode), FI_DATA_EXIST);
  1027. }
  1028. static inline bool f2fs_is_atomic_file(struct inode *inode)
  1029. {
  1030. return is_inode_flag_set(F2FS_I(inode), FI_ATOMIC_FILE);
  1031. }
  1032. static inline bool f2fs_is_volatile_file(struct inode *inode)
  1033. {
  1034. return is_inode_flag_set(F2FS_I(inode), FI_VOLATILE_FILE);
  1035. }
  1036. static inline void *inline_data_addr(struct page *page)
  1037. {
  1038. struct f2fs_inode *ri = F2FS_INODE(page);
  1039. return (void *)&(ri->i_addr[1]);
  1040. }
  1041. static inline int f2fs_has_inline_dentry(struct inode *inode)
  1042. {
  1043. return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DENTRY);
  1044. }
  1045. static inline void *inline_dentry_addr(struct page *page)
  1046. {
  1047. struct f2fs_inode *ri = F2FS_INODE(page);
  1048. return (void *)&(ri->i_addr[1]);
  1049. }
  1050. static inline void f2fs_dentry_kunmap(struct inode *dir, struct page *page)
  1051. {
  1052. if (!f2fs_has_inline_dentry(dir))
  1053. kunmap(page);
  1054. }
  1055. static inline int f2fs_readonly(struct super_block *sb)
  1056. {
  1057. return sb->s_flags & MS_RDONLY;
  1058. }
  1059. static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
  1060. {
  1061. return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
  1062. }
  1063. static inline void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi)
  1064. {
  1065. set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
  1066. sbi->sb->s_flags |= MS_RDONLY;
  1067. }
  1068. #define get_inode_mode(i) \
  1069. ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \
  1070. (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
  1071. /* get offset of first page in next direct node */
  1072. #define PGOFS_OF_NEXT_DNODE(pgofs, fi) \
  1073. ((pgofs < ADDRS_PER_INODE(fi)) ? ADDRS_PER_INODE(fi) : \
  1074. (pgofs - ADDRS_PER_INODE(fi) + ADDRS_PER_BLOCK) / \
  1075. ADDRS_PER_BLOCK * ADDRS_PER_BLOCK + ADDRS_PER_INODE(fi))
  1076. /*
  1077. * file.c
  1078. */
  1079. int f2fs_sync_file(struct file *, loff_t, loff_t, int);
  1080. void truncate_data_blocks(struct dnode_of_data *);
  1081. int truncate_blocks(struct inode *, u64, bool);
  1082. void f2fs_truncate(struct inode *);
  1083. int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  1084. int f2fs_setattr(struct dentry *, struct iattr *);
  1085. int truncate_hole(struct inode *, pgoff_t, pgoff_t);
  1086. int truncate_data_blocks_range(struct dnode_of_data *, int);
  1087. long f2fs_ioctl(struct file *, unsigned int, unsigned long);
  1088. long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
  1089. /*
  1090. * inode.c
  1091. */
  1092. void f2fs_set_inode_flags(struct inode *);
  1093. struct inode *f2fs_iget(struct super_block *, unsigned long);
  1094. int try_to_free_nats(struct f2fs_sb_info *, int);
  1095. void update_inode(struct inode *, struct page *);
  1096. void update_inode_page(struct inode *);
  1097. int f2fs_write_inode(struct inode *, struct writeback_control *);
  1098. void f2fs_evict_inode(struct inode *);
  1099. void handle_failed_inode(struct inode *);
  1100. /*
  1101. * namei.c
  1102. */
  1103. struct dentry *f2fs_get_parent(struct dentry *child);
  1104. /*
  1105. * dir.c
  1106. */
  1107. extern unsigned char f2fs_filetype_table[F2FS_FT_MAX];
  1108. void set_de_type(struct f2fs_dir_entry *, struct inode *);
  1109. struct f2fs_dir_entry *find_target_dentry(struct qstr *, int *,
  1110. struct f2fs_dentry_ptr *);
  1111. bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *,
  1112. unsigned int);
  1113. void do_make_empty_dir(struct inode *, struct inode *,
  1114. struct f2fs_dentry_ptr *);
  1115. struct page *init_inode_metadata(struct inode *, struct inode *,
  1116. const struct qstr *, struct page *);
  1117. void update_parent_metadata(struct inode *, struct inode *, unsigned int);
  1118. int room_for_filename(const void *, int, int);
  1119. void f2fs_drop_nlink(struct inode *, struct inode *, struct page *);
  1120. struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
  1121. struct page **);
  1122. struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
  1123. ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
  1124. void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
  1125. struct page *, struct inode *);
  1126. int update_dent_inode(struct inode *, const struct qstr *);
  1127. int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
  1128. void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *,
  1129. struct inode *);
  1130. int f2fs_do_tmpfile(struct inode *, struct inode *);
  1131. int f2fs_make_empty(struct inode *, struct inode *);
  1132. bool f2fs_empty_dir(struct inode *);
  1133. static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
  1134. {
  1135. return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name,
  1136. inode);
  1137. }
  1138. /*
  1139. * super.c
  1140. */
  1141. int f2fs_sync_fs(struct super_block *, int);
  1142. extern __printf(3, 4)
  1143. void f2fs_msg(struct super_block *, const char *, const char *, ...);
  1144. /*
  1145. * hash.c
  1146. */
  1147. f2fs_hash_t f2fs_dentry_hash(const struct qstr *);
  1148. /*
  1149. * node.c
  1150. */
  1151. struct dnode_of_data;
  1152. struct node_info;
  1153. bool available_free_memory(struct f2fs_sb_info *, int);
  1154. bool is_checkpointed_node(struct f2fs_sb_info *, nid_t);
  1155. bool has_fsynced_inode(struct f2fs_sb_info *, nid_t);
  1156. bool need_inode_block_update(struct f2fs_sb_info *, nid_t);
  1157. void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
  1158. int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
  1159. int truncate_inode_blocks(struct inode *, pgoff_t);
  1160. int truncate_xattr_node(struct inode *, struct page *);
  1161. int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t);
  1162. void remove_inode_page(struct inode *);
  1163. struct page *new_inode_page(struct inode *);
  1164. struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *);
  1165. void ra_node_page(struct f2fs_sb_info *, nid_t);
  1166. struct page *get_node_page(struct f2fs_sb_info *, pgoff_t);
  1167. struct page *get_node_page_ra(struct page *, int);
  1168. void sync_inode_page(struct dnode_of_data *);
  1169. int sync_node_pages(struct f2fs_sb_info *, nid_t, struct writeback_control *);
  1170. bool alloc_nid(struct f2fs_sb_info *, nid_t *);
  1171. void alloc_nid_done(struct f2fs_sb_info *, nid_t);
  1172. void alloc_nid_failed(struct f2fs_sb_info *, nid_t);
  1173. void recover_inline_xattr(struct inode *, struct page *);
  1174. void recover_xattr_data(struct inode *, struct page *, block_t);
  1175. int recover_inode_page(struct f2fs_sb_info *, struct page *);
  1176. int restore_node_summary(struct f2fs_sb_info *, unsigned int,
  1177. struct f2fs_summary_block *);
  1178. void flush_nat_entries(struct f2fs_sb_info *);
  1179. int build_node_manager(struct f2fs_sb_info *);
  1180. void destroy_node_manager(struct f2fs_sb_info *);
  1181. int __init create_node_manager_caches(void);
  1182. void destroy_node_manager_caches(void);
  1183. /*
  1184. * segment.c
  1185. */
  1186. void register_inmem_page(struct inode *, struct page *);
  1187. void invalidate_inmem_page(struct inode *, struct page *);
  1188. void commit_inmem_pages(struct inode *, bool);
  1189. void f2fs_balance_fs(struct f2fs_sb_info *);
  1190. void f2fs_balance_fs_bg(struct f2fs_sb_info *);
  1191. int f2fs_issue_flush(struct f2fs_sb_info *);
  1192. int create_flush_cmd_control(struct f2fs_sb_info *);
  1193. void destroy_flush_cmd_control(struct f2fs_sb_info *);
  1194. void invalidate_blocks(struct f2fs_sb_info *, block_t);
  1195. void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
  1196. void clear_prefree_segments(struct f2fs_sb_info *);
  1197. void release_discard_addrs(struct f2fs_sb_info *);
  1198. void discard_next_dnode(struct f2fs_sb_info *, block_t);
  1199. int npages_for_summary_flush(struct f2fs_sb_info *);
  1200. void allocate_new_segments(struct f2fs_sb_info *);
  1201. int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *);
  1202. struct page *get_sum_page(struct f2fs_sb_info *, unsigned int);
  1203. void write_meta_page(struct f2fs_sb_info *, struct page *);
  1204. void write_node_page(struct f2fs_sb_info *, struct page *,
  1205. struct f2fs_io_info *, unsigned int, block_t, block_t *);
  1206. void write_data_page(struct page *, struct dnode_of_data *, block_t *,
  1207. struct f2fs_io_info *);
  1208. void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *);
  1209. void recover_data_page(struct f2fs_sb_info *, struct page *,
  1210. struct f2fs_summary *, block_t, block_t);
  1211. void allocate_data_block(struct f2fs_sb_info *, struct page *,
  1212. block_t, block_t *, struct f2fs_summary *, int);
  1213. void f2fs_wait_on_page_writeback(struct page *, enum page_type);
  1214. void write_data_summaries(struct f2fs_sb_info *, block_t);
  1215. void write_node_summaries(struct f2fs_sb_info *, block_t);
  1216. int lookup_journal_in_cursum(struct f2fs_summary_block *,
  1217. int, unsigned int, int);
  1218. void flush_sit_entries(struct f2fs_sb_info *, struct cp_control *);
  1219. int build_segment_manager(struct f2fs_sb_info *);
  1220. void destroy_segment_manager(struct f2fs_sb_info *);
  1221. int __init create_segment_manager_caches(void);
  1222. void destroy_segment_manager_caches(void);
  1223. /*
  1224. * checkpoint.c
  1225. */
  1226. struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t);
  1227. struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t);
  1228. int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int);
  1229. void ra_meta_pages_cond(struct f2fs_sb_info *, pgoff_t);
  1230. long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long);
  1231. void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
  1232. void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type);
  1233. void release_dirty_inode(struct f2fs_sb_info *);
  1234. bool exist_written_data(struct f2fs_sb_info *, nid_t, int);
  1235. int acquire_orphan_inode(struct f2fs_sb_info *);
  1236. void release_orphan_inode(struct f2fs_sb_info *);
  1237. void add_orphan_inode(struct f2fs_sb_info *, nid_t);
  1238. void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
  1239. void recover_orphan_inodes(struct f2fs_sb_info *);
  1240. int get_valid_checkpoint(struct f2fs_sb_info *);
  1241. void update_dirty_page(struct inode *, struct page *);
  1242. void add_dirty_dir_inode(struct inode *);
  1243. void remove_dirty_dir_inode(struct inode *);
  1244. void sync_dirty_dir_inodes(struct f2fs_sb_info *);
  1245. void write_checkpoint(struct f2fs_sb_info *, struct cp_control *);
  1246. void init_ino_entry_info(struct f2fs_sb_info *);
  1247. int __init create_checkpoint_caches(void);
  1248. void destroy_checkpoint_caches(void);
  1249. /*
  1250. * data.c
  1251. */
  1252. void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int);
  1253. int f2fs_submit_page_bio(struct f2fs_sb_info *, struct page *, block_t, int);
  1254. void f2fs_submit_page_mbio(struct f2fs_sb_info *, struct page *, block_t,
  1255. struct f2fs_io_info *);
  1256. int reserve_new_block(struct dnode_of_data *);
  1257. int f2fs_reserve_block(struct dnode_of_data *, pgoff_t);
  1258. void update_extent_cache(block_t, struct dnode_of_data *);
  1259. struct page *find_data_page(struct inode *, pgoff_t, bool);
  1260. struct page *get_lock_data_page(struct inode *, pgoff_t);
  1261. struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
  1262. int do_write_data_page(struct page *, struct f2fs_io_info *);
  1263. int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64);
  1264. /*
  1265. * gc.c
  1266. */
  1267. int start_gc_thread(struct f2fs_sb_info *);
  1268. void stop_gc_thread(struct f2fs_sb_info *);
  1269. block_t start_bidx_of_node(unsigned int, struct f2fs_inode_info *);
  1270. int f2fs_gc(struct f2fs_sb_info *);
  1271. void build_gc_manager(struct f2fs_sb_info *);
  1272. int __init create_gc_caches(void);
  1273. void destroy_gc_caches(void);
  1274. /*
  1275. * recovery.c
  1276. */
  1277. int recover_fsync_data(struct f2fs_sb_info *);
  1278. bool space_for_roll_forward(struct f2fs_sb_info *);
  1279. /*
  1280. * debug.c
  1281. */
  1282. #ifdef CONFIG_F2FS_STAT_FS
  1283. struct f2fs_stat_info {
  1284. struct list_head stat_list;
  1285. struct f2fs_sb_info *sbi;
  1286. int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs;
  1287. int main_area_segs, main_area_sections, main_area_zones;
  1288. int hit_ext, total_ext;
  1289. int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta;
  1290. int nats, sits, fnids;
  1291. int total_count, utilization;
  1292. int bg_gc, inline_inode, inline_dir, inmem_pages;
  1293. unsigned int valid_count, valid_node_count, valid_inode_count;
  1294. unsigned int bimodal, avg_vblocks;
  1295. int util_free, util_valid, util_invalid;
  1296. int rsvd_segs, overp_segs;
  1297. int dirty_count, node_pages, meta_pages;
  1298. int prefree_count, call_count, cp_count;
  1299. int tot_segs, node_segs, data_segs, free_segs, free_secs;
  1300. int tot_blks, data_blks, node_blks;
  1301. int curseg[NR_CURSEG_TYPE];
  1302. int cursec[NR_CURSEG_TYPE];
  1303. int curzone[NR_CURSEG_TYPE];
  1304. unsigned int segment_count[2];
  1305. unsigned int block_count[2];
  1306. unsigned base_mem, cache_mem;
  1307. };
  1308. static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
  1309. {
  1310. return (struct f2fs_stat_info *)sbi->stat_info;
  1311. }
  1312. #define stat_inc_cp_count(si) ((si)->cp_count++)
  1313. #define stat_inc_call_count(si) ((si)->call_count++)
  1314. #define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++)
  1315. #define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++)
  1316. #define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--)
  1317. #define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++)
  1318. #define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++)
  1319. #define stat_inc_inline_inode(inode) \
  1320. do { \
  1321. if (f2fs_has_inline_data(inode)) \
  1322. (atomic_inc(&F2FS_I_SB(inode)->inline_inode)); \
  1323. } while (0)
  1324. #define stat_dec_inline_inode(inode) \
  1325. do { \
  1326. if (f2fs_has_inline_data(inode)) \
  1327. (atomic_dec(&F2FS_I_SB(inode)->inline_inode)); \
  1328. } while (0)
  1329. #define stat_inc_inline_dir(inode) \
  1330. do { \
  1331. if (f2fs_has_inline_dentry(inode)) \
  1332. (atomic_inc(&F2FS_I_SB(inode)->inline_dir)); \
  1333. } while (0)
  1334. #define stat_dec_inline_dir(inode) \
  1335. do { \
  1336. if (f2fs_has_inline_dentry(inode)) \
  1337. (atomic_dec(&F2FS_I_SB(inode)->inline_dir)); \
  1338. } while (0)
  1339. #define stat_inc_seg_type(sbi, curseg) \
  1340. ((sbi)->segment_count[(curseg)->alloc_type]++)
  1341. #define stat_inc_block_count(sbi, curseg) \
  1342. ((sbi)->block_count[(curseg)->alloc_type]++)
  1343. #define stat_inc_seg_count(sbi, type) \
  1344. do { \
  1345. struct f2fs_stat_info *si = F2FS_STAT(sbi); \
  1346. (si)->tot_segs++; \
  1347. if (type == SUM_TYPE_DATA) \
  1348. si->data_segs++; \
  1349. else \
  1350. si->node_segs++; \
  1351. } while (0)
  1352. #define stat_inc_tot_blk_count(si, blks) \
  1353. (si->tot_blks += (blks))
  1354. #define stat_inc_data_blk_count(sbi, blks) \
  1355. do { \
  1356. struct f2fs_stat_info *si = F2FS_STAT(sbi); \
  1357. stat_inc_tot_blk_count(si, blks); \
  1358. si->data_blks += (blks); \
  1359. } while (0)
  1360. #define stat_inc_node_blk_count(sbi, blks) \
  1361. do { \
  1362. struct f2fs_stat_info *si = F2FS_STAT(sbi); \
  1363. stat_inc_tot_blk_count(si, blks); \
  1364. si->node_blks += (blks); \
  1365. } while (0)
  1366. int f2fs_build_stats(struct f2fs_sb_info *);
  1367. void f2fs_destroy_stats(struct f2fs_sb_info *);
  1368. void __init f2fs_create_root_stats(void);
  1369. void f2fs_destroy_root_stats(void);
  1370. #else
  1371. #define stat_inc_cp_count(si)
  1372. #define stat_inc_call_count(si)
  1373. #define stat_inc_bggc_count(si)
  1374. #define stat_inc_dirty_dir(sbi)
  1375. #define stat_dec_dirty_dir(sbi)
  1376. #define stat_inc_total_hit(sb)
  1377. #define stat_inc_read_hit(sb)
  1378. #define stat_inc_inline_inode(inode)
  1379. #define stat_dec_inline_inode(inode)
  1380. #define stat_inc_inline_dir(inode)
  1381. #define stat_dec_inline_dir(inode)
  1382. #define stat_inc_seg_type(sbi, curseg)
  1383. #define stat_inc_block_count(sbi, curseg)
  1384. #define stat_inc_seg_count(si, type)
  1385. #define stat_inc_tot_blk_count(si, blks)
  1386. #define stat_inc_data_blk_count(si, blks)
  1387. #define stat_inc_node_blk_count(sbi, blks)
  1388. static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
  1389. static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
  1390. static inline void __init f2fs_create_root_stats(void) { }
  1391. static inline void f2fs_destroy_root_stats(void) { }
  1392. #endif
  1393. extern const struct file_operations f2fs_dir_operations;
  1394. extern const struct file_operations f2fs_file_operations;
  1395. extern const struct inode_operations f2fs_file_inode_operations;
  1396. extern const struct address_space_operations f2fs_dblock_aops;
  1397. extern const struct address_space_operations f2fs_node_aops;
  1398. extern const struct address_space_operations f2fs_meta_aops;
  1399. extern const struct inode_operations f2fs_dir_inode_operations;
  1400. extern const struct inode_operations f2fs_symlink_inode_operations;
  1401. extern const struct inode_operations f2fs_special_inode_operations;
  1402. /*
  1403. * inline.c
  1404. */
  1405. bool f2fs_may_inline(struct inode *);
  1406. void read_inline_data(struct page *, struct page *);
  1407. int f2fs_read_inline_data(struct inode *, struct page *);
  1408. int f2fs_convert_inline_page(struct dnode_of_data *, struct page *);
  1409. int f2fs_convert_inline_inode(struct inode *);
  1410. int f2fs_write_inline_data(struct inode *, struct page *);
  1411. void truncate_inline_data(struct page *, u64);
  1412. bool recover_inline_data(struct inode *, struct page *);
  1413. struct f2fs_dir_entry *find_in_inline_dir(struct inode *, struct qstr *,
  1414. struct page **);
  1415. struct f2fs_dir_entry *f2fs_parent_inline_dir(struct inode *, struct page **);
  1416. int make_empty_inline_dir(struct inode *inode, struct inode *, struct page *);
  1417. int f2fs_add_inline_entry(struct inode *, const struct qstr *, struct inode *);
  1418. void f2fs_delete_inline_entry(struct f2fs_dir_entry *, struct page *,
  1419. struct inode *, struct inode *);
  1420. bool f2fs_empty_inline_dir(struct inode *);
  1421. int f2fs_read_inline_dir(struct file *, struct dir_context *);
  1422. #endif