diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-01-28 12:48:42 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-02-12 04:04:38 +0300 |
commit | caf0047e7e1e60a7ad1d655d3b81b32e2dfb6095 (patch) | |
tree | 0d4725d944d54b437ac3fd7218794773197b1c2a /fs/f2fs/super.c | |
parent | 88dd8934194f6d1db7f824c03d1eee169cb891b0 (diff) | |
download | linux-caf0047e7e1e60a7ad1d655d3b81b32e2dfb6095.tar.xz |
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.c | 15 |
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) * But, the previous checkpoint was not done by umount, it needs to do * clean checkpoint again. */ - if (sbi->s_dirty || + if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) || !is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) { struct cp_control cpc = { .reason = CP_UMOUNT, @@ -492,8 +492,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync) if (sync) { struct cp_control cpc; - cpc.reason = (test_opt(sbi, FASTBOOT) || sbi->s_closing) ? - CP_UMOUNT : CP_SYNC; + cpc.reason = (test_opt(sbi, FASTBOOT) || + is_sbi_flag_set(sbi, SBI_IS_CLOSE)) ? + CP_UMOUNT : CP_SYNC; mutex_lock(&sbi->gc_mutex); write_checkpoint(sbi, &cpc); mutex_unlock(&sbi->gc_mutex); @@ -895,7 +896,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi) atomic_set(&sbi->nr_pages[i], 0); sbi->dir_level = DEF_DIR_LEVEL; - sbi->need_fsck = false; + clear_sbi_flag(sbi, SBI_NEED_FSCK); } /* @@ -1006,7 +1007,7 @@ try_onemore: mutex_init(&sbi->writepages); mutex_init(&sbi->cp_mutex); init_rwsem(&sbi->node_write); - sbi->por_doing = false; + clear_sbi_flag(sbi, SBI_POR_DOING); spin_lock_init(&sbi->stat_lock); init_rwsem(&sbi->read_io.io_rwsem); @@ -1130,7 +1131,7 @@ try_onemore: goto free_proc; if (!retry) - sbi->need_fsck = true; + set_sbi_flag(sbi, SBI_NEED_FSCK); /* recover fsynced data */ if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) { @@ -1199,7 +1200,7 @@ static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags, static void kill_f2fs_super(struct super_block *sb) { if (sb->s_root) - F2FS_SB(sb)->s_closing = true; + set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE); kill_block_super(sb); } |