diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-09-30 20:37:43 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-09-30 20:55:24 -0400 |
commit | e4c5d8489a41209534699220021dab409e4d4f55 (patch) | |
tree | c80e140a983e0c158c7732ca5528031065af2ba3 | |
parent | 6ca56ca429aa94399534ec00598f7f9847c4cae2 (diff) |
f2fs: introduce update_ckpt_flags to clean up
This patch add update_ckpt_flags() to clean up the flow.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/checkpoint.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 7e2632835031..7e9b504bd8b2 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -1006,6 +1006,37 @@ static void wait_on_all_pages_writeback(struct f2fs_sb_info *sbi) | |||
1006 | finish_wait(&sbi->cp_wait, &wait); | 1006 | finish_wait(&sbi->cp_wait, &wait); |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc) | ||
1010 | { | ||
1011 | unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num; | ||
1012 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); | ||
1013 | |||
1014 | spin_lock(&sbi->cp_lock); | ||
1015 | |||
1016 | if (cpc->reason == CP_UMOUNT) | ||
1017 | __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG); | ||
1018 | else | ||
1019 | __clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG); | ||
1020 | |||
1021 | if (cpc->reason == CP_FASTBOOT) | ||
1022 | __set_ckpt_flags(ckpt, CP_FASTBOOT_FLAG); | ||
1023 | else | ||
1024 | __clear_ckpt_flags(ckpt, CP_FASTBOOT_FLAG); | ||
1025 | |||
1026 | if (orphan_num) | ||
1027 | __set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | ||
1028 | else | ||
1029 | __clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | ||
1030 | |||
1031 | if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) | ||
1032 | __set_ckpt_flags(ckpt, CP_FSCK_FLAG); | ||
1033 | |||
1034 | /* set this flag to activate crc|cp_ver for recovery */ | ||
1035 | __set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG); | ||
1036 | |||
1037 | spin_unlock(&sbi->cp_lock); | ||
1038 | } | ||
1039 | |||
1009 | static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | 1040 | static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) |
1010 | { | 1041 | { |
1011 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); | 1042 | struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); |
@@ -1080,29 +1111,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
1080 | cp_payload_blks + data_sum_blocks + | 1111 | cp_payload_blks + data_sum_blocks + |
1081 | orphan_blocks); | 1112 | orphan_blocks); |
1082 | 1113 | ||
1083 | spin_lock(&sbi->cp_lock); | 1114 | /* update ckpt flag for checkpoint */ |
1084 | if (cpc->reason == CP_UMOUNT) | 1115 | update_ckpt_flags(sbi, cpc); |
1085 | __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG); | ||
1086 | else | ||
1087 | __clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG); | ||
1088 | |||
1089 | if (cpc->reason == CP_FASTBOOT) | ||
1090 | __set_ckpt_flags(ckpt, CP_FASTBOOT_FLAG); | ||
1091 | else | ||
1092 | __clear_ckpt_flags(ckpt, CP_FASTBOOT_FLAG); | ||
1093 | |||
1094 | if (orphan_num) | ||
1095 | __set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | ||
1096 | else | ||
1097 | __clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | ||
1098 | |||
1099 | if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) | ||
1100 | __set_ckpt_flags(ckpt, CP_FSCK_FLAG); | ||
1101 | |||
1102 | /* set this flag to activate crc|cp_ver for recovery */ | ||
1103 | __set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG); | ||
1104 | |||
1105 | spin_unlock(&sbi->cp_lock); | ||
1106 | 1116 | ||
1107 | /* update SIT/NAT bitmap */ | 1117 | /* update SIT/NAT bitmap */ |
1108 | get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP)); | 1118 | get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP)); |