Commit 6b2920a5 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: use inner macro and function to clean up codes

In this patch we use below inner macro and function to clean up codes.
1. ADDRS_PER_PAGE
2. SM_I
3. f2fs_readonly
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 3aab8f82
...@@ -272,8 +272,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) ...@@ -272,8 +272,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
} }
} }
end_offset = IS_INODE(dn.node_page) ? end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
ADDRS_PER_INODE(F2FS_I(inode)) : ADDRS_PER_BLOCK;
/* find data/hole in dnode block */ /* find data/hole in dnode block */
for (; dn.ofs_in_node < end_offset; for (; dn.ofs_in_node < end_offset;
......
...@@ -272,13 +272,13 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi) ...@@ -272,13 +272,13 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&fcc->issue_lock); spin_lock_init(&fcc->issue_lock);
init_waitqueue_head(&fcc->flush_wait_queue); init_waitqueue_head(&fcc->flush_wait_queue);
sbi->sm_info->cmd_control_info = fcc; SM_I(sbi)->cmd_control_info = fcc;
fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
if (IS_ERR(fcc->f2fs_issue_flush)) { if (IS_ERR(fcc->f2fs_issue_flush)) {
err = PTR_ERR(fcc->f2fs_issue_flush); err = PTR_ERR(fcc->f2fs_issue_flush);
kfree(fcc); kfree(fcc);
sbi->sm_info->cmd_control_info = NULL; SM_I(sbi)->cmd_control_info = NULL;
return err; return err;
} }
...@@ -287,13 +287,12 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi) ...@@ -287,13 +287,12 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
void destroy_flush_cmd_control(struct f2fs_sb_info *sbi) void destroy_flush_cmd_control(struct f2fs_sb_info *sbi)
{ {
struct flush_cmd_control *fcc = struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info;
sbi->sm_info->cmd_control_info;
if (fcc && fcc->f2fs_issue_flush) if (fcc && fcc->f2fs_issue_flush)
kthread_stop(fcc->f2fs_issue_flush); kthread_stop(fcc->f2fs_issue_flush);
kfree(fcc); kfree(fcc);
sbi->sm_info->cmd_control_info = NULL; SM_I(sbi)->cmd_control_info = NULL;
} }
static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
......
...@@ -615,7 +615,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) ...@@ -615,7 +615,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
* Previous and new state of filesystem is RO, * Previous and new state of filesystem is RO,
* so skip checking GC and FLUSH_MERGE conditions. * so skip checking GC and FLUSH_MERGE conditions.
*/ */
if ((sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) if (f2fs_readonly(sb) && (*flags & MS_RDONLY))
goto skip; goto skip;
/* /*
...@@ -642,8 +642,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) ...@@ -642,8 +642,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
*/ */
if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) { if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
destroy_flush_cmd_control(sbi); destroy_flush_cmd_control(sbi);
} else if (test_opt(sbi, FLUSH_MERGE) && } else if (test_opt(sbi, FLUSH_MERGE) && !SM_I(sbi)->cmd_control_info) {
!sbi->sm_info->cmd_control_info) {
err = create_flush_cmd_control(sbi); err = create_flush_cmd_control(sbi);
if (err) if (err)
goto restore_gc; goto restore_gc;
...@@ -1082,7 +1081,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1082,7 +1081,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
* If filesystem is not mounted as read-only then * If filesystem is not mounted as read-only then
* do start the gc_thread. * do start the gc_thread.
*/ */
if (!(sb->s_flags & MS_RDONLY)) { if (!f2fs_readonly(sb)) {
/* After POR, we can run background GC thread.*/ /* After POR, we can run background GC thread.*/
err = start_gc_thread(sbi); err = start_gc_thread(sbi);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment