btrfs-progs: fix check to catch gaps at the start of the file

When writing my test for the i_size patches, I noticed that I was not
actually failing without my patches as I should have been.  This is
because we only check if the inode record extent end is < isize, we
don't check if the inode record extent start is > 0.  Add this check to
make sure we're catching holes that start at the beginning of the file.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Josef Bacik 2020-02-04 09:32:40 -05:00 committed by David Sterba
parent fae40e9d73
commit 9123fc6142
1 changed files with 2 additions and 1 deletions

View File

@ -826,8 +826,9 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache,
/* Orphan inodes don't have correct nbytes */
if (rec->nlink > 0 && rec->found_size != rec->nbytes)
rec->errors |= I_ERR_FILE_NBYTES_WRONG;
if (rec->nlink > 0 && !no_holes &&
if (rec->nlink > 0 && !no_holes && rec->isize &&
(rec->extent_end < rec->isize ||
rec->extent_start != 0 ||
first_extent_gap(&rec->holes) < rec->isize))
rec->errors |= I_ERR_FILE_EXTENT_DISCOUNT;
}