echo 0 >/sys/fs/ext4/$sdev/extent_max_zeroout_kb
}
+# The default behavior of SEEK_HOLE is to always return EOF.
+# Filesystems that implement non-default behavior return the offset
+# of holes with SEEK_HOLE. There is no way to query the filesystem
+# of which behavior it is implementing.
+# We use this whitelist FSTYP, to set expectation and avoid silent
+# regression of filesystem seek hole behavior.
+#
+# Return 0 for true
+_fstyp_has_non_default_seek_data_hole()
+{
+ if [ -z $1 ]; then
+ local fstyp=$FSTYP
+ else
+ local fstyp=$1
+ fi
+
+ case "$fstyp" in
+ btrfs|ext4|xfs|ceph|cifs|f2fs|gfs2|nfs*|ocfs2|tmpfs)
+ return 0
+ ;;
+ overlay)
+ if [ ! -z $OVL_BASE_FSTYP -a $OVL_BASE_FSTYP != "overlay" ]; then
+ _fstyp_has_non_default_seek_data_hole $OVL_BASE_FSTYP
+ return $?
+ else
+ # Assume that base fs has default behavior
+ return 1
+ fi
+ ;;
+ *)
+ # by default fstyp has default SEEK_HOLE behavior;
+ # if your fs has non-default behavior, add it to whitelist above!
+ return 1
+ ;;
+ esac
+}
+
+# Run seek sanity test with predefined expectation for SEEK_DATA/HOLE behavior
+_run_seek_sanity_test()
+{
+ local testseekargs
+ if _fstyp_has_non_default_seek_data_hole; then
+ testseekargs+="-f"
+ fi
+ $here/src/seek_sanity_test $testseekargs $*
+}
+
# Check if the file system supports seek_data/hole
_require_seek_data_hole()
{
#endif
static blksize_t alloc_size;
+int allow_default_behavior = 1;
int default_behavior = 0;
int unwritten_extents = 0;
char *base_file_path;
fprintf(stderr, "File system supports the default behavior.\n");
}
+ if (default_behavior && !allow_default_behavior) {
+ fprintf(stderr, "Default behavior is not allowed. Aborting.\n");
+ ret = -1;
+ goto out;
+ }
+
ftruncate(fd, 0);
if (fallocate(fd, 0, 0, alloc_size) == -1) {
if (errno == EOPNOTSUPP)
void usage(char *cmd)
{
- fprintf(stdout, "Usage: %s [-t] [-s <starttest>] [-e <endtest>] base_file_path\n", cmd);
+ fprintf(stdout, "Usage: %s [-tf] [-s <starttest>] [-e <endtest>] base_file_path\n", cmd);
exit(1);
}
teststart = 1;
testend = 12;
- while ((opt = getopt(argc, argv, "ts:e:")) != -1) {
+ while ((opt = getopt(argc, argv, "tfs:e:")) != -1) {
switch (opt) {
case 't':
check_support++;
break;
+ case 'f':
+ allow_default_behavior = 0;
+ break;
case 's':
teststart = strtol(optarg, NULL, 10);
if (teststart <= 0 || teststart > numtests) {
eval "rm -f $BASE_TEST_FILE.*"
}
-$here/src/seek_sanity_test $BASE_TEST_FILE > $seqres.full 2>&1 ||
+_run_seek_sanity_test $BASE_TEST_FILE > $seqres.full 2>&1 ||
_fail "seek sanity check failed!"
# success, all done
rm -f $tmp.* $BASE_TEST_FILE.*
}
-$here/src/seek_sanity_test -s 13 -e 16 $BASE_TEST_FILE > $seqres.full 2>&1 ||
+_run_seek_sanity_test -s 13 -e 16 $BASE_TEST_FILE > $seqres.full 2>&1 ||
_fail "seek sanity check failed!"
# success, all done
rm -f $tmp.* $BASE_TEST_FILE.*
}
-$here/src/seek_sanity_test -s 17 -e 17 $BASE_TEST_FILE > $seqres.full 2>&1 ||
+_run_seek_sanity_test -s 17 -e 17 $BASE_TEST_FILE > $seqres.full 2>&1 ||
_fail "seek sanity check failed!"
# success, all done
_require_test_program "seek_sanity_test"
-$here/src/seek_sanity_test -s 18 -e 18 $BASE_TEST_FILE > $seqres.full 2>&1 ||
+_run_seek_sanity_test -s 18 -e 18 $BASE_TEST_FILE > $seqres.full 2>&1 ||
_fail "seek sanity check failed!"
_check_dmesg
rm -f $base_test_file*
}
-$here/src/seek_sanity_test -s 19 -e 20 $base_test_file > $seqres.full 2>&1 ||
+_run_seek_sanity_test -s 19 -e 20 $base_test_file > $seqres.full 2>&1 ||
_fail "seek sanity check failed!"
# success, all done