btrfs-progs: lowmem: move nbytes check before isize check

For files, lowmem repair will try to check nbytes and isize,
but isize check depends nbytes.

Once bytes has been repaired, then isize should be checked and
repaired.
So move nbytes check before isize check. Also set nbytes to
extent_size once repaired successfully.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
This commit is contained in:
Su Yue 2019-02-27 14:05:41 +08:00 committed by Qu Wenruo
parent ee455db07e
commit 0ea38ae08d
1 changed files with 16 additions and 13 deletions

View File

@ -2606,6 +2606,22 @@ out:
}
}
if (nbytes != extent_size) {
if (repair) {
ret = repair_inode_nbytes_lowmem(root, path,
inode_id, extent_size);
if (!ret)
nbytes = extent_size;
}
if (!repair || ret) {
err |= NBYTES_ERROR;
error(
"root %llu INODE[%llu] nbytes %llu not equal to extent_size %llu",
root->objectid, inode_id, nbytes,
extent_size);
}
}
if (!nbytes && !no_holes && extent_end < isize) {
if (repair)
ret = punch_extent_hole(root, path, inode_id,
@ -2617,19 +2633,6 @@ out:
root->objectid, inode_id, isize);
}
}
if (nbytes != extent_size) {
if (repair)
ret = repair_inode_nbytes_lowmem(root, path,
inode_id, extent_size);
if (!repair || ret) {
err |= NBYTES_ERROR;
error(
"root %llu INODE[%llu] nbytes %llu not equal to extent_size %llu",
root->objectid, inode_id, nbytes,
extent_size);
}
}
}
if (err & LAST_ITEM)