f2fs: flush pending checkpoints when freezing super
This avoids -EINVAL when trying to freeze f2fs. Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
@@ -1893,15 +1893,27 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
|
|||||||
void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi)
|
void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
struct ckpt_req_control *cprc = &sbi->cprc_info;
|
struct ckpt_req_control *cprc = &sbi->cprc_info;
|
||||||
|
struct task_struct *ckpt_task;
|
||||||
|
|
||||||
if (cprc->f2fs_issue_ckpt) {
|
if (!cprc->f2fs_issue_ckpt)
|
||||||
struct task_struct *ckpt_task = cprc->f2fs_issue_ckpt;
|
return;
|
||||||
|
|
||||||
|
ckpt_task = cprc->f2fs_issue_ckpt;
|
||||||
cprc->f2fs_issue_ckpt = NULL;
|
cprc->f2fs_issue_ckpt = NULL;
|
||||||
kthread_stop(ckpt_task);
|
kthread_stop(ckpt_task);
|
||||||
|
|
||||||
|
f2fs_flush_ckpt_thread(sbi);
|
||||||
|
}
|
||||||
|
|
||||||
|
void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi)
|
||||||
|
{
|
||||||
|
struct ckpt_req_control *cprc = &sbi->cprc_info;
|
||||||
|
|
||||||
flush_remained_ckpt_reqs(sbi, NULL);
|
flush_remained_ckpt_reqs(sbi, NULL);
|
||||||
}
|
|
||||||
|
/* Let's wait for the previous dispatched checkpoint. */
|
||||||
|
while (atomic_read(&cprc->queued_ckpt))
|
||||||
|
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi)
|
void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi)
|
||||||
|
|||||||
@@ -3749,6 +3749,7 @@ static inline bool f2fs_need_rand_seg(struct f2fs_sb_info *sbi)
|
|||||||
* checkpoint.c
|
* checkpoint.c
|
||||||
*/
|
*/
|
||||||
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io);
|
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io);
|
||||||
|
void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi);
|
||||||
struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
|
struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
|
||||||
struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
|
struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
|
||||||
struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index);
|
struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index);
|
||||||
|
|||||||
@@ -1657,9 +1657,8 @@ static int f2fs_freeze(struct super_block *sb)
|
|||||||
if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY))
|
if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* ensure no checkpoint required */
|
/* Let's flush checkpoints and stop the thread. */
|
||||||
if (!llist_empty(&F2FS_SB(sb)->cprc_info.issue_list))
|
f2fs_flush_ckpt_thread(F2FS_SB(sb));
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */
|
/* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */
|
||||||
set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING);
|
set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING);
|
||||||
|
|||||||
Reference in New Issue
Block a user