diff options
author | Sheng Yong <shengyong1@huawei.com> | 2016-03-14 14:16:54 +0800 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2016-11-12 11:32:44 +0100 |
commit | 376c258c97b83f3b02440e4fa4313ff9e26bde64 (patch) | |
tree | 6e479a5986d4505fc14e7cb5a8a4892fff581a92 /fsck | |
parent | 2e43334233ed12bd5d1cdd3041b1c47366f9c17c (diff) | |
download | android_external_f2fs-tools-376c258c97b83f3b02440e4fa4313ff9e26bde64.tar.gz android_external_f2fs-tools-376c258c97b83f3b02440e4fa4313ff9e26bde64.tar.bz2 android_external_f2fs-tools-376c258c97b83f3b02440e4fa4313ff9e26bde64.zip |
fsck.f2fs: count the number of inodes during building nat_area_bitmap
The nid and ino of an inode are the same. So during building
nat_area_bitmap, we can know which nat entry represents an
inode, thus, we can count the number of inodes.
Then in fsck_chk_meta, the amount of inodes can be compared
with that recorded in CP.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fsck')
-rw-r--r-- | fsck/fsck.c | 8 | ||||
-rw-r--r-- | fsck/fsck.h | 1 | ||||
-rw-r--r-- | fsck/mount.c | 10 |
3 files changed, 19 insertions, 0 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index fede8e1..7100397 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -1573,6 +1573,14 @@ int fsck_chk_meta(struct f2fs_sb_info *sbi) return -EINVAL; } + if (fsck->nat_valid_inode_cnt != le32_to_cpu(cp->valid_inode_count)) { + ASSERT_MSG("valid inode does not match: nat_valid_inode_cnt %u," + " valid_inode_count %u", + fsck->nat_valid_inode_cnt, + le32_to_cpu(cp->valid_inode_count)); + return -EINVAL; + } + return 0; } diff --git a/fsck/fsck.h b/fsck/fsck.h index f03efb8..da4e6ad 100644 --- a/fsck/fsck.h +++ b/fsck/fsck.h @@ -76,6 +76,7 @@ struct f2fs_fsck { u32 nr_nat_entries; u32 dentry_depth; + u32 nat_valid_inode_cnt; }; #define BLOCK_SZ 4096 diff --git a/fsck/mount.c b/fsck/mount.c index af1e0c3..4f907ef 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -1679,6 +1679,11 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi) if (lookup_nat_in_journal(sbi, nid + i, &raw_nat) >= 0) { node_info_from_raw_nat(&ni, &raw_nat); + if (ni.ino == (nid + i) && ni.blk_addr != 0) { + fsck->nat_valid_inode_cnt++; + DBG(3, "ino[0x%8x] maybe is inode\n", + ni.ino); + } if (ni.blk_addr != 0x0) { f2fs_set_bit(nid + i, fsck->nat_area_bitmap); @@ -1689,6 +1694,11 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi) } else { node_info_from_raw_nat(&ni, &nat_block->entries[i]); + if (ni.ino == (nid + i) && ni.blk_addr != 0) { + fsck->nat_valid_inode_cnt++; + DBG(3, "ino[0x%8x] maybe is inode\n", + ni.ino); + } if (ni.blk_addr == 0) continue; if (nid + i == 0) { |