f2fs: add the flush_merge handle in the remount flow
Add the *remount* handle of flush_merge option, so that the users can enable flush_merge in the runtime, such as the underlying device handles the cache_flush command relatively slowly. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
8abfb36ab3
commit
876dc59eb1
|
@ -1177,6 +1177,7 @@ void destroy_node_manager_caches(void);
|
||||||
*/
|
*/
|
||||||
void f2fs_balance_fs(struct f2fs_sb_info *);
|
void f2fs_balance_fs(struct f2fs_sb_info *);
|
||||||
void f2fs_balance_fs_bg(struct f2fs_sb_info *);
|
void f2fs_balance_fs_bg(struct f2fs_sb_info *);
|
||||||
|
int issue_flush_thread(void *);
|
||||||
int f2fs_issue_flush(struct f2fs_sb_info *);
|
int f2fs_issue_flush(struct f2fs_sb_info *);
|
||||||
void invalidate_blocks(struct f2fs_sb_info *, block_t);
|
void invalidate_blocks(struct f2fs_sb_info *, block_t);
|
||||||
void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
|
void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t);
|
||||||
|
|
|
@ -197,7 +197,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
|
||||||
f2fs_sync_fs(sbi->sb, true);
|
f2fs_sync_fs(sbi->sb, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int issue_flush_thread(void *data)
|
int issue_flush_thread(void *data)
|
||||||
{
|
{
|
||||||
struct f2fs_sb_info *sbi = data;
|
struct f2fs_sb_info *sbi = data;
|
||||||
struct f2fs_sm_info *sm_i = SM_I(sbi);
|
struct f2fs_sm_info *sm_i = SM_I(sbi);
|
||||||
|
|
|
@ -594,6 +594,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
|
||||||
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
||||||
struct f2fs_mount_info org_mount_opt;
|
struct f2fs_mount_info org_mount_opt;
|
||||||
int err, active_logs;
|
int err, active_logs;
|
||||||
|
bool need_restart_gc = false;
|
||||||
|
bool need_stop_gc = false;
|
||||||
|
|
||||||
sync_filesystem(sb);
|
sync_filesystem(sb);
|
||||||
|
|
||||||
|
@ -611,7 +613,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 no point in checking GC conditions.
|
* so skip checking GC and FLUSH_MERGE conditions.
|
||||||
*/
|
*/
|
||||||
if ((sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY))
|
if ((sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY))
|
||||||
goto skip;
|
goto skip;
|
||||||
|
@ -625,18 +627,57 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
|
||||||
if (sbi->gc_thread) {
|
if (sbi->gc_thread) {
|
||||||
stop_gc_thread(sbi);
|
stop_gc_thread(sbi);
|
||||||
f2fs_sync_fs(sb, 1);
|
f2fs_sync_fs(sb, 1);
|
||||||
|
need_restart_gc = true;
|
||||||
}
|
}
|
||||||
} else if (test_opt(sbi, BG_GC) && !sbi->gc_thread) {
|
} else if (test_opt(sbi, BG_GC) && !sbi->gc_thread) {
|
||||||
err = start_gc_thread(sbi);
|
err = start_gc_thread(sbi);
|
||||||
if (err)
|
if (err)
|
||||||
goto restore_opts;
|
goto restore_opts;
|
||||||
|
need_stop_gc = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We stop issue flush thread if FS is mounted as RO
|
||||||
|
* or if flush_merge is not passed in mount option.
|
||||||
|
*/
|
||||||
|
if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
|
||||||
|
struct f2fs_sm_info *sm_info = sbi->sm_info;
|
||||||
|
|
||||||
|
if (sm_info->f2fs_issue_flush)
|
||||||
|
kthread_stop(sm_info->f2fs_issue_flush);
|
||||||
|
sm_info->issue_list = sm_info->dispatch_list = NULL;
|
||||||
|
sm_info->f2fs_issue_flush = NULL;
|
||||||
|
} else if (test_opt(sbi, FLUSH_MERGE)) {
|
||||||
|
struct f2fs_sm_info *sm_info = sbi->sm_info;
|
||||||
|
|
||||||
|
if (!sm_info->f2fs_issue_flush) {
|
||||||
|
dev_t dev = sbi->sb->s_bdev->bd_dev;
|
||||||
|
|
||||||
|
spin_lock_init(&sm_info->issue_lock);
|
||||||
|
init_waitqueue_head(&sm_info->flush_wait_queue);
|
||||||
|
sm_info->f2fs_issue_flush =
|
||||||
|
kthread_run(issue_flush_thread, sbi,
|
||||||
|
"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
|
||||||
|
if (IS_ERR(sm_info->f2fs_issue_flush)) {
|
||||||
|
err = PTR_ERR(sm_info->f2fs_issue_flush);
|
||||||
|
sm_info->f2fs_issue_flush = NULL;
|
||||||
|
goto restore_gc;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
skip:
|
skip:
|
||||||
/* Update the POSIXACL Flag */
|
/* Update the POSIXACL Flag */
|
||||||
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
|
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
|
||||||
(test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
|
(test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
restore_gc:
|
||||||
|
if (need_restart_gc) {
|
||||||
|
if (start_gc_thread(sbi))
|
||||||
|
f2fs_msg(sbi->sb, KERN_WARNING,
|
||||||
|
"background gc thread is stop");
|
||||||
|
} else if (need_stop_gc) {
|
||||||
|
stop_gc_thread(sbi);
|
||||||
|
}
|
||||||
restore_opts:
|
restore_opts:
|
||||||
sbi->mount_opt = org_mount_opt;
|
sbi->mount_opt = org_mount_opt;
|
||||||
sbi->active_logs = active_logs;
|
sbi->active_logs = active_logs;
|
||||||
|
|
Loading…
Reference in New Issue