aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/f2fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r--fs/f2fs/f2fs.h93
1 files changed, 58 insertions, 35 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 201c8d3b0f86..20aab02f2a42 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -125,11 +125,15 @@ static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
125 * file keeping -1 as its node offset to 125 * file keeping -1 as its node offset to
126 * distinguish from index node blocks. 126 * distinguish from index node blocks.
127 */ 127 */
128#define RDONLY_NODE 1 /* 128enum {
129 * specify a read-only mode when getting 129 ALLOC_NODE, /* allocate a new node page if needed */
130 * a node block. 0 is read-write mode. 130 LOOKUP_NODE, /* look up a node without readahead */
131 * used by get_dnode_of_data(). 131 LOOKUP_NODE_RA, /*
132 * look up a node with readahead called
133 * by get_datablock_ro.
132 */ 134 */
135};
136
133#define F2FS_LINK_MAX 32000 /* maximum link count per file */ 137#define F2FS_LINK_MAX 32000 /* maximum link count per file */
134 138
135/* for in-memory extent cache entry */ 139/* for in-memory extent cache entry */
@@ -144,6 +148,7 @@ struct extent_info {
144 * i_advise uses FADVISE_XXX_BIT. We can add additional hints later. 148 * i_advise uses FADVISE_XXX_BIT. We can add additional hints later.
145 */ 149 */
146#define FADVISE_COLD_BIT 0x01 150#define FADVISE_COLD_BIT 0x01
151#define FADVISE_CP_BIT 0x02
147 152
148struct f2fs_inode_info { 153struct f2fs_inode_info {
149 struct inode vfs_inode; /* serve a vfs inode */ 154 struct inode vfs_inode; /* serve a vfs inode */
@@ -155,7 +160,6 @@ struct f2fs_inode_info {
155 160
156 /* Use below internally in f2fs*/ 161 /* Use below internally in f2fs*/
157 unsigned long flags; /* use to pass per-file flags */ 162 unsigned long flags; /* use to pass per-file flags */
158 unsigned long long data_version;/* latest version of data for fsync */
159 atomic_t dirty_dents; /* # of dirty dentry pages */ 163 atomic_t dirty_dents; /* # of dirty dentry pages */
160 f2fs_hash_t chash; /* hash value of given file name */ 164 f2fs_hash_t chash; /* hash value of given file name */
161 unsigned int clevel; /* maximum level of given file name */ 165 unsigned int clevel; /* maximum level of given file name */
@@ -186,7 +190,6 @@ static inline void set_raw_extent(struct extent_info *ext,
186struct f2fs_nm_info { 190struct f2fs_nm_info {
187 block_t nat_blkaddr; /* base disk address of NAT */ 191 block_t nat_blkaddr; /* base disk address of NAT */
188 nid_t max_nid; /* maximum possible node ids */ 192 nid_t max_nid; /* maximum possible node ids */
189 nid_t init_scan_nid; /* the first nid to be scanned */
190 nid_t next_scan_nid; /* the next nid to be scanned */ 193 nid_t next_scan_nid; /* the next nid to be scanned */
191 194
192 /* NAT cache management */ 195 /* NAT cache management */
@@ -305,23 +308,12 @@ enum count_type {
305}; 308};
306 309
307/* 310/*
308 * FS_LOCK nesting subclasses for the lock validator: 311 * Uses as sbi->fs_lock[NR_GLOBAL_LOCKS].
309 * 312 * The checkpoint procedure blocks all the locks in this fs_lock array.
310 * The locking order between these classes is 313 * Some FS operations grab free locks, and if there is no free lock,
311 * RENAME -> DENTRY_OPS -> DATA_WRITE -> DATA_NEW 314 * then wait to grab a lock in a round-robin manner.
312 * -> DATA_TRUNC -> NODE_WRITE -> NODE_NEW -> NODE_TRUNC
313 */ 315 */
314enum lock_type { 316#define NR_GLOBAL_LOCKS 8
315 RENAME, /* for renaming operations */
316 DENTRY_OPS, /* for directory operations */
317 DATA_WRITE, /* for data write */
318 DATA_NEW, /* for data allocation */
319 DATA_TRUNC, /* for data truncate */
320 NODE_NEW, /* for node allocation */
321 NODE_TRUNC, /* for node truncate */
322 NODE_WRITE, /* for node write */
323 NR_LOCK_TYPE,
324};
325 317
326/* 318/*
327 * The below are the page types of bios used in submti_bio(). 319 * The below are the page types of bios used in submti_bio().
@@ -361,11 +353,13 @@ struct f2fs_sb_info {
361 /* for checkpoint */ 353 /* for checkpoint */
362 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ 354 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
363 struct inode *meta_inode; /* cache meta blocks */ 355 struct inode *meta_inode; /* cache meta blocks */
364 struct mutex cp_mutex; /* for checkpoint procedure */ 356 struct mutex cp_mutex; /* checkpoint procedure lock */
365 struct mutex fs_lock[NR_LOCK_TYPE]; /* for blocking FS operations */ 357 struct mutex fs_lock[NR_GLOBAL_LOCKS]; /* blocking FS operations */
366 struct mutex write_inode; /* mutex for write inode */ 358 struct mutex node_write; /* locking node writes */
367 struct mutex writepages; /* mutex for writepages() */ 359 struct mutex writepages; /* mutex for writepages() */
360 unsigned char next_lock_num; /* round-robin global locks */
368 int por_doing; /* recovery is doing or not */ 361 int por_doing; /* recovery is doing or not */
362 int on_build_free_nids; /* build_free_nids is doing */
369 363
370 /* for orphan inode management */ 364 /* for orphan inode management */
371 struct list_head orphan_inode_list; /* orphan inode list */ 365 struct list_head orphan_inode_list; /* orphan inode list */
@@ -406,6 +400,7 @@ struct f2fs_sb_info {
406 /* for cleaning operations */ 400 /* for cleaning operations */
407 struct mutex gc_mutex; /* mutex for GC */ 401 struct mutex gc_mutex; /* mutex for GC */
408 struct f2fs_gc_kthread *gc_thread; /* GC thread */ 402 struct f2fs_gc_kthread *gc_thread; /* GC thread */
403 unsigned int cur_victim_sec; /* current victim section num */
409 404
410 /* 405 /*
411 * for stat information. 406 * for stat information.
@@ -498,22 +493,51 @@ static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
498 cp->ckpt_flags = cpu_to_le32(ckpt_flags); 493 cp->ckpt_flags = cpu_to_le32(ckpt_flags);
499} 494}
500 495
501static inline void mutex_lock_op(struct f2fs_sb_info *sbi, enum lock_type t) 496static inline void mutex_lock_all(struct f2fs_sb_info *sbi)
502{ 497{
503 mutex_lock_nested(&sbi->fs_lock[t], t); 498 int i = 0;
499 for (; i < NR_GLOBAL_LOCKS; i++)
500 mutex_lock(&sbi->fs_lock[i]);
504} 501}
505 502
506static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, enum lock_type t) 503static inline void mutex_unlock_all(struct f2fs_sb_info *sbi)
507{ 504{
508 mutex_unlock(&sbi->fs_lock[t]); 505 int i = 0;
506 for (; i < NR_GLOBAL_LOCKS; i++)
507 mutex_unlock(&sbi->fs_lock[i]);
508}
509
510static inline int mutex_lock_op(struct f2fs_sb_info *sbi)
511{
512 unsigned char next_lock = sbi->next_lock_num % NR_GLOBAL_LOCKS;
513 int i = 0;
514
515 for (; i < NR_GLOBAL_LOCKS; i++)
516 if (mutex_trylock(&sbi->fs_lock[i]))
517 return i;
518
519 mutex_lock(&sbi->fs_lock[next_lock]);
520 sbi->next_lock_num++;
521 return next_lock;
522}
523
524static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, int ilock)
525{
526 if (ilock < 0)
527 return;
528 BUG_ON(ilock >= NR_GLOBAL_LOCKS);
529 mutex_unlock(&sbi->fs_lock[ilock]);
509} 530}
510 531
511/* 532/*
512 * Check whether the given nid is within node id range. 533 * Check whether the given nid is within node id range.
513 */ 534 */
514static inline void check_nid_range(struct f2fs_sb_info *sbi, nid_t nid) 535static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
515{ 536{
516 BUG_ON((nid >= NM_I(sbi)->max_nid)); 537 WARN_ON((nid >= NM_I(sbi)->max_nid));
538 if (nid >= NM_I(sbi)->max_nid)
539 return -EINVAL;
540 return 0;
517} 541}
518 542
519#define F2FS_DEFAULT_ALLOCATED_BLOCKS 1 543#define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
@@ -819,7 +843,6 @@ static inline int f2fs_clear_bit(unsigned int nr, char *addr)
819/* used for f2fs_inode_info->flags */ 843/* used for f2fs_inode_info->flags */
820enum { 844enum {
821 FI_NEW_INODE, /* indicate newly allocated inode */ 845 FI_NEW_INODE, /* indicate newly allocated inode */
822 FI_NEED_CP, /* need to do checkpoint during fsync */
823 FI_INC_LINK, /* need to increment i_nlink */ 846 FI_INC_LINK, /* need to increment i_nlink */
824 FI_ACL_MODE, /* indicate acl mode */ 847 FI_ACL_MODE, /* indicate acl mode */
825 FI_NO_ALLOC, /* should not allocate any blocks */ 848 FI_NO_ALLOC, /* should not allocate any blocks */
@@ -872,6 +895,7 @@ long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
872void f2fs_set_inode_flags(struct inode *); 895void f2fs_set_inode_flags(struct inode *);
873struct inode *f2fs_iget(struct super_block *, unsigned long); 896struct inode *f2fs_iget(struct super_block *, unsigned long);
874void update_inode(struct inode *, struct page *); 897void update_inode(struct inode *, struct page *);
898int update_inode_page(struct inode *);
875int f2fs_write_inode(struct inode *, struct writeback_control *); 899int f2fs_write_inode(struct inode *, struct writeback_control *);
876void f2fs_evict_inode(struct inode *); 900void f2fs_evict_inode(struct inode *);
877 901
@@ -973,7 +997,6 @@ int lookup_journal_in_cursum(struct f2fs_summary_block *,
973 int, unsigned int, int); 997 int, unsigned int, int);
974void flush_sit_entries(struct f2fs_sb_info *); 998void flush_sit_entries(struct f2fs_sb_info *);
975int build_segment_manager(struct f2fs_sb_info *); 999int build_segment_manager(struct f2fs_sb_info *);
976void reset_victim_segmap(struct f2fs_sb_info *);
977void destroy_segment_manager(struct f2fs_sb_info *); 1000void destroy_segment_manager(struct f2fs_sb_info *);
978 1001
979/* 1002/*
@@ -1000,7 +1023,7 @@ void destroy_checkpoint_caches(void);
1000 */ 1023 */
1001int reserve_new_block(struct dnode_of_data *); 1024int reserve_new_block(struct dnode_of_data *);
1002void update_extent_cache(block_t, struct dnode_of_data *); 1025void update_extent_cache(block_t, struct dnode_of_data *);
1003struct page *find_data_page(struct inode *, pgoff_t); 1026struct page *find_data_page(struct inode *, pgoff_t, bool);
1004struct page *get_lock_data_page(struct inode *, pgoff_t); 1027struct page *get_lock_data_page(struct inode *, pgoff_t);
1005struct page *get_new_data_page(struct inode *, pgoff_t, bool); 1028struct page *get_new_data_page(struct inode *, pgoff_t, bool);
1006int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int); 1029int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
@@ -1020,7 +1043,7 @@ void destroy_gc_caches(void);
1020/* 1043/*
1021 * recovery.c 1044 * recovery.c
1022 */ 1045 */
1023void recover_fsync_data(struct f2fs_sb_info *); 1046int recover_fsync_data(struct f2fs_sb_info *);
1024bool space_for_roll_forward(struct f2fs_sb_info *); 1047bool space_for_roll_forward(struct f2fs_sb_info *);
1025 1048
1026/* 1049/*