f2fs: add need_dentry_mark
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 30 Apr 2015 01:31:19 +0000 (18:31 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 28 May 2015 22:41:36 +0000 (15:41 -0700)
This patch introduces need_dentry_mark() to clean up and avoid redundant
node locks.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/node.c

index b8f99fd4fcff5deb0a428b13fca4114a5085e7a5..9e43ddcdba84d42b10aa96d50683fc76952e32d9 100644 (file)
@@ -1565,6 +1565,7 @@ struct dnode_of_data;
 struct node_info;
 
 bool available_free_memory(struct f2fs_sb_info *, int);
+int need_dentry_mark(struct f2fs_sb_info *, nid_t);
 bool is_checkpointed_node(struct f2fs_sb_info *, nid_t);
 bool need_inode_block_update(struct f2fs_sb_info *, nid_t);
 void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *);
index 880d5781b1b39a20eb3e7cd5282913f609e75509..62982e671d1808f5dc594b3cdbe403764a16fc7f 100644 (file)
@@ -195,32 +195,35 @@ static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i,
                                                        start, nr);
 }
 
-bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
+int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct nat_entry *e;
-       bool is_cp = true;
+       bool need = false;
 
        down_read(&nm_i->nat_tree_lock);
        e = __lookup_nat_cache(nm_i, nid);
-       if (e && !get_nat_flag(e, IS_CHECKPOINTED))
-               is_cp = false;
+       if (e) {
+               if (!get_nat_flag(e, IS_CHECKPOINTED) &&
+                               !get_nat_flag(e, HAS_FSYNCED_INODE))
+                       need = true;
+       }
        up_read(&nm_i->nat_tree_lock);
-       return is_cp;
+       return need;
 }
 
-static bool has_fsynced_inode(struct f2fs_sb_info *sbi, nid_t ino)
+bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct nat_entry *e;
-       bool fsynced = false;
+       bool is_cp = true;
 
        down_read(&nm_i->nat_tree_lock);
-       e = __lookup_nat_cache(nm_i, ino);
-       if (e && get_nat_flag(e, HAS_FSYNCED_INODE))
-               fsynced = true;
+       e = __lookup_nat_cache(nm_i, nid);
+       if (e && !get_nat_flag(e, IS_CHECKPOINTED))
+               is_cp = false;
        up_read(&nm_i->nat_tree_lock);
-       return fsynced;
+       return is_cp;
 }
 
 bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
@@ -1206,13 +1209,9 @@ continue_unlock:
                        /* called by fsync() */
                        if (ino && IS_DNODE(page)) {
                                set_fsync_mark(page, 1);
-                               if (IS_INODE(page)) {
-                                       if (!is_checkpointed_node(sbi, ino) &&
-                                               !has_fsynced_inode(sbi, ino))
-                                               set_dentry_mark(page, 1);
-                                       else
-                                               set_dentry_mark(page, 0);
-                               }
+                               if (IS_INODE(page))
+                                       set_dentry_mark(page,
+                                               need_dentry_mark(sbi, ino));
                                nwritten++;
                        } else {
                                set_fsync_mark(page, 0);