f2fs: pass checkpoint reason on roll-forward recovery
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 10 Apr 2015 00:03:53 +0000 (17:03 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 16 Apr 2015 16:45:40 +0000 (09:45 -0700)
This patch adds CP_RECOVERY to remain recovery information for checkpoint.
And, it makes sure writing checkpoint in this case.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/recovery.c
include/trace/events/f2fs.h

index 384bfc4c36c3f2fcd98711e9354f6b680fcb615d..a5e17a2a078147bcbabf40e177714abcb1360aba 100644 (file)
@@ -1051,7 +1051,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        mutex_lock(&sbi->cp_mutex);
 
        if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) &&
-                       cpc->reason != CP_DISCARD && cpc->reason != CP_UMOUNT)
+               (cpc->reason == CP_FASTBOOT || cpc->reason == CP_SYNC))
                goto out;
        if (unlikely(f2fs_cp_error(sbi)))
                goto out;
@@ -1086,6 +1086,10 @@ void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        unblock_operations(sbi);
        stat_inc_cp_count(sbi->stat_info);
+
+       if (cpc->reason == CP_RECOVERY)
+               f2fs_msg(sbi->sb, KERN_NOTICE,
+                       "checkpoint: version = %llx", ckpt_ver);
 out:
        mutex_unlock(&sbi->cp_mutex);
        trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
index 053361ace0ec8e927f1b7ac662dc5b21eb398bfa..c06a25e5cec335d8195cf027623fc8021bca1f38 100644 (file)
@@ -103,6 +103,7 @@ enum {
        CP_UMOUNT,
        CP_FASTBOOT,
        CP_SYNC,
+       CP_RECOVERY,
        CP_DISCARD,
 };
 
index 4b742c96c22385964719a6b946833aa4aaef990d..8d8ea99f2156278c7423b05f56be54d7006599a0 100644 (file)
@@ -564,7 +564,7 @@ out:
                mutex_unlock(&sbi->cp_mutex);
        } else if (need_writecp) {
                struct cp_control cpc = {
-                       .reason = CP_SYNC,
+                       .reason = CP_RECOVERY,
                };
                mutex_unlock(&sbi->cp_mutex);
                write_checkpoint(sbi, &cpc);
index 75724bd28356be59d9cfd6c16f9c80c8dc889b0f..8804f22a08d19b7216600140bbecece1ddede59c 100644 (file)
@@ -78,6 +78,7 @@
                { CP_UMOUNT,    "Umount" },                             \
                { CP_FASTBOOT,  "Fastboot" },                           \
                { CP_SYNC,      "Sync" },                               \
+               { CP_RECOVERY,  "Recovery" },                           \
                { CP_DISCARD,   "Discard" })
 
 struct victim_sel_policy;