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@xxxxxxxxxxxxxx>
---
check/main.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/check/main.c b/check/main.c
index 22f4e24c..71b68ff9 100644
--- a/check/main.c
+++ b/check/main.c
@@ -639,10 +639,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 */
--
2.24.1