OSDN Git Service

f2fs: clean up checkpoint flow
authorChao Yu <yuchao0@huawei.com>
Wed, 12 Dec 2018 10:12:32 +0000 (18:12 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 26 Dec 2018 23:16:54 +0000 (15:16 -0800)
This patch cleans up checkpoint flow a bit:
- remove unneeded circulation of flushing meta pages.
- don't flush nat_bits pages in prior to other checkpoint pages.
- add bug_on to check remained meta pages after flushing.

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

index 1d82833..5401ea5 100644 (file)
@@ -1329,11 +1329,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        int err;
 
        /* Flush all the NAT/SIT pages */
-       while (get_pages(sbi, F2FS_DIRTY_META)) {
-               f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
-               if (unlikely(f2fs_cp_error(sbi)))
-                       break;
-       }
+       f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+       f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
+                                       !f2fs_cp_error(sbi));
 
        /*
         * modify checkpoint
@@ -1406,14 +1404,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                for (i = 0; i < nm_i->nat_bits_blocks; i++)
                        f2fs_update_meta_page(sbi, nm_i->nat_bits +
                                        (i << F2FS_BLKSIZE_BITS), blk + i);
-
-               /* Flush all the NAT BITS pages */
-               while (get_pages(sbi, F2FS_DIRTY_META)) {
-                       f2fs_sync_meta_pages(sbi, META, LONG_MAX,
-                                                       FS_CP_META_IO);
-                       if (unlikely(f2fs_cp_error(sbi)))
-                               break;
-               }
        }
 
        /* write out checkpoint buffer at block 0 */
@@ -1449,6 +1439,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        /* Here, we have one bio having CP pack except cp pack 2 page */
        f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+       f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
+                                       !f2fs_cp_error(sbi));
 
        /* wait for previous submitted meta pages writeback */
        f2fs_wait_on_all_pages_writeback(sbi);