f2fs: move write_node_page above fsync_node_pages
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 3 Feb 2017 02:27:17 +0000 (18:27 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 23 Feb 2017 18:09:43 +0000 (10:09 -0800)
This patch just moves write_node_page and introduces an inner function.

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

index 69c38a0022e7ed7db0ea5a3891dc7bce17290804..0cb6e86bcf28a33c152e55cba35aa331ab1d21c4 100644 (file)
@@ -1318,6 +1318,78 @@ continue_unlock:
        return last_page;
 }
 
+static int __write_node_page(struct page *page,
+                               struct writeback_control *wbc)
+{
+       struct f2fs_sb_info *sbi = F2FS_P_SB(page);
+       nid_t nid;
+       struct node_info ni;
+       struct f2fs_io_info fio = {
+               .sbi = sbi,
+               .type = NODE,
+               .op = REQ_OP_WRITE,
+               .op_flags = wbc_to_write_flags(wbc),
+               .page = page,
+               .encrypted_page = NULL,
+       };
+
+       trace_f2fs_writepage(page, NODE);
+
+       if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
+               goto redirty_out;
+       if (unlikely(f2fs_cp_error(sbi)))
+               goto redirty_out;
+
+       /* get old block addr of this node page */
+       nid = nid_of_node(page);
+       f2fs_bug_on(sbi, page->index != nid);
+
+       if (wbc->for_reclaim) {
+               if (!down_read_trylock(&sbi->node_write))
+                       goto redirty_out;
+       } else {
+               down_read(&sbi->node_write);
+       }
+
+       get_node_info(sbi, nid, &ni);
+
+       /* This page is already truncated */
+       if (unlikely(ni.blk_addr == NULL_ADDR)) {
+               ClearPageUptodate(page);
+               dec_page_count(sbi, F2FS_DIRTY_NODES);
+               up_read(&sbi->node_write);
+               unlock_page(page);
+               return 0;
+       }
+
+       set_page_writeback(page);
+       fio.old_blkaddr = ni.blk_addr;
+       write_node_page(nid, &fio);
+       set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(page));
+       dec_page_count(sbi, F2FS_DIRTY_NODES);
+       up_read(&sbi->node_write);
+
+       if (wbc->for_reclaim)
+               f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, NODE, WRITE);
+
+       unlock_page(page);
+
+       if (unlikely(f2fs_cp_error(sbi)))
+               f2fs_submit_merged_bio(sbi, NODE, WRITE);
+
+       return 0;
+
+redirty_out:
+       redirty_page_for_writepage(wbc, page);
+       return AOP_WRITEPAGE_ACTIVATE;
+}
+
+static int f2fs_write_node_page(struct page *page,
+                               struct writeback_control *wbc)
+{
+       return __write_node_page(page, wbc);
+}
+
 int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                        struct writeback_control *wbc, bool atomic)
 {
@@ -1397,7 +1469,7 @@ continue_unlock:
                        if (!clear_page_dirty_for_io(page))
                                goto continue_unlock;
 
-                       ret = NODE_MAPPING(sbi)->a_ops->writepage(page, wbc);
+                       ret = __write_node_page(page, wbc);
                        if (ret) {
                                unlock_page(page);
                                f2fs_put_page(last_page, 0);
@@ -1577,72 +1649,6 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
        return ret;
 }
 
-static int f2fs_write_node_page(struct page *page,
-                               struct writeback_control *wbc)
-{
-       struct f2fs_sb_info *sbi = F2FS_P_SB(page);
-       nid_t nid;
-       struct node_info ni;
-       struct f2fs_io_info fio = {
-               .sbi = sbi,
-               .type = NODE,
-               .op = REQ_OP_WRITE,
-               .op_flags = wbc_to_write_flags(wbc),
-               .page = page,
-               .encrypted_page = NULL,
-       };
-
-       trace_f2fs_writepage(page, NODE);
-
-       if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-               goto redirty_out;
-       if (unlikely(f2fs_cp_error(sbi)))
-               goto redirty_out;
-
-       /* get old block addr of this node page */
-       nid = nid_of_node(page);
-       f2fs_bug_on(sbi, page->index != nid);
-
-       if (wbc->for_reclaim) {
-               if (!down_read_trylock(&sbi->node_write))
-                       goto redirty_out;
-       } else {
-               down_read(&sbi->node_write);
-       }
-
-       get_node_info(sbi, nid, &ni);
-
-       /* This page is already truncated */
-       if (unlikely(ni.blk_addr == NULL_ADDR)) {
-               ClearPageUptodate(page);
-               dec_page_count(sbi, F2FS_DIRTY_NODES);
-               up_read(&sbi->node_write);
-               unlock_page(page);
-               return 0;
-       }
-
-       set_page_writeback(page);
-       fio.old_blkaddr = ni.blk_addr;
-       write_node_page(nid, &fio);
-       set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(page));
-       dec_page_count(sbi, F2FS_DIRTY_NODES);
-       up_read(&sbi->node_write);
-
-       if (wbc->for_reclaim)
-               f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, NODE, WRITE);
-
-       unlock_page(page);
-
-       if (unlikely(f2fs_cp_error(sbi)))
-               f2fs_submit_merged_bio(sbi, NODE, WRITE);
-
-       return 0;
-
-redirty_out:
-       redirty_page_for_writepage(wbc, page);
-       return AOP_WRITEPAGE_ACTIVATE;
-}
-
 static int f2fs_write_node_pages(struct address_space *mapping,
                            struct writeback_control *wbc)
 {