f2fs.h (8df22a4d6f5b81c9c1703579d4907b57002689ed) | f2fs.h (88b88a66797159949cec32eaab12b4968f6fae2d) |
---|---|
1/* 2 * fs/f2fs/f2fs.h 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 7 unchanged lines hidden (view full) --- 16#include <linux/buffer_head.h> 17#include <linux/slab.h> 18#include <linux/crc32.h> 19#include <linux/magic.h> 20#include <linux/kobject.h> 21#include <linux/sched.h> 22 23#ifdef CONFIG_F2FS_CHECK_FS | 1/* 2 * fs/f2fs/f2fs.h 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 7 unchanged lines hidden (view full) --- 16#include <linux/buffer_head.h> 17#include <linux/slab.h> 18#include <linux/crc32.h> 19#include <linux/magic.h> 20#include <linux/kobject.h> 21#include <linux/sched.h> 22 23#ifdef CONFIG_F2FS_CHECK_FS |
24#define f2fs_bug_on(condition) BUG_ON(condition) | 24#define f2fs_bug_on(sbi, condition) BUG_ON(condition) |
25#define f2fs_down_write(x, y) down_write_nest_lock(x, y) 26#else | 25#define f2fs_down_write(x, y) down_write_nest_lock(x, y) 26#else |
27#define f2fs_bug_on(condition) WARN_ON(condition) | 27#define f2fs_bug_on(sbi, condition) \ 28 do { \ 29 if (unlikely(condition)) { \ 30 WARN_ON(1); \ 31 sbi->need_fsck = true; \ 32 } \ 33 } while (0) |
28#define f2fs_down_write(x, y) down_write(x) 29#endif 30 31/* 32 * For mount options 33 */ 34#define F2FS_MOUNT_BG_GC 0x00000001 35#define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002 --- 49 unchanged lines hidden (view full) --- 85/* 86 * For checkpoint manager 87 */ 88enum { 89 NAT_BITMAP, 90 SIT_BITMAP 91}; 92 | 34#define f2fs_down_write(x, y) down_write(x) 35#endif 36 37/* 38 * For mount options 39 */ 40#define F2FS_MOUNT_BG_GC 0x00000001 41#define F2FS_MOUNT_DISABLE_ROLL_FORWARD 0x00000002 --- 49 unchanged lines hidden (view full) --- 91/* 92 * For checkpoint manager 93 */ 94enum { 95 NAT_BITMAP, 96 SIT_BITMAP 97}; 98 |
99enum { 100 CP_UMOUNT, 101 CP_SYNC, 102 CP_DISCARD, 103}; 104 105struct cp_control { 106 int reason; 107 __u64 trim_start; 108 __u64 trim_end; 109 __u64 trim_minlen; 110 __u64 trimmed; 111}; 112 |
|
93/* 94 * For CP/NAT/SIT/SSA readahead 95 */ 96enum { 97 META_CP, 98 META_NAT, 99 META_SIT, | 113/* 114 * For CP/NAT/SIT/SSA readahead 115 */ 116enum { 117 META_CP, 118 META_NAT, 119 META_SIT, |
100 META_SSA | 120 META_SSA, 121 META_POR, |
101}; 102 103/* for the list of ino */ 104enum { 105 ORPHAN_INO, /* for orphan ino list */ 106 APPEND_INO, /* for append ino list */ 107 UPDATE_INO, /* for update ino list */ 108 MAX_INO_ENTRY, /* max. list */ --- 16 unchanged lines hidden (view full) --- 125 block_t blkaddr; /* block address to be discarded */ 126 int len; /* # of consecutive blocks of the discard */ 127}; 128 129/* for the list of fsync inodes, used only during recovery */ 130struct fsync_inode_entry { 131 struct list_head list; /* list head */ 132 struct inode *inode; /* vfs inode pointer */ | 122}; 123 124/* for the list of ino */ 125enum { 126 ORPHAN_INO, /* for orphan ino list */ 127 APPEND_INO, /* for append ino list */ 128 UPDATE_INO, /* for update ino list */ 129 MAX_INO_ENTRY, /* max. list */ --- 16 unchanged lines hidden (view full) --- 146 block_t blkaddr; /* block address to be discarded */ 147 int len; /* # of consecutive blocks of the discard */ 148}; 149 150/* for the list of fsync inodes, used only during recovery */ 151struct fsync_inode_entry { 152 struct list_head list; /* list head */ 153 struct inode *inode; /* vfs inode pointer */ |
133 block_t blkaddr; /* block address locating the last inode */ | 154 block_t blkaddr; /* block address locating the last fsync */ 155 block_t last_dentry; /* block address locating the last dentry */ 156 block_t last_inode; /* block address locating the last inode */ |
134}; 135 136#define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats)) 137#define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits)) 138 139#define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne) 140#define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid) 141#define sit_in_journal(sum, i) (sum->sit_j.entries[i].se) 142#define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno) 143 | 157}; 158 159#define nats_in_cursum(sum) (le16_to_cpu(sum->n_nats)) 160#define sits_in_cursum(sum) (le16_to_cpu(sum->n_sits)) 161 162#define nat_in_journal(sum, i) (sum->nat_j.entries[i].ne) 163#define nid_in_journal(sum, i) (sum->nat_j.entries[i].nid) 164#define sit_in_journal(sum, i) (sum->sit_j.entries[i].se) 165#define segno_in_journal(sum, i) (sum->sit_j.entries[i].segno) 166 |
167#define MAX_NAT_JENTRIES(sum) (NAT_JOURNAL_ENTRIES - nats_in_cursum(sum)) 168#define MAX_SIT_JENTRIES(sum) (SIT_JOURNAL_ENTRIES - sits_in_cursum(sum)) 169 |
|
144static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i) 145{ 146 int before = nats_in_cursum(rs); 147 rs->n_nats = cpu_to_le16(before + i); 148 return before; 149} 150 151static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i) 152{ 153 int before = sits_in_cursum(rs); 154 rs->n_sits = cpu_to_le16(before + i); 155 return before; 156} 157 | 170static inline int update_nats_in_cursum(struct f2fs_summary_block *rs, int i) 171{ 172 int before = nats_in_cursum(rs); 173 rs->n_nats = cpu_to_le16(before + i); 174 return before; 175} 176 177static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i) 178{ 179 int before = sits_in_cursum(rs); 180 rs->n_sits = cpu_to_le16(before + i); 181 return before; 182} 183 |
184static inline bool __has_cursum_space(struct f2fs_summary_block *sum, int size, 185 int type) 186{ 187 if (type == NAT_JOURNAL) 188 return size <= MAX_NAT_JENTRIES(sum); 189 return size <= MAX_SIT_JENTRIES(sum); 190} 191 |
|
158/* 159 * ioctl commands 160 */ | 192/* 193 * ioctl commands 194 */ |
161#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS 162#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS | 195#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS 196#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS |
163 | 197 |
198#define F2FS_IOCTL_MAGIC 0xf5 199#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) 200#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) 201 |
|
164#if defined(__KERNEL__) && defined(CONFIG_COMPAT) 165/* 166 * ioctl commands in 32 bit emulation 167 */ 168#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS 169#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS 170#endif 171 --- 45 unchanged lines hidden (view full) --- 217 unsigned char i_dir_level; /* use for dentry level for large dir */ 218 unsigned int i_current_depth; /* use only in directory structure */ 219 unsigned int i_pino; /* parent inode number */ 220 umode_t i_acl_mode; /* keep file acl mode temporarily */ 221 222 /* Use below internally in f2fs*/ 223 unsigned long flags; /* use to pass per-file flags */ 224 struct rw_semaphore i_sem; /* protect fi info */ | 202#if defined(__KERNEL__) && defined(CONFIG_COMPAT) 203/* 204 * ioctl commands in 32 bit emulation 205 */ 206#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS 207#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS 208#endif 209 --- 45 unchanged lines hidden (view full) --- 255 unsigned char i_dir_level; /* use for dentry level for large dir */ 256 unsigned int i_current_depth; /* use only in directory structure */ 257 unsigned int i_pino; /* parent inode number */ 258 umode_t i_acl_mode; /* keep file acl mode temporarily */ 259 260 /* Use below internally in f2fs*/ 261 unsigned long flags; /* use to pass per-file flags */ 262 struct rw_semaphore i_sem; /* protect fi info */ |
225 atomic_t dirty_dents; /* # of dirty dentry pages */ | 263 atomic_t dirty_pages; /* # of dirty pages */ |
226 f2fs_hash_t chash; /* hash value of given file name */ 227 unsigned int clevel; /* maximum level of given file name */ 228 nid_t i_xattr_nid; /* node id that contains xattrs */ 229 unsigned long long xattr_ver; /* cp version of xattr modification */ 230 struct extent_info ext; /* in-memory extent cache entry */ 231 struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */ | 264 f2fs_hash_t chash; /* hash value of given file name */ 265 unsigned int clevel; /* maximum level of given file name */ 266 nid_t i_xattr_nid; /* node id that contains xattrs */ 267 unsigned long long xattr_ver; /* cp version of xattr modification */ 268 struct extent_info ext; /* in-memory extent cache entry */ 269 struct dir_inode_entry *dirty_dir; /* the pointer of dirty dir */ |
270 271 struct list_head inmem_pages; /* inmemory pages managed by f2fs */ 272 struct mutex inmem_lock; /* lock for inmemory pages */ |
|
232}; 233 234static inline void get_extent_info(struct extent_info *ext, 235 struct f2fs_extent i_ext) 236{ 237 write_lock(&ext->ext_lock); 238 ext->fofs = le32_to_cpu(i_ext.fofs); 239 ext->blk_addr = le32_to_cpu(i_ext.blk_addr); --- 15 unchanged lines hidden (view full) --- 255 block_t nat_blkaddr; /* base disk address of NAT */ 256 nid_t max_nid; /* maximum possible node ids */ 257 nid_t available_nids; /* maximum available node ids */ 258 nid_t next_scan_nid; /* the next nid to be scanned */ 259 unsigned int ram_thresh; /* control the memory footprint */ 260 261 /* NAT cache management */ 262 struct radix_tree_root nat_root;/* root of the nat entry cache */ | 273}; 274 275static inline void get_extent_info(struct extent_info *ext, 276 struct f2fs_extent i_ext) 277{ 278 write_lock(&ext->ext_lock); 279 ext->fofs = le32_to_cpu(i_ext.fofs); 280 ext->blk_addr = le32_to_cpu(i_ext.blk_addr); --- 15 unchanged lines hidden (view full) --- 296 block_t nat_blkaddr; /* base disk address of NAT */ 297 nid_t max_nid; /* maximum possible node ids */ 298 nid_t available_nids; /* maximum available node ids */ 299 nid_t next_scan_nid; /* the next nid to be scanned */ 300 unsigned int ram_thresh; /* control the memory footprint */ 301 302 /* NAT cache management */ 303 struct radix_tree_root nat_root;/* root of the nat entry cache */ |
304 struct radix_tree_root nat_set_root;/* root of the nat set cache */ |
|
263 rwlock_t nat_tree_lock; /* protect nat_tree_lock */ | 305 rwlock_t nat_tree_lock; /* protect nat_tree_lock */ |
264 unsigned int nat_cnt; /* the # of cached nat entries */ | |
265 struct list_head nat_entries; /* cached nat entry list (clean) */ | 306 struct list_head nat_entries; /* cached nat entry list (clean) */ |
266 struct list_head dirty_nat_entries; /* cached nat entry list (dirty) */ 267 struct list_head nat_entry_set; /* nat entry set list */ | 307 unsigned int nat_cnt; /* the # of cached nat entries */ |
268 unsigned int dirty_nat_cnt; /* total num of nat entries in set */ 269 270 /* free node ids management */ 271 struct radix_tree_root free_nid_root;/* root of the free_nid cache */ 272 struct list_head free_nid_list; /* a list for free nids */ 273 spinlock_t free_nid_list_lock; /* protect free nid list */ 274 unsigned int fcnt; /* the number of free node id */ 275 struct mutex build_lock; /* lock for build free nids */ --- 51 unchanged lines hidden (view full) --- 327 CURSEG_COLD_DATA, /* multimedia or GCed data blocks */ 328 CURSEG_HOT_NODE, /* direct node blocks of directory files */ 329 CURSEG_WARM_NODE, /* direct node blocks of normal files */ 330 CURSEG_COLD_NODE, /* indirect node blocks */ 331 NO_CHECK_TYPE 332}; 333 334struct flush_cmd { | 308 unsigned int dirty_nat_cnt; /* total num of nat entries in set */ 309 310 /* free node ids management */ 311 struct radix_tree_root free_nid_root;/* root of the free_nid cache */ 312 struct list_head free_nid_list; /* a list for free nids */ 313 spinlock_t free_nid_list_lock; /* protect free nid list */ 314 unsigned int fcnt; /* the number of free node id */ 315 struct mutex build_lock; /* lock for build free nids */ --- 51 unchanged lines hidden (view full) --- 367 CURSEG_COLD_DATA, /* multimedia or GCed data blocks */ 368 CURSEG_HOT_NODE, /* direct node blocks of directory files */ 369 CURSEG_WARM_NODE, /* direct node blocks of normal files */ 370 CURSEG_COLD_NODE, /* indirect node blocks */ 371 NO_CHECK_TYPE 372}; 373 374struct flush_cmd { |
335 struct flush_cmd *next; | |
336 struct completion wait; | 375 struct completion wait; |
376 struct llist_node llnode; |
|
337 int ret; 338}; 339 340struct flush_cmd_control { 341 struct task_struct *f2fs_issue_flush; /* flush thread */ 342 wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */ | 377 int ret; 378}; 379 380struct flush_cmd_control { 381 struct task_struct *f2fs_issue_flush; /* flush thread */ 382 wait_queue_head_t flush_wait_queue; /* waiting queue for wake-up */ |
343 struct flush_cmd *issue_list; /* list for command issue */ 344 struct flush_cmd *dispatch_list; /* list for command dispatch */ 345 spinlock_t issue_lock; /* for issue list lock */ 346 struct flush_cmd *issue_tail; /* list tail of issue list */ | 383 struct llist_head issue_list; /* list for command issue */ 384 struct llist_node *dispatch_list; /* list for command dispatch */ |
347}; 348 349struct f2fs_sm_info { 350 struct sit_info *sit_info; /* whole segment information */ 351 struct free_segmap_info *free_info; /* free segment information */ 352 struct dirty_seglist_info *dirty_info; /* dirty segment information */ 353 struct curseg_info *curseg_array; /* active segment information */ 354 --- 9 unchanged lines hidden (view full) --- 364 /* a threshold to reclaim prefree segments */ 365 unsigned int rec_prefree_segments; 366 367 /* for small discard management */ 368 struct list_head discard_list; /* 4KB discard list */ 369 int nr_discards; /* # of discards in the list */ 370 int max_discards; /* max. discards to be issued */ 371 | 385}; 386 387struct f2fs_sm_info { 388 struct sit_info *sit_info; /* whole segment information */ 389 struct free_segmap_info *free_info; /* free segment information */ 390 struct dirty_seglist_info *dirty_info; /* dirty segment information */ 391 struct curseg_info *curseg_array; /* active segment information */ 392 --- 9 unchanged lines hidden (view full) --- 402 /* a threshold to reclaim prefree segments */ 403 unsigned int rec_prefree_segments; 404 405 /* for small discard management */ 406 struct list_head discard_list; /* 4KB discard list */ 407 int nr_discards; /* # of discards in the list */ 408 int max_discards; /* max. discards to be issued */ 409 |
410 struct list_head sit_entry_set; /* sit entry set list */ 411 |
|
372 unsigned int ipu_policy; /* in-place-update policy */ 373 unsigned int min_ipu_util; /* in-place-update threshold */ | 412 unsigned int ipu_policy; /* in-place-update policy */ 413 unsigned int min_ipu_util; /* in-place-update threshold */ |
414 unsigned int min_fsync_blocks; /* threshold for fsync */ |
|
374 375 /* for flush command control */ 376 struct flush_cmd_control *cmd_control_info; 377 378}; 379 380/* 381 * For superblock --- 47 unchanged lines hidden (view full) --- 429}; 430 431struct f2fs_sb_info { 432 struct super_block *sb; /* pointer to VFS super block */ 433 struct proc_dir_entry *s_proc; /* proc entry */ 434 struct buffer_head *raw_super_buf; /* buffer head of raw sb */ 435 struct f2fs_super_block *raw_super; /* raw super block pointer */ 436 int s_dirty; /* dirty flag for checkpoint */ | 415 416 /* for flush command control */ 417 struct flush_cmd_control *cmd_control_info; 418 419}; 420 421/* 422 * For superblock --- 47 unchanged lines hidden (view full) --- 470}; 471 472struct f2fs_sb_info { 473 struct super_block *sb; /* pointer to VFS super block */ 474 struct proc_dir_entry *s_proc; /* proc entry */ 475 struct buffer_head *raw_super_buf; /* buffer head of raw sb */ 476 struct f2fs_super_block *raw_super; /* raw super block pointer */ 477 int s_dirty; /* dirty flag for checkpoint */ |
478 bool need_fsck; /* need fsck.f2fs to fix */ |
|
437 438 /* for node-related operations */ 439 struct f2fs_nm_info *nm_info; /* node manager */ 440 struct inode *node_inode; /* cache node blocks */ 441 442 /* for segment-related operations */ 443 struct f2fs_sm_info *sm_info; /* segment manager */ 444 --- 89 unchanged lines hidden (view full) --- 534 return container_of(inode, struct f2fs_inode_info, vfs_inode); 535} 536 537static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb) 538{ 539 return sb->s_fs_info; 540} 541 | 479 480 /* for node-related operations */ 481 struct f2fs_nm_info *nm_info; /* node manager */ 482 struct inode *node_inode; /* cache node blocks */ 483 484 /* for segment-related operations */ 485 struct f2fs_sm_info *sm_info; /* segment manager */ 486 --- 89 unchanged lines hidden (view full) --- 576 return container_of(inode, struct f2fs_inode_info, vfs_inode); 577} 578 579static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb) 580{ 581 return sb->s_fs_info; 582} 583 |
584static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode) 585{ 586 return F2FS_SB(inode->i_sb); 587} 588 589static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping) 590{ 591 return F2FS_I_SB(mapping->host); 592} 593 594static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page) 595{ 596 return F2FS_M_SB(page->mapping); 597} 598 |
|
542static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) 543{ 544 return (struct f2fs_super_block *)(sbi->raw_super); 545} 546 547static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi) 548{ 549 return (struct f2fs_checkpoint *)(sbi->ckpt); --- 148 unchanged lines hidden (view full) --- 698 return true; 699} 700 701static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, 702 struct inode *inode, 703 blkcnt_t count) 704{ 705 spin_lock(&sbi->stat_lock); | 599static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) 600{ 601 return (struct f2fs_super_block *)(sbi->raw_super); 602} 603 604static inline struct f2fs_checkpoint *F2FS_CKPT(struct f2fs_sb_info *sbi) 605{ 606 return (struct f2fs_checkpoint *)(sbi->ckpt); --- 148 unchanged lines hidden (view full) --- 755 return true; 756} 757 758static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, 759 struct inode *inode, 760 blkcnt_t count) 761{ 762 spin_lock(&sbi->stat_lock); |
706 f2fs_bug_on(sbi->total_valid_block_count < (block_t) count); 707 f2fs_bug_on(inode->i_blocks < count); | 763 f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count); 764 f2fs_bug_on(sbi, inode->i_blocks < count); |
708 inode->i_blocks -= count; 709 sbi->total_valid_block_count -= (block_t)count; 710 spin_unlock(&sbi->stat_lock); 711} 712 713static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type) 714{ 715 atomic_inc(&sbi->nr_pages[count_type]); 716 F2FS_SET_SB_DIRT(sbi); 717} 718 | 765 inode->i_blocks -= count; 766 sbi->total_valid_block_count -= (block_t)count; 767 spin_unlock(&sbi->stat_lock); 768} 769 770static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type) 771{ 772 atomic_inc(&sbi->nr_pages[count_type]); 773 F2FS_SET_SB_DIRT(sbi); 774} 775 |
719static inline void inode_inc_dirty_dents(struct inode *inode) | 776static inline void inode_inc_dirty_pages(struct inode *inode) |
720{ | 777{ |
721 inc_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS); 722 atomic_inc(&F2FS_I(inode)->dirty_dents); | 778 atomic_inc(&F2FS_I(inode)->dirty_pages); 779 if (S_ISDIR(inode->i_mode)) 780 inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS); |
723} 724 725static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type) 726{ 727 atomic_dec(&sbi->nr_pages[count_type]); 728} 729 | 781} 782 783static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type) 784{ 785 atomic_dec(&sbi->nr_pages[count_type]); 786} 787 |
730static inline void inode_dec_dirty_dents(struct inode *inode) | 788static inline void inode_dec_dirty_pages(struct inode *inode) |
731{ | 789{ |
732 if (!S_ISDIR(inode->i_mode)) | 790 if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode)) |
733 return; 734 | 791 return; 792 |
735 dec_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS); 736 atomic_dec(&F2FS_I(inode)->dirty_dents); | 793 atomic_dec(&F2FS_I(inode)->dirty_pages); 794 795 if (S_ISDIR(inode->i_mode)) 796 dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS); |
737} 738 739static inline int get_pages(struct f2fs_sb_info *sbi, int count_type) 740{ 741 return atomic_read(&sbi->nr_pages[count_type]); 742} 743 | 797} 798 799static inline int get_pages(struct f2fs_sb_info *sbi, int count_type) 800{ 801 return atomic_read(&sbi->nr_pages[count_type]); 802} 803 |
744static inline int get_dirty_dents(struct inode *inode) | 804static inline int get_dirty_pages(struct inode *inode) |
745{ | 805{ |
746 return atomic_read(&F2FS_I(inode)->dirty_dents); | 806 return atomic_read(&F2FS_I(inode)->dirty_pages); |
747} 748 749static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) 750{ 751 unsigned int pages_per_sec = sbi->segs_per_sec * 752 (1 << sbi->log_blocks_per_seg); 753 return ((get_pages(sbi, block_type) + pages_per_sec - 1) 754 >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; --- 88 unchanged lines hidden (view full) --- 843 return true; 844} 845 846static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, 847 struct inode *inode) 848{ 849 spin_lock(&sbi->stat_lock); 850 | 807} 808 809static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type) 810{ 811 unsigned int pages_per_sec = sbi->segs_per_sec * 812 (1 << sbi->log_blocks_per_seg); 813 return ((get_pages(sbi, block_type) + pages_per_sec - 1) 814 >> sbi->log_blocks_per_seg) / sbi->segs_per_sec; --- 88 unchanged lines hidden (view full) --- 903 return true; 904} 905 906static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, 907 struct inode *inode) 908{ 909 spin_lock(&sbi->stat_lock); 910 |
851 f2fs_bug_on(!sbi->total_valid_block_count); 852 f2fs_bug_on(!sbi->total_valid_node_count); 853 f2fs_bug_on(!inode->i_blocks); | 911 f2fs_bug_on(sbi, !sbi->total_valid_block_count); 912 f2fs_bug_on(sbi, !sbi->total_valid_node_count); 913 f2fs_bug_on(sbi, !inode->i_blocks); |
854 855 inode->i_blocks--; 856 sbi->total_valid_node_count--; 857 sbi->total_valid_block_count--; 858 859 spin_unlock(&sbi->stat_lock); 860} 861 862static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) 863{ 864 return sbi->total_valid_node_count; 865} 866 867static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) 868{ 869 spin_lock(&sbi->stat_lock); | 914 915 inode->i_blocks--; 916 sbi->total_valid_node_count--; 917 sbi->total_valid_block_count--; 918 919 spin_unlock(&sbi->stat_lock); 920} 921 922static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) 923{ 924 return sbi->total_valid_node_count; 925} 926 927static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) 928{ 929 spin_lock(&sbi->stat_lock); |
870 f2fs_bug_on(sbi->total_valid_inode_count == sbi->total_node_count); | 930 f2fs_bug_on(sbi, sbi->total_valid_inode_count == sbi->total_node_count); |
871 sbi->total_valid_inode_count++; 872 spin_unlock(&sbi->stat_lock); 873} 874 875static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) 876{ 877 spin_lock(&sbi->stat_lock); | 931 sbi->total_valid_inode_count++; 932 spin_unlock(&sbi->stat_lock); 933} 934 935static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) 936{ 937 spin_lock(&sbi->stat_lock); |
878 f2fs_bug_on(!sbi->total_valid_inode_count); | 938 f2fs_bug_on(sbi, !sbi->total_valid_inode_count); |
879 sbi->total_valid_inode_count--; 880 spin_unlock(&sbi->stat_lock); 881} 882 883static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) 884{ 885 return sbi->total_valid_inode_count; 886} 887 888static inline void f2fs_put_page(struct page *page, int unlock) 889{ 890 if (!page) 891 return; 892 893 if (unlock) { | 939 sbi->total_valid_inode_count--; 940 spin_unlock(&sbi->stat_lock); 941} 942 943static inline unsigned int valid_inode_count(struct f2fs_sb_info *sbi) 944{ 945 return sbi->total_valid_inode_count; 946} 947 948static inline void f2fs_put_page(struct page *page, int unlock) 949{ 950 if (!page) 951 return; 952 953 if (unlock) { |
894 f2fs_bug_on(!PageLocked(page)); | 954 f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page)); |
895 unlock_page(page); 896 } 897 page_cache_release(page); 898} 899 900static inline void f2fs_put_dnode(struct dnode_of_data *dn) 901{ 902 if (dn->node_page) --- 90 unchanged lines hidden (view full) --- 993 FI_NO_ALLOC, /* should not allocate any blocks */ 994 FI_UPDATE_DIR, /* should update inode block for consistency */ 995 FI_DELAY_IPUT, /* used for the recovery */ 996 FI_NO_EXTENT, /* not to use the extent cache */ 997 FI_INLINE_XATTR, /* used for inline xattr */ 998 FI_INLINE_DATA, /* used for inline data*/ 999 FI_APPEND_WRITE, /* inode has appended data */ 1000 FI_UPDATE_WRITE, /* inode has in-place-update data */ | 955 unlock_page(page); 956 } 957 page_cache_release(page); 958} 959 960static inline void f2fs_put_dnode(struct dnode_of_data *dn) 961{ 962 if (dn->node_page) --- 90 unchanged lines hidden (view full) --- 1053 FI_NO_ALLOC, /* should not allocate any blocks */ 1054 FI_UPDATE_DIR, /* should update inode block for consistency */ 1055 FI_DELAY_IPUT, /* used for the recovery */ 1056 FI_NO_EXTENT, /* not to use the extent cache */ 1057 FI_INLINE_XATTR, /* used for inline xattr */ 1058 FI_INLINE_DATA, /* used for inline data*/ 1059 FI_APPEND_WRITE, /* inode has appended data */ 1060 FI_UPDATE_WRITE, /* inode has in-place-update data */ |
1001 FI_NEED_IPU, /* used fo ipu for fdatasync */ | 1061 FI_NEED_IPU, /* used for ipu per file */ 1062 FI_ATOMIC_FILE, /* indicate atomic file */ |
1002}; 1003 1004static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) 1005{ 1006 if (!test_bit(flag, &fi->flags)) 1007 set_bit(flag, &fi->flags); 1008} 1009 --- 70 unchanged lines hidden (view full) --- 1080 return 0; 1081} 1082 1083static inline int f2fs_has_inline_data(struct inode *inode) 1084{ 1085 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA); 1086} 1087 | 1063}; 1064 1065static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) 1066{ 1067 if (!test_bit(flag, &fi->flags)) 1068 set_bit(flag, &fi->flags); 1069} 1070 --- 70 unchanged lines hidden (view full) --- 1141 return 0; 1142} 1143 1144static inline int f2fs_has_inline_data(struct inode *inode) 1145{ 1146 return is_inode_flag_set(F2FS_I(inode), FI_INLINE_DATA); 1147} 1148 |
1149static inline bool f2fs_is_atomic_file(struct inode *inode) 1150{ 1151 return is_inode_flag_set(F2FS_I(inode), FI_ATOMIC_FILE); 1152} 1153 |
|
1088static inline void *inline_data_addr(struct page *page) 1089{ 1090 struct f2fs_inode *ri = F2FS_INODE(page); 1091 return (void *)&(ri->i_addr[1]); 1092} 1093 1094static inline int f2fs_readonly(struct super_block *sb) 1095{ --- 40 unchanged lines hidden (view full) --- 1136 */ 1137void f2fs_set_inode_flags(struct inode *); 1138struct inode *f2fs_iget(struct super_block *, unsigned long); 1139int try_to_free_nats(struct f2fs_sb_info *, int); 1140void update_inode(struct inode *, struct page *); 1141void update_inode_page(struct inode *); 1142int f2fs_write_inode(struct inode *, struct writeback_control *); 1143void f2fs_evict_inode(struct inode *); | 1154static inline void *inline_data_addr(struct page *page) 1155{ 1156 struct f2fs_inode *ri = F2FS_INODE(page); 1157 return (void *)&(ri->i_addr[1]); 1158} 1159 1160static inline int f2fs_readonly(struct super_block *sb) 1161{ --- 40 unchanged lines hidden (view full) --- 1202 */ 1203void f2fs_set_inode_flags(struct inode *); 1204struct inode *f2fs_iget(struct super_block *, unsigned long); 1205int try_to_free_nats(struct f2fs_sb_info *, int); 1206void update_inode(struct inode *, struct page *); 1207void update_inode_page(struct inode *); 1208int f2fs_write_inode(struct inode *, struct writeback_control *); 1209void f2fs_evict_inode(struct inode *); |
1210void handle_failed_inode(struct inode *); |
|
1144 1145/* 1146 * namei.c 1147 */ 1148struct dentry *f2fs_get_parent(struct dentry *child); 1149 1150/* 1151 * dir.c --- 31 unchanged lines hidden (view full) --- 1183 1184/* 1185 * node.c 1186 */ 1187struct dnode_of_data; 1188struct node_info; 1189 1190bool available_free_memory(struct f2fs_sb_info *, int); | 1211 1212/* 1213 * namei.c 1214 */ 1215struct dentry *f2fs_get_parent(struct dentry *child); 1216 1217/* 1218 * dir.c --- 31 unchanged lines hidden (view full) --- 1250 1251/* 1252 * node.c 1253 */ 1254struct dnode_of_data; 1255struct node_info; 1256 1257bool available_free_memory(struct f2fs_sb_info *, int); |
1191int is_checkpointed_node(struct f2fs_sb_info *, nid_t); 1192bool fsync_mark_done(struct f2fs_sb_info *, nid_t); 1193void fsync_mark_clear(struct f2fs_sb_info *, nid_t); | 1258bool is_checkpointed_node(struct f2fs_sb_info *, nid_t); 1259bool has_fsynced_inode(struct f2fs_sb_info *, nid_t); 1260bool need_inode_block_update(struct f2fs_sb_info *, nid_t); |
1194void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); 1195int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); 1196int truncate_inode_blocks(struct inode *, pgoff_t); 1197int truncate_xattr_node(struct inode *, struct page *); 1198int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t); 1199void remove_inode_page(struct inode *); 1200struct page *new_inode_page(struct inode *); 1201struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); --- 14 unchanged lines hidden (view full) --- 1216int build_node_manager(struct f2fs_sb_info *); 1217void destroy_node_manager(struct f2fs_sb_info *); 1218int __init create_node_manager_caches(void); 1219void destroy_node_manager_caches(void); 1220 1221/* 1222 * segment.c 1223 */ | 1261void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); 1262int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); 1263int truncate_inode_blocks(struct inode *, pgoff_t); 1264int truncate_xattr_node(struct inode *, struct page *); 1265int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t); 1266void remove_inode_page(struct inode *); 1267struct page *new_inode_page(struct inode *); 1268struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); --- 14 unchanged lines hidden (view full) --- 1283int build_node_manager(struct f2fs_sb_info *); 1284void destroy_node_manager(struct f2fs_sb_info *); 1285int __init create_node_manager_caches(void); 1286void destroy_node_manager_caches(void); 1287 1288/* 1289 * segment.c 1290 */ |
1291void register_inmem_page(struct inode *, struct page *); 1292void commit_inmem_pages(struct inode *, bool); |
|
1224void f2fs_balance_fs(struct f2fs_sb_info *); 1225void f2fs_balance_fs_bg(struct f2fs_sb_info *); 1226int f2fs_issue_flush(struct f2fs_sb_info *); 1227int create_flush_cmd_control(struct f2fs_sb_info *); 1228void destroy_flush_cmd_control(struct f2fs_sb_info *); 1229void invalidate_blocks(struct f2fs_sb_info *, block_t); 1230void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); 1231void clear_prefree_segments(struct f2fs_sb_info *); | 1293void f2fs_balance_fs(struct f2fs_sb_info *); 1294void f2fs_balance_fs_bg(struct f2fs_sb_info *); 1295int f2fs_issue_flush(struct f2fs_sb_info *); 1296int create_flush_cmd_control(struct f2fs_sb_info *); 1297void destroy_flush_cmd_control(struct f2fs_sb_info *); 1298void invalidate_blocks(struct f2fs_sb_info *, block_t); 1299void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); 1300void clear_prefree_segments(struct f2fs_sb_info *); |
1301void release_discard_addrs(struct f2fs_sb_info *); |
|
1232void discard_next_dnode(struct f2fs_sb_info *, block_t); 1233int npages_for_summary_flush(struct f2fs_sb_info *); 1234void allocate_new_segments(struct f2fs_sb_info *); | 1302void discard_next_dnode(struct f2fs_sb_info *, block_t); 1303int npages_for_summary_flush(struct f2fs_sb_info *); 1304void allocate_new_segments(struct f2fs_sb_info *); |
1305int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); |
|
1235struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); 1236void write_meta_page(struct f2fs_sb_info *, struct page *); 1237void write_node_page(struct f2fs_sb_info *, struct page *, 1238 struct f2fs_io_info *, unsigned int, block_t, block_t *); 1239void write_data_page(struct page *, struct dnode_of_data *, block_t *, 1240 struct f2fs_io_info *); 1241void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *); 1242void recover_data_page(struct f2fs_sb_info *, struct page *, 1243 struct f2fs_summary *, block_t, block_t); 1244void allocate_data_block(struct f2fs_sb_info *, struct page *, 1245 block_t, block_t *, struct f2fs_summary *, int); 1246void f2fs_wait_on_page_writeback(struct page *, enum page_type); 1247void write_data_summaries(struct f2fs_sb_info *, block_t); 1248void write_node_summaries(struct f2fs_sb_info *, block_t); 1249int lookup_journal_in_cursum(struct f2fs_summary_block *, 1250 int, unsigned int, int); | 1306struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); 1307void write_meta_page(struct f2fs_sb_info *, struct page *); 1308void write_node_page(struct f2fs_sb_info *, struct page *, 1309 struct f2fs_io_info *, unsigned int, block_t, block_t *); 1310void write_data_page(struct page *, struct dnode_of_data *, block_t *, 1311 struct f2fs_io_info *); 1312void rewrite_data_page(struct page *, block_t, struct f2fs_io_info *); 1313void recover_data_page(struct f2fs_sb_info *, struct page *, 1314 struct f2fs_summary *, block_t, block_t); 1315void allocate_data_block(struct f2fs_sb_info *, struct page *, 1316 block_t, block_t *, struct f2fs_summary *, int); 1317void f2fs_wait_on_page_writeback(struct page *, enum page_type); 1318void write_data_summaries(struct f2fs_sb_info *, block_t); 1319void write_node_summaries(struct f2fs_sb_info *, block_t); 1320int lookup_journal_in_cursum(struct f2fs_summary_block *, 1321 int, unsigned int, int); |
1251void flush_sit_entries(struct f2fs_sb_info *); | 1322void flush_sit_entries(struct f2fs_sb_info *, struct cp_control *); |
1252int build_segment_manager(struct f2fs_sb_info *); 1253void destroy_segment_manager(struct f2fs_sb_info *); 1254int __init create_segment_manager_caches(void); 1255void destroy_segment_manager_caches(void); 1256 1257/* 1258 * checkpoint.c 1259 */ 1260struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); 1261struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); | 1323int build_segment_manager(struct f2fs_sb_info *); 1324void destroy_segment_manager(struct f2fs_sb_info *); 1325int __init create_segment_manager_caches(void); 1326void destroy_segment_manager_caches(void); 1327 1328/* 1329 * checkpoint.c 1330 */ 1331struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); 1332struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); |
1262int ra_meta_pages(struct f2fs_sb_info *, int, int, int); | 1333struct page *get_meta_page_ra(struct f2fs_sb_info *, pgoff_t); 1334int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int); |
1263long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); 1264void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 1265void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 1266void release_dirty_inode(struct f2fs_sb_info *); 1267bool exist_written_data(struct f2fs_sb_info *, nid_t, int); 1268int acquire_orphan_inode(struct f2fs_sb_info *); 1269void release_orphan_inode(struct f2fs_sb_info *); 1270void add_orphan_inode(struct f2fs_sb_info *, nid_t); 1271void remove_orphan_inode(struct f2fs_sb_info *, nid_t); 1272void recover_orphan_inodes(struct f2fs_sb_info *); 1273int get_valid_checkpoint(struct f2fs_sb_info *); | 1335long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); 1336void add_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 1337void remove_dirty_inode(struct f2fs_sb_info *, nid_t, int type); 1338void release_dirty_inode(struct f2fs_sb_info *); 1339bool exist_written_data(struct f2fs_sb_info *, nid_t, int); 1340int acquire_orphan_inode(struct f2fs_sb_info *); 1341void release_orphan_inode(struct f2fs_sb_info *); 1342void add_orphan_inode(struct f2fs_sb_info *, nid_t); 1343void remove_orphan_inode(struct f2fs_sb_info *, nid_t); 1344void recover_orphan_inodes(struct f2fs_sb_info *); 1345int get_valid_checkpoint(struct f2fs_sb_info *); |
1274void set_dirty_dir_page(struct inode *, struct page *); | 1346void update_dirty_page(struct inode *, struct page *); |
1275void add_dirty_dir_inode(struct inode *); 1276void remove_dirty_dir_inode(struct inode *); 1277void sync_dirty_dir_inodes(struct f2fs_sb_info *); | 1347void add_dirty_dir_inode(struct inode *); 1348void remove_dirty_dir_inode(struct inode *); 1349void sync_dirty_dir_inodes(struct f2fs_sb_info *); |
1278void write_checkpoint(struct f2fs_sb_info *, bool); | 1350void write_checkpoint(struct f2fs_sb_info *, struct cp_control *); |
1279void init_ino_entry_info(struct f2fs_sb_info *); 1280int __init create_checkpoint_caches(void); 1281void destroy_checkpoint_caches(void); 1282 1283/* 1284 * data.c 1285 */ 1286void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int); --- 67 unchanged lines hidden (view full) --- 1354#define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++) 1355#define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++) 1356#define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--) 1357#define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++) 1358#define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++) 1359#define stat_inc_inline_inode(inode) \ 1360 do { \ 1361 if (f2fs_has_inline_data(inode)) \ | 1351void init_ino_entry_info(struct f2fs_sb_info *); 1352int __init create_checkpoint_caches(void); 1353void destroy_checkpoint_caches(void); 1354 1355/* 1356 * data.c 1357 */ 1358void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int); --- 67 unchanged lines hidden (view full) --- 1426#define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++) 1427#define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++) 1428#define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--) 1429#define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++) 1430#define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++) 1431#define stat_inc_inline_inode(inode) \ 1432 do { \ 1433 if (f2fs_has_inline_data(inode)) \ |
1362 ((F2FS_SB(inode->i_sb))->inline_inode++); \ | 1434 ((F2FS_I_SB(inode))->inline_inode++); \ |
1363 } while (0) 1364#define stat_dec_inline_inode(inode) \ 1365 do { \ 1366 if (f2fs_has_inline_data(inode)) \ | 1435 } while (0) 1436#define stat_dec_inline_inode(inode) \ 1437 do { \ 1438 if (f2fs_has_inline_data(inode)) \ |
1367 ((F2FS_SB(inode->i_sb))->inline_inode--); \ | 1439 ((F2FS_I_SB(inode))->inline_inode--); \ |
1368 } while (0) 1369 1370#define stat_inc_seg_type(sbi, curseg) \ 1371 ((sbi)->segment_count[(curseg)->alloc_type]++) 1372#define stat_inc_block_count(sbi, curseg) \ 1373 ((sbi)->block_count[(curseg)->alloc_type]++) 1374 1375#define stat_inc_seg_count(sbi, type) \ --- 73 unchanged lines hidden --- | 1440 } while (0) 1441 1442#define stat_inc_seg_type(sbi, curseg) \ 1443 ((sbi)->segment_count[(curseg)->alloc_type]++) 1444#define stat_inc_block_count(sbi, curseg) \ 1445 ((sbi)->block_count[(curseg)->alloc_type]++) 1446 1447#define stat_inc_seg_count(sbi, type) \ --- 73 unchanged lines hidden --- |