diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-02-24 10:09:07 -0800 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2015-03-23 10:10:27 -0700 |
commit | 3e2c7b7ed31829c836958b87656b286d9ddfa10c (patch) | |
tree | 771c78bf9c11f4c648476a69b91d608c146057d2 | |
parent | 0bdc381123301faf15867e8728f6dca34d6a78d6 (diff) | |
download | f2fs-tools-3e2c7b7ed31829c836958b87656b286d9ddfa10c.tar.gz |
fsck.f2fs: remove corrupted data indices in direct node blocks
Previously, only data blocks locating in its inode block could be fixed.
This patch investigates direct node blocks to fix indices too.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/fsck.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index 9d6fc42..1b27ae0 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -556,6 +556,7 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, { int idx, ret; u32 child_cnt = 0, child_files = 0; + int need_fix = 0; for (idx = 0; idx < ADDRS_PER_BLOCK; idx++) { if (le32_to_cpu(node_blk->dn.addr[idx]) == 0x0) @@ -565,8 +566,17 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, &child_cnt, &child_files, le64_to_cpu(inode->i_blocks) == *blk_cnt, ftype, nid, idx, ni->version); - if (!ret) + if (!ret) { *blk_cnt = *blk_cnt + 1; + } else if (config.fix_on) { + node_blk->dn.addr[idx] = 0; + need_fix = 1; + FIX_MSG("[0x%x] dn.addr[%d] = 0", nid, idx); + } + } + if (need_fix) { + ret = dev_write_block(node_blk, ni->blk_addr); + ASSERT(ret >= 0); } return 0; } |