]> git.karo-electronics.de Git - linux-beck.git/blobdiff - fs/f2fs/node.h
f2fs: split grab_cache_page and wait_on_page_writeback for node pages
[linux-beck.git] / fs / f2fs / node.h
index c4c79885c99344aa9e999b5562fea34954356276..4ee29d506f8cb8e336ef1c21885f5846d6c98f14 100644 (file)
 /* # of pages to perform readahead before building free nids */
 #define FREE_NID_PAGES 4
 
-/* maximum # of free node ids to produce during build_free_nids */
-#define MAX_FREE_NIDS (NAT_ENTRY_PER_BLOCK * FREE_NID_PAGES)
-
 /* maximum readahead size for node during getting data blocks */
 #define MAX_RA_NODE            128
 
-/* maximum cached nat entries to manage memory footprint */
-#define NM_WOUT_THRESHOLD      (64 * NAT_ENTRY_PER_BLOCK)
+/* control the memory footprint threshold (10MB per 1GB ram) */
+#define DEF_RAM_THRESHOLD      10
 
 /* vector size for gang look-up from nat cache that consists of radix tree */
 #define NATVEC_SIZE    64
@@ -45,6 +42,7 @@ struct node_info {
 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 */
        struct node_info ni;    /* in-memory node information */
 };
 
@@ -58,9 +56,15 @@ struct nat_entry {
 #define nat_set_version(nat, v)                (nat->ni.version = v)
 
 #define __set_nat_cache_dirty(nm_i, ne)                                        \
-       list_move_tail(&ne->list, &nm_i->dirty_nat_entries);
+       do {                                                            \
+               ne->checkpointed = false;                               \
+               list_move_tail(&ne->list, &nm_i->dirty_nat_entries);    \
+       } while (0);
 #define __clear_nat_cache_dirty(nm_i, ne)                              \
-       list_move_tail(&ne->list, &nm_i->nat_entries);
+       do {                                                            \
+               ne->checkpointed = true;                                \
+               list_move_tail(&ne->list, &nm_i->nat_entries);          \
+       } while (0);
 #define inc_node_version(version)      (++version)
 
 static inline void node_info_from_raw_nat(struct node_info *ni,
@@ -71,6 +75,20 @@ static inline void node_info_from_raw_nat(struct node_info *ni,
        ni->version = raw_ne->version;
 }
 
+static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne,
+                                               struct node_info *ni)
+{
+       raw_ne->ino = cpu_to_le32(ni->ino);
+       raw_ne->block_addr = cpu_to_le32(ni->blk_addr);
+       raw_ne->version = ni->version;
+}
+
+enum mem_type {
+       FREE_NIDS,      /* indicates the free nid list */
+       NAT_ENTRIES,    /* indicates the cached nat entry */
+       DIRTY_DENTS     /* indicates dirty dentry pages */
+};
+
 /*
  * For free nid mangement
  */
@@ -236,7 +254,7 @@ static inline bool IS_DNODE(struct page *node_page)
 {
        unsigned int ofs = ofs_of_node(node_page);
 
-       if (ofs == XATTR_NODE_OFFSET)
+       if (f2fs_has_xattr_block(ofs))
                return false;
 
        if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
@@ -254,7 +272,7 @@ static inline void set_nid(struct page *p, int off, nid_t nid, bool i)
 {
        struct f2fs_node *rn = F2FS_NODE(p);
 
-       wait_on_page_writeback(p);
+       f2fs_wait_on_page_writeback(p, NODE);
 
        if (i)
                rn->i.i_nid[off - NODE_DIR1_BLOCK] = cpu_to_le32(nid);