mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
f2fs: fix changing cursegs if recovery fails on zoned device
Fsync data recovery attempts to check and fix write pointer consistency of cursegs and all other zones. If the write pointers of cursegs are unaligned, cursegs are changed to new sections. If recovery fails, zone write pointers are still checked and fixed, but the latest checkpoint cannot be written back. Additionally, retry- mount skips recovery and rolls back to reuse the old cursegs whose zones are already finished. This can lead to unaligned write later. This patch addresses the issue by leaving writer pointers untouched if recovery fails. When retry-mount is performed, cursegs and other zones are checked and fixed after skipping recovery. Signed-off-by: Song Feng <songfeng@oppo.com> Signed-off-by: Yongpeng Yang <yangyongpeng1@oppo.com> Signed-off-by: Sheng Yong <shengyong@oppo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
a35749b1ed
commit
1015035609
@ -3775,8 +3775,7 @@ void f2fs_write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
|
||||
int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
|
||||
unsigned int val, int alloc);
|
||||
void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
|
||||
int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi);
|
||||
int f2fs_check_write_pointer(struct f2fs_sb_info *sbi);
|
||||
int f2fs_check_and_fix_write_pointer(struct f2fs_sb_info *sbi);
|
||||
int f2fs_build_segment_manager(struct f2fs_sb_info *sbi);
|
||||
void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi);
|
||||
int __init f2fs_create_segment_manager_caches(void);
|
||||
|
@ -899,13 +899,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
|
||||
* and the f2fs is not read only, check and fix zoned block devices'
|
||||
* write pointer consistency.
|
||||
*/
|
||||
if (f2fs_sb_has_blkzoned(sbi) && !f2fs_readonly(sbi->sb)) {
|
||||
int err2 = f2fs_fix_curseg_write_pointer(sbi);
|
||||
|
||||
if (!err2)
|
||||
err2 = f2fs_check_write_pointer(sbi);
|
||||
if (err2)
|
||||
err = err2;
|
||||
if (!err) {
|
||||
err = f2fs_check_and_fix_write_pointer(sbi);
|
||||
ret = err;
|
||||
}
|
||||
|
||||
|
@ -5246,7 +5246,7 @@ static int report_one_zone_cb(struct blk_zone *zone, unsigned int idx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
|
||||
static int do_fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
|
||||
{
|
||||
struct curseg_info *cs = CURSEG_I(sbi, type);
|
||||
struct f2fs_dev_info *zbd;
|
||||
@ -5351,12 +5351,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi)
|
||||
static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < NR_PERSISTENT_LOG; i++) {
|
||||
ret = fix_curseg_write_pointer(sbi, i);
|
||||
ret = do_fix_curseg_write_pointer(sbi, i);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
@ -5379,7 +5379,7 @@ static int check_zone_write_pointer_cb(struct blk_zone *zone, unsigned int idx,
|
||||
return check_zone_write_pointer(args->sbi, args->fdev, zone);
|
||||
}
|
||||
|
||||
int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)
|
||||
static int check_write_pointer(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
int i, ret;
|
||||
struct check_zone_write_pointer_args args;
|
||||
@ -5399,6 +5399,20 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_check_and_fix_write_pointer(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!f2fs_sb_has_blkzoned(sbi) || f2fs_readonly(sbi->sb))
|
||||
return 0;
|
||||
|
||||
f2fs_notice(sbi, "Checking entire write pointers");
|
||||
ret = fix_curseg_write_pointer(sbi);
|
||||
if (!ret)
|
||||
ret = check_write_pointer(sbi);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of usable blocks in a segment. The number of blocks
|
||||
* returned is always equal to the number of blocks in a segment for
|
||||
@ -5435,12 +5449,7 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(
|
||||
return BLKS_PER_SEG(sbi);
|
||||
}
|
||||
#else
|
||||
int f2fs_fix_curseg_write_pointer(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)
|
||||
int f2fs_check_and_fix_write_pointer(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -4774,16 +4774,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
reset_checkpoint:
|
||||
/*
|
||||
* If the f2fs is not readonly and fsync data recovery succeeds,
|
||||
* check zoned block devices' write pointer consistency.
|
||||
* write pointer consistency of cursegs and other zones are already
|
||||
* checked and fixed during recovery. However, if recovery fails,
|
||||
* write pointers are left untouched, and retry-mount should check
|
||||
* them here.
|
||||
*/
|
||||
if (f2fs_sb_has_blkzoned(sbi) && !f2fs_readonly(sb)) {
|
||||
int err2;
|
||||
|
||||
f2fs_notice(sbi, "Checking entire write pointers");
|
||||
err2 = f2fs_check_write_pointer(sbi);
|
||||
if (err2)
|
||||
err = err2;
|
||||
}
|
||||
if (skip_recovery)
|
||||
err = f2fs_check_and_fix_write_pointer(sbi);
|
||||
if (err)
|
||||
goto free_meta;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user