Skip to content

Commit

Permalink
f2fs: keep meta pages in cp_error state
Browse files Browse the repository at this point in the history
It turns out losing meta pages in shutdown period makes f2fs very unstable
so that I could see many unexpected error conditions.

Let's keep meta pages for fault injection and sudden power-off tests.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: khusika <khusikadhamar@gmail.com>
  • Loading branch information
Jaegeuk Kim authored and khusika committed Oct 13, 2018
1 parent 6e50e47 commit d7d9af6
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,8 @@ static int __f2fs_write_meta_page(struct page *page,

trace_f2fs_writepage(page, META);

if (unlikely(f2fs_cp_error(sbi))) {
dec_page_count(sbi, F2FS_DIRTY_META);
unlock_page(page);
return 0;
}
if (unlikely(f2fs_cp_error(sbi)))
goto redirty_out;
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
goto redirty_out;
if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
Expand Down Expand Up @@ -1125,6 +1122,9 @@ static void wait_on_all_pages_writeback(struct f2fs_sb_info *sbi)
if (!get_pages(sbi, F2FS_WB_CP_DATA))
break;

if (unlikely(f2fs_cp_error(sbi)))
break;

io_schedule_timeout(5*HZ);
}
finish_wait(&sbi->cp_wait, &wait);
Expand Down Expand Up @@ -1198,8 +1198,12 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi,

/* writeout cp pack 2 page */
err = __f2fs_write_meta_page(page, &wbc, FS_CP_META_IO);
f2fs_bug_on(sbi, err);
if (unlikely(err && f2fs_cp_error(sbi))) {
f2fs_put_page(page, 1);
return;
}

f2fs_bug_on(sbi, err);
f2fs_put_page(page, 0);

/* submit checkpoint (with barrier if NOBARRIER is not set) */
Expand All @@ -1225,7 +1229,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
while (get_pages(sbi, F2FS_DIRTY_META)) {
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
break;
}

/*
Expand Down Expand Up @@ -1305,7 +1309,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
f2fs_sync_meta_pages(sbi, META, LONG_MAX,
FS_CP_META_IO);
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
break;
}
}

Expand Down Expand Up @@ -1346,9 +1350,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
/* wait for previous submitted meta pages writeback */
wait_on_all_pages_writeback(sbi);

if (unlikely(f2fs_cp_error(sbi)))
return -EIO;

/* flush all device cache */
err = f2fs_flush_device_cache(sbi);
if (err)
Expand All @@ -1360,9 +1361,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

f2fs_release_ino_entry(sbi, false);

if (unlikely(f2fs_cp_error(sbi)))
return -EIO;

clear_sbi_flag(sbi, SBI_IS_DIRTY);
clear_sbi_flag(sbi, SBI_NEED_CP);
__set_cp_next_pack(sbi);
Expand All @@ -1377,7 +1375,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_DENTS));

return 0;
return unlikely(f2fs_cp_error(sbi)) ? -EIO : 0;
}

/*
Expand Down

0 comments on commit d7d9af6

Please sign in to comment.