10a8165d7SJaegeuk Kim /* 239a53e0cSJaegeuk Kim * fs/f2fs/f2fs.h 339a53e0cSJaegeuk Kim * 439a53e0cSJaegeuk Kim * Copyright (c) 2012 Samsung Electronics Co., Ltd. 539a53e0cSJaegeuk Kim * http://www.samsung.com/ 639a53e0cSJaegeuk Kim * 739a53e0cSJaegeuk Kim * This program is free software; you can redistribute it and/or modify 839a53e0cSJaegeuk Kim * it under the terms of the GNU General Public License version 2 as 939a53e0cSJaegeuk Kim * published by the Free Software Foundation. 1039a53e0cSJaegeuk Kim */ 1139a53e0cSJaegeuk Kim #ifndef _LINUX_F2FS_H 1239a53e0cSJaegeuk Kim #define _LINUX_F2FS_H 1339a53e0cSJaegeuk Kim 1439a53e0cSJaegeuk Kim #include <linux/types.h> 1539a53e0cSJaegeuk Kim #include <linux/page-flags.h> 1639a53e0cSJaegeuk Kim #include <linux/buffer_head.h> 1739a53e0cSJaegeuk Kim #include <linux/slab.h> 1839a53e0cSJaegeuk Kim #include <linux/crc32.h> 1939a53e0cSJaegeuk Kim #include <linux/magic.h> 20c2d715d1SJaegeuk Kim #include <linux/kobject.h> 217bd59381SGu Zheng #include <linux/sched.h> 2239a53e0cSJaegeuk Kim 235d56b671SJaegeuk Kim #ifdef CONFIG_F2FS_CHECK_FS 249850cf4aSJaegeuk Kim #define f2fs_bug_on(sbi, condition) BUG_ON(condition) 250daaad97SJaegeuk Kim #define f2fs_down_write(x, y) down_write_nest_lock(x, y) 265d56b671SJaegeuk Kim #else 279850cf4aSJaegeuk Kim #define f2fs_bug_on(sbi, condition) \ 289850cf4aSJaegeuk Kim do { \ 299850cf4aSJaegeuk Kim if (unlikely(condition)) { \ 309850cf4aSJaegeuk Kim WARN_ON(1); \ 319850cf4aSJaegeuk Kim sbi->need_fsck = true; \ 329850cf4aSJaegeuk Kim } \ 339850cf4aSJaegeuk Kim } while (0) 340daaad97SJaegeuk Kim #define f2fs_down_write(x, y) down_write(x) 355d56b671SJaegeuk Kim #endif 365d56b671SJaegeuk Kim 3739a53e0cSJaegeuk Kim /* 3839a53e0cSJaegeuk Kim * For mount options 3939a53e0cSJaegeuk Kim */ 4039a53e0cSJaegeuk Kim #define F2FS_MOUNT_BG_GC 0x00000001 4139a53e0cSJaegeuk Kim #define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002 4239a53e0cSJaegeuk Kim #define F2FS_MOUNT_DISCARD 0x00000004 4339a53e0cSJaegeuk Kim #define F2FS_MOUNT_NOHEAP 0x00000008 4439a53e0cSJaegeuk Kim #define F2FS_MOUNT_XATTR_USER 0x00000010 4539a53e0cSJaegeuk Kim #define F2FS_MOUNT_POSIX_ACL 0x00000020 4639a53e0cSJaegeuk Kim #define F2FS_MOUNT_DISABLE_EXT_IDENTIFY 0x00000040 47444c580fSJaegeuk Kim #define F2FS_MOUNT_INLINE_XATTR 0x00000080 481001b347SHuajun Li #define F2FS_MOUNT_INLINE_DATA 0x00000100 4934d67debSChao Yu #define F2FS_MOUNT_INLINE_DENTRY 0x00000200 5034d67debSChao Yu #define F2FS_MOUNT_FLUSH_MERGE 0x00000400 5134d67debSChao Yu #define F2FS_MOUNT_NOBARRIER 0x00000800 52d5053a34SJaegeuk Kim #define F2FS_MOUNT_FASTBOOT 0x00001000 5339a53e0cSJaegeuk Kim 5439a53e0cSJaegeuk Kim #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option) 5539a53e0cSJaegeuk Kim #define set_opt(sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option) 5639a53e0cSJaegeuk Kim #define test_opt(sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option) 5739a53e0cSJaegeuk Kim 5839a53e0cSJaegeuk Kim #define ver_after(a, b) (typecheck(unsigned long long, a) && \ 5939a53e0cSJaegeuk Kim typecheck(unsigned long long, b) && \ 6039a53e0cSJaegeuk Kim ((long long)((a) - (b)) > 0)) 6139a53e0cSJaegeuk Kim 62a9841c4dSJaegeuk Kim typedef u32 block_t; /* 63a9841c4dSJaegeuk Kim * should not change u32, since it is the on-disk block 64a9841c4dSJaegeuk Kim * address format, __le32. 65a9841c4dSJaegeuk Kim */ 6639a53e0cSJaegeuk Kim typedef u32 nid_t; 6739a53e0cSJaegeuk Kim 6839a53e0cSJaegeuk Kim struct f2fs_mount_info { 6939a53e0cSJaegeuk Kim unsigned int opt; 7039a53e0cSJaegeuk Kim }; 7139a53e0cSJaegeuk Kim 727e586fa0SJaegeuk Kim #define CRCPOLY_LE 0xedb88320 737e586fa0SJaegeuk Kim 747e586fa0SJaegeuk Kim static inline __u32 f2fs_crc32(void *buf, size_t len) 7539a53e0cSJaegeuk Kim { 767e586fa0SJaegeuk Kim unsigned char *p = (unsigned char *)buf; 777e586fa0SJaegeuk Kim __u32 crc = F2FS_SUPER_MAGIC; 787e586fa0SJaegeuk Kim int i; 797e586fa0SJaegeuk Kim 807e586fa0SJaegeuk Kim while (len--) { 817e586fa0SJaegeuk Kim crc ^= *p++; 827e586fa0SJaegeuk Kim for (i = 0; i < 8; i++) 837e586fa0SJaegeuk Kim crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); 847e586fa0SJaegeuk Kim } 857e586fa0SJaegeuk Kim return crc; 8639a53e0cSJaegeuk Kim } 8739a53e0cSJaegeuk Kim 887e586fa0SJaegeuk Kim static inline bool f2fs_crc_valid(__u32 blk_crc, void *buf, size_t buf_size) 8939a53e0cSJaegeuk Kim { 907e586fa0SJaegeuk Kim return f2fs_crc32(buf, buf_size) == blk_crc; 9139a53e0cSJaegeuk Kim } 9239a53e0cSJaegeuk Kim 9339a53e0cSJaegeuk Kim /* 9439a53e0cSJaegeuk Kim * For checkpoint manager 9539a53e0cSJaegeuk Kim */ 9639a53e0cSJaegeuk Kim enum { 9739a53e0cSJaegeuk Kim NAT_BITMAP, 9839a53e0cSJaegeuk Kim SIT_BITMAP 9939a53e0cSJaegeuk Kim }; 10039a53e0cSJaegeuk Kim 10175ab4cb8SJaegeuk Kim enum { 10275ab4cb8SJaegeuk Kim CP_UMOUNT, 10375ab4cb8SJaegeuk Kim CP_SYNC, 1044b2fecc8SJaegeuk Kim CP_DISCARD, 10575ab4cb8SJaegeuk Kim }; 10675ab4cb8SJaegeuk Kim 10775ab4cb8SJaegeuk Kim struct cp_control { 10875ab4cb8SJaegeuk Kim int reason; 1094b2fecc8SJaegeuk Kim __u64 trim_start; 1104b2fecc8SJaegeuk Kim __u64 trim_end; 1114b2fecc8SJaegeuk Kim __u64 trim_minlen; 1124b2fecc8SJaegeuk Kim __u64 trimmed; 11375ab4cb8SJaegeuk Kim }; 11475ab4cb8SJaegeuk Kim 115662befdaSChao Yu /* 11681c1a0f1SChao Yu * For CP/NAT/SIT/SSA readahead 117662befdaSChao Yu */ 118662befdaSChao Yu enum { 119662befdaSChao Yu META_CP, 120662befdaSChao Yu META_NAT, 12181c1a0f1SChao Yu META_SIT, 1224c521f49SJaegeuk Kim META_SSA, 1234c521f49SJaegeuk Kim META_POR, 124662befdaSChao Yu }; 125662befdaSChao Yu 1266451e041SJaegeuk Kim /* for the list of ino */ 1276451e041SJaegeuk Kim enum { 1286451e041SJaegeuk Kim ORPHAN_INO, /* for orphan ino list */ 129fff04f90SJaegeuk Kim APPEND_INO, /* for append ino list */ 130fff04f90SJaegeuk Kim UPDATE_INO, /* for update ino list */ 1316451e041SJaegeuk Kim MAX_INO_ENTRY, /* max. list */ 1326451e041SJaegeuk Kim }; 1336451e041SJaegeuk Kim 1346451e041SJaegeuk Kim struct ino_entry { 13539a53e0cSJaegeuk Kim struct list_head list; /* list head */ 13639a53e0cSJaegeuk Kim nid_t ino; /* inode number */ 13739a53e0cSJaegeuk Kim }; 13839a53e0cSJaegeuk Kim 13939a53e0cSJaegeuk Kim /* for the list of directory inodes */ 14039a53e0cSJaegeuk Kim struct dir_inode_entry { 14139a53e0cSJaegeuk Kim struct list_head list; /* list head */ 14239a53e0cSJaegeuk Kim struct inode *inode; /* vfs inode pointer */ 14339a53e0cSJaegeuk Kim }; 14439a53e0cSJaegeuk Kim 1457fd9e544SJaegeuk Kim /* for the list of blockaddresses to be discarded */ 1467fd9e544SJaegeuk Kim struct discard_entry { 1477fd9e544SJaegeuk Kim struct list_head list; /* list head */ 1487fd9e544SJaegeuk Kim block_t blkaddr; /* block address to be discarded */ 1497fd9e544SJaegeuk Kim int len; /* # of consecutive blocks of the discard */ 1507fd9e544SJaegeuk Kim }; 1517fd9e544SJaegeuk Kim 15239a53e0cSJaegeuk Kim /* for the list of fsync inodes, used only during recovery */ 15339a53e0cSJaegeuk Kim struct fsync_inode_entry { 15439a53e0cSJaegeuk Kim struct list_head list; /* list head */ 15539a53e0cSJaegeuk Kim struct inode *inode; /* vfs inode pointer */ 156c52e1b10SJaegeuk Kim block_t blkaddr; /* block address locating the last fsync */ 157c52e1b10SJaegeuk Kim block_t last_dentry; /* block address locating the last dentry */ 158c52e1b10SJaegeuk Kim block_t last_inode; /* block address locating the last inode */ 15939a53e0cSJaegeuk Kim }; 16039a53e0cSJaegeuk Kim 16139a53e0cSJaegeuk Kim #define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats)) 16239a53e0cSJaegeuk Kim #define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits)) 16339a53e0cSJaegeuk Kim 16439a53e0cSJaegeuk Kim #define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne) 16539a53e0cSJaegeuk Kim #define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid) 16639a53e0cSJaegeuk Kim #define sit_in_journal(sum, i) (sum->sit_j.entries[i].se) 16739a53e0cSJaegeuk Kim #define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno) 16839a53e0cSJaegeuk Kim 169309cc2b6SJaegeuk Kim #define MAX_NAT_JENTRIES(sum) (NAT_JOURNAL_ENTRIES - nats_in_cursum(sum)) 170309cc2b6SJaegeuk Kim #define MAX_SIT_JENTRIES(sum) (SIT_JOURNAL_ENTRIES - sits_in_cursum(sum)) 171309cc2b6SJaegeuk Kim 17239a53e0cSJaegeuk Kim static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i) 17339a53e0cSJaegeuk Kim { 17439a53e0cSJaegeuk Kim int before = nats_in_cursum(rs); 17539a53e0cSJaegeuk Kim rs->n_nats = cpu_to_le16(before + i); 17639a53e0cSJaegeuk Kim return before; 17739a53e0cSJaegeuk Kim } 17839a53e0cSJaegeuk Kim 17939a53e0cSJaegeuk Kim static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i) 18039a53e0cSJaegeuk Kim { 18139a53e0cSJaegeuk Kim int before = sits_in_cursum(rs); 18239a53e0cSJaegeuk Kim rs->n_sits = cpu_to_le16(before + i); 18339a53e0cSJaegeuk Kim return before; 18439a53e0cSJaegeuk Kim } 18539a53e0cSJaegeuk Kim 186184a5cd2SChao Yu static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size, 187184a5cd2SChao Yu int type) 188184a5cd2SChao Yu { 189184a5cd2SChao Yu if (type == NAT_JOURNAL) 190309cc2b6SJaegeuk Kim return size <= MAX_NAT_JENTRIES(sum); 191309cc2b6SJaegeuk Kim return size <= MAX_SIT_JENTRIES(sum); 192184a5cd2SChao Yu } 193184a5cd2SChao Yu 19439a53e0cSJaegeuk Kim /* 195e9750824SNamjae Jeon * ioctl commands 196e9750824SNamjae Jeon */ 197e9750824SNamjae Jeon #define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS 198e9750824SNamjae Jeon #define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS 199e9750824SNamjae Jeon 20088b88a66SJaegeuk Kim #define F2FS_IOCTL_MAGIC 0xf5 20188b88a66SJaegeuk Kim #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) 20288b88a66SJaegeuk Kim #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) 20302a1335fSJaegeuk Kim #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) 20488b88a66SJaegeuk Kim 205e9750824SNamjae Jeon #if defined(__KERNEL__) && defined(CONFIG_COMPAT) 206e9750824SNamjae Jeon /* 207e9750824SNamjae Jeon * ioctl commands in 32 bit emulation 208e9750824SNamjae Jeon */ 209e9750824SNamjae Jeon #define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS 210e9750824SNamjae Jeon #define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS 211e9750824SNamjae Jeon #endif 212e9750824SNamjae Jeon 213e9750824SNamjae Jeon /* 21439a53e0cSJaegeuk Kim * For INODE and NODE manager 21539a53e0cSJaegeuk Kim */ 2167b3cd7d6SJaegeuk Kim /* for directory operations */ 2177b3cd7d6SJaegeuk Kim struct f2fs_dentry_ptr { 2187b3cd7d6SJaegeuk Kim const void *bitmap; 2197b3cd7d6SJaegeuk Kim struct f2fs_dir_entry *dentry; 2207b3cd7d6SJaegeuk Kim __u8 (*filename)[F2FS_SLOT_LEN]; 2217b3cd7d6SJaegeuk Kim int max; 2227b3cd7d6SJaegeuk Kim }; 2237b3cd7d6SJaegeuk Kim 2247b3cd7d6SJaegeuk Kim static inline void make_dentry_ptr(struct f2fs_dentry_ptr *d, 2257b3cd7d6SJaegeuk Kim void *src, int type) 2267b3cd7d6SJaegeuk Kim { 2277b3cd7d6SJaegeuk Kim if (type == 1) { 2287b3cd7d6SJaegeuk Kim struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src; 2297b3cd7d6SJaegeuk Kim d->max = NR_DENTRY_IN_BLOCK; 2307b3cd7d6SJaegeuk Kim d->bitmap = &t->dentry_bitmap; 2317b3cd7d6SJaegeuk Kim d->dentry = t->dentry; 2327b3cd7d6SJaegeuk Kim d->filename = t->filename; 2337b3cd7d6SJaegeuk Kim } else { 2347b3cd7d6SJaegeuk Kim struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src; 2357b3cd7d6SJaegeuk Kim d->max = NR_INLINE_DENTRY; 2367b3cd7d6SJaegeuk Kim d->bitmap = &t->dentry_bitmap; 2377b3cd7d6SJaegeuk Kim d->dentry = t->dentry; 2387b3cd7d6SJaegeuk Kim d->filename = t->filename; 2397b3cd7d6SJaegeuk Kim } 2407b3cd7d6SJaegeuk Kim } 2417b3cd7d6SJaegeuk Kim 242dbe6a5ffSJaegeuk Kim /* 243dbe6a5ffSJaegeuk Kim * XATTR_NODE_OFFSET stores xattrs to one node block per file keeping -1 244dbe6a5ffSJaegeuk Kim * as its node offset to distinguish from index node blocks. 245dbe6a5ffSJaegeuk Kim * But some bits are used to mark the node block. 24639a53e0cSJaegeuk Kim */ 247dbe6a5ffSJaegeuk Kim #define XATTR_NODE_OFFSET ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \ 248dbe6a5ffSJaegeuk Kim >> OFFSET_BIT_SHIFT) 249266e97a8SJaegeuk Kim enum { 250266e97a8SJaegeuk Kim ALLOC_NODE, /* allocate a new node page if needed */ 251266e97a8SJaegeuk Kim LOOKUP_NODE, /* look up a node without readahead */ 252266e97a8SJaegeuk Kim LOOKUP_NODE_RA, /* 253266e97a8SJaegeuk Kim * look up a node with readahead called 2544f4124d0SChao Yu * by get_data_block. 25539a53e0cSJaegeuk Kim */ 256266e97a8SJaegeuk Kim }; 257266e97a8SJaegeuk Kim 25839a53e0cSJaegeuk Kim #define F2FS_LINK_MAX 32000 /* maximum link count per file */ 25939a53e0cSJaegeuk Kim 260817202d9SChao Yu #define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */ 261817202d9SChao Yu 26239a53e0cSJaegeuk Kim /* for in-memory extent cache entry */ 263c11abd1aSJaegeuk Kim #define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */ 264c11abd1aSJaegeuk Kim 26539a53e0cSJaegeuk Kim struct extent_info { 26639a53e0cSJaegeuk Kim rwlock_t ext_lock; /* rwlock for consistency */ 26739a53e0cSJaegeuk Kim unsigned int fofs; /* start offset in a file */ 26839a53e0cSJaegeuk Kim u32 blk_addr; /* start block address of the extent */ 269111d2495SMasanari Iida unsigned int len; /* length of the extent */ 27039a53e0cSJaegeuk Kim }; 27139a53e0cSJaegeuk Kim 27239a53e0cSJaegeuk Kim /* 27339a53e0cSJaegeuk Kim * i_advise uses FADVISE_XXX_BIT. We can add additional hints later. 27439a53e0cSJaegeuk Kim */ 27539a53e0cSJaegeuk Kim #define FADVISE_COLD_BIT 0x01 276354a3399SJaegeuk Kim #define FADVISE_LOST_PINO_BIT 0x02 27739a53e0cSJaegeuk Kim 278ab9fa662SJaegeuk Kim #define DEF_DIR_LEVEL 0 279ab9fa662SJaegeuk Kim 28039a53e0cSJaegeuk Kim struct f2fs_inode_info { 28139a53e0cSJaegeuk Kim struct inode vfs_inode; /* serve a vfs inode */ 28239a53e0cSJaegeuk Kim unsigned long i_flags; /* keep an inode flags for ioctl */ 28339a53e0cSJaegeuk Kim unsigned char i_advise; /* use to give file attribute hints */ 28438431545SJaegeuk Kim unsigned char i_dir_level; /* use for dentry level for large dir */ 28539a53e0cSJaegeuk Kim unsigned int i_current_depth; /* use only in directory structure */ 2866666e6aaSJaegeuk Kim unsigned int i_pino; /* parent inode number */ 28739a53e0cSJaegeuk Kim umode_t i_acl_mode; /* keep file acl mode temporarily */ 28839a53e0cSJaegeuk Kim 28939a53e0cSJaegeuk Kim /* Use below internally in f2fs*/ 29039a53e0cSJaegeuk Kim unsigned long flags; /* use to pass per-file flags */ 291d928bfbfSJaegeuk Kim struct rw_semaphore i_sem; /* protect fi info */ 292a7ffdbe2SJaegeuk Kim atomic_t dirty_pages; /* # of dirty pages */ 29339a53e0cSJaegeuk Kim f2fs_hash_t chash; /* hash value of given file name */ 29439a53e0cSJaegeuk Kim unsigned int clevel; /* maximum level of given file name */ 29539a53e0cSJaegeuk Kim nid_t i_xattr_nid; /* node id that contains xattrs */ 296e518ff81SJaegeuk Kim unsigned long long xattr_ver; /* cp version of xattr modification */ 29739a53e0cSJaegeuk Kim struct extent_info ext; /* in-memory extent cache entry */ 298ed57c27fSJaegeuk Kim struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */ 29988b88a66SJaegeuk Kim 30034ba94baSJaegeuk Kim struct radix_tree_root inmem_root; /* radix tree for inmem pages */ 30188b88a66SJaegeuk Kim struct list_head inmem_pages; /* inmemory pages managed by f2fs */ 30288b88a66SJaegeuk Kim struct mutex inmem_lock; /* lock for inmemory pages */ 30339a53e0cSJaegeuk Kim }; 30439a53e0cSJaegeuk Kim 30539a53e0cSJaegeuk Kim static inline void get_extent_info(struct extent_info *ext, 30639a53e0cSJaegeuk Kim struct f2fs_extent i_ext) 30739a53e0cSJaegeuk Kim { 30839a53e0cSJaegeuk Kim write_lock(&ext->ext_lock); 30939a53e0cSJaegeuk Kim ext->fofs = le32_to_cpu(i_ext.fofs); 31039a53e0cSJaegeuk Kim ext->blk_addr = le32_to_cpu(i_ext.blk_addr); 31139a53e0cSJaegeuk Kim ext->len = le32_to_cpu(i_ext.len); 31239a53e0cSJaegeuk Kim write_unlock(&ext->ext_lock); 31339a53e0cSJaegeuk Kim } 31439a53e0cSJaegeuk Kim 31539a53e0cSJaegeuk Kim static inline void set_raw_extent(struct extent_info *ext, 31639a53e0cSJaegeuk Kim struct f2fs_extent *i_ext) 31739a53e0cSJaegeuk Kim { 31839a53e0cSJaegeuk Kim read_lock(&ext->ext_lock); 31939a53e0cSJaegeuk Kim i_ext->fofs = cpu_to_le32(ext->fofs); 32039a53e0cSJaegeuk Kim i_ext->blk_addr = cpu_to_le32(ext->blk_addr); 32139a53e0cSJaegeuk Kim i_ext->len = cpu_to_le32(ext->len); 32239a53e0cSJaegeuk Kim read_unlock(&ext->ext_lock); 32339a53e0cSJaegeuk Kim } 32439a53e0cSJaegeuk Kim 32539a53e0cSJaegeuk Kim struct f2fs_nm_info { 32639a53e0cSJaegeuk Kim block_t nat_blkaddr; /* base disk address of NAT */ 32739a53e0cSJaegeuk Kim nid_t max_nid; /* maximum possible node ids */ 3287ee0eeabSJaegeuk Kim nid_t available_nids; /* maximum available node ids */ 32939a53e0cSJaegeuk Kim nid_t next_scan_nid; /* the next nid to be scanned */ 330cdfc41c1SJaegeuk Kim unsigned int ram_thresh; /* control the memory footprint */ 33139a53e0cSJaegeuk Kim 33239a53e0cSJaegeuk Kim /* NAT cache management */ 33339a53e0cSJaegeuk Kim struct radix_tree_root nat_root;/* root of the nat entry cache */ 334309cc2b6SJaegeuk Kim struct radix_tree_root nat_set_root;/* root of the nat set cache */ 33539a53e0cSJaegeuk Kim rwlock_t nat_tree_lock; /* protect nat_tree_lock */ 33639a53e0cSJaegeuk Kim struct list_head nat_entries; /* cached nat entry list (clean) */ 337309cc2b6SJaegeuk Kim unsigned int nat_cnt; /* the # of cached nat entries */ 338aec71382SChao Yu unsigned int dirty_nat_cnt; /* total num of nat entries in set */ 33939a53e0cSJaegeuk Kim 34039a53e0cSJaegeuk Kim /* free node ids management */ 3418a7ed66aSJaegeuk Kim struct radix_tree_root free_nid_root;/* root of the free_nid cache */ 34239a53e0cSJaegeuk Kim struct list_head free_nid_list; /* a list for free nids */ 34339a53e0cSJaegeuk Kim spinlock_t free_nid_list_lock; /* protect free nid list */ 34439a53e0cSJaegeuk Kim unsigned int fcnt; /* the number of free node id */ 34539a53e0cSJaegeuk Kim struct mutex build_lock; /* lock for build free nids */ 34639a53e0cSJaegeuk Kim 34739a53e0cSJaegeuk Kim /* for checkpoint */ 34839a53e0cSJaegeuk Kim char *nat_bitmap; /* NAT bitmap pointer */ 34939a53e0cSJaegeuk Kim int bitmap_size; /* bitmap size */ 35039a53e0cSJaegeuk Kim }; 35139a53e0cSJaegeuk Kim 35239a53e0cSJaegeuk Kim /* 35339a53e0cSJaegeuk Kim * this structure is used as one of function parameters. 35439a53e0cSJaegeuk Kim * all the information are dedicated to a given direct node block determined 35539a53e0cSJaegeuk Kim * by the data offset in a file. 35639a53e0cSJaegeuk Kim */ 35739a53e0cSJaegeuk Kim struct dnode_of_data { 35839a53e0cSJaegeuk Kim struct inode *inode; /* vfs inode pointer */ 35939a53e0cSJaegeuk Kim struct page *inode_page; /* its inode page, NULL is possible */ 36039a53e0cSJaegeuk Kim struct page *node_page; /* cached direct node page */ 36139a53e0cSJaegeuk Kim nid_t nid; /* node id of the direct node block */ 36239a53e0cSJaegeuk Kim unsigned int ofs_in_node; /* data offset in the node page */ 36339a53e0cSJaegeuk Kim bool inode_page_locked; /* inode page is locked or not */ 36439a53e0cSJaegeuk Kim block_t data_blkaddr; /* block address of the node block */ 36539a53e0cSJaegeuk Kim }; 36639a53e0cSJaegeuk Kim 36739a53e0cSJaegeuk Kim static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode, 36839a53e0cSJaegeuk Kim struct page *ipage, struct page *npage, nid_t nid) 36939a53e0cSJaegeuk Kim { 370d66d1f76SJaegeuk Kim memset(dn, 0, sizeof(*dn)); 37139a53e0cSJaegeuk Kim dn->inode = inode; 37239a53e0cSJaegeuk Kim dn->inode_page = ipage; 37339a53e0cSJaegeuk Kim dn->node_page = npage; 37439a53e0cSJaegeuk Kim dn->nid = nid; 37539a53e0cSJaegeuk Kim } 37639a53e0cSJaegeuk Kim 37739a53e0cSJaegeuk Kim /* 37839a53e0cSJaegeuk Kim * For SIT manager 37939a53e0cSJaegeuk Kim * 38039a53e0cSJaegeuk Kim * By default, there are 6 active log areas across the whole main area. 38139a53e0cSJaegeuk Kim * When considering hot and cold data separation to reduce cleaning overhead, 38239a53e0cSJaegeuk Kim * we split 3 for data logs and 3 for node logs as hot, warm, and cold types, 38339a53e0cSJaegeuk Kim * respectively. 38439a53e0cSJaegeuk Kim * In the current design, you should not change the numbers intentionally. 38539a53e0cSJaegeuk Kim * Instead, as a mount option such as active_logs=x, you can use 2, 4, and 6 38639a53e0cSJaegeuk Kim * logs individually according to the underlying devices. (default: 6) 38739a53e0cSJaegeuk Kim * Just in case, on-disk layout covers maximum 16 logs that consist of 8 for 38839a53e0cSJaegeuk Kim * data and 8 for node logs. 38939a53e0cSJaegeuk Kim */ 39039a53e0cSJaegeuk Kim #define NR_CURSEG_DATA_TYPE (3) 39139a53e0cSJaegeuk Kim #define NR_CURSEG_NODE_TYPE (3) 39239a53e0cSJaegeuk Kim #define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) 39339a53e0cSJaegeuk Kim 39439a53e0cSJaegeuk Kim enum { 39539a53e0cSJaegeuk Kim CURSEG_HOT_DATA = 0, /* directory entry blocks */ 39639a53e0cSJaegeuk Kim CURSEG_WARM_DATA, /* data blocks */ 39739a53e0cSJaegeuk Kim CURSEG_COLD_DATA, /* multimedia or GCed data blocks */ 39839a53e0cSJaegeuk Kim CURSEG_HOT_NODE, /* direct node blocks of directory files */ 39939a53e0cSJaegeuk Kim CURSEG_WARM_NODE, /* direct node blocks of normal files */ 40039a53e0cSJaegeuk Kim CURSEG_COLD_NODE, /* indirect node blocks */ 40139a53e0cSJaegeuk Kim NO_CHECK_TYPE 40239a53e0cSJaegeuk Kim }; 40339a53e0cSJaegeuk Kim 4046b4afdd7SJaegeuk Kim struct flush_cmd { 4056b4afdd7SJaegeuk Kim struct completion wait; 406721bd4d5SGu Zheng struct llist_node llnode; 4076b4afdd7SJaegeuk Kim int ret; 4086b4afdd7SJaegeuk Kim }; 4096b4afdd7SJaegeuk Kim 410a688b9d9SGu Zheng struct flush_cmd_control { 411a688b9d9SGu Zheng struct task_struct *f2fs_issue_flush; /* flush thread */ 412a688b9d9SGu Zheng wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */ 413721bd4d5SGu Zheng struct llist_head issue_list; /* list for command issue */ 414721bd4d5SGu Zheng struct llist_node *dispatch_list; /* list for command dispatch */ 415a688b9d9SGu Zheng }; 416a688b9d9SGu Zheng 41739a53e0cSJaegeuk Kim struct f2fs_sm_info { 41839a53e0cSJaegeuk Kim struct sit_info *sit_info; /* whole segment information */ 41939a53e0cSJaegeuk Kim struct free_segmap_info *free_info; /* free segment information */ 42039a53e0cSJaegeuk Kim struct dirty_seglist_info *dirty_info; /* dirty segment information */ 42139a53e0cSJaegeuk Kim struct curseg_info *curseg_array; /* active segment information */ 42239a53e0cSJaegeuk Kim 42339a53e0cSJaegeuk Kim block_t seg0_blkaddr; /* block address of 0'th segment */ 42439a53e0cSJaegeuk Kim block_t main_blkaddr; /* start block address of main area */ 42539a53e0cSJaegeuk Kim block_t ssa_blkaddr; /* start block address of SSA area */ 42639a53e0cSJaegeuk Kim 42739a53e0cSJaegeuk Kim unsigned int segment_count; /* total # of segments */ 42839a53e0cSJaegeuk Kim unsigned int main_segments; /* # of segments in main area */ 42939a53e0cSJaegeuk Kim unsigned int reserved_segments; /* # of reserved segments */ 43039a53e0cSJaegeuk Kim unsigned int ovp_segments; /* # of overprovision segments */ 43181eb8d6eSJaegeuk Kim 43281eb8d6eSJaegeuk Kim /* a threshold to reclaim prefree segments */ 43381eb8d6eSJaegeuk Kim unsigned int rec_prefree_segments; 4347fd9e544SJaegeuk Kim 4357fd9e544SJaegeuk Kim /* for small discard management */ 4367fd9e544SJaegeuk Kim struct list_head discard_list; /* 4KB discard list */ 4377fd9e544SJaegeuk Kim int nr_discards; /* # of discards in the list */ 4387fd9e544SJaegeuk Kim int max_discards; /* max. discards to be issued */ 439216fbd64SJaegeuk Kim 440184a5cd2SChao Yu struct list_head sit_entry_set; /* sit entry set list */ 441184a5cd2SChao Yu 442216fbd64SJaegeuk Kim unsigned int ipu_policy; /* in-place-update policy */ 443216fbd64SJaegeuk Kim unsigned int min_ipu_util; /* in-place-update threshold */ 444c1ce1b02SJaegeuk Kim unsigned int min_fsync_blocks; /* threshold for fsync */ 4456b4afdd7SJaegeuk Kim 4466b4afdd7SJaegeuk Kim /* for flush command control */ 447a688b9d9SGu Zheng struct flush_cmd_control *cmd_control_info; 448a688b9d9SGu Zheng 44939a53e0cSJaegeuk Kim }; 45039a53e0cSJaegeuk Kim 45139a53e0cSJaegeuk Kim /* 45239a53e0cSJaegeuk Kim * For superblock 45339a53e0cSJaegeuk Kim */ 45439a53e0cSJaegeuk Kim /* 45539a53e0cSJaegeuk Kim * COUNT_TYPE for monitoring 45639a53e0cSJaegeuk Kim * 45739a53e0cSJaegeuk Kim * f2fs monitors the number of several block types such as on-writeback, 45839a53e0cSJaegeuk Kim * dirty dentry blocks, dirty node blocks, and dirty meta blocks. 45939a53e0cSJaegeuk Kim */ 46039a53e0cSJaegeuk Kim enum count_type { 46139a53e0cSJaegeuk Kim F2FS_WRITEBACK, 46239a53e0cSJaegeuk Kim F2FS_DIRTY_DENTS, 46339a53e0cSJaegeuk Kim F2FS_DIRTY_NODES, 46439a53e0cSJaegeuk Kim F2FS_DIRTY_META, 46539a53e0cSJaegeuk Kim NR_COUNT_TYPE, 46639a53e0cSJaegeuk Kim }; 46739a53e0cSJaegeuk Kim 46839a53e0cSJaegeuk Kim /* 469e1c42045Sarter97 * The below are the page types of bios used in submit_bio(). 47039a53e0cSJaegeuk Kim * The available types are: 47139a53e0cSJaegeuk Kim * DATA User data pages. It operates as async mode. 47239a53e0cSJaegeuk Kim * NODE Node pages. It operates as async mode. 47339a53e0cSJaegeuk Kim * META FS metadata pages such as SIT, NAT, CP. 47439a53e0cSJaegeuk Kim * NR_PAGE_TYPE The number of page types. 47539a53e0cSJaegeuk Kim * META_FLUSH Make sure the previous pages are written 47639a53e0cSJaegeuk Kim * with waiting the bio's completion 47739a53e0cSJaegeuk Kim * ... Only can be used with META. 47839a53e0cSJaegeuk Kim */ 4797d5e5109SJaegeuk Kim #define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type)) 48039a53e0cSJaegeuk Kim enum page_type { 48139a53e0cSJaegeuk Kim DATA, 48239a53e0cSJaegeuk Kim NODE, 48339a53e0cSJaegeuk Kim META, 48439a53e0cSJaegeuk Kim NR_PAGE_TYPE, 48539a53e0cSJaegeuk Kim META_FLUSH, 48639a53e0cSJaegeuk Kim }; 48739a53e0cSJaegeuk Kim 488458e6197SJaegeuk Kim struct f2fs_io_info { 489458e6197SJaegeuk Kim enum page_type type; /* contains DATA/NODE/META/META_FLUSH */ 4907e8f2308SGu Zheng int rw; /* contains R/RS/W/WS with REQ_META/REQ_PRIO */ 491458e6197SJaegeuk Kim }; 492458e6197SJaegeuk Kim 49393dfe2acSJaegeuk Kim #define is_read_io(rw) (((rw) & 1) == READ) 4941ff7bd3bSJaegeuk Kim struct f2fs_bio_info { 495458e6197SJaegeuk Kim struct f2fs_sb_info *sbi; /* f2fs superblock */ 4961ff7bd3bSJaegeuk Kim struct bio *bio; /* bios to merge */ 4971ff7bd3bSJaegeuk Kim sector_t last_block_in_bio; /* last block number */ 498458e6197SJaegeuk Kim struct f2fs_io_info fio; /* store buffered io info. */ 499df0f8dc0SChao Yu struct rw_semaphore io_rwsem; /* blocking op for bio */ 5001ff7bd3bSJaegeuk Kim }; 5011ff7bd3bSJaegeuk Kim 502*67298804SChao Yu /* for inner inode cache management */ 503*67298804SChao Yu struct inode_management { 504*67298804SChao Yu struct radix_tree_root ino_root; /* ino entry array */ 505*67298804SChao Yu spinlock_t ino_lock; /* for ino entry lock */ 506*67298804SChao Yu struct list_head ino_list; /* inode list head */ 507*67298804SChao Yu unsigned long ino_num; /* number of entries */ 508*67298804SChao Yu }; 509*67298804SChao Yu 51039a53e0cSJaegeuk Kim struct f2fs_sb_info { 51139a53e0cSJaegeuk Kim struct super_block *sb; /* pointer to VFS super block */ 5125e176d54SJaegeuk Kim struct proc_dir_entry *s_proc; /* proc entry */ 51339a53e0cSJaegeuk Kim struct buffer_head *raw_super_buf; /* buffer head of raw sb */ 51439a53e0cSJaegeuk Kim struct f2fs_super_block *raw_super; /* raw super block pointer */ 51539a53e0cSJaegeuk Kim int s_dirty; /* dirty flag for checkpoint */ 5162ae4c673SJaegeuk Kim bool need_fsck; /* need fsck.f2fs to fix */ 51739a53e0cSJaegeuk Kim 51839a53e0cSJaegeuk Kim /* for node-related operations */ 51939a53e0cSJaegeuk Kim struct f2fs_nm_info *nm_info; /* node manager */ 52039a53e0cSJaegeuk Kim struct inode *node_inode; /* cache node blocks */ 52139a53e0cSJaegeuk Kim 52239a53e0cSJaegeuk Kim /* for segment-related operations */ 52339a53e0cSJaegeuk Kim struct f2fs_sm_info *sm_info; /* segment manager */ 5241ff7bd3bSJaegeuk Kim 5251ff7bd3bSJaegeuk Kim /* for bio operations */ 526924b720bSChao Yu struct f2fs_bio_info read_io; /* for read bios */ 5271ff7bd3bSJaegeuk Kim struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */ 52839a53e0cSJaegeuk Kim 52939a53e0cSJaegeuk Kim /* for checkpoint */ 53039a53e0cSJaegeuk Kim struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ 53139a53e0cSJaegeuk Kim struct inode *meta_inode; /* cache meta blocks */ 53239936837SJaegeuk Kim struct mutex cp_mutex; /* checkpoint procedure lock */ 533e479556bSGu Zheng struct rw_semaphore cp_rwsem; /* blocking FS operations */ 534b3582c68SChao Yu struct rw_semaphore node_write; /* locking node writes */ 53539a53e0cSJaegeuk Kim struct mutex writepages; /* mutex for writepages() */ 536aabe5136SHaicheng Li bool por_doing; /* recovery is doing or not */ 537fb51b5efSChangman Lee wait_queue_head_t cp_wait; 53839a53e0cSJaegeuk Kim 539*67298804SChao Yu struct inode_management im[MAX_INO_ENTRY]; /* manage inode cache */ 5406451e041SJaegeuk Kim 5416451e041SJaegeuk Kim /* for orphan inode, use 0'th array */ 5420d47c1adSGu Zheng unsigned int max_orphans; /* max orphan inodes */ 54339a53e0cSJaegeuk Kim 54439a53e0cSJaegeuk Kim /* for directory inode management */ 54539a53e0cSJaegeuk Kim struct list_head dir_inode_list; /* dir inode list */ 54639a53e0cSJaegeuk Kim spinlock_t dir_inode_lock; /* for dir inode list lock */ 54739a53e0cSJaegeuk Kim 54839a53e0cSJaegeuk Kim /* basic filesystem units */ 54939a53e0cSJaegeuk Kim unsigned int log_sectors_per_block; /* log2 sectors per block */ 55039a53e0cSJaegeuk Kim unsigned int log_blocksize; /* log2 block size */ 55139a53e0cSJaegeuk Kim unsigned int blocksize; /* block size */ 55239a53e0cSJaegeuk Kim unsigned int root_ino_num; /* root inode number*/ 55339a53e0cSJaegeuk Kim unsigned int node_ino_num; /* node inode number*/ 55439a53e0cSJaegeuk Kim unsigned int meta_ino_num; /* meta inode number*/ 55539a53e0cSJaegeuk Kim unsigned int log_blocks_per_seg; /* log2 blocks per segment */ 55639a53e0cSJaegeuk Kim unsigned int blocks_per_seg; /* blocks per segment */ 55739a53e0cSJaegeuk Kim unsigned int segs_per_sec; /* segments per section */ 55839a53e0cSJaegeuk Kim unsigned int secs_per_zone; /* sections per zone */ 55939a53e0cSJaegeuk Kim unsigned int total_sections; /* total section count */ 56039a53e0cSJaegeuk Kim unsigned int total_node_count; /* total node block count */ 56139a53e0cSJaegeuk Kim unsigned int total_valid_node_count; /* valid node block count */ 56239a53e0cSJaegeuk Kim unsigned int total_valid_inode_count; /* valid inode count */ 56339a53e0cSJaegeuk Kim int active_logs; /* # of active logs */ 564ab9fa662SJaegeuk Kim int dir_level; /* directory level */ 56539a53e0cSJaegeuk Kim 56639a53e0cSJaegeuk Kim block_t user_block_count; /* # of user blocks */ 56739a53e0cSJaegeuk Kim block_t total_valid_block_count; /* # of valid blocks */ 56839a53e0cSJaegeuk Kim block_t alloc_valid_block_count; /* # of allocated blocks */ 56939a53e0cSJaegeuk Kim block_t last_valid_block_count; /* for recovery */ 57039a53e0cSJaegeuk Kim u32 s_next_generation; /* for NFS support */ 57139a53e0cSJaegeuk Kim atomic_t nr_pages[NR_COUNT_TYPE]; /* # of pages, see count_type */ 57239a53e0cSJaegeuk Kim 57339a53e0cSJaegeuk Kim struct f2fs_mount_info mount_opt; /* mount options */ 57439a53e0cSJaegeuk Kim 57539a53e0cSJaegeuk Kim /* for cleaning operations */ 57639a53e0cSJaegeuk Kim struct mutex gc_mutex; /* mutex for GC */ 57739a53e0cSJaegeuk Kim struct f2fs_gc_kthread *gc_thread; /* GC thread */ 5785ec4e49fSJaegeuk Kim unsigned int cur_victim_sec; /* current victim section num */ 57939a53e0cSJaegeuk Kim 580b1c57c1cSJaegeuk Kim /* maximum # of trials to find a victim segment for SSR and GC */ 581b1c57c1cSJaegeuk Kim unsigned int max_victim_search; 582b1c57c1cSJaegeuk Kim 58339a53e0cSJaegeuk Kim /* 58439a53e0cSJaegeuk Kim * for stat information. 58539a53e0cSJaegeuk Kim * one is for the LFS mode, and the other is for the SSR mode. 58639a53e0cSJaegeuk Kim */ 58735b09d82SNamjae Jeon #ifdef CONFIG_F2FS_STAT_FS 58839a53e0cSJaegeuk Kim struct f2fs_stat_info *stat_info; /* FS status information */ 58939a53e0cSJaegeuk Kim unsigned int segment_count[2]; /* # of allocated segments */ 59039a53e0cSJaegeuk Kim unsigned int block_count[2]; /* # of allocated blocks */ 59139a53e0cSJaegeuk Kim int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ 5920dbdc2aeSJaegeuk Kim int inline_inode; /* # of inline_data inodes */ 5933289c061SJaegeuk Kim int inline_dir; /* # of inline_dentry inodes */ 59439a53e0cSJaegeuk Kim int bg_gc; /* background gc calls */ 59535b09d82SNamjae Jeon unsigned int n_dirty_dirs; /* # of dir inodes */ 59635b09d82SNamjae Jeon #endif 59735b09d82SNamjae Jeon unsigned int last_victim[2]; /* last victim segment # */ 59839a53e0cSJaegeuk Kim spinlock_t stat_lock; /* lock for stat operations */ 599b59d0baeSNamjae Jeon 600b59d0baeSNamjae Jeon /* For sysfs suppport */ 601b59d0baeSNamjae Jeon struct kobject s_kobj; 602b59d0baeSNamjae Jeon struct completion s_kobj_unregister; 60339a53e0cSJaegeuk Kim }; 60439a53e0cSJaegeuk Kim 60539a53e0cSJaegeuk Kim /* 60639a53e0cSJaegeuk Kim * Inline functions 60739a53e0cSJaegeuk Kim */ 60839a53e0cSJaegeuk Kim static inline struct f2fs_inode_info *F2FS_I(struct inode *inode) 60939a53e0cSJaegeuk Kim { 61039a53e0cSJaegeuk Kim return container_of(inode, struct f2fs_inode_info, vfs_inode); 61139a53e0cSJaegeuk Kim } 61239a53e0cSJaegeuk Kim 61339a53e0cSJaegeuk Kim static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb) 61439a53e0cSJaegeuk Kim { 61539a53e0cSJaegeuk Kim return sb->s_fs_info; 61639a53e0cSJaegeuk Kim } 61739a53e0cSJaegeuk Kim 6184081363fSJaegeuk Kim static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode) 6194081363fSJaegeuk Kim { 6204081363fSJaegeuk Kim return F2FS_SB(inode->i_sb); 6214081363fSJaegeuk Kim } 6224081363fSJaegeuk Kim 6234081363fSJaegeuk Kim static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping) 6244081363fSJaegeuk Kim { 6254081363fSJaegeuk Kim return F2FS_I_SB(mapping->host); 6264081363fSJaegeuk Kim } 6274081363fSJaegeuk Kim 6284081363fSJaegeuk Kim static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page) 6294081363fSJaegeuk Kim { 6304081363fSJaegeuk Kim return F2FS_M_SB(page->mapping); 6314081363fSJaegeuk Kim } 6324081363fSJaegeuk Kim 63339a53e0cSJaegeuk Kim static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) 63439a53e0cSJaegeuk Kim { 63539a53e0cSJaegeuk Kim return (struct f2fs_super_block *)(sbi->raw_super); 63639a53e0cSJaegeuk Kim } 63739a53e0cSJaegeuk Kim 63839a53e0cSJaegeuk Kim static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi) 63939a53e0cSJaegeuk Kim { 64039a53e0cSJaegeuk Kim return (struct f2fs_checkpoint *)(sbi->ckpt); 64139a53e0cSJaegeuk Kim } 64239a53e0cSJaegeuk Kim 64345590710SGu Zheng static inline struct f2fs_node *F2FS_NODE(struct page *page) 64445590710SGu Zheng { 64545590710SGu Zheng return (struct f2fs_node *)page_address(page); 64645590710SGu Zheng } 64745590710SGu Zheng 64858bfaf44SJaegeuk Kim static inline struct f2fs_inode *F2FS_INODE(struct page *page) 64958bfaf44SJaegeuk Kim { 65058bfaf44SJaegeuk Kim return &((struct f2fs_node *)page_address(page))->i; 65158bfaf44SJaegeuk Kim } 65258bfaf44SJaegeuk Kim 65339a53e0cSJaegeuk Kim static inline struct f2fs_nm_info *NM_I(struct f2fs_sb_info *sbi) 65439a53e0cSJaegeuk Kim { 65539a53e0cSJaegeuk Kim return (struct f2fs_nm_info *)(sbi->nm_info); 65639a53e0cSJaegeuk Kim } 65739a53e0cSJaegeuk Kim 65839a53e0cSJaegeuk Kim static inline struct f2fs_sm_info *SM_I(struct f2fs_sb_info *sbi) 65939a53e0cSJaegeuk Kim { 66039a53e0cSJaegeuk Kim return (struct f2fs_sm_info *)(sbi->sm_info); 66139a53e0cSJaegeuk Kim } 66239a53e0cSJaegeuk Kim 66339a53e0cSJaegeuk Kim static inline struct sit_info *SIT_I(struct f2fs_sb_info *sbi) 66439a53e0cSJaegeuk Kim { 66539a53e0cSJaegeuk Kim return (struct sit_info *)(SM_I(sbi)->sit_info); 66639a53e0cSJaegeuk Kim } 66739a53e0cSJaegeuk Kim 66839a53e0cSJaegeuk Kim static inline struct free_segmap_info *FREE_I(struct f2fs_sb_info *sbi) 66939a53e0cSJaegeuk Kim { 67039a53e0cSJaegeuk Kim return (struct free_segmap_info *)(SM_I(sbi)->free_info); 67139a53e0cSJaegeuk Kim } 67239a53e0cSJaegeuk Kim 67339a53e0cSJaegeuk Kim static inline struct dirty_seglist_info *DIRTY_I(struct f2fs_sb_info *sbi) 67439a53e0cSJaegeuk Kim { 67539a53e0cSJaegeuk Kim return (struct dirty_seglist_info *)(SM_I(sbi)->dirty_info); 67639a53e0cSJaegeuk Kim } 67739a53e0cSJaegeuk Kim 6789df27d98SGu Zheng static inline struct address_space *META_MAPPING(struct f2fs_sb_info *sbi) 6799df27d98SGu Zheng { 6809df27d98SGu Zheng return sbi->meta_inode->i_mapping; 6819df27d98SGu Zheng } 6829df27d98SGu Zheng 6834ef51a8fSJaegeuk Kim static inline struct address_space *NODE_MAPPING(struct f2fs_sb_info *sbi) 6844ef51a8fSJaegeuk Kim { 6854ef51a8fSJaegeuk Kim return sbi->node_inode->i_mapping; 6864ef51a8fSJaegeuk Kim } 6874ef51a8fSJaegeuk Kim 68839a53e0cSJaegeuk Kim static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi) 68939a53e0cSJaegeuk Kim { 69039a53e0cSJaegeuk Kim sbi->s_dirty = 1; 69139a53e0cSJaegeuk Kim } 69239a53e0cSJaegeuk Kim 69339a53e0cSJaegeuk Kim static inline void F2FS_RESET_SB_DIRT(struct f2fs_sb_info *sbi) 69439a53e0cSJaegeuk Kim { 69539a53e0cSJaegeuk Kim sbi->s_dirty = 0; 69639a53e0cSJaegeuk Kim } 69739a53e0cSJaegeuk Kim 698d71b5564SJaegeuk Kim static inline unsigned long long cur_cp_version(struct f2fs_checkpoint *cp) 699d71b5564SJaegeuk Kim { 700d71b5564SJaegeuk Kim return le64_to_cpu(cp->checkpoint_ver); 701d71b5564SJaegeuk Kim } 702d71b5564SJaegeuk Kim 70325ca923bSJaegeuk Kim static inline bool is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f) 70425ca923bSJaegeuk Kim { 70525ca923bSJaegeuk Kim unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags); 70625ca923bSJaegeuk Kim return ckpt_flags & f; 70725ca923bSJaegeuk Kim } 70825ca923bSJaegeuk Kim 70925ca923bSJaegeuk Kim static inline void set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f) 71025ca923bSJaegeuk Kim { 71125ca923bSJaegeuk Kim unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags); 71225ca923bSJaegeuk Kim ckpt_flags |= f; 71325ca923bSJaegeuk Kim cp->ckpt_flags = cpu_to_le32(ckpt_flags); 71425ca923bSJaegeuk Kim } 71525ca923bSJaegeuk Kim 71625ca923bSJaegeuk Kim static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f) 71725ca923bSJaegeuk Kim { 71825ca923bSJaegeuk Kim unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags); 71925ca923bSJaegeuk Kim ckpt_flags &= (~f); 72025ca923bSJaegeuk Kim cp->ckpt_flags = cpu_to_le32(ckpt_flags); 72125ca923bSJaegeuk Kim } 72225ca923bSJaegeuk Kim 723e479556bSGu Zheng static inline void f2fs_lock_op(struct f2fs_sb_info *sbi) 72439a53e0cSJaegeuk Kim { 725e479556bSGu Zheng down_read(&sbi->cp_rwsem); 72639a53e0cSJaegeuk Kim } 72739a53e0cSJaegeuk Kim 728e479556bSGu Zheng static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi) 72939a53e0cSJaegeuk Kim { 730e479556bSGu Zheng up_read(&sbi->cp_rwsem); 73139936837SJaegeuk Kim } 73239936837SJaegeuk Kim 733e479556bSGu Zheng static inline void f2fs_lock_all(struct f2fs_sb_info *sbi) 73439936837SJaegeuk Kim { 7350daaad97SJaegeuk Kim f2fs_down_write(&sbi->cp_rwsem, &sbi->cp_mutex); 73639936837SJaegeuk Kim } 73739936837SJaegeuk Kim 738e479556bSGu Zheng static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi) 73939936837SJaegeuk Kim { 740e479556bSGu Zheng up_write(&sbi->cp_rwsem); 74139a53e0cSJaegeuk Kim } 74239a53e0cSJaegeuk Kim 74339a53e0cSJaegeuk Kim /* 74439a53e0cSJaegeuk Kim * Check whether the given nid is within node id range. 74539a53e0cSJaegeuk Kim */ 746064e0823SNamjae Jeon static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid) 74739a53e0cSJaegeuk Kim { 748d6b7d4b3SChao Yu if (unlikely(nid < F2FS_ROOT_INO(sbi))) 749d6b7d4b3SChao Yu return -EINVAL; 750cfb271d4SChao Yu if (unlikely(nid >= NM_I(sbi)->max_nid)) 751064e0823SNamjae Jeon return -EINVAL; 752064e0823SNamjae Jeon return 0; 75339a53e0cSJaegeuk Kim } 75439a53e0cSJaegeuk Kim 75539a53e0cSJaegeuk Kim #define F2FS_DEFAULT_ALLOCATED_BLOCKS 1 75639a53e0cSJaegeuk Kim 75739a53e0cSJaegeuk Kim /* 75839a53e0cSJaegeuk Kim * Check whether the inode has blocks or not 75939a53e0cSJaegeuk Kim */ 76039a53e0cSJaegeuk Kim static inline int F2FS_HAS_BLOCKS(struct inode *inode) 76139a53e0cSJaegeuk Kim { 76239a53e0cSJaegeuk Kim if (F2FS_I(inode)->i_xattr_nid) 7636c311ec6SChris Fries return inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS + 1; 76439a53e0cSJaegeuk Kim else 7656c311ec6SChris Fries return inode->i_blocks > F2FS_DEFAULT_ALLOCATED_BLOCKS; 76639a53e0cSJaegeuk Kim } 76739a53e0cSJaegeuk Kim 7684bc8e9bcSChao Yu static inline bool f2fs_has_xattr_block(unsigned int ofs) 7694bc8e9bcSChao Yu { 7704bc8e9bcSChao Yu return ofs == XATTR_NODE_OFFSET; 7714bc8e9bcSChao Yu } 7724bc8e9bcSChao Yu 77339a53e0cSJaegeuk Kim static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi, 77439a53e0cSJaegeuk Kim struct inode *inode, blkcnt_t count) 77539a53e0cSJaegeuk Kim { 77639a53e0cSJaegeuk Kim block_t valid_block_count; 77739a53e0cSJaegeuk Kim 77839a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 77939a53e0cSJaegeuk Kim valid_block_count = 78039a53e0cSJaegeuk Kim sbi->total_valid_block_count + (block_t)count; 781cfb271d4SChao Yu if (unlikely(valid_block_count > sbi->user_block_count)) { 78239a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 78339a53e0cSJaegeuk Kim return false; 78439a53e0cSJaegeuk Kim } 78539a53e0cSJaegeuk Kim inode->i_blocks += count; 78639a53e0cSJaegeuk Kim sbi->total_valid_block_count = valid_block_count; 78739a53e0cSJaegeuk Kim sbi->alloc_valid_block_count += (block_t)count; 78839a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 78939a53e0cSJaegeuk Kim return true; 79039a53e0cSJaegeuk Kim } 79139a53e0cSJaegeuk Kim 792da19b0dcSGu Zheng static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, 79339a53e0cSJaegeuk Kim struct inode *inode, 79439a53e0cSJaegeuk Kim blkcnt_t count) 79539a53e0cSJaegeuk Kim { 79639a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 7979850cf4aSJaegeuk Kim f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count); 7989850cf4aSJaegeuk Kim f2fs_bug_on(sbi, inode->i_blocks < count); 79939a53e0cSJaegeuk Kim inode->i_blocks -= count; 80039a53e0cSJaegeuk Kim sbi->total_valid_block_count -= (block_t)count; 80139a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 80239a53e0cSJaegeuk Kim } 80339a53e0cSJaegeuk Kim 80439a53e0cSJaegeuk Kim static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type) 80539a53e0cSJaegeuk Kim { 80639a53e0cSJaegeuk Kim atomic_inc(&sbi->nr_pages[count_type]); 80739a53e0cSJaegeuk Kim F2FS_SET_SB_DIRT(sbi); 80839a53e0cSJaegeuk Kim } 80939a53e0cSJaegeuk Kim 810a7ffdbe2SJaegeuk Kim static inline void inode_inc_dirty_pages(struct inode *inode) 81139a53e0cSJaegeuk Kim { 812a7ffdbe2SJaegeuk Kim atomic_inc(&F2FS_I(inode)->dirty_pages); 813a7ffdbe2SJaegeuk Kim if (S_ISDIR(inode->i_mode)) 8144081363fSJaegeuk Kim inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS); 81539a53e0cSJaegeuk Kim } 81639a53e0cSJaegeuk Kim 81739a53e0cSJaegeuk Kim static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type) 81839a53e0cSJaegeuk Kim { 81939a53e0cSJaegeuk Kim atomic_dec(&sbi->nr_pages[count_type]); 82039a53e0cSJaegeuk Kim } 82139a53e0cSJaegeuk Kim 822a7ffdbe2SJaegeuk Kim static inline void inode_dec_dirty_pages(struct inode *inode) 82339a53e0cSJaegeuk Kim { 824a7ffdbe2SJaegeuk Kim if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode)) 8251fe54f9dSJaegeuk Kim return; 8261fe54f9dSJaegeuk Kim 827a7ffdbe2SJaegeuk Kim atomic_dec(&F2FS_I(inode)->dirty_pages); 828a7ffdbe2SJaegeuk Kim 829a7ffdbe2SJaegeuk Kim if (S_ISDIR(inode->i_mode)) 8304081363fSJaegeuk Kim dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS); 83139a53e0cSJaegeuk Kim } 83239a53e0cSJaegeuk Kim 83339a53e0cSJaegeuk Kim static inline int get_pages(struct f2fs_sb_info *sbi, int count_type) 83439a53e0cSJaegeuk Kim { 83539a53e0cSJaegeuk Kim return atomic_read(&sbi->nr_pages[count_type]); 83639a53e0cSJaegeuk Kim } 83739a53e0cSJaegeuk Kim 838a7ffdbe2SJaegeuk Kim static inline int get_dirty_pages(struct inode *inode) 839f8b2c1f9SJaegeuk Kim { 840a7ffdbe2SJaegeuk Kim return atomic_read(&F2FS_I(inode)->dirty_pages); 841f8b2c1f9SJaegeuk Kim } 842f8b2c1f9SJaegeuk Kim 8435ac206cfSNamjae Jeon static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) 8445ac206cfSNamjae Jeon { 8455ac206cfSNamjae Jeon unsigned int pages_per_sec = sbi->segs_per_sec * 8465ac206cfSNamjae Jeon (1 << sbi->log_blocks_per_seg); 8475ac206cfSNamjae Jeon return ((get_pages(sbi, block_type) + pages_per_sec - 1) 8485ac206cfSNamjae Jeon >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; 8495ac206cfSNamjae Jeon } 8505ac206cfSNamjae Jeon 85139a53e0cSJaegeuk Kim static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi) 85239a53e0cSJaegeuk Kim { 8538b8343faSJaegeuk Kim return sbi->total_valid_block_count; 85439a53e0cSJaegeuk Kim } 85539a53e0cSJaegeuk Kim 85639a53e0cSJaegeuk Kim static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag) 85739a53e0cSJaegeuk Kim { 85839a53e0cSJaegeuk Kim struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 85939a53e0cSJaegeuk Kim 86039a53e0cSJaegeuk Kim /* return NAT or SIT bitmap */ 86139a53e0cSJaegeuk Kim if (flag == NAT_BITMAP) 86239a53e0cSJaegeuk Kim return le32_to_cpu(ckpt->nat_ver_bitmap_bytesize); 86339a53e0cSJaegeuk Kim else if (flag == SIT_BITMAP) 86439a53e0cSJaegeuk Kim return le32_to_cpu(ckpt->sit_ver_bitmap_bytesize); 86539a53e0cSJaegeuk Kim 86639a53e0cSJaegeuk Kim return 0; 86739a53e0cSJaegeuk Kim } 86839a53e0cSJaegeuk Kim 86939a53e0cSJaegeuk Kim static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag) 87039a53e0cSJaegeuk Kim { 87139a53e0cSJaegeuk Kim struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 8721dbe4152SChangman Lee int offset; 8731dbe4152SChangman Lee 8741dbe4152SChangman Lee if (le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload) > 0) { 8751dbe4152SChangman Lee if (flag == NAT_BITMAP) 8761dbe4152SChangman Lee return &ckpt->sit_nat_version_bitmap; 8771dbe4152SChangman Lee else 87865b85cccSJaegeuk Kim return (unsigned char *)ckpt + F2FS_BLKSIZE; 8791dbe4152SChangman Lee } else { 8801dbe4152SChangman Lee offset = (flag == NAT_BITMAP) ? 88125ca923bSJaegeuk Kim le32_to_cpu(ckpt->sit_ver_bitmap_bytesize) : 0; 88239a53e0cSJaegeuk Kim return &ckpt->sit_nat_version_bitmap + offset; 88339a53e0cSJaegeuk Kim } 8841dbe4152SChangman Lee } 88539a53e0cSJaegeuk Kim 88639a53e0cSJaegeuk Kim static inline block_t __start_cp_addr(struct f2fs_sb_info *sbi) 88739a53e0cSJaegeuk Kim { 88839a53e0cSJaegeuk Kim block_t start_addr; 88939a53e0cSJaegeuk Kim struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 890d71b5564SJaegeuk Kim unsigned long long ckpt_version = cur_cp_version(ckpt); 89139a53e0cSJaegeuk Kim 89225ca923bSJaegeuk Kim start_addr = le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_blkaddr); 89339a53e0cSJaegeuk Kim 89439a53e0cSJaegeuk Kim /* 89539a53e0cSJaegeuk Kim * odd numbered checkpoint should at cp segment 0 896e1c42045Sarter97 * and even segment must be at cp segment 1 89739a53e0cSJaegeuk Kim */ 89839a53e0cSJaegeuk Kim if (!(ckpt_version & 1)) 89939a53e0cSJaegeuk Kim start_addr += sbi->blocks_per_seg; 90039a53e0cSJaegeuk Kim 90139a53e0cSJaegeuk Kim return start_addr; 90239a53e0cSJaegeuk Kim } 90339a53e0cSJaegeuk Kim 90439a53e0cSJaegeuk Kim static inline block_t __start_sum_addr(struct f2fs_sb_info *sbi) 90539a53e0cSJaegeuk Kim { 90639a53e0cSJaegeuk Kim return le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum); 90739a53e0cSJaegeuk Kim } 90839a53e0cSJaegeuk Kim 90939a53e0cSJaegeuk Kim static inline bool inc_valid_node_count(struct f2fs_sb_info *sbi, 910ef86d709SGu Zheng struct inode *inode) 91139a53e0cSJaegeuk Kim { 91239a53e0cSJaegeuk Kim block_t valid_block_count; 91339a53e0cSJaegeuk Kim unsigned int valid_node_count; 91439a53e0cSJaegeuk Kim 91539a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 91639a53e0cSJaegeuk Kim 917ef86d709SGu Zheng valid_block_count = sbi->total_valid_block_count + 1; 918cfb271d4SChao Yu if (unlikely(valid_block_count > sbi->user_block_count)) { 91939a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 92039a53e0cSJaegeuk Kim return false; 92139a53e0cSJaegeuk Kim } 92239a53e0cSJaegeuk Kim 923ef86d709SGu Zheng valid_node_count = sbi->total_valid_node_count + 1; 924cfb271d4SChao Yu if (unlikely(valid_node_count > sbi->total_node_count)) { 92539a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 92639a53e0cSJaegeuk Kim return false; 92739a53e0cSJaegeuk Kim } 92839a53e0cSJaegeuk Kim 92939a53e0cSJaegeuk Kim if (inode) 930ef86d709SGu Zheng inode->i_blocks++; 931ef86d709SGu Zheng 932ef86d709SGu Zheng sbi->alloc_valid_block_count++; 933ef86d709SGu Zheng sbi->total_valid_node_count++; 934ef86d709SGu Zheng sbi->total_valid_block_count++; 93539a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 93639a53e0cSJaegeuk Kim 93739a53e0cSJaegeuk Kim return true; 93839a53e0cSJaegeuk Kim } 93939a53e0cSJaegeuk Kim 94039a53e0cSJaegeuk Kim static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, 941ef86d709SGu Zheng struct inode *inode) 94239a53e0cSJaegeuk Kim { 94339a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 94439a53e0cSJaegeuk Kim 9459850cf4aSJaegeuk Kim f2fs_bug_on(sbi, !sbi->total_valid_block_count); 9469850cf4aSJaegeuk Kim f2fs_bug_on(sbi, !sbi->total_valid_node_count); 9479850cf4aSJaegeuk Kim f2fs_bug_on(sbi, !inode->i_blocks); 94839a53e0cSJaegeuk Kim 949ef86d709SGu Zheng inode->i_blocks--; 950ef86d709SGu Zheng sbi->total_valid_node_count--; 951ef86d709SGu Zheng sbi->total_valid_block_count--; 95239a53e0cSJaegeuk Kim 95339a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 95439a53e0cSJaegeuk Kim } 95539a53e0cSJaegeuk Kim 95639a53e0cSJaegeuk Kim static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) 95739a53e0cSJaegeuk Kim { 9588b8343faSJaegeuk Kim return sbi->total_valid_node_count; 95939a53e0cSJaegeuk Kim } 96039a53e0cSJaegeuk Kim 96139a53e0cSJaegeuk Kim static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) 96239a53e0cSJaegeuk Kim { 96339a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 9649850cf4aSJaegeuk Kim f2fs_bug_on(sbi, sbi->total_valid_inode_count == sbi->total_node_count); 96539a53e0cSJaegeuk Kim sbi->total_valid_inode_count++; 96639a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 96739a53e0cSJaegeuk Kim } 96839a53e0cSJaegeuk Kim 9690e80220aSJaegeuk Kim static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) 97039a53e0cSJaegeuk Kim { 97139a53e0cSJaegeuk Kim spin_lock(&sbi->stat_lock); 9729850cf4aSJaegeuk Kim f2fs_bug_on(sbi, !sbi->total_valid_inode_count); 97339a53e0cSJaegeuk Kim sbi->total_valid_inode_count--; 97439a53e0cSJaegeuk Kim spin_unlock(&sbi->stat_lock); 97539a53e0cSJaegeuk Kim } 97639a53e0cSJaegeuk Kim 97739a53e0cSJaegeuk Kim static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) 97839a53e0cSJaegeuk Kim { 9798b8343faSJaegeuk Kim return sbi->total_valid_inode_count; 98039a53e0cSJaegeuk Kim } 98139a53e0cSJaegeuk Kim 98239a53e0cSJaegeuk Kim static inline void f2fs_put_page(struct page *page, int unlock) 98339a53e0cSJaegeuk Kim { 984031fa8ccSJaegeuk Kim if (!page) 98539a53e0cSJaegeuk Kim return; 98639a53e0cSJaegeuk Kim 98739a53e0cSJaegeuk Kim if (unlock) { 9889850cf4aSJaegeuk Kim f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page)); 98939a53e0cSJaegeuk Kim unlock_page(page); 99039a53e0cSJaegeuk Kim } 99139a53e0cSJaegeuk Kim page_cache_release(page); 99239a53e0cSJaegeuk Kim } 99339a53e0cSJaegeuk Kim 99439a53e0cSJaegeuk Kim static inline void f2fs_put_dnode(struct dnode_of_data *dn) 99539a53e0cSJaegeuk Kim { 99639a53e0cSJaegeuk Kim if (dn->node_page) 99739a53e0cSJaegeuk Kim f2fs_put_page(dn->node_page, 1); 99839a53e0cSJaegeuk Kim if (dn->inode_page && dn->node_page != dn->inode_page) 99939a53e0cSJaegeuk Kim f2fs_put_page(dn->inode_page, 0); 100039a53e0cSJaegeuk Kim dn->node_page = NULL; 100139a53e0cSJaegeuk Kim dn->inode_page = NULL; 100239a53e0cSJaegeuk Kim } 100339a53e0cSJaegeuk Kim 100439a53e0cSJaegeuk Kim static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name, 1005e8512d2eSGu Zheng size_t size) 100639a53e0cSJaegeuk Kim { 1007e8512d2eSGu Zheng return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, NULL); 100839a53e0cSJaegeuk Kim } 100939a53e0cSJaegeuk Kim 10107bd59381SGu Zheng static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep, 10117bd59381SGu Zheng gfp_t flags) 10127bd59381SGu Zheng { 10137bd59381SGu Zheng void *entry; 10147bd59381SGu Zheng retry: 10157bd59381SGu Zheng entry = kmem_cache_alloc(cachep, flags); 10167bd59381SGu Zheng if (!entry) { 10177bd59381SGu Zheng cond_resched(); 10187bd59381SGu Zheng goto retry; 10197bd59381SGu Zheng } 10207bd59381SGu Zheng 10217bd59381SGu Zheng return entry; 10227bd59381SGu Zheng } 10237bd59381SGu Zheng 102439a53e0cSJaegeuk Kim #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino) 102539a53e0cSJaegeuk Kim 102639a53e0cSJaegeuk Kim static inline bool IS_INODE(struct page *page) 102739a53e0cSJaegeuk Kim { 102845590710SGu Zheng struct f2fs_node *p = F2FS_NODE(page); 102939a53e0cSJaegeuk Kim return RAW_IS_INODE(p); 103039a53e0cSJaegeuk Kim } 103139a53e0cSJaegeuk Kim 103239a53e0cSJaegeuk Kim static inline __le32 *blkaddr_in_node(struct f2fs_node *node) 103339a53e0cSJaegeuk Kim { 103439a53e0cSJaegeuk Kim return RAW_IS_INODE(node) ? node->i.i_addr : node->dn.addr; 103539a53e0cSJaegeuk Kim } 103639a53e0cSJaegeuk Kim 103739a53e0cSJaegeuk Kim static inline block_t datablock_addr(struct page *node_page, 103839a53e0cSJaegeuk Kim unsigned int offset) 103939a53e0cSJaegeuk Kim { 104039a53e0cSJaegeuk Kim struct f2fs_node *raw_node; 104139a53e0cSJaegeuk Kim __le32 *addr_array; 104245590710SGu Zheng raw_node = F2FS_NODE(node_page); 104339a53e0cSJaegeuk Kim addr_array = blkaddr_in_node(raw_node); 104439a53e0cSJaegeuk Kim return le32_to_cpu(addr_array[offset]); 104539a53e0cSJaegeuk Kim } 104639a53e0cSJaegeuk Kim 104739a53e0cSJaegeuk Kim static inline int f2fs_test_bit(unsigned int nr, char *addr) 104839a53e0cSJaegeuk Kim { 104939a53e0cSJaegeuk Kim int mask; 105039a53e0cSJaegeuk Kim 105139a53e0cSJaegeuk Kim addr += (nr >> 3); 105239a53e0cSJaegeuk Kim mask = 1 << (7 - (nr & 0x07)); 105339a53e0cSJaegeuk Kim return mask & *addr; 105439a53e0cSJaegeuk Kim } 105539a53e0cSJaegeuk Kim 105652aca074SGu Zheng static inline int f2fs_test_and_set_bit(unsigned int nr, char *addr) 105739a53e0cSJaegeuk Kim { 105839a53e0cSJaegeuk Kim int mask; 105939a53e0cSJaegeuk Kim int ret; 106039a53e0cSJaegeuk Kim 106139a53e0cSJaegeuk Kim addr += (nr >> 3); 106239a53e0cSJaegeuk Kim mask = 1 << (7 - (nr & 0x07)); 106339a53e0cSJaegeuk Kim ret = mask & *addr; 106439a53e0cSJaegeuk Kim *addr |= mask; 106539a53e0cSJaegeuk Kim return ret; 106639a53e0cSJaegeuk Kim } 106739a53e0cSJaegeuk Kim 106852aca074SGu Zheng static inline int f2fs_test_and_clear_bit(unsigned int nr, char *addr) 106939a53e0cSJaegeuk Kim { 107039a53e0cSJaegeuk Kim int mask; 107139a53e0cSJaegeuk Kim int ret; 107239a53e0cSJaegeuk Kim 107339a53e0cSJaegeuk Kim addr += (nr >> 3); 107439a53e0cSJaegeuk Kim mask = 1 << (7 - (nr & 0x07)); 107539a53e0cSJaegeuk Kim ret = mask & *addr; 107639a53e0cSJaegeuk Kim *addr &= ~mask; 107739a53e0cSJaegeuk Kim return ret; 107839a53e0cSJaegeuk Kim } 107939a53e0cSJaegeuk Kim 1080c6ac4c0eSGu Zheng static inline void f2fs_change_bit(unsigned int nr, char *addr) 1081c6ac4c0eSGu Zheng { 1082c6ac4c0eSGu Zheng int mask; 1083c6ac4c0eSGu Zheng 1084c6ac4c0eSGu Zheng addr += (nr >> 3); 1085c6ac4c0eSGu Zheng mask = 1 << (7 - (nr & 0x07)); 1086c6ac4c0eSGu Zheng *addr ^= mask; 1087c6ac4c0eSGu Zheng } 1088c6ac4c0eSGu Zheng 108939a53e0cSJaegeuk Kim /* used for f2fs_inode_info->flags */ 109039a53e0cSJaegeuk Kim enum { 109139a53e0cSJaegeuk Kim FI_NEW_INODE, /* indicate newly allocated inode */ 1092b3783873SJaegeuk Kim FI_DIRTY_INODE, /* indicate inode is dirty or not */ 1093ed57c27fSJaegeuk Kim FI_DIRTY_DIR, /* indicate directory has dirty pages */ 109439a53e0cSJaegeuk Kim FI_INC_LINK, /* need to increment i_nlink */ 109539a53e0cSJaegeuk Kim FI_ACL_MODE, /* indicate acl mode */ 109639a53e0cSJaegeuk Kim FI_NO_ALLOC, /* should not allocate any blocks */ 1097699489bbSJaegeuk Kim FI_UPDATE_DIR, /* should update inode block for consistency */ 109874d0b917SJaegeuk Kim FI_DELAY_IPUT, /* used for the recovery */ 1099c11abd1aSJaegeuk Kim FI_NO_EXTENT, /* not to use the extent cache */ 1100444c580fSJaegeuk Kim FI_INLINE_XATTR, /* used for inline xattr */ 11011001b347SHuajun Li FI_INLINE_DATA, /* used for inline data*/ 110234d67debSChao Yu FI_INLINE_DENTRY, /* used for inline dentry */ 1103fff04f90SJaegeuk Kim FI_APPEND_WRITE, /* inode has appended data */ 1104fff04f90SJaegeuk Kim FI_UPDATE_WRITE, /* inode has in-place-update data */ 110588b88a66SJaegeuk Kim FI_NEED_IPU, /* used for ipu per file */ 110688b88a66SJaegeuk Kim FI_ATOMIC_FILE, /* indicate atomic file */ 110702a1335fSJaegeuk Kim FI_VOLATILE_FILE, /* indicate volatile file */ 1108b3d208f9SJaegeuk Kim FI_DATA_EXIST, /* indicate data exists */ 110939a53e0cSJaegeuk Kim }; 111039a53e0cSJaegeuk Kim 111139a53e0cSJaegeuk Kim static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) 111239a53e0cSJaegeuk Kim { 111361e0f2d0SJaegeuk Kim if (!test_bit(flag, &fi->flags)) 111439a53e0cSJaegeuk Kim set_bit(flag, &fi->flags); 111539a53e0cSJaegeuk Kim } 111639a53e0cSJaegeuk Kim 111739a53e0cSJaegeuk Kim static inline int is_inode_flag_set(struct f2fs_inode_info *fi, int flag) 111839a53e0cSJaegeuk Kim { 111939a53e0cSJaegeuk Kim return test_bit(flag, &fi->flags); 112039a53e0cSJaegeuk Kim } 112139a53e0cSJaegeuk Kim 112239a53e0cSJaegeuk Kim static inline void clear_inode_flag(struct f2fs_inode_info *fi, int flag) 112339a53e0cSJaegeuk Kim { 112461e0f2d0SJaegeuk Kim if (test_bit(flag, &fi->flags)) 112539a53e0cSJaegeuk Kim clear_bit(flag, &fi->flags); 112639a53e0cSJaegeuk Kim } 112739a53e0cSJaegeuk Kim 112839a53e0cSJaegeuk Kim static inline void set_acl_inode(struct f2fs_inode_info *fi, umode_t mode) 112939a53e0cSJaegeuk Kim { 113039a53e0cSJaegeuk Kim fi->i_acl_mode = mode; 113139a53e0cSJaegeuk Kim set_inode_flag(fi, FI_ACL_MODE); 113239a53e0cSJaegeuk Kim } 113339a53e0cSJaegeuk Kim 1134444c580fSJaegeuk Kim static inline void get_inline_info(struct f2fs_inode_info *fi, 1135444c580fSJaegeuk Kim struct f2fs_inode *ri) 1136444c580fSJaegeuk Kim { 1137444c580fSJaegeuk Kim if (ri->i_inline & F2FS_INLINE_XATTR) 1138444c580fSJaegeuk Kim set_inode_flag(fi, FI_INLINE_XATTR); 11391001b347SHuajun Li if (ri->i_inline & F2FS_INLINE_DATA) 11401001b347SHuajun Li set_inode_flag(fi, FI_INLINE_DATA); 114134d67debSChao Yu if (ri->i_inline & F2FS_INLINE_DENTRY) 114234d67debSChao Yu set_inode_flag(fi, FI_INLINE_DENTRY); 1143b3d208f9SJaegeuk Kim if (ri->i_inline & F2FS_DATA_EXIST) 1144b3d208f9SJaegeuk Kim set_inode_flag(fi, FI_DATA_EXIST); 1145444c580fSJaegeuk Kim } 1146444c580fSJaegeuk Kim 1147444c580fSJaegeuk Kim static inline void set_raw_inline(struct f2fs_inode_info *fi, 1148444c580fSJaegeuk Kim struct f2fs_inode *ri) 1149444c580fSJaegeuk Kim { 1150444c580fSJaegeuk Kim ri->i_inline = 0; 1151444c580fSJaegeuk Kim 1152444c580fSJaegeuk Kim if (is_inode_flag_set(fi, FI_INLINE_XATTR)) 1153444c580fSJaegeuk Kim ri->i_inline |= F2FS_INLINE_XATTR; 11541001b347SHuajun Li if (is_inode_flag_set(fi, FI_INLINE_DATA)) 11551001b347SHuajun Li ri->i_inline |= F2FS_INLINE_DATA; 115634d67debSChao Yu if (is_inode_flag_set(fi, FI_INLINE_DENTRY)) 115734d67debSChao Yu ri->i_inline |= F2FS_INLINE_DENTRY; 1158b3d208f9SJaegeuk Kim if (is_inode_flag_set(fi, FI_DATA_EXIST)) 1159b3d208f9SJaegeuk Kim ri->i_inline |= F2FS_DATA_EXIST; 1160444c580fSJaegeuk Kim } 1161444c580fSJaegeuk Kim 1162987c7c31SChao Yu static inline int f2fs_has_inline_xattr(struct inode *inode) 1163987c7c31SChao Yu { 1164987c7c31SChao Yu return is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR); 1165987c7c31SChao Yu } 1166987c7c31SChao Yu 1167de93653fSJaegeuk Kim static inline unsigned int addrs_per_inode(struct f2fs_inode_info *fi) 1168de93653fSJaegeuk Kim { 1169987c7c31SChao Yu if (f2fs_has_inline_xattr(&fi->vfs_inode)) 1170de93653fSJaegeuk Kim return DEF_ADDRS_PER_INODE - F2FS_INLINE_XATTR_ADDRS; 1171de93653fSJaegeuk Kim return DEF_ADDRS_PER_INODE; 1172de93653fSJaegeuk Kim } 1173de93653fSJaegeuk Kim 117465985d93SJaegeuk Kim static inline void *inline_xattr_addr(struct page *page) 117565985d93SJaegeuk Kim { 1176695fd1edSChao Yu struct f2fs_inode *ri = F2FS_INODE(page); 117765985d93SJaegeuk Kim return (void *)&(ri->i_addr[DEF_ADDRS_PER_INODE - 117865985d93SJaegeuk Kim F2FS_INLINE_XATTR_ADDRS]); 117965985d93SJaegeuk Kim } 118065985d93SJaegeuk Kim 118165985d93SJaegeuk Kim static inline int inline_xattr_size(struct inode *inode) 118265985d93SJaegeuk Kim { 1183987c7c31SChao Yu if (f2fs_has_inline_xattr(inode)) 118465985d93SJaegeuk Kim return F2FS_INLINE_XATTR_ADDRS << 2; 118565985d93SJaegeuk Kim else 118665985d93SJaegeuk Kim return 0; 118765985d93SJaegeuk Kim } 118865985d93SJaegeuk Kim 11890dbdc2aeSJaegeuk Kim static inline int f2fs_has_inline_data(struct inode *inode) 11900dbdc2aeSJaegeuk Kim { 11910dbdc2aeSJaegeuk Kim return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA); 11920dbdc2aeSJaegeuk Kim } 11930dbdc2aeSJaegeuk Kim 1194b3d208f9SJaegeuk Kim static inline void f2fs_clear_inline_inode(struct inode *inode) 1195b3d208f9SJaegeuk Kim { 1196b3d208f9SJaegeuk Kim clear_inode_flag(F2FS_I(inode), FI_INLINE_DATA); 1197b3d208f9SJaegeuk Kim clear_inode_flag(F2FS_I(inode), FI_DATA_EXIST); 1198b3d208f9SJaegeuk Kim } 1199b3d208f9SJaegeuk Kim 1200b3d208f9SJaegeuk Kim static inline int f2fs_exist_data(struct inode *inode) 1201b3d208f9SJaegeuk Kim { 1202b3d208f9SJaegeuk Kim return is_inode_flag_set(F2FS_I(inode), FI_DATA_EXIST); 1203b3d208f9SJaegeuk Kim } 1204b3d208f9SJaegeuk Kim 120588b88a66SJaegeuk Kim static inline bool f2fs_is_atomic_file(struct inode *inode) 120688b88a66SJaegeuk Kim { 120788b88a66SJaegeuk Kim return is_inode_flag_set(F2FS_I(inode), FI_ATOMIC_FILE); 120888b88a66SJaegeuk Kim } 120988b88a66SJaegeuk Kim 121002a1335fSJaegeuk Kim static inline bool f2fs_is_volatile_file(struct inode *inode) 121102a1335fSJaegeuk Kim { 121202a1335fSJaegeuk Kim return is_inode_flag_set(F2FS_I(inode), FI_VOLATILE_FILE); 121302a1335fSJaegeuk Kim } 121402a1335fSJaegeuk Kim 12151001b347SHuajun Li static inline void *inline_data_addr(struct page *page) 12161001b347SHuajun Li { 1217695fd1edSChao Yu struct f2fs_inode *ri = F2FS_INODE(page); 12181001b347SHuajun Li return (void *)&(ri->i_addr[1]); 12191001b347SHuajun Li } 12201001b347SHuajun Li 122134d67debSChao Yu static inline int f2fs_has_inline_dentry(struct inode *inode) 122234d67debSChao Yu { 122334d67debSChao Yu return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DENTRY); 122434d67debSChao Yu } 122534d67debSChao Yu 122634d67debSChao Yu static inline void *inline_dentry_addr(struct page *page) 122734d67debSChao Yu { 122834d67debSChao Yu struct f2fs_inode *ri = F2FS_INODE(page); 122934d67debSChao Yu return (void *)&(ri->i_addr[1]); 123034d67debSChao Yu } 123134d67debSChao Yu 123277888c1eSJaegeuk Kim static inline int f2fs_readonly(struct super_block *sb) 123377888c1eSJaegeuk Kim { 123477888c1eSJaegeuk Kim return sb->s_flags & MS_RDONLY; 123577888c1eSJaegeuk Kim } 123677888c1eSJaegeuk Kim 12371e968fdfSJaegeuk Kim static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi) 12381e968fdfSJaegeuk Kim { 12391e968fdfSJaegeuk Kim return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); 12401e968fdfSJaegeuk Kim } 12411e968fdfSJaegeuk Kim 1242744602cfSJaegeuk Kim static inline void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi) 1243744602cfSJaegeuk Kim { 1244744602cfSJaegeuk Kim set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); 1245744602cfSJaegeuk Kim sbi->sb->s_flags |= MS_RDONLY; 1246744602cfSJaegeuk Kim } 1247744602cfSJaegeuk Kim 1248a6dda0e6SChristoph Hellwig #define get_inode_mode(i) \ 1249a6dda0e6SChristoph Hellwig ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \ 1250a6dda0e6SChristoph Hellwig (F2FS_I(i)->i_acl_mode) : ((i)->i_mode)) 1251a6dda0e6SChristoph Hellwig 1252267378d4SChao Yu /* get offset of first page in next direct node */ 1253267378d4SChao Yu #define PGOFS_OF_NEXT_DNODE(pgofs, fi) \ 1254267378d4SChao Yu ((pgofs < ADDRS_PER_INODE(fi)) ? ADDRS_PER_INODE(fi) : \ 1255267378d4SChao Yu (pgofs - ADDRS_PER_INODE(fi) + ADDRS_PER_BLOCK) / \ 1256267378d4SChao Yu ADDRS_PER_BLOCK * ADDRS_PER_BLOCK + ADDRS_PER_INODE(fi)) 1257267378d4SChao Yu 125839a53e0cSJaegeuk Kim /* 125939a53e0cSJaegeuk Kim * file.c 126039a53e0cSJaegeuk Kim */ 126139a53e0cSJaegeuk Kim int f2fs_sync_file(struct file *, loff_t, loff_t, int); 126239a53e0cSJaegeuk Kim void truncate_data_blocks(struct dnode_of_data *); 1263764aa3e9SJaegeuk Kim int truncate_blocks(struct inode *, u64, bool); 126439a53e0cSJaegeuk Kim void f2fs_truncate(struct inode *); 12652d4d9fb5SJaegeuk Kim int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 126639a53e0cSJaegeuk Kim int f2fs_setattr(struct dentry *, struct iattr *); 126739a53e0cSJaegeuk Kim int truncate_hole(struct inode *, pgoff_t, pgoff_t); 1268b292dcabSJaegeuk Kim int truncate_data_blocks_range(struct dnode_of_data *, int); 126939a53e0cSJaegeuk Kim long f2fs_ioctl(struct file *, unsigned int, unsigned long); 1270e9750824SNamjae Jeon long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); 127139a53e0cSJaegeuk Kim 127239a53e0cSJaegeuk Kim /* 127339a53e0cSJaegeuk Kim * inode.c 127439a53e0cSJaegeuk Kim */ 127539a53e0cSJaegeuk Kim void f2fs_set_inode_flags(struct inode *); 127639a53e0cSJaegeuk Kim struct inode *f2fs_iget(struct super_block *, unsigned long); 12774660f9c0SJaegeuk Kim int try_to_free_nats(struct f2fs_sb_info *, int); 127839a53e0cSJaegeuk Kim void update_inode(struct inode *, struct page *); 1279744602cfSJaegeuk Kim void update_inode_page(struct inode *); 128039a53e0cSJaegeuk Kim int f2fs_write_inode(struct inode *, struct writeback_control *); 128139a53e0cSJaegeuk Kim void f2fs_evict_inode(struct inode *); 128244c16156SJaegeuk Kim void handle_failed_inode(struct inode *); 128339a53e0cSJaegeuk Kim 128439a53e0cSJaegeuk Kim /* 128539a53e0cSJaegeuk Kim * namei.c 128639a53e0cSJaegeuk Kim */ 128739a53e0cSJaegeuk Kim struct dentry *f2fs_get_parent(struct dentry *child); 128839a53e0cSJaegeuk Kim 128939a53e0cSJaegeuk Kim /* 129039a53e0cSJaegeuk Kim * dir.c 129139a53e0cSJaegeuk Kim */ 1292dbeacf02SChao Yu extern unsigned char f2fs_filetype_table[F2FS_FT_MAX]; 1293dbeacf02SChao Yu void set_de_type(struct f2fs_dir_entry *, struct inode *); 12947b3cd7d6SJaegeuk Kim struct f2fs_dir_entry *find_target_dentry(struct qstr *, int *, 12957b3cd7d6SJaegeuk Kim struct f2fs_dentry_ptr *); 12967b3cd7d6SJaegeuk Kim bool f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *, 12977b3cd7d6SJaegeuk Kim unsigned int); 1298062a3e7bSJaegeuk Kim void do_make_empty_dir(struct inode *, struct inode *, 1299062a3e7bSJaegeuk Kim struct f2fs_dentry_ptr *); 1300dbeacf02SChao Yu struct page *init_inode_metadata(struct inode *, struct inode *, 1301bce8d112SJaegeuk Kim const struct qstr *, struct page *); 1302dbeacf02SChao Yu void update_parent_metadata(struct inode *, struct inode *, unsigned int); 1303a82afa20SJaegeuk Kim int room_for_filename(const void *, int, int); 1304dbeacf02SChao Yu void f2fs_drop_nlink(struct inode *, struct inode *, struct page *); 130539a53e0cSJaegeuk Kim struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *, 130639a53e0cSJaegeuk Kim struct page **); 130739a53e0cSJaegeuk Kim struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **); 130839a53e0cSJaegeuk Kim ino_t f2fs_inode_by_name(struct inode *, struct qstr *); 130939a53e0cSJaegeuk Kim void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, 131039a53e0cSJaegeuk Kim struct page *, struct inode *); 13111cd14cafSJaegeuk Kim int update_dent_inode(struct inode *, const struct qstr *); 1312b7f7a5e0SAl Viro int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); 1313dbeacf02SChao Yu void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *, 1314dbeacf02SChao Yu struct inode *); 1315b97a9b5dSJaegeuk Kim int f2fs_do_tmpfile(struct inode *, struct inode *); 131639a53e0cSJaegeuk Kim int f2fs_make_empty(struct inode *, struct inode *); 131739a53e0cSJaegeuk Kim bool f2fs_empty_dir(struct inode *); 131839a53e0cSJaegeuk Kim 1319b7f7a5e0SAl Viro static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) 1320b7f7a5e0SAl Viro { 1321b7f7a5e0SAl Viro return __f2fs_add_link(dentry->d_parent->d_inode, &dentry->d_name, 1322b7f7a5e0SAl Viro inode); 1323b7f7a5e0SAl Viro } 1324b7f7a5e0SAl Viro 132539a53e0cSJaegeuk Kim /* 132639a53e0cSJaegeuk Kim * super.c 132739a53e0cSJaegeuk Kim */ 132839a53e0cSJaegeuk Kim int f2fs_sync_fs(struct super_block *, int); 1329a07ef784SNamjae Jeon extern __printf(3, 4) 1330a07ef784SNamjae Jeon void f2fs_msg(struct super_block *, const char *, const char *, ...); 133139a53e0cSJaegeuk Kim 133239a53e0cSJaegeuk Kim /* 133339a53e0cSJaegeuk Kim * hash.c 133439a53e0cSJaegeuk Kim */ 1335eee6160fSGu Zheng f2fs_hash_t f2fs_dentry_hash(const struct qstr *); 133639a53e0cSJaegeuk Kim 133739a53e0cSJaegeuk Kim /* 133839a53e0cSJaegeuk Kim * node.c 133939a53e0cSJaegeuk Kim */ 134039a53e0cSJaegeuk Kim struct dnode_of_data; 134139a53e0cSJaegeuk Kim struct node_info; 134239a53e0cSJaegeuk Kim 13436fb03f3aSJaegeuk Kim bool available_free_memory(struct f2fs_sb_info *, int); 134488bd02c9SJaegeuk Kim bool is_checkpointed_node(struct f2fs_sb_info *, nid_t); 134588bd02c9SJaegeuk Kim bool has_fsynced_inode(struct f2fs_sb_info *, nid_t); 134688bd02c9SJaegeuk Kim bool need_inode_block_update(struct f2fs_sb_info *, nid_t); 134739a53e0cSJaegeuk Kim void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); 134839a53e0cSJaegeuk Kim int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); 134939a53e0cSJaegeuk Kim int truncate_inode_blocks(struct inode *, pgoff_t); 13504f16fb0fSJaegeuk Kim int truncate_xattr_node(struct inode *, struct page *); 1351cfe58f9dSJaegeuk Kim int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t); 135258e674d6SGu Zheng void remove_inode_page(struct inode *); 1353a014e037SJaegeuk Kim struct page *new_inode_page(struct inode *); 13548ae8f162SJaegeuk Kim struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); 135539a53e0cSJaegeuk Kim void ra_node_page(struct f2fs_sb_info *, nid_t); 135639a53e0cSJaegeuk Kim struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); 135739a53e0cSJaegeuk Kim struct page *get_node_page_ra(struct page *, int); 135839a53e0cSJaegeuk Kim void sync_inode_page(struct dnode_of_data *); 135939a53e0cSJaegeuk Kim int sync_node_pages(struct f2fs_sb_info *, nid_t, struct writeback_control *); 136039a53e0cSJaegeuk Kim bool alloc_nid(struct f2fs_sb_info *, nid_t *); 136139a53e0cSJaegeuk Kim void alloc_nid_done(struct f2fs_sb_info *, nid_t); 136239a53e0cSJaegeuk Kim void alloc_nid_failed(struct f2fs_sb_info *, nid_t); 136370cfed88SChao Yu void recover_inline_xattr(struct inode *, struct page *); 13641c35a90eSJaegeuk Kim void recover_xattr_data(struct inode *, struct page *, block_t); 136539a53e0cSJaegeuk Kim int recover_inode_page(struct f2fs_sb_info *, struct page *); 136639a53e0cSJaegeuk Kim int restore_node_summary(struct f2fs_sb_info *, unsigned int, 136739a53e0cSJaegeuk Kim struct f2fs_summary_block *); 136839a53e0cSJaegeuk Kim void flush_nat_entries(struct f2fs_sb_info *); 136939a53e0cSJaegeuk Kim int build_node_manager(struct f2fs_sb_info *); 137039a53e0cSJaegeuk Kim void destroy_node_manager(struct f2fs_sb_info *); 13716e6093a8SNamjae Jeon int __init create_node_manager_caches(void); 137239a53e0cSJaegeuk Kim void destroy_node_manager_caches(void); 137339a53e0cSJaegeuk Kim 137439a53e0cSJaegeuk Kim /* 137539a53e0cSJaegeuk Kim * segment.c 137639a53e0cSJaegeuk Kim */ 137788b88a66SJaegeuk Kim void register_inmem_page(struct inode *, struct page *); 1378cbcb2872SJaegeuk Kim void invalidate_inmem_page(struct inode *, struct page *); 137988b88a66SJaegeuk Kim void commit_inmem_pages(struct inode *, bool); 138039a53e0cSJaegeuk Kim void f2fs_balance_fs(struct f2fs_sb_info *); 13814660f9c0SJaegeuk Kim void f2fs_balance_fs_bg(struct f2fs_sb_info *); 13826b4afdd7SJaegeuk Kim int f2fs_issue_flush(struct f2fs_sb_info *); 13832163d198SGu Zheng int create_flush_cmd_control(struct f2fs_sb_info *); 13842163d198SGu Zheng void destroy_flush_cmd_control(struct f2fs_sb_info *); 138539a53e0cSJaegeuk Kim void invalidate_blocks(struct f2fs_sb_info *, block_t); 13865e443818SJaegeuk Kim void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); 138739a53e0cSJaegeuk Kim void clear_prefree_segments(struct f2fs_sb_info *); 13884b2fecc8SJaegeuk Kim void release_discard_addrs(struct f2fs_sb_info *); 1389cf2271e7SJaegeuk Kim void discard_next_dnode(struct f2fs_sb_info *, block_t); 139039a53e0cSJaegeuk Kim int npages_for_summary_flush(struct f2fs_sb_info *); 139139a53e0cSJaegeuk Kim void allocate_new_segments(struct f2fs_sb_info *); 13924b2fecc8SJaegeuk Kim int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); 139339a53e0cSJaegeuk Kim struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); 1394577e3495SJaegeuk Kim void write_meta_page(struct f2fs_sb_info *, struct page *); 1395fb5566daSJaegeuk Kim void write_node_page(struct f2fs_sb_info *, struct page *, 1396fb5566daSJaegeuk Kim struct f2fs_io_info *, unsigned int, block_t, block_t *); 1397458e6197SJaegeuk Kim void write_data_page(struct page *, struct dnode_of_data *, block_t *, 1398458e6197SJaegeuk Kim struct f2fs_io_info *); 1399458e6197SJaegeuk Kim void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *); 140039a53e0cSJaegeuk Kim void recover_data_page(struct f2fs_sb_info *, struct page *, 140139a53e0cSJaegeuk Kim struct f2fs_summary *, block_t, block_t); 1402bfad7c2dSJaegeuk Kim void allocate_data_block(struct f2fs_sb_info *, struct page *, 1403bfad7c2dSJaegeuk Kim block_t, block_t *, struct f2fs_summary *, int); 14045514f0aaSYuan Zhong void f2fs_wait_on_page_writeback(struct page *, enum page_type); 140539a53e0cSJaegeuk Kim void write_data_summaries(struct f2fs_sb_info *, block_t); 140639a53e0cSJaegeuk Kim void write_node_summaries(struct f2fs_sb_info *, block_t); 140739a53e0cSJaegeuk Kim int lookup_journal_in_cursum(struct f2fs_summary_block *, 140839a53e0cSJaegeuk Kim int, unsigned int, int); 14094b2fecc8SJaegeuk Kim void flush_sit_entries(struct f2fs_sb_info *, struct cp_control *); 141039a53e0cSJaegeuk Kim int build_segment_manager(struct f2fs_sb_info *); 141139a53e0cSJaegeuk Kim void destroy_segment_manager(struct f2fs_sb_info *); 14127fd9e544SJaegeuk Kim int __init create_segment_manager_caches(void); 14137fd9e544SJaegeuk Kim void destroy_segment_manager_caches(void); 141439a53e0cSJaegeuk Kim 141539a53e0cSJaegeuk Kim /* 141639a53e0cSJaegeuk Kim * checkpoint.c 141739a53e0cSJaegeuk Kim */ 141839a53e0cSJaegeuk Kim struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); 141939a53e0cSJaegeuk Kim struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); 14204c521f49SJaegeuk Kim struct page *get_meta_page_ra(struct f2fs_sb_info *, pgoff_t); 14214c521f49SJaegeuk Kim int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int); 142239a53e0cSJaegeuk Kim long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); 1423fff04f90SJaegeuk Kim void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 1424fff04f90SJaegeuk Kim void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 14256f12ac25SJaegeuk Kim void release_dirty_inode(struct f2fs_sb_info *); 1426fff04f90SJaegeuk Kim bool exist_written_data(struct f2fs_sb_info *, nid_t, int); 1427cbd56e7dSJaegeuk Kim int acquire_orphan_inode(struct f2fs_sb_info *); 1428cbd56e7dSJaegeuk Kim void release_orphan_inode(struct f2fs_sb_info *); 142939a53e0cSJaegeuk Kim void add_orphan_inode(struct f2fs_sb_info *, nid_t); 143039a53e0cSJaegeuk Kim void remove_orphan_inode(struct f2fs_sb_info *, nid_t); 14318f99a946SChao Yu void recover_orphan_inodes(struct f2fs_sb_info *); 143239a53e0cSJaegeuk Kim int get_valid_checkpoint(struct f2fs_sb_info *); 1433a7ffdbe2SJaegeuk Kim void update_dirty_page(struct inode *, struct page *); 14345deb8267SJaegeuk Kim void add_dirty_dir_inode(struct inode *); 143539a53e0cSJaegeuk Kim void remove_dirty_dir_inode(struct inode *); 143639a53e0cSJaegeuk Kim void sync_dirty_dir_inodes(struct f2fs_sb_info *); 143775ab4cb8SJaegeuk Kim void write_checkpoint(struct f2fs_sb_info *, struct cp_control *); 14386451e041SJaegeuk Kim void init_ino_entry_info(struct f2fs_sb_info *); 14396e6093a8SNamjae Jeon int __init create_checkpoint_caches(void); 144039a53e0cSJaegeuk Kim void destroy_checkpoint_caches(void); 144139a53e0cSJaegeuk Kim 144239a53e0cSJaegeuk Kim /* 144339a53e0cSJaegeuk Kim * data.c 144439a53e0cSJaegeuk Kim */ 1445458e6197SJaegeuk Kim void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int); 144693dfe2acSJaegeuk Kim int f2fs_submit_page_bio(struct f2fs_sb_info *, struct page *, block_t, int); 144793dfe2acSJaegeuk Kim void f2fs_submit_page_mbio(struct f2fs_sb_info *, struct page *, block_t, 1448458e6197SJaegeuk Kim struct f2fs_io_info *); 144939a53e0cSJaegeuk Kim int reserve_new_block(struct dnode_of_data *); 1450b600965cSHuajun Li int f2fs_reserve_block(struct dnode_of_data *, pgoff_t); 145139a53e0cSJaegeuk Kim void update_extent_cache(block_t, struct dnode_of_data *); 1452c718379bSJaegeuk Kim struct page *find_data_page(struct inode *, pgoff_t, bool); 145339a53e0cSJaegeuk Kim struct page *get_lock_data_page(struct inode *, pgoff_t); 145464aa7ed9SJaegeuk Kim struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool); 1455458e6197SJaegeuk Kim int do_write_data_page(struct page *, struct f2fs_io_info *); 14569ab70134SJaegeuk Kim int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64); 145739a53e0cSJaegeuk Kim 145839a53e0cSJaegeuk Kim /* 145939a53e0cSJaegeuk Kim * gc.c 146039a53e0cSJaegeuk Kim */ 146139a53e0cSJaegeuk Kim int start_gc_thread(struct f2fs_sb_info *); 146239a53e0cSJaegeuk Kim void stop_gc_thread(struct f2fs_sb_info *); 1463de93653fSJaegeuk Kim block_t start_bidx_of_node(unsigned int, struct f2fs_inode_info *); 1464408e9375SJaegeuk Kim int f2fs_gc(struct f2fs_sb_info *); 146539a53e0cSJaegeuk Kim void build_gc_manager(struct f2fs_sb_info *); 14666e6093a8SNamjae Jeon int __init create_gc_caches(void); 146739a53e0cSJaegeuk Kim void destroy_gc_caches(void); 146839a53e0cSJaegeuk Kim 146939a53e0cSJaegeuk Kim /* 147039a53e0cSJaegeuk Kim * recovery.c 147139a53e0cSJaegeuk Kim */ 14726ead1142SJaegeuk Kim int recover_fsync_data(struct f2fs_sb_info *); 147339a53e0cSJaegeuk Kim bool space_for_roll_forward(struct f2fs_sb_info *); 147439a53e0cSJaegeuk Kim 147539a53e0cSJaegeuk Kim /* 147639a53e0cSJaegeuk Kim * debug.c 147739a53e0cSJaegeuk Kim */ 147839a53e0cSJaegeuk Kim #ifdef CONFIG_F2FS_STAT_FS 147939a53e0cSJaegeuk Kim struct f2fs_stat_info { 148039a53e0cSJaegeuk Kim struct list_head stat_list; 148139a53e0cSJaegeuk Kim struct f2fs_sb_info *sbi; 148239a53e0cSJaegeuk Kim int all_area_segs, sit_area_segs, nat_area_segs, ssa_area_segs; 148339a53e0cSJaegeuk Kim int main_area_segs, main_area_sections, main_area_zones; 148439a53e0cSJaegeuk Kim int hit_ext, total_ext; 148539a53e0cSJaegeuk Kim int ndirty_node, ndirty_dent, ndirty_dirs, ndirty_meta; 148639a53e0cSJaegeuk Kim int nats, sits, fnids; 148739a53e0cSJaegeuk Kim int total_count, utilization; 14883289c061SJaegeuk Kim int bg_gc, inline_inode, inline_dir; 148939a53e0cSJaegeuk Kim unsigned int valid_count, valid_node_count, valid_inode_count; 149039a53e0cSJaegeuk Kim unsigned int bimodal, avg_vblocks; 149139a53e0cSJaegeuk Kim int util_free, util_valid, util_invalid; 149239a53e0cSJaegeuk Kim int rsvd_segs, overp_segs; 149339a53e0cSJaegeuk Kim int dirty_count, node_pages, meta_pages; 1494942e0be6SChangman Lee int prefree_count, call_count, cp_count; 149539a53e0cSJaegeuk Kim int tot_segs, node_segs, data_segs, free_segs, free_secs; 149639a53e0cSJaegeuk Kim int tot_blks, data_blks, node_blks; 149739a53e0cSJaegeuk Kim int curseg[NR_CURSEG_TYPE]; 149839a53e0cSJaegeuk Kim int cursec[NR_CURSEG_TYPE]; 149939a53e0cSJaegeuk Kim int curzone[NR_CURSEG_TYPE]; 150039a53e0cSJaegeuk Kim 150139a53e0cSJaegeuk Kim unsigned int segment_count[2]; 150239a53e0cSJaegeuk Kim unsigned int block_count[2]; 150339a53e0cSJaegeuk Kim unsigned base_mem, cache_mem; 150439a53e0cSJaegeuk Kim }; 150539a53e0cSJaegeuk Kim 1506963d4f7dSGu Zheng static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) 1507963d4f7dSGu Zheng { 1508963d4f7dSGu Zheng return (struct f2fs_stat_info *)sbi->stat_info; 1509963d4f7dSGu Zheng } 1510963d4f7dSGu Zheng 1511942e0be6SChangman Lee #define stat_inc_cp_count(si) ((si)->cp_count++) 151239a53e0cSJaegeuk Kim #define stat_inc_call_count(si) ((si)->call_count++) 1513dcdfff65SJaegeuk Kim #define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++) 1514dcdfff65SJaegeuk Kim #define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++) 1515dcdfff65SJaegeuk Kim #define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--) 1516dcdfff65SJaegeuk Kim #define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++) 1517dcdfff65SJaegeuk Kim #define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++) 15180dbdc2aeSJaegeuk Kim #define stat_inc_inline_inode(inode) \ 15190dbdc2aeSJaegeuk Kim do { \ 15200dbdc2aeSJaegeuk Kim if (f2fs_has_inline_data(inode)) \ 15214081363fSJaegeuk Kim ((F2FS_I_SB(inode))->inline_inode++); \ 15220dbdc2aeSJaegeuk Kim } while (0) 15230dbdc2aeSJaegeuk Kim #define stat_dec_inline_inode(inode) \ 15240dbdc2aeSJaegeuk Kim do { \ 15250dbdc2aeSJaegeuk Kim if (f2fs_has_inline_data(inode)) \ 15264081363fSJaegeuk Kim ((F2FS_I_SB(inode))->inline_inode--); \ 15270dbdc2aeSJaegeuk Kim } while (0) 15283289c061SJaegeuk Kim #define stat_inc_inline_dir(inode) \ 15293289c061SJaegeuk Kim do { \ 15303289c061SJaegeuk Kim if (f2fs_has_inline_dentry(inode)) \ 15313289c061SJaegeuk Kim ((F2FS_I_SB(inode))->inline_dir++); \ 15323289c061SJaegeuk Kim } while (0) 15333289c061SJaegeuk Kim #define stat_dec_inline_dir(inode) \ 15343289c061SJaegeuk Kim do { \ 15353289c061SJaegeuk Kim if (f2fs_has_inline_dentry(inode)) \ 15363289c061SJaegeuk Kim ((F2FS_I_SB(inode))->inline_dir--); \ 15373289c061SJaegeuk Kim } while (0) 1538dcdfff65SJaegeuk Kim #define stat_inc_seg_type(sbi, curseg) \ 1539dcdfff65SJaegeuk Kim ((sbi)->segment_count[(curseg)->alloc_type]++) 1540dcdfff65SJaegeuk Kim #define stat_inc_block_count(sbi, curseg) \ 1541dcdfff65SJaegeuk Kim ((sbi)->block_count[(curseg)->alloc_type]++) 154239a53e0cSJaegeuk Kim 154339a53e0cSJaegeuk Kim #define stat_inc_seg_count(sbi, type) \ 154439a53e0cSJaegeuk Kim do { \ 1545963d4f7dSGu Zheng struct f2fs_stat_info *si = F2FS_STAT(sbi); \ 154639a53e0cSJaegeuk Kim (si)->tot_segs++; \ 154739a53e0cSJaegeuk Kim if (type == SUM_TYPE_DATA) \ 154839a53e0cSJaegeuk Kim si->data_segs++; \ 154939a53e0cSJaegeuk Kim else \ 155039a53e0cSJaegeuk Kim si->node_segs++; \ 155139a53e0cSJaegeuk Kim } while (0) 155239a53e0cSJaegeuk Kim 155339a53e0cSJaegeuk Kim #define stat_inc_tot_blk_count(si, blks) \ 155439a53e0cSJaegeuk Kim (si->tot_blks += (blks)) 155539a53e0cSJaegeuk Kim 155639a53e0cSJaegeuk Kim #define stat_inc_data_blk_count(sbi, blks) \ 155739a53e0cSJaegeuk Kim do { \ 1558963d4f7dSGu Zheng struct f2fs_stat_info *si = F2FS_STAT(sbi); \ 155939a53e0cSJaegeuk Kim stat_inc_tot_blk_count(si, blks); \ 156039a53e0cSJaegeuk Kim si->data_blks += (blks); \ 156139a53e0cSJaegeuk Kim } while (0) 156239a53e0cSJaegeuk Kim 156339a53e0cSJaegeuk Kim #define stat_inc_node_blk_count(sbi, blks) \ 156439a53e0cSJaegeuk Kim do { \ 1565963d4f7dSGu Zheng struct f2fs_stat_info *si = F2FS_STAT(sbi); \ 156639a53e0cSJaegeuk Kim stat_inc_tot_blk_count(si, blks); \ 156739a53e0cSJaegeuk Kim si->node_blks += (blks); \ 156839a53e0cSJaegeuk Kim } while (0) 156939a53e0cSJaegeuk Kim 157039a53e0cSJaegeuk Kim int f2fs_build_stats(struct f2fs_sb_info *); 157139a53e0cSJaegeuk Kim void f2fs_destroy_stats(struct f2fs_sb_info *); 15726e6093a8SNamjae Jeon void __init f2fs_create_root_stats(void); 15734589d25dSNamjae Jeon void f2fs_destroy_root_stats(void); 157439a53e0cSJaegeuk Kim #else 1575942e0be6SChangman Lee #define stat_inc_cp_count(si) 157639a53e0cSJaegeuk Kim #define stat_inc_call_count(si) 1577dcdfff65SJaegeuk Kim #define stat_inc_bggc_count(si) 1578dcdfff65SJaegeuk Kim #define stat_inc_dirty_dir(sbi) 1579dcdfff65SJaegeuk Kim #define stat_dec_dirty_dir(sbi) 1580dcdfff65SJaegeuk Kim #define stat_inc_total_hit(sb) 1581dcdfff65SJaegeuk Kim #define stat_inc_read_hit(sb) 15820dbdc2aeSJaegeuk Kim #define stat_inc_inline_inode(inode) 15830dbdc2aeSJaegeuk Kim #define stat_dec_inline_inode(inode) 15843289c061SJaegeuk Kim #define stat_inc_inline_dir(inode) 15853289c061SJaegeuk Kim #define stat_dec_inline_dir(inode) 1586dcdfff65SJaegeuk Kim #define stat_inc_seg_type(sbi, curseg) 1587dcdfff65SJaegeuk Kim #define stat_inc_block_count(sbi, curseg) 158839a53e0cSJaegeuk Kim #define stat_inc_seg_count(si, type) 158939a53e0cSJaegeuk Kim #define stat_inc_tot_blk_count(si, blks) 159039a53e0cSJaegeuk Kim #define stat_inc_data_blk_count(si, blks) 159139a53e0cSJaegeuk Kim #define stat_inc_node_blk_count(sbi, blks) 159239a53e0cSJaegeuk Kim 159339a53e0cSJaegeuk Kim static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; } 159439a53e0cSJaegeuk Kim static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { } 15956e6093a8SNamjae Jeon static inline void __init f2fs_create_root_stats(void) { } 15964589d25dSNamjae Jeon static inline void f2fs_destroy_root_stats(void) { } 159739a53e0cSJaegeuk Kim #endif 159839a53e0cSJaegeuk Kim 159939a53e0cSJaegeuk Kim extern const struct file_operations f2fs_dir_operations; 160039a53e0cSJaegeuk Kim extern const struct file_operations f2fs_file_operations; 160139a53e0cSJaegeuk Kim extern const struct inode_operations f2fs_file_inode_operations; 160239a53e0cSJaegeuk Kim extern const struct address_space_operations f2fs_dblock_aops; 160339a53e0cSJaegeuk Kim extern const struct address_space_operations f2fs_node_aops; 160439a53e0cSJaegeuk Kim extern const struct address_space_operations f2fs_meta_aops; 160539a53e0cSJaegeuk Kim extern const struct inode_operations f2fs_dir_inode_operations; 160639a53e0cSJaegeuk Kim extern const struct inode_operations f2fs_symlink_inode_operations; 160739a53e0cSJaegeuk Kim extern const struct inode_operations f2fs_special_inode_operations; 16081001b347SHuajun Li 1609e18c65b2SHuajun Li /* 1610e18c65b2SHuajun Li * inline.c 1611e18c65b2SHuajun Li */ 1612e18c65b2SHuajun Li bool f2fs_may_inline(struct inode *); 1613b3d208f9SJaegeuk Kim void read_inline_data(struct page *, struct page *); 1614e18c65b2SHuajun Li int f2fs_read_inline_data(struct inode *, struct page *); 1615b3d208f9SJaegeuk Kim int f2fs_convert_inline_page(struct dnode_of_data *, struct page *); 1616b3d208f9SJaegeuk Kim int f2fs_convert_inline_inode(struct inode *); 1617b3d208f9SJaegeuk Kim int f2fs_write_inline_data(struct inode *, struct page *); 1618b3d208f9SJaegeuk Kim void truncate_inline_data(struct page *, u64); 16190342fd30SJaegeuk Kim bool recover_inline_data(struct inode *, struct page *); 1620201a05beSChao Yu struct f2fs_dir_entry *find_in_inline_dir(struct inode *, struct qstr *, 1621201a05beSChao Yu struct page **); 1622201a05beSChao Yu struct f2fs_dir_entry *f2fs_parent_inline_dir(struct inode *, struct page **); 1623201a05beSChao Yu int make_empty_inline_dir(struct inode *inode, struct inode *, struct page *); 1624201a05beSChao Yu int f2fs_add_inline_entry(struct inode *, const struct qstr *, struct inode *); 1625201a05beSChao Yu void f2fs_delete_inline_entry(struct f2fs_dir_entry *, struct page *, 1626201a05beSChao Yu struct inode *, struct inode *); 1627201a05beSChao Yu bool f2fs_empty_inline_dir(struct inode *); 1628201a05beSChao Yu int f2fs_read_inline_dir(struct file *, struct dir_context *); 162939a53e0cSJaegeuk Kim #endif 1630