aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/node.h')
-rw-r--r--fs/f2fs/node.h45
1 files changed, 33 insertions, 12 deletions
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index d10b6448a671..f405bbf2435a 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -25,10 +25,19 @@
25 25
26/* vector size for gang look-up from nat cache that consists of radix tree */ 26/* vector size for gang look-up from nat cache that consists of radix tree */
27#define NATVEC_SIZE 64 27#define NATVEC_SIZE 64
28#define SETVEC_SIZE 32
28 29
29/* return value for read_node_page */ 30/* return value for read_node_page */
30#define LOCKED_PAGE 1 31#define LOCKED_PAGE 1
31 32
33/* For flag in struct node_info */
34enum {
35 IS_CHECKPOINTED, /* is it checkpointed before? */
36 HAS_FSYNCED_INODE, /* is the inode fsynced before? */
37 HAS_LAST_FSYNC, /* has the latest node fsync mark? */
38 IS_DIRTY, /* this nat entry is dirty? */
39};
40
32/* 41/*
33 * For node information 42 * For node information
34 */ 43 */
@@ -37,18 +46,11 @@ struct node_info {
37 nid_t ino; /* inode number of the node's owner */ 46 nid_t ino; /* inode number of the node's owner */
38 block_t blk_addr; /* block address of the node */ 47 block_t blk_addr; /* block address of the node */
39 unsigned char version; /* version of the node */ 48 unsigned char version; /* version of the node */
40}; 49 unsigned char flag; /* for node information bits */
41
42enum {
43 IS_CHECKPOINTED, /* is it checkpointed before? */
44 HAS_FSYNCED_INODE, /* is the inode fsynced before? */
45 HAS_LAST_FSYNC, /* has the latest node fsync mark? */
46 IS_DIRTY, /* this nat entry is dirty? */
47}; 50};
48 51
49struct nat_entry { 52struct nat_entry {
50 struct list_head list; /* for clean or dirty nat list */ 53 struct list_head list; /* for clean or dirty nat list */
51 unsigned char flag; /* for node information bits */
52 struct node_info ni; /* in-memory node information */ 54 struct node_info ni; /* in-memory node information */
53}; 55};
54 56
@@ -63,20 +65,30 @@ struct nat_entry {
63 65
64#define inc_node_version(version) (++version) 66#define inc_node_version(version) (++version)
65 67
68static inline void copy_node_info(struct node_info *dst,
69 struct node_info *src)
70{
71 dst->nid = src->nid;
72 dst->ino = src->ino;
73 dst->blk_addr = src->blk_addr;
74 dst->version = src->version;
75 /* should not copy flag here */
76}
77
66static inline void set_nat_flag(struct nat_entry *ne, 78static inline void set_nat_flag(struct nat_entry *ne,
67 unsigned int type, bool set) 79 unsigned int type, bool set)
68{ 80{
69 unsigned char mask = 0x01 << type; 81 unsigned char mask = 0x01 << type;
70 if (set) 82 if (set)
71 ne->flag |= mask; 83 ne->ni.flag |= mask;
72 else 84 else
73 ne->flag &= ~mask; 85 ne->ni.flag &= ~mask;
74} 86}
75 87
76static inline bool get_nat_flag(struct nat_entry *ne, unsigned int type) 88static inline bool get_nat_flag(struct nat_entry *ne, unsigned int type)
77{ 89{
78 unsigned char mask = 0x01 << type; 90 unsigned char mask = 0x01 << type;
79 return ne->flag & mask; 91 return ne->ni.flag & mask;
80} 92}
81 93
82static inline void nat_reset_flag(struct nat_entry *ne) 94static inline void nat_reset_flag(struct nat_entry *ne)
@@ -108,6 +120,7 @@ enum mem_type {
108 NAT_ENTRIES, /* indicates the cached nat entry */ 120 NAT_ENTRIES, /* indicates the cached nat entry */
109 DIRTY_DENTS, /* indicates dirty dentry pages */ 121 DIRTY_DENTS, /* indicates dirty dentry pages */
110 INO_ENTRIES, /* indicates inode entries */ 122 INO_ENTRIES, /* indicates inode entries */
123 BASE_CHECK, /* check kernel status */
111}; 124};
112 125
113struct nat_entry_set { 126struct nat_entry_set {
@@ -200,11 +213,19 @@ static inline void fill_node_footer(struct page *page, nid_t nid,
200 nid_t ino, unsigned int ofs, bool reset) 213 nid_t ino, unsigned int ofs, bool reset)
201{ 214{
202 struct f2fs_node *rn = F2FS_NODE(page); 215 struct f2fs_node *rn = F2FS_NODE(page);
216 unsigned int old_flag = 0;
217
203 if (reset) 218 if (reset)
204 memset(rn, 0, sizeof(*rn)); 219 memset(rn, 0, sizeof(*rn));
220 else
221 old_flag = le32_to_cpu(rn->footer.flag);
222
205 rn->footer.nid = cpu_to_le32(nid); 223 rn->footer.nid = cpu_to_le32(nid);
206 rn->footer.ino = cpu_to_le32(ino); 224 rn->footer.ino = cpu_to_le32(ino);
207 rn->footer.flag = cpu_to_le32(ofs << OFFSET_BIT_SHIFT); 225
226 /* should remain old flag bits such as COLD_BIT_SHIFT */
227 rn->footer.flag = cpu_to_le32((ofs << OFFSET_BIT_SHIFT) |
228 (old_flag & OFFSET_BIT_MASK));
208} 229}
209 230
210static inline void copy_node_footer(struct page *dst, struct page *src) 231static inline void copy_node_footer(struct page *dst, struct page *src)