From c387c694bde333fb3e1f46e09b65a7d4b5e52572 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 2 May 2023 13:08:34 -0700 Subject: [PATCH] fiemap-tester: holes can be backed by unwritten extents Filesystem behavior is pretty open-ended for sparse ranges (i.e. holes) of a file that have not yet been written to. That space can remain unmapped, it can be mapped to written space that has been zeroed, or it can be mapped to unwritten extents. This program trips over that last condition on XFS. If the file is located on a data device with a raid stripe geometry or on a realtime device with a realtime extent size larger than 1 filesystem block, it's possible for unwritten areas to be backed by unwritten preallocations or unwritten rt blocks, respectively. Fix the test to skip unwritten extents here. Signed-off-by: Darrick J. Wong Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- src/fiemap-tester.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c index 3db24daa..7e9f9fe8 100644 --- a/src/fiemap-tester.c +++ b/src/fiemap-tester.c @@ -375,6 +375,13 @@ check_hole(struct fiemap *fiemap, int fd, __u64 logical_offset, int blocksize) if (logical_offset + blocksize < start) break; + /* + * Filesystems are allowed to fill in holes with preallocated + * unwritten extents + */ + if (extent->fe_flags & FIEMAP_EXTENT_UNWRITTEN) + continue; + if (logical_offset >= start && logical_offset < end) { -- 2.39.5