f2fs: prevent checkpoint during roll-forward
Jaegeuk Kim [Wed, 13 Aug 2014 23:30:46 +0000 (16:30 -0700)]
Any checkpoint should not be done during the core roll-forward procedure.
Especially, it includes error cases too.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Conflicts:
fs/f2fs/recovery.c

Change-Id: Ic06005da17a41f18bac387b3984996bac41ef278

fs/f2fs/recovery.c

index 4b6764b..26d82c2 100644 (file)
@@ -502,6 +502,9 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
        /* step #1: find fsynced inode numbers */
        sbi->por_doing = true;
 
+       /* prevent checkpoint */
+       mutex_lock(&sbi->cp_mutex);
+
        blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
 
        err = find_fsync_dnodes(sbi, &inode_list);
@@ -538,11 +541,15 @@ out:
                /* Flush all the NAT/SIT pages */
                while (get_pages(sbi, F2FS_DIRTY_META))
                        sync_meta_pages(sbi, META, LONG_MAX);
+               set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
+               mutex_unlock(&sbi->cp_mutex);
                f2fs_msg(sbi->sb, KERN_INFO, "recovery complete");
        } else if (need_writecp) {
+               mutex_unlock(&sbi->cp_mutex);
                write_checkpoint(sbi, false);
                f2fs_msg(sbi->sb, KERN_INFO, "recovery complete");
        } else {
+               mutex_unlock(&sbi->cp_mutex);
                f2fs_msg(sbi->sb, KERN_ERR, "recovery did not fully complete");
        }
        return err;