aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-09-21 00:57:51 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-09-30 18:01:28 -0400
commit75ab4cb8301adb3a02a96c5c03c837ed941f1bc5 (patch)
tree30a8db554b044b90a8ba59ca0bac2afb5ddb59d3
parent95dd89730119b97d82f9edc806757cef737703e5 (diff)
f2fs: introduce cp_control structure
This patch add a new data structure to control checkpoint parameters. Currently, it presents the reason of checkpoint such as is_umount and normal sync. Reviewed-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/checkpoint.c16
-rw-r--r--fs/f2fs/f2fs.h11
-rw-r--r--fs/f2fs/gc.c7
-rw-r--r--fs/f2fs/recovery.c5
-rw-r--r--fs/f2fs/super.c13
-rw-r--r--include/trace/events/f2fs.h15
6 files changed, 47 insertions, 20 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index b4a813345de2..efc530cb74a9 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -826,7 +826,7 @@ static void wait_on_all_pages_writeback(struct f2fs_sb_info *sbi)
826 finish_wait(&sbi->cp_wait, &wait); 826 finish_wait(&sbi->cp_wait, &wait);
827} 827}
828 828
829static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount) 829static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
830{ 830{
831 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 831 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
832 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE); 832 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
@@ -894,7 +894,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
894 ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks + 894 ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks +
895 orphan_blocks); 895 orphan_blocks);
896 896
897 if (is_umount) { 897 if (cpc->reason == CP_UMOUNT) {
898 set_ckpt_flags(ckpt, CP_UMOUNT_FLAG); 898 set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
899 ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS+ 899 ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS+
900 cp_payload_blks + data_sum_blocks + 900 cp_payload_blks + data_sum_blocks +
@@ -948,7 +948,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
948 948
949 write_data_summaries(sbi, start_blk); 949 write_data_summaries(sbi, start_blk);
950 start_blk += data_sum_blocks; 950 start_blk += data_sum_blocks;
951 if (is_umount) { 951 if (cpc->reason == CP_UMOUNT) {
952 write_node_summaries(sbi, start_blk); 952 write_node_summaries(sbi, start_blk);
953 start_blk += NR_CURSEG_NODE_TYPE; 953 start_blk += NR_CURSEG_NODE_TYPE;
954 } 954 }
@@ -988,12 +988,12 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
988/* 988/*
989 * We guarantee that this checkpoint procedure will not fail. 989 * We guarantee that this checkpoint procedure will not fail.
990 */ 990 */
991void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount) 991void write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
992{ 992{
993 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 993 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
994 unsigned long long ckpt_ver; 994 unsigned long long ckpt_ver;
995 995
996 trace_f2fs_write_checkpoint(sbi->sb, is_umount, "start block_ops"); 996 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops");
997 997
998 mutex_lock(&sbi->cp_mutex); 998 mutex_lock(&sbi->cp_mutex);
999 999
@@ -1004,7 +1004,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
1004 if (block_operations(sbi)) 1004 if (block_operations(sbi))
1005 goto out; 1005 goto out;
1006 1006
1007 trace_f2fs_write_checkpoint(sbi->sb, is_umount, "finish block_ops"); 1007 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops");
1008 1008
1009 f2fs_submit_merged_bio(sbi, DATA, WRITE); 1009 f2fs_submit_merged_bio(sbi, DATA, WRITE);
1010 f2fs_submit_merged_bio(sbi, NODE, WRITE); 1010 f2fs_submit_merged_bio(sbi, NODE, WRITE);
@@ -1023,13 +1023,13 @@ void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
1023 flush_sit_entries(sbi); 1023 flush_sit_entries(sbi);
1024 1024
1025 /* unlock all the fs_lock[] in do_checkpoint() */ 1025 /* unlock all the fs_lock[] in do_checkpoint() */
1026 do_checkpoint(sbi, is_umount); 1026 do_checkpoint(sbi, cpc);
1027 1027
1028 unblock_operations(sbi); 1028 unblock_operations(sbi);
1029 stat_inc_cp_count(sbi->stat_info); 1029 stat_inc_cp_count(sbi->stat_info);
1030out: 1030out:
1031 mutex_unlock(&sbi->cp_mutex); 1031 mutex_unlock(&sbi->cp_mutex);
1032 trace_f2fs_write_checkpoint(sbi->sb, is_umount, "finish checkpoint"); 1032 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
1033} 1033}
1034 1034
1035void init_ino_entry_info(struct f2fs_sb_info *sbi) 1035void init_ino_entry_info(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3b70b0137191..529892418862 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -96,6 +96,15 @@ enum {
96 SIT_BITMAP 96 SIT_BITMAP
97}; 97};
98 98
99enum {
100 CP_UMOUNT,
101 CP_SYNC,
102};
103
104struct cp_control {
105 int reason;
106};
107
99/* 108/*
100 * For CP/NAT/SIT/SSA readahead 109 * For CP/NAT/SIT/SSA readahead
101 */ 110 */
@@ -1314,7 +1323,7 @@ void update_dirty_page(struct inode *, struct page *);
1314void add_dirty_dir_inode(struct inode *); 1323void add_dirty_dir_inode(struct inode *);
1315void remove_dirty_dir_inode(struct inode *); 1324void remove_dirty_dir_inode(struct inode *);
1316void sync_dirty_dir_inodes(struct f2fs_sb_info *); 1325void sync_dirty_dir_inodes(struct f2fs_sb_info *);
1317void write_checkpoint(struct f2fs_sb_info *, bool); 1326void write_checkpoint(struct f2fs_sb_info *, struct cp_control *);
1318void init_ino_entry_info(struct f2fs_sb_info *); 1327void init_ino_entry_info(struct f2fs_sb_info *);
1319int __init create_checkpoint_caches(void); 1328int __init create_checkpoint_caches(void);
1320void destroy_checkpoint_caches(void); 1329void destroy_checkpoint_caches(void);
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 7bf8392d555f..e88fcf65aa7f 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -694,6 +694,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi)
694 int gc_type = BG_GC; 694 int gc_type = BG_GC;
695 int nfree = 0; 695 int nfree = 0;
696 int ret = -1; 696 int ret = -1;
697 struct cp_control cpc = {
698 .reason = CP_SYNC,
699 };
697 700
698 INIT_LIST_HEAD(&ilist); 701 INIT_LIST_HEAD(&ilist);
699gc_more: 702gc_more:
@@ -704,7 +707,7 @@ gc_more:
704 707
705 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, nfree)) { 708 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, nfree)) {
706 gc_type = FG_GC; 709 gc_type = FG_GC;
707 write_checkpoint(sbi, false); 710 write_checkpoint(sbi, &cpc);
708 } 711 }
709 712
710 if (!__get_victim(sbi, &segno, gc_type, NO_CHECK_TYPE)) 713 if (!__get_victim(sbi, &segno, gc_type, NO_CHECK_TYPE))
@@ -729,7 +732,7 @@ gc_more:
729 goto gc_more; 732 goto gc_more;
730 733
731 if (gc_type == FG_GC) 734 if (gc_type == FG_GC)
732 write_checkpoint(sbi, false); 735 write_checkpoint(sbi, &cpc);
733stop: 736stop:
734 mutex_unlock(&sbi->gc_mutex); 737 mutex_unlock(&sbi->gc_mutex);
735 738
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 39c4ff69990e..947b92273d08 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -542,8 +542,11 @@ out:
542 set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG); 542 set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
543 mutex_unlock(&sbi->cp_mutex); 543 mutex_unlock(&sbi->cp_mutex);
544 } else if (need_writecp) { 544 } else if (need_writecp) {
545 struct cp_control cpc = {
546 .reason = CP_SYNC,
547 };
545 mutex_unlock(&sbi->cp_mutex); 548 mutex_unlock(&sbi->cp_mutex);
546 write_checkpoint(sbi, false); 549 write_checkpoint(sbi, &cpc);
547 } else { 550 } else {
548 mutex_unlock(&sbi->cp_mutex); 551 mutex_unlock(&sbi->cp_mutex);
549 } 552 }
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7a91a381dced..128c42000fa3 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -434,8 +434,12 @@ static void f2fs_put_super(struct super_block *sb)
434 stop_gc_thread(sbi); 434 stop_gc_thread(sbi);
435 435
436 /* We don't need to do checkpoint when it's clean */ 436 /* We don't need to do checkpoint when it's clean */
437 if (sbi->s_dirty) 437 if (sbi->s_dirty) {
438 write_checkpoint(sbi, true); 438 struct cp_control cpc = {
439 .reason = CP_UMOUNT,
440 };
441 write_checkpoint(sbi, &cpc);
442 }
439 443
440 /* 444 /*
441 * normally superblock is clean, so we need to release this. 445 * normally superblock is clean, so we need to release this.
@@ -466,8 +470,11 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
466 trace_f2fs_sync_fs(sb, sync); 470 trace_f2fs_sync_fs(sb, sync);
467 471
468 if (sync) { 472 if (sync) {
473 struct cp_control cpc = {
474 .reason = CP_SYNC,
475 };
469 mutex_lock(&sbi->gc_mutex); 476 mutex_lock(&sbi->gc_mutex);
470 write_checkpoint(sbi, false); 477 write_checkpoint(sbi, &cpc);
471 mutex_unlock(&sbi->gc_mutex); 478 mutex_unlock(&sbi->gc_mutex);
472 } else { 479 } else {
473 f2fs_balance_fs(sbi); 480 f2fs_balance_fs(sbi);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index d06d44363fea..66eaace9c07e 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -69,6 +69,11 @@
69 { GC_GREEDY, "Greedy" }, \ 69 { GC_GREEDY, "Greedy" }, \
70 { GC_CB, "Cost-Benefit" }) 70 { GC_CB, "Cost-Benefit" })
71 71
72#define show_cpreason(type) \
73 __print_symbolic(type, \
74 { CP_UMOUNT, "Umount" }, \
75 { CP_SYNC, "Sync" })
76
72struct victim_sel_policy; 77struct victim_sel_policy;
73 78
74DECLARE_EVENT_CLASS(f2fs__inode, 79DECLARE_EVENT_CLASS(f2fs__inode,
@@ -944,25 +949,25 @@ TRACE_EVENT(f2fs_submit_page_mbio,
944 949
945TRACE_EVENT(f2fs_write_checkpoint, 950TRACE_EVENT(f2fs_write_checkpoint,
946 951
947 TP_PROTO(struct super_block *sb, bool is_umount, char *msg), 952 TP_PROTO(struct super_block *sb, int reason, char *msg),
948 953
949 TP_ARGS(sb, is_umount, msg), 954 TP_ARGS(sb, reason, msg),
950 955
951 TP_STRUCT__entry( 956 TP_STRUCT__entry(
952 __field(dev_t, dev) 957 __field(dev_t, dev)
953 __field(bool, is_umount) 958 __field(int, reason)
954 __field(char *, msg) 959 __field(char *, msg)
955 ), 960 ),
956 961
957 TP_fast_assign( 962 TP_fast_assign(
958 __entry->dev = sb->s_dev; 963 __entry->dev = sb->s_dev;
959 __entry->is_umount = is_umount; 964 __entry->reason = reason;
960 __entry->msg = msg; 965 __entry->msg = msg;
961 ), 966 ),
962 967
963 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s", 968 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s",
964 show_dev(__entry), 969 show_dev(__entry),
965 __entry->is_umount ? "clean umount" : "consistency", 970 show_cpreason(__entry->reason),
966 __entry->msg) 971 __entry->msg)
967); 972);
968 973