f2fs: drop page cache after fs shutdown
authorChao Yu <yuchao0@huawei.com>
Thu, 18 Jan 2018 09:29:10 +0000 (17:29 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 22 Jan 2018 22:56:56 +0000 (14:56 -0800)
Don't remain dirtied page cache in f2fs after shutdown, it can mitigate
memory pressure of whole system, in order to keep other modules working
properly.

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

index 097eadc..9c7596f 100644 (file)
@@ -237,12 +237,15 @@ static int __f2fs_write_meta_page(struct page *page,
 
        trace_f2fs_writepage(page, META);
 
+       if (unlikely(f2fs_cp_error(sbi))) {
+               dec_page_count(sbi, F2FS_DIRTY_META);
+               unlock_page(page);
+               return 0;
+       }
        if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
                goto redirty_out;
        if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
                goto redirty_out;
-       if (unlikely(f2fs_cp_error(sbi)))
-               goto redirty_out;
 
        write_meta_page(sbi, page, io_type);
        dec_page_count(sbi, F2FS_DIRTY_META);
index f428f7b..6cba74e 100644 (file)
@@ -1716,6 +1716,12 @@ static int __write_data_page(struct page *page, bool *submitted,
 
        trace_f2fs_writepage(page, DATA);
 
+       /* we should bypass data pages to proceed the kworkder jobs */
+       if (unlikely(f2fs_cp_error(sbi))) {
+               mapping_set_error(page->mapping, -EIO);
+               goto out;
+       }
+
        if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
                goto redirty_out;
 
@@ -1740,12 +1746,6 @@ write:
                        available_free_memory(sbi, BASE_CHECK))))
                goto redirty_out;
 
-       /* we should bypass data pages to proceed the kworkder jobs */
-       if (unlikely(f2fs_cp_error(sbi))) {
-               mapping_set_error(page->mapping, -EIO);
-               goto out;
-       }
-
        /* Dentry blocks are controlled by checkpoint */
        if (S_ISDIR(inode->i_mode)) {
                fio.need_lock = LOCK_DONE;
index ea29314..833b46b 100644 (file)
@@ -1340,10 +1340,14 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
 
        trace_f2fs_writepage(page, NODE);
 
+       if (unlikely(f2fs_cp_error(sbi))) {
+               dec_page_count(sbi, F2FS_DIRTY_NODES);
+               unlock_page(page);
+               return 0;
+       }
+
        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);
@@ -1580,12 +1584,6 @@ next_step:
                        struct page *page = pvec.pages[i];
                        bool submitted = false;
 
-                       if (unlikely(f2fs_cp_error(sbi))) {
-                               pagevec_release(&pvec);
-                               ret = -EIO;
-                               goto out;
-                       }
-
                        /*
                         * flushing sequence with step:
                         * 0. indirect nodes
@@ -1655,9 +1653,12 @@ continue_unlock:
                step++;
                goto next_step;
        }
-out:
+
        if (nwritten)
                f2fs_submit_merged_write(sbi, NODE);
+
+       if (unlikely(f2fs_cp_error(sbi)))
+               return -EIO;
        return ret;
 }