diff mbox series

[1/3] btrfs-progs: fix check to catch gaps at the start of the file

Message ID 20200204143243.696500-2-josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Fix btrfs check handling of missing file extents | expand

Commit Message

Josef Bacik Feb. 4, 2020, 2:32 p.m. UTC
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>
---
 check/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index 4115049a..22f4e24c 100644
--- a/check/main.c
+++ b/check/main.c
@@ -827,8 +827,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;
 	}