aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2018-07-10 20:29:08 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2018-08-27 23:49:26 -0700
commitee0cb1c45e8f5f3ea388bdc477bb50ed4c934833 (patch)
tree2320ef77a4cf3dd4ccbe338343d578fb2bdb55d7
parenteb9d8037ed3b37a647d514470f1a1df91daedb64 (diff)
downloadf2fs-tools-ee0cb1c45e8f5f3ea388bdc477bb50ed4c934833.tar.gz
fsck.f2fs: fix to do sanity check with extra_attr feature
This patch tries to fix incorrect extra_attr bit or i_extra_isize value in fsck. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fsck/fsck.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 1c1a5bb..544e008 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -658,7 +658,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
u32 i_links = le32_to_cpu(node_blk->i.i_links);
u64 i_size = le64_to_cpu(node_blk->i.i_size);
u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
- int ofs = get_extra_isize(node_blk);
+ int ofs;
unsigned char *en;
int namelen;
unsigned int idx = 0;
@@ -726,6 +726,22 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
get_extent_info(&child.ei, &node_blk->i.i_ext);
child.last_blk = 0;
+ if (f2fs_has_extra_isize(&node_blk->i)) {
+ if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
+ if (node_blk->i.i_extra_isize >
+ cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE)) {
+ node_blk->i.i_extra_isize =
+ cpu_to_le16(F2FS_TOTAL_EXTRA_ATTR_SIZE);
+ need_fix = 1;
+ }
+ } else {
+ /* we don't support tuning F2FS_FEATURE_EXTRA_ATTR now */
+ node_blk->i.i_inline &= ~F2FS_EXTRA_ATTR;
+ need_fix = 1;
+ }
+ }
+ ofs = get_extra_isize(node_blk);
+
if ((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
if (le32_to_cpu(node_blk->i.i_addr[ofs]) != 0) {
/* should fix this bug all the time */