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