From 1173a4ba26eb3788653dcfc541e0994b9ee7b29f Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 4 Feb 2020 09:32:42 -0500 Subject: [PATCH] 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 Signed-off-by: David Sterba --- check/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/check/main.c b/check/main.c index 6fe00309..b56255bc 100644 --- a/check/main.c +++ b/check/main.c @@ -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 */