btrfs-progs: fix hole error output in fsck

If we don't find holes in our hole rb tree we'll just assume there's a
gap from 0 to the length of the file and print that out.  But this
simply isn't correct, we could have a gap between the last extent and
the isize, or 0 and the start of the first extent.  Fix the error
message to tell us exactly where the hole is.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Josef Bacik 2020-02-04 09:32:42 -05:00 committed by David Sterba
parent f2832d534b
commit 1173a4ba26
1 changed files with 14 additions and 4 deletions

View File

@ -638,10 +638,20 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
hole->start, hole->len);
node = rb_next(node);
}
if (!found)
fprintf(stderr, "\tstart: 0, len: %llu\n",
round_up(rec->isize,
root->fs_info->sectorsize));
if (!found) {
u64 start, len;
if (rec->extent_end < rec->isize) {
start = rec->extent_end;
len = round_up(rec->isize,
root->fs_info->sectorsize) -
start;
} else {
start = 0;
len = rec->extent_start;
}
fprintf(stderr, "\tstart: %llu, len: %llu\n", start,
len);
}
}
/* Print dir item with mismatch hash */