diff mbox series

[5/7] fiemap-tester: holes can be backed by unwritten extents

Message ID 168305811472.331137.10386168929752413533.stgit@frogsfrogsfrogs (mailing list archive)
State New, archived
Headers show
Series fstests: random fixes for v2023.05.01 | expand

Commit Message

Darrick J. Wong May 2, 2023, 8:08 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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 <djwong@kernel.org>
---
 src/fiemap-tester.c |    7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c
index 3db24daa79..7e9f9fe8c1 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) {