f2fs: seperate read nat page from nat_tree_lock
authorYunlei He <heyunlei@huawei.com>
Sat, 22 Apr 2017 10:06:26 +0000 (18:06 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 25 Apr 2017 21:16:39 +0000 (14:16 -0700)
This patch seperate nat page read io from nat_tree_lock.

-lock_page
-get_node_info()
-current_nat_addr

......            ->       write_checkpoint

-get_meta_page

Because we lock node page, we can make sure no other threads
modify this nid concurrently. So we just obtain current_nat_addr
under nat_tree_lock, node info is always same in both nat pack.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.c

index ad54e907b97b2798cb0a42466279b47731d62f7d..b99e318bce584b0c4b0adad3114fb1f17ddcdee2 100644 (file)
@@ -376,6 +376,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
        struct page *page = NULL;
        struct f2fs_nat_entry ne;
        struct nat_entry *e;
+       pgoff_t index;
        int i;
 
        ni->nid = nid;
@@ -401,17 +402,21 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
                node_info_from_raw_nat(ni, &ne);
        }
        up_read(&curseg->journal_rwsem);
-       if (i >= 0)
+       if (i >= 0) {
+               up_read(&nm_i->nat_tree_lock);
                goto cache;
+       }
 
        /* Fill node_info from nat page */
-       page = get_current_nat_page(sbi, start_nid);
+       index = current_nat_addr(sbi, nid);
+       up_read(&nm_i->nat_tree_lock);
+
+       page = get_meta_page(sbi, index);
        nat_blk = (struct f2fs_nat_block *)page_address(page);
        ne = nat_blk->entries[nid - start_nid];
        node_info_from_raw_nat(ni, &ne);
        f2fs_put_page(page, 1);
 cache:
-       up_read(&nm_i->nat_tree_lock);
        /* cache nat entry */
        down_write(&nm_i->nat_tree_lock);
        cache_nat_entry(sbi, nid, &ne);