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.h66
1 files changed, 50 insertions, 16 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 20aab02f2a42..467d42d65c48 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -37,21 +37,35 @@
37 typecheck(unsigned long long, b) && \ 37 typecheck(unsigned long long, b) && \
38 ((long long)((a) - (b)) > 0)) 38 ((long long)((a) - (b)) > 0))
39 39
40typedef u64 block_t; 40typedef u32 block_t; /*
41 * should not change u32, since it is the on-disk block
42 * address format, __le32.
43 */
41typedef u32 nid_t; 44typedef u32 nid_t;
42 45
43struct f2fs_mount_info { 46struct f2fs_mount_info {
44 unsigned int opt; 47 unsigned int opt;
45}; 48};
46 49
47static inline __u32 f2fs_crc32(void *buff, size_t len) 50#define CRCPOLY_LE 0xedb88320
51
52static inline __u32 f2fs_crc32(void *buf, size_t len)
48{ 53{
49 return crc32_le(F2FS_SUPER_MAGIC, buff, len); 54 unsigned char *p = (unsigned char *)buf;
55 __u32 crc = F2FS_SUPER_MAGIC;
56 int i;
57
58 while (len--) {
59 crc ^= *p++;
60 for (i = 0; i < 8; i++)
61 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
62 }
63 return crc;
50} 64}
51 65
52static inline bool f2fs_crc_valid(__u32 blk_crc, void *buff, size_t buff_size) 66static inline bool f2fs_crc_valid(__u32 blk_crc, void *buf, size_t buf_size)
53{ 67{
54 return f2fs_crc32(buff, buff_size) == blk_crc; 68 return f2fs_crc32(buf, buf_size) == blk_crc;
55} 69}
56 70
57/* 71/*
@@ -148,7 +162,7 @@ struct extent_info {
148 * i_advise uses FADVISE_XXX_BIT. We can add additional hints later. 162 * i_advise uses FADVISE_XXX_BIT. We can add additional hints later.
149 */ 163 */
150#define FADVISE_COLD_BIT 0x01 164#define FADVISE_COLD_BIT 0x01
151#define FADVISE_CP_BIT 0x02 165#define FADVISE_LOST_PINO_BIT 0x02
152 166
153struct f2fs_inode_info { 167struct f2fs_inode_info {
154 struct inode vfs_inode; /* serve a vfs inode */ 168 struct inode vfs_inode; /* serve a vfs inode */
@@ -369,7 +383,6 @@ struct f2fs_sb_info {
369 /* for directory inode management */ 383 /* for directory inode management */
370 struct list_head dir_inode_list; /* dir inode list */ 384 struct list_head dir_inode_list; /* dir inode list */
371 spinlock_t dir_inode_lock; /* for dir inode list lock */ 385 spinlock_t dir_inode_lock; /* for dir inode list lock */
372 unsigned int n_dirty_dirs; /* # of dir inodes */
373 386
374 /* basic file system units */ 387 /* basic file system units */
375 unsigned int log_sectors_per_block; /* log2 sectors per block */ 388 unsigned int log_sectors_per_block; /* log2 sectors per block */
@@ -406,12 +419,15 @@ struct f2fs_sb_info {
406 * for stat information. 419 * for stat information.
407 * one is for the LFS mode, and the other is for the SSR mode. 420 * one is for the LFS mode, and the other is for the SSR mode.
408 */ 421 */
422#ifdef CONFIG_F2FS_STAT_FS
409 struct f2fs_stat_info *stat_info; /* FS status information */ 423 struct f2fs_stat_info *stat_info; /* FS status information */
410 unsigned int segment_count[2]; /* # of allocated segments */ 424 unsigned int segment_count[2]; /* # of allocated segments */
411 unsigned int block_count[2]; /* # of allocated blocks */ 425 unsigned int block_count[2]; /* # of allocated blocks */
412 unsigned int last_victim[2]; /* last victim segment # */
413 int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ 426 int total_hit_ext, read_hit_ext; /* extent cache hit ratio */
414 int bg_gc; /* background gc calls */ 427 int bg_gc; /* background gc calls */
428 unsigned int n_dirty_dirs; /* # of dir inodes */
429#endif
430 unsigned int last_victim[2]; /* last victim segment # */
415 spinlock_t stat_lock; /* lock for stat operations */ 431 spinlock_t stat_lock; /* lock for stat operations */
416}; 432};
417 433
@@ -495,9 +511,17 @@ static inline void clear_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
495 511
496static inline void mutex_lock_all(struct f2fs_sb_info *sbi) 512static inline void mutex_lock_all(struct f2fs_sb_info *sbi)
497{ 513{
498 int i = 0; 514 int i;
499 for (; i < NR_GLOBAL_LOCKS; i++) 515
500 mutex_lock(&sbi->fs_lock[i]); 516 for (i = 0; i < NR_GLOBAL_LOCKS; i++) {
517 /*
518 * This is the only time we take multiple fs_lock[]
519 * instances; the order is immaterial since we
520 * always hold cp_mutex, which serializes multiple
521 * such operations.
522 */
523 mutex_lock_nest_lock(&sbi->fs_lock[i], &sbi->cp_mutex);
524 }
501} 525}
502 526
503static inline void mutex_unlock_all(struct f2fs_sb_info *sbi) 527static inline void mutex_unlock_all(struct f2fs_sb_info *sbi)
@@ -843,9 +867,12 @@ static inline int f2fs_clear_bit(unsigned int nr, char *addr)
843/* used for f2fs_inode_info->flags */ 867/* used for f2fs_inode_info->flags */
844enum { 868enum {
845 FI_NEW_INODE, /* indicate newly allocated inode */ 869 FI_NEW_INODE, /* indicate newly allocated inode */
870 FI_DIRTY_INODE, /* indicate inode is dirty or not */
846 FI_INC_LINK, /* need to increment i_nlink */ 871 FI_INC_LINK, /* need to increment i_nlink */
847 FI_ACL_MODE, /* indicate acl mode */ 872 FI_ACL_MODE, /* indicate acl mode */
848 FI_NO_ALLOC, /* should not allocate any blocks */ 873 FI_NO_ALLOC, /* should not allocate any blocks */
874 FI_UPDATE_DIR, /* should update inode block for consistency */
875 FI_DELAY_IPUT, /* used for the recovery */
849}; 876};
850 877
851static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) 878static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
@@ -878,14 +905,21 @@ static inline int cond_clear_inode_flag(struct f2fs_inode_info *fi, int flag)
878 return 0; 905 return 0;
879} 906}
880 907
908static inline int f2fs_readonly(struct super_block *sb)
909{
910 return sb->s_flags & MS_RDONLY;
911}
912
881/* 913/*
882 * file.c 914 * file.c
883 */ 915 */
884int f2fs_sync_file(struct file *, loff_t, loff_t, int); 916int f2fs_sync_file(struct file *, loff_t, loff_t, int);
885void truncate_data_blocks(struct dnode_of_data *); 917void truncate_data_blocks(struct dnode_of_data *);
886void f2fs_truncate(struct inode *); 918void f2fs_truncate(struct inode *);
919int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
887int f2fs_setattr(struct dentry *, struct iattr *); 920int f2fs_setattr(struct dentry *, struct iattr *);
888int truncate_hole(struct inode *, pgoff_t, pgoff_t); 921int truncate_hole(struct inode *, pgoff_t, pgoff_t);
922int truncate_data_blocks_range(struct dnode_of_data *, int);
889long f2fs_ioctl(struct file *, unsigned int, unsigned long); 923long f2fs_ioctl(struct file *, unsigned int, unsigned long);
890long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); 924long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
891 925
@@ -913,7 +947,6 @@ struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **);
913ino_t f2fs_inode_by_name(struct inode *, struct qstr *); 947ino_t f2fs_inode_by_name(struct inode *, struct qstr *);
914void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, 948void f2fs_set_link(struct inode *, struct f2fs_dir_entry *,
915 struct page *, struct inode *); 949 struct page *, struct inode *);
916void init_dent_inode(const struct qstr *, struct page *);
917int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); 950int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *);
918void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); 951void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *);
919int f2fs_make_empty(struct inode *, struct inode *); 952int f2fs_make_empty(struct inode *, struct inode *);
@@ -948,8 +981,8 @@ void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
948int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); 981int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int);
949int truncate_inode_blocks(struct inode *, pgoff_t); 982int truncate_inode_blocks(struct inode *, pgoff_t);
950int remove_inode_page(struct inode *); 983int remove_inode_page(struct inode *);
951int new_inode_page(struct inode *, const struct qstr *); 984struct page *new_inode_page(struct inode *, const struct qstr *);
952struct page *new_node_page(struct dnode_of_data *, unsigned int); 985struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *);
953void ra_node_page(struct f2fs_sb_info *, nid_t); 986void ra_node_page(struct f2fs_sb_info *, nid_t);
954struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); 987struct page *get_node_page(struct f2fs_sb_info *, pgoff_t);
955struct page *get_node_page_ra(struct page *, int); 988struct page *get_node_page_ra(struct page *, int);
@@ -974,7 +1007,6 @@ void destroy_node_manager_caches(void);
974 */ 1007 */
975void f2fs_balance_fs(struct f2fs_sb_info *); 1008void f2fs_balance_fs(struct f2fs_sb_info *);
976void invalidate_blocks(struct f2fs_sb_info *, block_t); 1009void invalidate_blocks(struct f2fs_sb_info *, block_t);
977void locate_dirty_segment(struct f2fs_sb_info *, unsigned int);
978void clear_prefree_segments(struct f2fs_sb_info *); 1010void clear_prefree_segments(struct f2fs_sb_info *);
979int npages_for_summary_flush(struct f2fs_sb_info *); 1011int npages_for_summary_flush(struct f2fs_sb_info *);
980void allocate_new_segments(struct f2fs_sb_info *); 1012void allocate_new_segments(struct f2fs_sb_info *);
@@ -1011,7 +1043,9 @@ void remove_orphan_inode(struct f2fs_sb_info *, nid_t);
1011int recover_orphan_inodes(struct f2fs_sb_info *); 1043int recover_orphan_inodes(struct f2fs_sb_info *);
1012int get_valid_checkpoint(struct f2fs_sb_info *); 1044int get_valid_checkpoint(struct f2fs_sb_info *);
1013void set_dirty_dir_page(struct inode *, struct page *); 1045void set_dirty_dir_page(struct inode *, struct page *);
1046void add_dirty_dir_inode(struct inode *);
1014void remove_dirty_dir_inode(struct inode *); 1047void remove_dirty_dir_inode(struct inode *);
1048struct inode *check_dirty_dir_inode(struct f2fs_sb_info *, nid_t);
1015void sync_dirty_dir_inodes(struct f2fs_sb_info *); 1049void sync_dirty_dir_inodes(struct f2fs_sb_info *);
1016void write_checkpoint(struct f2fs_sb_info *, bool); 1050void write_checkpoint(struct f2fs_sb_info *, bool);
1017void init_orphan_info(struct f2fs_sb_info *); 1051void init_orphan_info(struct f2fs_sb_info *);
@@ -1025,7 +1059,7 @@ int reserve_new_block(struct dnode_of_data *);
1025void update_extent_cache(block_t, struct dnode_of_data *); 1059void update_extent_cache(block_t, struct dnode_of_data *);
1026struct page *find_data_page(struct inode *, pgoff_t, bool); 1060struct page *find_data_page(struct inode *, pgoff_t, bool);
1027struct page *get_lock_data_page(struct inode *, pgoff_t); 1061struct page *get_lock_data_page(struct inode *, pgoff_t);
1028struct page *get_new_data_page(struct inode *, pgoff_t, bool); 1062struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool);
1029int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int); 1063int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int);
1030int do_write_data_page(struct page *); 1064int do_write_data_page(struct page *);
1031 1065