summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/f2fs/node.c13
-rw-r--r--fs/f2fs/node.h28
2 files changed, 31 insertions, 10 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b32eb565e6b3..d19d6b18cd4e 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -131,7 +131,7 @@ int is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
131 131
132 read_lock(&nm_i->nat_tree_lock); 132 read_lock(&nm_i->nat_tree_lock);
133 e = __lookup_nat_cache(nm_i, nid); 133 e = __lookup_nat_cache(nm_i, nid);
134 if (e && !e->checkpointed) 134 if (e && !get_nat_flag(e, IS_CHECKPOINTED))
135 is_cp = 0; 135 is_cp = 0;
136 read_unlock(&nm_i->nat_tree_lock); 136 read_unlock(&nm_i->nat_tree_lock);
137 return is_cp; 137 return is_cp;
@@ -146,7 +146,7 @@ bool fsync_mark_done(struct f2fs_sb_info *sbi, nid_t nid)
146 read_lock(&nm_i->nat_tree_lock); 146 read_lock(&nm_i->nat_tree_lock);
147 e = __lookup_nat_cache(nm_i, nid); 147 e = __lookup_nat_cache(nm_i, nid);
148 if (e) 148 if (e)
149 fsync_done = e->fsync_done; 149 fsync_done = get_nat_flag(e, HAS_FSYNC_MARK);
150 read_unlock(&nm_i->nat_tree_lock); 150 read_unlock(&nm_i->nat_tree_lock);
151 return fsync_done; 151 return fsync_done;
152} 152}
@@ -159,7 +159,7 @@ void fsync_mark_clear(struct f2fs_sb_info *sbi, nid_t nid)
159 write_lock(&nm_i->nat_tree_lock); 159 write_lock(&nm_i->nat_tree_lock);
160 e = __lookup_nat_cache(nm_i, nid); 160 e = __lookup_nat_cache(nm_i, nid);
161 if (e) 161 if (e)
162 e->fsync_done = false; 162 set_nat_flag(e, HAS_FSYNC_MARK, false);
163 write_unlock(&nm_i->nat_tree_lock); 163 write_unlock(&nm_i->nat_tree_lock);
164} 164}
165 165
@@ -176,7 +176,7 @@ static struct nat_entry *grab_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid)
176 } 176 }
177 memset(new, 0, sizeof(struct nat_entry)); 177 memset(new, 0, sizeof(struct nat_entry));
178 nat_set_nid(new, nid); 178 nat_set_nid(new, nid);
179 new->checkpointed = true; 179 set_nat_flag(new, IS_CHECKPOINTED, true);
180 list_add_tail(&new->list, &nm_i->nat_entries); 180 list_add_tail(&new->list, &nm_i->nat_entries);
181 nm_i->nat_cnt++; 181 nm_i->nat_cnt++;
182 return new; 182 return new;
@@ -249,7 +249,7 @@ retry:
249 /* update fsync_mark if its inode nat entry is still alive */ 249 /* update fsync_mark if its inode nat entry is still alive */
250 e = __lookup_nat_cache(nm_i, ni->ino); 250 e = __lookup_nat_cache(nm_i, ni->ino);
251 if (e) 251 if (e)
252 e->fsync_done = fsync_done; 252 set_nat_flag(e, HAS_FSYNC_MARK, fsync_done);
253 write_unlock(&nm_i->nat_tree_lock); 253 write_unlock(&nm_i->nat_tree_lock);
254} 254}
255 255
@@ -1349,7 +1349,8 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
1349 read_lock(&nm_i->nat_tree_lock); 1349 read_lock(&nm_i->nat_tree_lock);
1350 ne = __lookup_nat_cache(nm_i, nid); 1350 ne = __lookup_nat_cache(nm_i, nid);
1351 if (ne && 1351 if (ne &&
1352 (!ne->checkpointed || nat_get_blkaddr(ne) != NULL_ADDR)) 1352 (!get_nat_flag(ne, IS_CHECKPOINTED) ||
1353 nat_get_blkaddr(ne) != NULL_ADDR))
1353 allocated = true; 1354 allocated = true;
1354 read_unlock(&nm_i->nat_tree_lock); 1355 read_unlock(&nm_i->nat_tree_lock);
1355 if (allocated) 1356 if (allocated)
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 324917d757f7..3043778d805b 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -39,10 +39,14 @@ struct node_info {
39 unsigned char version; /* version of the node */ 39 unsigned char version; /* version of the node */
40}; 40};
41 41
42enum {
43 IS_CHECKPOINTED, /* is it checkpointed before? */
44 HAS_FSYNC_MARK, /* has the latest node fsync mark? */
45};
46
42struct nat_entry { 47struct nat_entry {
43 struct list_head list; /* for clean or dirty nat list */ 48 struct list_head list; /* for clean or dirty nat list */
44 bool checkpointed; /* whether it is checkpointed or not */ 49 unsigned char flag; /* for node information bits */
45 bool fsync_done; /* whether the latest node has fsync mark */
46 struct node_info ni; /* in-memory node information */ 50 struct node_info ni; /* in-memory node information */
47}; 51};
48 52
@@ -57,16 +61,32 @@ struct nat_entry {
57 61
58#define __set_nat_cache_dirty(nm_i, ne) \ 62#define __set_nat_cache_dirty(nm_i, ne) \
59 do { \ 63 do { \
60 ne->checkpointed = false; \ 64 set_nat_flag(ne, IS_CHECKPOINTED, false); \
61 list_move_tail(&ne->list, &nm_i->dirty_nat_entries); \ 65 list_move_tail(&ne->list, &nm_i->dirty_nat_entries); \
62 } while (0) 66 } while (0)
63#define __clear_nat_cache_dirty(nm_i, ne) \ 67#define __clear_nat_cache_dirty(nm_i, ne) \
64 do { \ 68 do { \
65 ne->checkpointed = true; \ 69 set_nat_flag(ne, IS_CHECKPOINTED, true); \
66 list_move_tail(&ne->list, &nm_i->nat_entries); \ 70 list_move_tail(&ne->list, &nm_i->nat_entries); \
67 } while (0) 71 } while (0)
68#define inc_node_version(version) (++version) 72#define inc_node_version(version) (++version)
69 73
74static inline void set_nat_flag(struct nat_entry *ne,
75 unsigned int type, bool set)
76{
77 unsigned char mask = 0x01 << type;
78 if (set)
79 ne->flag |= mask;
80 else
81 ne->flag &= ~mask;
82}
83
84static inline bool get_nat_flag(struct nat_entry *ne, unsigned int type)
85{
86 unsigned char mask = 0x01 << type;
87 return ne->flag & mask;
88}
89
70static inline void node_info_from_raw_nat(struct node_info *ni, 90static inline void node_info_from_raw_nat(struct node_info *ni,
71 struct f2fs_nat_entry *raw_ne) 91 struct f2fs_nat_entry *raw_ne)
72{ 92{