diff options
author | Yunlei He <heyunlei@huawei.com> | 2016-01-30 10:26:29 +0800 |
---|---|---|
committer | luca020400 <luca.stefani.ge1@gmail.com> | 2016-04-04 17:16:17 +0200 |
commit | 6bcd4d121518c507dc85fe5b0adc4a08ed47ab9f (patch) | |
tree | 5155c3b26c29a725fb27966ae0936ad0a936b167 | |
parent | 5353147d8f0e55f51290a3a78858afe24594f19f (diff) | |
download | android_external_f2fs-tools-6bcd4d121518c507dc85fe5b0adc4a08ed47ab9f.tar.gz android_external_f2fs-tools-6bcd4d121518c507dc85fe5b0adc4a08ed47ab9f.tar.bz2 android_external_f2fs-tools-6bcd4d121518c507dc85fe5b0adc4a08ed47ab9f.zip |
fsck.f2fs: avoid fix ssa in some case
In some case, we need confirm node or data blkaddr is ok at first,
and then fix the conflict in ssa block. If the node blkaddr happen to
locate in data type segment caused by something error, may be we 'd
better ignore it, and it's same with data blkaddr.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index e7dd02f..7facf07 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -129,6 +129,7 @@ static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, { struct f2fs_summary_block *sum_blk; struct f2fs_summary *sum_entry; + struct seg_entry * se; u32 segno, offset; int need_fix = 0, ret = 0; int type; @@ -145,9 +146,16 @@ static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, ret = -EINVAL; goto out; } - FIX_MSG("Summary footer indicates a node segment: 0x%x", segno); - sum_blk->footer.entry_type = SUM_TYPE_NODE; + need_fix = 1; + se = get_seg_entry(sbi, segno); + if(IS_NODESEG(se->type)) { + FIX_MSG("Summary footer indicates a node segment: 0x%x", segno); + sum_blk->footer.entry_type = SUM_TYPE_NODE; + } else { + ret = -EINVAL; + goto out; + } } sum_entry = &(sum_blk->entries[offset]); @@ -235,6 +243,7 @@ static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, { struct f2fs_summary_block *sum_blk; struct f2fs_summary *sum_entry; + struct seg_entry * se; u32 segno, offset; int need_fix = 0, ret = 0; int type; @@ -251,9 +260,16 @@ static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, ret = -EINVAL; goto out; } - FIX_MSG("Summary footer indicates a data segment: 0x%x", segno); - sum_blk->footer.entry_type = SUM_TYPE_DATA; + need_fix = 1; + se = get_seg_entry(sbi, segno); + if (IS_DATASEG(se->type)) { + FIX_MSG("Summary footer indicates a data segment: 0x%x", segno); + sum_blk->footer.entry_type = SUM_TYPE_DATA; + } else { + ret = -EINVAL; + goto out; + } } sum_entry = &(sum_blk->entries[offset]); @@ -352,11 +368,6 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, return -EINVAL; } - if (is_valid_ssa_node_blk(sbi, nid, ni->blk_addr)) { - ASSERT_MSG("summary node block is not valid. [0x%x]", nid); - return -EINVAL; - } - ret = dev_read_block(node_blk, ni->blk_addr); ASSERT(ret >= 0); @@ -427,6 +438,11 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, ASSERT_MSG("orphan or xattr nid is duplicated [0x%x]\n", nid); + if (is_valid_ssa_node_blk(sbi, nid, ni->blk_addr)) { + ASSERT_MSG("summary node block is not valid. [0x%x]", nid); + return -EINVAL; + } + if (f2fs_test_sit_bitmap(sbi, ni->blk_addr) == 0) ASSERT_MSG("SIT bitmap is 0x0. blk_addr[0x%x]", ni->blk_addr); |