On 2018/10/23 下午5:41, Su Yue wrote:
> 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.
>
> Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com>
Overall looks good.
Just a small nitpick.
> ---
> check/mode-lowmem.c | 29 ++++++++++++++++-------------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index c8e4f13d816f..76e7be81ceb1 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -2125,7 +2125,7 @@ out:
> error("failed to set nbytes in inode %llu root %llu",
> ino, root->root_key.objectid);
> else
> - printf("Set nbytes in inode item %llu root %llu\n to %llu", ino,
> + printf("Set nbytes in inode item %llu root %llu to %llu\n", ino,
It's better to fix it in another patch.
Thanks,
Qu
> root->root_key.objectid, nbytes);
>
> /* research path */
> @@ -2543,28 +2543,31 @@ out:
> }
> }
>
> - if (!nbytes && !no_holes && extent_end < isize) {
> - if (repair)
> - ret = punch_extent_hole(root, path, inode_id,
> - extent_end, isize - extent_end);
> + 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] size %llu should have a file extent hole",
> - root->objectid, inode_id, isize);
> + "root %llu INODE[%llu] nbytes %llu not equal to extent_size %llu",
> + root->objectid, inode_id, nbytes,
> + extent_size);
> }
> }
>
> - if (nbytes != extent_size) {
> + if (!nbytes && !no_holes && extent_end < isize) {
> if (repair)
> - ret = repair_inode_nbytes_lowmem(root, path,
> - inode_id, extent_size);
> + ret = punch_extent_hole(root, path, inode_id,
> + extent_end, isize - extent_end);
> 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);
> + "root %llu INODE[%llu] size %llu should have a file extent hole",
> + root->objectid, inode_id, isize);
> }
> }
> }
>