aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk.kim@samsung.com>2013-03-31 19:32:21 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2013-04-03 04:27:51 -0400
commitb74737541c5190ab2ad3ee0d7b323e860b988df1 (patch)
tree5f836c7bf8ac075169b89238a5f6a865c9d4c3a8 /fs/f2fs
parent60374688a1a1cc8ef173d3dab42574719b851ac4 (diff)
f2fs: avoid race for summary information
In order to do GC more reliably, I'd like to lock the vicitm summary page until its GC is completed, and also prevent any checkpoint process. Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/gc.c8
-rw-r--r--fs/f2fs/node.c2
-rw-r--r--fs/f2fs/super.c7
3 files changed, 7 insertions, 10 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 136c0f7a670b..e97f30157aa6 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -642,12 +642,6 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno,
642 if (IS_ERR(sum_page)) 642 if (IS_ERR(sum_page))
643 return; 643 return;
644 644
645 /*
646 * CP needs to lock sum_page. In this time, we don't need
647 * to lock this page, because this summary page is not gone anywhere.
648 * Also, this page is not gonna be updated before GC is done.
649 */
650 unlock_page(sum_page);
651 sum = page_address(sum_page); 645 sum = page_address(sum_page);
652 646
653 switch (GET_SUM_TYPE((&sum->footer))) { 647 switch (GET_SUM_TYPE((&sum->footer))) {
@@ -661,7 +655,7 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno,
661 stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer))); 655 stat_inc_seg_count(sbi, GET_SUM_TYPE((&sum->footer)));
662 stat_inc_call_count(sbi->stat_info); 656 stat_inc_call_count(sbi->stat_info);
663 657
664 f2fs_put_page(sum_page, 0); 658 f2fs_put_page(sum_page, 1);
665} 659}
666 660
667int f2fs_gc(struct f2fs_sb_info *sbi) 661int f2fs_gc(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 8510c5ed402e..95298ef68262 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1149,7 +1149,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
1149 1149
1150 /* First check balancing cached NAT entries */ 1150 /* First check balancing cached NAT entries */
1151 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) { 1151 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) {
1152 write_checkpoint(sbi, false); 1152 f2fs_sync_fs(sbi->sb, true);
1153 return 0; 1153 return 0;
1154 } 1154 }
1155 1155
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 728c20a8e456..ca5413346653 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -137,10 +137,13 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
137 if (!sbi->s_dirty && !get_pages(sbi, F2FS_DIRTY_NODES)) 137 if (!sbi->s_dirty && !get_pages(sbi, F2FS_DIRTY_NODES))
138 return 0; 138 return 0;
139 139
140 if (sync) 140 if (sync) {
141 mutex_lock(&sbi->gc_mutex);
141 write_checkpoint(sbi, false); 142 write_checkpoint(sbi, false);
142 else 143 mutex_unlock(&sbi->gc_mutex);
144 } else {
143 f2fs_balance_fs(sbi); 145 f2fs_balance_fs(sbi);
146 }
144 147
145 return 0; 148 return 0;
146} 149}