read_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
- if (e && !e->checkpointed)
+ if (e && !get_nat_flag(e, IS_CHECKPOINTED))
is_cp = 0;
read_unlock(&nm_i->nat_tree_lock);
return is_cp;
read_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
if (e)
- fsync_done = e->fsync_done;
+ fsync_done = get_nat_flag(e, HAS_FSYNC_MARK);
read_unlock(&nm_i->nat_tree_lock);
return fsync_done;
}
write_lock(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid);
if (e)
- e->fsync_done = false;
+ set_nat_flag(e, HAS_FSYNC_MARK, false);
write_unlock(&nm_i->nat_tree_lock);
}
}
memset(new, 0, sizeof(struct nat_entry));
nat_set_nid(new, nid);
- new->checkpointed = true;
+ set_nat_flag(new, IS_CHECKPOINTED, true);
list_add_tail(&new->list, &nm_i->nat_entries);
nm_i->nat_cnt++;
return new;
/* update fsync_mark if its inode nat entry is still alive */
e = __lookup_nat_cache(nm_i, ni->ino);
if (e)
- e->fsync_done = fsync_done;
+ set_nat_flag(e, HAS_FSYNC_MARK, fsync_done);
write_unlock(&nm_i->nat_tree_lock);
}
read_lock(&nm_i->nat_tree_lock);
ne = __lookup_nat_cache(nm_i, nid);
if (ne &&
- (!ne->checkpointed || nat_get_blkaddr(ne) != NULL_ADDR))
+ (!get_nat_flag(ne, IS_CHECKPOINTED) ||
+ nat_get_blkaddr(ne) != NULL_ADDR))
allocated = true;
read_unlock(&nm_i->nat_tree_lock);
if (allocated)
unsigned char version; /* version of the node */
};
+enum {
+ IS_CHECKPOINTED, /* is it checkpointed before? */
+ HAS_FSYNC_MARK, /* has the latest node fsync mark? */
+};
+
struct nat_entry {
struct list_head list; /* for clean or dirty nat list */
- bool checkpointed; /* whether it is checkpointed or not */
- bool fsync_done; /* whether the latest node has fsync mark */
+ unsigned char flag; /* for node information bits */
struct node_info ni; /* in-memory node information */
};
#define __set_nat_cache_dirty(nm_i, ne) \
do { \
- ne->checkpointed = false; \
+ set_nat_flag(ne, IS_CHECKPOINTED, false); \
list_move_tail(&ne->list, &nm_i->dirty_nat_entries); \
} while (0)
#define __clear_nat_cache_dirty(nm_i, ne) \
do { \
- ne->checkpointed = true; \
+ set_nat_flag(ne, IS_CHECKPOINTED, true); \
list_move_tail(&ne->list, &nm_i->nat_entries); \
} while (0)
#define inc_node_version(version) (++version)
+static inline void set_nat_flag(struct nat_entry *ne,
+ unsigned int type, bool set)
+{
+ unsigned char mask = 0x01 << type;
+ if (set)
+ ne->flag |= mask;
+ else
+ ne->flag &= ~mask;
+}
+
+static inline bool get_nat_flag(struct nat_entry *ne, unsigned int type)
+{
+ unsigned char mask = 0x01 << type;
+ return ne->flag & mask;
+}
+
static inline void node_info_from_raw_nat(struct node_info *ni,
struct f2fs_nat_entry *raw_ne)
{