aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-01-28 04:48:42 -0500
committerJaegeuk Kim <jaegeuk@kernel.org>2015-02-11 20:04:38 -0500
commitcaf0047e7e1e60a7ad1d655d3b81b32e2dfb6095 (patch)
tree0d4725d944d54b437ac3fd7218794773197b1c2a /fs/f2fs/super.c
parent88dd8934194f6d1db7f824c03d1eee169cb891b0 (diff)
f2fs: merge flags in struct f2fs_sb_info
Currently, there are several variables with Boolean type as below: struct f2fs_sb_info { ... int s_dirty; bool need_fsck; bool s_closing; ... bool por_doing; ... } For this there are some issues: 1. there are some space of f2fs_sb_info is wasted due to aligning after Boolean type variables by compiler. 2. if we continuously add new flag into f2fs_sb_info, structure will be messed up. So in this patch, we try to: 1. switch s_dirty to Boolean type variable since it has two status 0/1. 2. merge s_dirty/need_fsck/s_closing/por_doing variables into s_flag. 3. introduce an enum type which can indicate different states of sbi. 4. use new introduced universal interfaces is_sbi_flag_set/{set,clear}_sbi_flag to operate flags for sbi. After that, above issues will be fixed. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0d627f2d1828..c3aa72f9c8c8 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -452,7 +452,7 @@ static void f2fs_put_super(struct super_block *sb)
452 * But, the previous checkpoint was not done by umount, it needs to do 452 * But, the previous checkpoint was not done by umount, it needs to do
453 * clean checkpoint again. 453 * clean checkpoint again.
454 */ 454 */
455 if (sbi->s_dirty || 455 if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||
456 !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) { 456 !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) {
457 struct cp_control cpc = { 457 struct cp_control cpc = {
458 .reason = CP_UMOUNT, 458 .reason = CP_UMOUNT,
@@ -492,8 +492,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
492 if (sync) { 492 if (sync) {
493 struct cp_control cpc; 493 struct cp_control cpc;
494 494
495 cpc.reason = (test_opt(sbi, FASTBOOT) || sbi->s_closing) ? 495 cpc.reason = (test_opt(sbi, FASTBOOT) ||
496 CP_UMOUNT : CP_SYNC; 496 is_sbi_flag_set(sbi, SBI_IS_CLOSE)) ?
497 CP_UMOUNT : CP_SYNC;
497 mutex_lock(&sbi->gc_mutex); 498 mutex_lock(&sbi->gc_mutex);
498 write_checkpoint(sbi, &cpc); 499 write_checkpoint(sbi, &cpc);
499 mutex_unlock(&sbi->gc_mutex); 500 mutex_unlock(&sbi->gc_mutex);
@@ -895,7 +896,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
895 atomic_set(&sbi->nr_pages[i], 0); 896 atomic_set(&sbi->nr_pages[i], 0);
896 897
897 sbi->dir_level = DEF_DIR_LEVEL; 898 sbi->dir_level = DEF_DIR_LEVEL;
898 sbi->need_fsck = false; 899 clear_sbi_flag(sbi, SBI_NEED_FSCK);
899} 900}
900 901
901/* 902/*
@@ -1006,7 +1007,7 @@ try_onemore:
1006 mutex_init(&sbi->writepages); 1007 mutex_init(&sbi->writepages);
1007 mutex_init(&sbi->cp_mutex); 1008 mutex_init(&sbi->cp_mutex);
1008 init_rwsem(&sbi->node_write); 1009 init_rwsem(&sbi->node_write);
1009 sbi->por_doing = false; 1010 clear_sbi_flag(sbi, SBI_POR_DOING);
1010 spin_lock_init(&sbi->stat_lock); 1011 spin_lock_init(&sbi->stat_lock);
1011 1012
1012 init_rwsem(&sbi->read_io.io_rwsem); 1013 init_rwsem(&sbi->read_io.io_rwsem);
@@ -1130,7 +1131,7 @@ try_onemore:
1130 goto free_proc; 1131 goto free_proc;
1131 1132
1132 if (!retry) 1133 if (!retry)
1133 sbi->need_fsck = true; 1134 set_sbi_flag(sbi, SBI_NEED_FSCK);
1134 1135
1135 /* recover fsynced data */ 1136 /* recover fsynced data */
1136 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) { 1137 if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
@@ -1199,7 +1200,7 @@ static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
1199static void kill_f2fs_super(struct super_block *sb) 1200static void kill_f2fs_super(struct super_block *sb)
1200{ 1201{
1201 if (sb->s_root) 1202 if (sb->s_root)
1202 F2FS_SB(sb)->s_closing = true; 1203 set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE);
1203 kill_block_super(sb); 1204 kill_block_super(sb);
1204} 1205}
1205 1206