diff options
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r-- | fs/f2fs/f2fs.h | 66 |
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 | ||
40 | typedef u64 block_t; | 40 | typedef u32 block_t; /* |
41 | * should not change u32, since it is the on-disk block | ||
42 | * address format, __le32. | ||
43 | */ | ||
41 | typedef u32 nid_t; | 44 | typedef u32 nid_t; |
42 | 45 | ||
43 | struct f2fs_mount_info { | 46 | struct f2fs_mount_info { |
44 | unsigned int opt; | 47 | unsigned int opt; |
45 | }; | 48 | }; |
46 | 49 | ||
47 | static inline __u32 f2fs_crc32(void *buff, size_t len) | 50 | #define CRCPOLY_LE 0xedb88320 |
51 | |||
52 | static 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 | ||
52 | static inline bool f2fs_crc_valid(__u32 blk_crc, void *buff, size_t buff_size) | 66 | static 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 | ||
153 | struct f2fs_inode_info { | 167 | struct 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 | ||
496 | static inline void mutex_lock_all(struct f2fs_sb_info *sbi) | 512 | static 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 | ||
503 | static inline void mutex_unlock_all(struct f2fs_sb_info *sbi) | 527 | static 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 */ |
844 | enum { | 868 | enum { |
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 | ||
851 | static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) | 878 | static 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 | ||
908 | static 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 | */ |
884 | int f2fs_sync_file(struct file *, loff_t, loff_t, int); | 916 | int f2fs_sync_file(struct file *, loff_t, loff_t, int); |
885 | void truncate_data_blocks(struct dnode_of_data *); | 917 | void truncate_data_blocks(struct dnode_of_data *); |
886 | void f2fs_truncate(struct inode *); | 918 | void f2fs_truncate(struct inode *); |
919 | int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *); | ||
887 | int f2fs_setattr(struct dentry *, struct iattr *); | 920 | int f2fs_setattr(struct dentry *, struct iattr *); |
888 | int truncate_hole(struct inode *, pgoff_t, pgoff_t); | 921 | int truncate_hole(struct inode *, pgoff_t, pgoff_t); |
922 | int truncate_data_blocks_range(struct dnode_of_data *, int); | ||
889 | long f2fs_ioctl(struct file *, unsigned int, unsigned long); | 923 | long f2fs_ioctl(struct file *, unsigned int, unsigned long); |
890 | long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); | 924 | long 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 **); | |||
913 | ino_t f2fs_inode_by_name(struct inode *, struct qstr *); | 947 | ino_t f2fs_inode_by_name(struct inode *, struct qstr *); |
914 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, | 948 | void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, |
915 | struct page *, struct inode *); | 949 | struct page *, struct inode *); |
916 | void init_dent_inode(const struct qstr *, struct page *); | ||
917 | int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); | 950 | int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *); |
918 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); | 951 | void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *); |
919 | int f2fs_make_empty(struct inode *, struct inode *); | 952 | int f2fs_make_empty(struct inode *, struct inode *); |
@@ -948,8 +981,8 @@ void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); | |||
948 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); | 981 | int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); |
949 | int truncate_inode_blocks(struct inode *, pgoff_t); | 982 | int truncate_inode_blocks(struct inode *, pgoff_t); |
950 | int remove_inode_page(struct inode *); | 983 | int remove_inode_page(struct inode *); |
951 | int new_inode_page(struct inode *, const struct qstr *); | 984 | struct page *new_inode_page(struct inode *, const struct qstr *); |
952 | struct page *new_node_page(struct dnode_of_data *, unsigned int); | 985 | struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); |
953 | void ra_node_page(struct f2fs_sb_info *, nid_t); | 986 | void ra_node_page(struct f2fs_sb_info *, nid_t); |
954 | struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); | 987 | struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); |
955 | struct page *get_node_page_ra(struct page *, int); | 988 | struct page *get_node_page_ra(struct page *, int); |
@@ -974,7 +1007,6 @@ void destroy_node_manager_caches(void); | |||
974 | */ | 1007 | */ |
975 | void f2fs_balance_fs(struct f2fs_sb_info *); | 1008 | void f2fs_balance_fs(struct f2fs_sb_info *); |
976 | void invalidate_blocks(struct f2fs_sb_info *, block_t); | 1009 | void invalidate_blocks(struct f2fs_sb_info *, block_t); |
977 | void locate_dirty_segment(struct f2fs_sb_info *, unsigned int); | ||
978 | void clear_prefree_segments(struct f2fs_sb_info *); | 1010 | void clear_prefree_segments(struct f2fs_sb_info *); |
979 | int npages_for_summary_flush(struct f2fs_sb_info *); | 1011 | int npages_for_summary_flush(struct f2fs_sb_info *); |
980 | void allocate_new_segments(struct f2fs_sb_info *); | 1012 | void allocate_new_segments(struct f2fs_sb_info *); |
@@ -1011,7 +1043,9 @@ void remove_orphan_inode(struct f2fs_sb_info *, nid_t); | |||
1011 | int recover_orphan_inodes(struct f2fs_sb_info *); | 1043 | int recover_orphan_inodes(struct f2fs_sb_info *); |
1012 | int get_valid_checkpoint(struct f2fs_sb_info *); | 1044 | int get_valid_checkpoint(struct f2fs_sb_info *); |
1013 | void set_dirty_dir_page(struct inode *, struct page *); | 1045 | void set_dirty_dir_page(struct inode *, struct page *); |
1046 | void add_dirty_dir_inode(struct inode *); | ||
1014 | void remove_dirty_dir_inode(struct inode *); | 1047 | void remove_dirty_dir_inode(struct inode *); |
1048 | struct inode *check_dirty_dir_inode(struct f2fs_sb_info *, nid_t); | ||
1015 | void sync_dirty_dir_inodes(struct f2fs_sb_info *); | 1049 | void sync_dirty_dir_inodes(struct f2fs_sb_info *); |
1016 | void write_checkpoint(struct f2fs_sb_info *, bool); | 1050 | void write_checkpoint(struct f2fs_sb_info *, bool); |
1017 | void init_orphan_info(struct f2fs_sb_info *); | 1051 | void init_orphan_info(struct f2fs_sb_info *); |
@@ -1025,7 +1059,7 @@ int reserve_new_block(struct dnode_of_data *); | |||
1025 | void update_extent_cache(block_t, struct dnode_of_data *); | 1059 | void update_extent_cache(block_t, struct dnode_of_data *); |
1026 | struct page *find_data_page(struct inode *, pgoff_t, bool); | 1060 | struct page *find_data_page(struct inode *, pgoff_t, bool); |
1027 | struct page *get_lock_data_page(struct inode *, pgoff_t); | 1061 | struct page *get_lock_data_page(struct inode *, pgoff_t); |
1028 | struct page *get_new_data_page(struct inode *, pgoff_t, bool); | 1062 | struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool); |
1029 | int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int); | 1063 | int f2fs_readpage(struct f2fs_sb_info *, struct page *, block_t, int); |
1030 | int do_write_data_page(struct page *); | 1064 | int do_write_data_page(struct page *); |
1031 | 1065 | ||