#include <string.h>
#include <unistd.h>
#include <getopt.h>
+#include <stdbool.h>
/*
* btrfs has a fixed stripewidth of 64k, so we need to write enough data to
static void usage()
{
- printf("Usage: fsync-err [ -b bufsize ] [ -n num_fds ] -d dmerror path <filename>\n");
+ printf("Usage: fsync-err [ -b bufsize ] [ -n num_fds ] [ -s ] -d dmerror path <filename>\n");
}
int main(int argc, char **argv)
char *dmerror_path = NULL;
char *cmdbuf;
size_t cmdsize, bufsize = DEFAULT_BUFSIZE;
+ bool simple_mode = false;
- while ((i = getopt(argc, argv, "b:d:n:")) != -1) {
+ while ((i = getopt(argc, argv, "b:d:n:s")) != -1) {
switch (i) {
case 'b':
bufsize = strtol(optarg, &buf, 0);
return 1;
}
break;
+ case 's':
+ /*
+ * Many filesystems will continue to throw errors after
+ * fsync has already advanced to the current error,
+ * due to metadata writeback failures or other
+ * issues. Allow those fs' to opt out of more thorough
+ * testing.
+ */
+ simple_mode = true;
}
}
}
}
- for (i = 0; i < numfds; ++i) {
- ret = fsync(fd[i]);
- if (ret < 0) {
- /*
- * We did a failed write and fsync on each fd before.
- * Now the error should be clear since we've not done
- * any writes since then.
- */
- printf("Third fsync on fd[%d] failed: %m\n", i);
- return 1;
+ if (!simple_mode) {
+ for (i = 0; i < numfds; ++i) {
+ ret = fsync(fd[i]);
+ if (ret < 0) {
+ /*
+ * We did a failed write and fsync on each fd before.
+ * Now the error should be clear since we've not done
+ * any writes since then.
+ */
+ printf("Third fsync on fd[%d] failed: %m\n", i);
+ return 1;
+ }
}
}
return 1;
}
- for (i = 0; i < numfds; ++i) {
- ret = fsync(fd[i]);
- if (ret < 0) {
- /* The error should still be clear */
- printf("fsync after healing device on fd[%d] failed: %m\n", i);
- return 1;
+ if (!simple_mode) {
+ for (i = 0; i < numfds; ++i) {
+ ret = fsync(fd[i]);
+ if (ret < 0) {
+ /* The error should still be clear */
+ printf("fsync after healing device on fd[%d] failed: %m\n", i);
+ return 1;
+ }
}
}
. ./common/dmerror
# real QA test starts here
-_supported_fs ext2 ext3 ext4 xfs
_supported_os Linux
_require_scratch
-# Generally, we want to avoid journal errors in this test. Ensure that
-# journalled fs' have a logdev.
-if [ "$FSTYP" != "ext2" ]; then
- _require_logdev
-fi
+# Generally, we want to avoid journal errors on the extended testcase. Only
+# unset the -s flag if we have a logdev
+sflag='-s'
+case $FSTYP in
+ btrfs)
+ _notrun "btrfs has a specialized test for this"
+ ;;
+ ext3|ext4|xfs)
+ # Do the more thorough test if we have a logdev
+ _has_logdev && sflag=''
+ ;;
+ *)
+ ;;
+esac
_require_dm_target error
_require_test_program fsync-err
testfile=$SCRATCH_MNT/fsync-err-test
-$here/src/fsync-err -d $here/src/dmerror $testfile
+echo "$here/src/fsync-err $sflag -d $here/src/dmerror $testfile" >> $seqres.full
+$here/src/fsync-err $sflag -d $here/src/dmerror $testfile
# success, all done
_dmerror_load_working_table