f2fs: skip writeback meta pages if cp_mutex acquire failed
authorYunlei He <heyunlei@huawei.com>
Wed, 1 Mar 2017 10:07:10 +0000 (18:07 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 22 Mar 2017 02:34:22 +0000 (22:34 -0400)
Skip writeback meta pages if cp_mutex lock acquire failed, cp will
flush dirty pages instead.

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/checkpoint.c

index 3c3d2d01448d3f1c1d02e6ccae5341ed9bfe1332..22348c7df67daa50843d94880126ebbbefd51143 100644 (file)
@@ -275,10 +275,11 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
                get_pages(sbi, F2FS_DIRTY_META) < nr_pages_to_skip(sbi, META))
                goto skip_write;
 
-       trace_f2fs_writepages(mapping->host, wbc, META);
+       /* if locked failed, cp will flush dirty pages instead */
+       if (!mutex_trylock(&sbi->cp_mutex))
+               goto skip_write;
 
-       /* if mounting is failed, skip writing node pages */
-       mutex_lock(&sbi->cp_mutex);
+       trace_f2fs_writepages(mapping->host, wbc, META);
        diff = nr_pages_to_write(sbi, META, wbc);
        written = sync_meta_pages(sbi, META, wbc->nr_to_write);
        mutex_unlock(&sbi->cp_mutex);