]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
fiemap-tester: holes can be backed by unwritten extents
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 May 2023 20:08:34 +0000 (13:08 -0700)
committerZorro Lang <zlang@kernel.org>
Sun, 14 May 2023 13:51:47 +0000 (21:51 +0800)
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>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/fiemap-tester.c

index 3db24daa792b0e7a6338adbc6626b3a4351c2552..7e9f9fe8c12b24c2395162292a11df099cd55831 100644 (file)
@@ -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) {