Skip to contentSkip to conversation

Crash consistency xfstest using dm-log-writes

PATCH Superseded Amir Goldstein 5 participants 35 messages Sep 5, 2017 – Dec 4, 2017 3 messages not in the archive

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Crash consistency xfstest using dm-log-writes

Eryu,

This is the 3rd revision of crash consistency patch set. I addressed all your review commennts on v2 patches.

These patches are originally from Josef Bacik.

I've added some debugging options for running fsx and replay-log, which I used to analyze the crash consistency bugs uncovered by the tests.

The original fsx crash consistency test (500) is failing sometimes on kernel v4.13 for ext4, btrfs and xfs.
A fix for xfs is queued for v4.14, I think there is a fix by Josef for btrfs queued for v4.14 as well.

A 'quick' and reliable regression test (501) was created for the ext4 issue.

I created another crash consistency test which runs fsx on cloned files (502). This test is failing check fs sometimes on kernel v4.13, at the end of the test, but this is not related to crash consistency. There is a fix is the works for v4.14.

A 'quick' and reliable regression test (503) was created for this issue.

The new 'clones crash' test (502) is also failing sometimes on xfs_repair errors like: "fatal error -- illegal state 13 in block map 147", on crash points, but I havn't been able to narrow down the issue yet.

Amir.

Amir Goldstein (13):
fsx: add support for integrity check with dm-log-writes target
fsx: add optional logid prefix to log messages
fsx: add support for recording operations to a file
fsx: add support for writing constant instead of random data
fsx: add support for keeping existing file
log-writes: add replay-log program to replay dm-log-writes target
replay-log: add validations for corrupt log entries
replay-log: add support for replaying ops in target device sector
fstests: add support for working with dm-log-writes target
fstests: crash consistency fsx test using dm-log-writes
fstests: regression test for ext4 crash consistency bug
fstests: crash consistency fsx test for cloned files
fstests: regression test for xfs leftover CoW extent error

 .gitignore                   |   1 +
 README                       |   2 +
 common/dmlogwrites           |  94 +++++++++
 doc/auxiliary-programs.txt   |   8 +
 doc/requirement-checking.txt |  20 ++
 ltp/fsx.c                    | 246 ++++++++++++++++++-----
 src/Makefile                 |   2 +-
 src/log-writes/Makefile      |  23 +++
 src/log-writes/SOURCE        |   6 +
 src/log-writes/log-writes.c  | 458 +++++++++++++++++++++++++++++++++++++++++++
 src/log-writes/log-writes.h  |  81 ++++++++
 src/log-writes/replay-log.c  | 389 ++++++++++++++++++++++++++++++++++++
 tests/generic/500            | 135 +++++++++++++
 tests/generic/500.out        |   2 +
 tests/generic/501            |  80 ++++++++
 tests/generic/501.out        |   2 +
 tests/generic/502            | 142 ++++++++++++++
 tests/generic/502.out        |   2 +
 tests/generic/503            |  69 +++++++
 tests/generic/503.out        |   2 +
 tests/generic/group          |   4 +
 21 files changed, 1721 insertions(+), 47 deletions(-)
 create mode 100644 common/dmlogwrites
 create mode 100644 src/log-writes/Makefile
 create mode 100644 src/log-writes/SOURCE
 create mode 100644 src/log-writes/log-writes.c
 create mode 100644 src/log-writes/log-writes.h
 create mode 100644 src/log-writes/replay-log.c
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
 create mode 100755 tests/generic/501
 create mode 100644 tests/generic/501.out
 create mode 100755 tests/generic/502
 create mode 100644 tests/generic/502.out
 create mode 100755 tests/generic/503
 create mode 100644 tests/generic/503.out
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/13 fsx: add support for integrity check with dm-log-writes target

Cherry-picked the relevant fsx bits from commit 70d41e17164b in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

I've rigged up fsx to have an integrity check mode. Basically it works like it normally works, but when it fsync()'s it marks the log with a unique mark and dumps it's buffer to a file with the mark in the filename. I did this with a system() call simply because it was the fastest. I can link the device-mapper libraries and do it programatically if that would be preferred, but this works pretty well.

[Amir:]
- Fix some exit codes
- Require -P dirpath for -i logdev

---
 ltp/fsx.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 123 insertions(+), 24 deletions(-)
ltp/fsx.c +123 -24
index ea00ff7..ac466ee 100644
@@ -67,15 +67,17 @@ int			logcount = 0;	/* total ops */
  * be careful in how we select the different operations. The active operations
  * are mapped to numbers as follows:
  *
- *		lite	!lite
- * READ:	0	0
- * WRITE:	1	1
- * MAPREAD:	2	2
- * MAPWRITE:	3	3
- * TRUNCATE:	-	4
- * FALLOCATE:	-	5
- * PUNCH HOLE:	-	6
- * ZERO RANGE:	-	7
+ *			lite	!lite	integrity
+ * READ:		0	0	0
+ * WRITE:		1	1	1
+ * MAPREAD:		2	2	2
+ * MAPWRITE:		3	3	3
+ * TRUNCATE:		-	4	4
+ * FALLOCATE:		-	5	5
+ * PUNCH HOLE:		-	6	6
+ * ZERO RANGE:		-	7	7
+ * COLLAPSE RANGE:	-	8	8
+ * FSYNC:		-	-	9
  *
  * When mapped read/writes are disabled, they are simply converted to normal
  * reads and writes. When fallocate/fpunch calls are disabled, they are
@@ -102,6 +104,10 @@ int			logcount = 0;	/* total ops */
 #define OP_INSERT_RANGE	9
 #define OP_MAX_FULL		10
 
+/* integrity operations */
+#define OP_FSYNC		10
+#define OP_MAX_INTEGRITY	11
+
 #undef PAGE_SIZE
 #define PAGE_SIZE       getpagesize()
 #undef PAGE_MASK
@@ -111,6 +117,10 @@ char	*original_buf;			/* a pointer to the original data */
 char	*good_buf;			/* a pointer to the correct data */
 char	*temp_buf;			/* a pointer to the current data */
 char	*fname;				/* name of our test file */
+char	*bname;				/* basename of our test file */
+char	*logdev;			/* -i flag */
+char	dname[1024];			/* -P flag */
+int	dirpath = 0;			/* -P flag */
 int	fd;				/* fd for our test file */
 
 blksize_t	block_size = 0;
@@ -148,9 +158,11 @@ int     zero_range_calls = 1;           /* -z flag disables */
 int	collapse_range_calls = 1;	/* -C flag disables */
 int	insert_range_calls = 1;		/* -I flag disables */
 int 	mapped_reads = 1;		/* -R flag disables it */
+int	integrity = 0;			/* -i flag */
 int	fsxgoodfd = 0;
 int	o_direct;			/* -Z */
 int	aio = 0;
+int	mark_nr = 0;
 
 int page_size;
 int page_mask;
@@ -234,6 +246,7 @@ static const char *op_names[] = {
 	[OP_ZERO_RANGE] = "zero_range",
 	[OP_COLLAPSE_RANGE] = "collapse_range",
 	[OP_INSERT_RANGE] = "insert_range",
+	[OP_FSYNC] = "fsync",
 };
 
 static const char *op_name(int operation)
@@ -397,6 +410,9 @@ logdump(void)
 			if (overlap)
 				prt("\t******IIII");
 			break;
+		case OP_FSYNC:
+			prt("FSYNC");
+			break;
 		default:
 			prt("BOGUS LOG ENTRY (operation code = %d)!",
 			    lp->operation);
@@ -500,6 +516,43 @@ report_failure(int status)
 				        *(((unsigned char *)(cp)) + 1)))
 
 void
+mark_log(void)
+{
+	char command[256];
+	int ret;
+
+	snprintf(command, 256, "dmsetup message %s 0 mark %s.mark%d", logdev,
+		 bname, mark_nr);
+	ret = system(command);
+	if (ret) {
+		prterr("dmsetup mark failed");
+		exit(211);
+	}
+}
+
+void
+dump_fsync_buffer(void)
+{
+	char fname_buffer[1024];
+	int good_fd;
+
+	if (!good_buf)
+		return;
+
+	snprintf(fname_buffer, 1024, "%s%s.mark%d", dname,
+		 bname, mark_nr);
+	good_fd = open(fname_buffer, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+	if (good_fd < 0) {
+		prterr(fname_buffer);
+		exit(212);
+	}
+
+	save_buffer(good_buf, file_size, good_fd);
+	close(good_fd);
+	prt("Dumped fsync buffer to %s\n", fname_buffer + dirpath);
+}
+
+void
 check_buffers(unsigned offset, unsigned size)
 {
 	unsigned char c, t;
@@ -1256,6 +1309,25 @@ docloseopen(void)
 	}
 }
 
+void
+dofsync(void)
+{
+	int ret;
+
+	if (testcalls <= simulatedopcount)
+		return;
+	if (debug)
+		prt("%lu fsync\n", testcalls);
+	log4(OP_FSYNC, 0, 0, 0);
+	ret = fsync(fd);
+	if (ret < 0) {
+		prterr("dofsync");
+		report_failure(210);
+	}
+	mark_log();
+	dump_fsync_buffer();
+	mark_nr++;
+}
 
 #define TRIM_OFF(off, size)			\
 do {						\
@@ -1403,8 +1475,10 @@ test(void)
 	/* calculate appropriate op to run */
 	if (lite)
 		op = rv % OP_MAX_LITE;
-	else
+	else if (!integrity)
 		op = rv % OP_MAX_FULL;
+	else
+		op = rv % OP_MAX_INTEGRITY;
 
 	switch(op) {
 	case OP_TRUNCATE:
@@ -1528,6 +1602,9 @@ have_op:
 
 		do_insert_range(offset, size);
 		break;
+	case OP_FSYNC:
+		dofsync();
+		break;
 	default:
 		prterr("test: unknown operation");
 		report_failure(42);
@@ -1547,11 +1624,12 @@ void
 usage(void)
 {
 	fprintf(stdout, "usage: %s",
-		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
 	-b opnum: beginning operation number (default 1)\n\
 	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
 	-d: debug output for all operations\n\
 	-f flush and invalidate cache after I/O\n\
+	-i logdev: do integrity testing, logdev is the dm log writes device\n\
 	-l flen: the upper bound on file size (default 262144)\n\
 	-m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
 	-n: no verifications of file size\n\
@@ -1767,14 +1845,14 @@ int
 main(int argc, char **argv)
 {
 	int	i, style, ch;
-	char	*endp;
+	char	*endp, *tmp;
 	char goodfile[1024];
 	char logfile[1024];
-	int dirpath = 0;
 	struct stat statbuf;
 
 	goodfile[0] = 0;
 	logfile[0] = 0;
+	dname[0] = 0;
 
 	page_size = getpagesize();
 	page_mask = page_size - 1;
@@ -1784,7 +1862,7 @@ main(int argc, char **argv)
 	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
 	while ((ch = getopt_long(argc, argv,
-				 "b:c:dfl:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
+				 "b:c:dfi:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
 				 longopts, NULL)) != EOF)
 		switch (ch) {
 		case 'b':
@@ -1811,6 +1889,14 @@ main(int argc, char **argv)
 		case 'f':
 			flush = 1;
 			break;
+		case 'i':
+			integrity = 1;
+			logdev = strdup(optarg);
+			if (!logdev) {
+				prterr("strdup");
+				exit(101);
+			}
+			break;
 		case 'l':
 			maxfilelen = getnum(optarg, &endp);
 			if (maxfilelen <= 0)
@@ -1908,13 +1994,13 @@ main(int argc, char **argv)
 			randomoplen = 0;
 			break;
 		case 'P':
-			strncpy(goodfile, optarg, sizeof(goodfile));
-			strcat(goodfile, "/");
-			strncpy(logfile, optarg, sizeof(logfile));
-			strcat(logfile, "/");
-			strncpy(opsfile, optarg, sizeof(logfile));
-			strcat(opsfile, "/");
-			dirpath = 1;
+			strncpy(dname, optarg, sizeof(dname));
+			strcat(dname, "/");
+			dirpath = strlen(dname);
+
+			strncpy(goodfile, dname, sizeof(goodfile));
+			strncpy(logfile, dname, sizeof(logfile));
+			strncpy(opsfile, dname, sizeof(logfile));
 			break;
                 case 'R':
                         mapped_reads = 0;
@@ -1949,7 +2035,19 @@ main(int argc, char **argv)
 	argv += optind;
 	if (argc != 1)
 		usage();
+
+	if (integrity && !dirpath) {
+		fprintf(stderr, "option -i <logdev> requires -P <dirpath>\n");
+		usage();
+	}
+
 	fname = argv[0];
+	tmp = strdup(fname);
+	if (!tmp) {
+		prterr("strdup");
+		exit(101);
+	}
+	bname = basename(tmp);
 
 	signal(SIGHUP,	cleanup);
 	signal(SIGINT,	cleanup);
@@ -1991,21 +2089,21 @@ main(int argc, char **argv)
 		}
 	}
 #endif
-	strncat(goodfile, dirpath ? basename(fname) : fname, 256);
+	strncat(goodfile, dirpath ? bname : fname, 256);
 	strcat (goodfile, ".fsxgood");
 	fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
 	if (fsxgoodfd < 0) {
 		prterr(goodfile);
 		exit(92);
 	}
-	strncat(logfile, dirpath ? basename(fname) : fname, 256);
+	strncat(logfile, dirpath ? bname : fname, 256);
 	strcat (logfile, ".fsxlog");
 	fsxlogf = fopen(logfile, "w");
 	if (fsxlogf == NULL) {
 		prterr(logfile);
 		exit(93);
 	}
-	strncat(opsfile, dirpath ? basename(fname) : fname, 256);
+	strncat(opsfile, dirpath ? bname : fname, 256);
 	strcat(opsfile, ".fsxops");
 	unlink(opsfile);
 
@@ -2081,6 +2179,7 @@ main(int argc, char **argv)
 		if (!test())
 			break;
 
+	free(tmp);
 	if (close(fd)) {
 		prterr("close");
 		report_failure(99);
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/13 fsx: add optional logid prefix to log messages

In reply to Amir Goldstein

When writing the intermixed output of several fsx processes to a single log file, it is usefull to prefix logs with a log id. Use fsx -j <logid> to define the log messages prefix.

---
 ltp/fsx.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
ltp/fsx.c +19 -9
index ac466ee..16684cc 100644
@@ -132,6 +132,7 @@ unsigned long	simulatedopcount = 0;	/* -b flag */
 int	closeprob = 0;			/* -c flag */
 int	debug = 0;			/* -d flag */
 unsigned long	debugstart = 0;		/* -D flag */
+int	logid = 0;			/* -j flag */
 int	flush = 0;			/* -f flag */
 int	do_fsync = 0;			/* -y flag */
 unsigned long	maxfilelen = 256 * 1024;	/* -l flag */
@@ -195,13 +196,16 @@ static void *round_ptr_up(void *ptr, unsigned long align, unsigned long offset)
 }
 
 void
-vwarnc(int code, const char *fmt, va_list ap) {
-  fprintf(stderr, "fsx: ");
-  if (fmt != NULL) {
-	vfprintf(stderr, fmt, ap);
-	fprintf(stderr, ": ");
-  }
-  fprintf(stderr, "%s\n", strerror(code));
+vwarnc(int code, const char *fmt, va_list ap)
+{
+	if (logid)
+		fprintf(stderr, "%d: ", logid);
+	fprintf(stderr, "fsx: ");
+	if (fmt != NULL) {
+		vfprintf(stderr, fmt, ap);
+		fprintf(stderr, ": ");
+	}
+	fprintf(stderr, "%s\n", strerror(code));
 }
 
 void
@@ -223,6 +227,8 @@ prt(const char *fmt, ...)
 	va_start(args, fmt);
 	vsnprintf(buffer, BUF_SIZE, fmt, args);
 	va_end(args);
+	if (logid)
+		fprintf(stdout, "%d: ", logid);
 	fprintf(stdout, "%s", buffer);
 	if (fsxlogf)
 		fprintf(fsxlogf, "%s", buffer);
@@ -1624,12 +1630,13 @@ void
 usage(void)
 {
 	fprintf(stdout, "usage: %s",
-		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
 	-b opnum: beginning operation number (default 1)\n\
 	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
 	-d: debug output for all operations\n\
 	-f flush and invalidate cache after I/O\n\
 	-i logdev: do integrity testing, logdev is the dm log writes device\n\
+	-j logid: prefix logs with this id\n\
 	-l flen: the upper bound on file size (default 262144)\n\
 	-m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
 	-n: no verifications of file size\n\
@@ -1862,7 +1869,7 @@ main(int argc, char **argv)
 	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
 	while ((ch = getopt_long(argc, argv,
-				 "b:c:dfi:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
+				 "b:c:dfi:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
 				 longopts, NULL)) != EOF)
 		switch (ch) {
 		case 'b':
@@ -1897,6 +1904,9 @@ main(int argc, char **argv)
 				exit(101);
 			}
 			break;
+		case 'j':
+			logid = getnum(optarg, &endp);
+			break;
 		case 'l':
 			maxfilelen = getnum(optarg, &endp);
 			if (maxfilelen <= 0)
Signature · 1 line
2.7.4
#3 lore raw

PATCH v3 3/13 fsx: add support for recording operations to a file

In reply to Amir Goldstein

Usually, fsx dumps an .fsxops file on failure with same basename as work file and possibly under dirctory specified by -P dirpath.

The --record-ops[=opsfile] flag can be use to dump ops file also on success and to optionally specify the ops file name.

---
 ltp/fsx.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
ltp/fsx.c +15 -2
index 16684cc..85fd50a 100644
@@ -180,6 +180,7 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset);
 #endif
 
 const char *replayops = NULL;
+const char *recordops = NULL;
 FILE *	fsxlogf = NULL;
 FILE *	replayopsf = NULL;
 char opsfile[1024];
@@ -1677,6 +1678,8 @@ usage(void)
 	-W: mapped write operations DISabled\n\
         -R: read() system calls only (mapped reads disabled)\n\
         -Z: O_DIRECT (use -R, -W, -r and -w too)\n\
+	--replay-ops opsfile: replay ops from recorded .fsxops file\n\
+	--record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\
 	fname: this filename is REQUIRED (no default)\n");
 	exit(90);
 }
@@ -1845,6 +1848,7 @@ __test_fallocate(int mode, const char *mode_str)
 
 static struct option longopts[] = {
 	{"replay-ops", required_argument, 0, 256},
+	{"record-ops", optional_argument, 0, 255},
 	{ }
 };
 
@@ -2034,6 +2038,11 @@ main(int argc, char **argv)
 		case 'Z':
 			o_direct = O_DIRECT;
 			break;
+		case 255:  /* --record-ops */
+			if (optarg)
+				strncpy(opsfile, optarg, sizeof(opsfile));
+			recordops = opsfile;
+			break;
 		case 256:  /* --replay-ops */
 			replayops = optarg;
 			break;
@@ -2113,8 +2122,10 @@ main(int argc, char **argv)
 		prterr(logfile);
 		exit(93);
 	}
-	strncat(opsfile, dirpath ? bname : fname, 256);
-	strcat(opsfile, ".fsxops");
+	if (!*opsfile) {
+		strncat(opsfile, dirpath ? bname : fname, 256);
+		strcat(opsfile, ".fsxops");
+	}
 	unlink(opsfile);
 
 	if (replayops) {
@@ -2195,6 +2206,8 @@ main(int argc, char **argv)
 		report_failure(99);
 	}
 	prt("All %lu operations completed A-OK!\n", testcalls);
+	if (recordops)
+		logdump();
 
 	exit(0);
 	return 0;
Signature · 1 line
2.7.4
#4 lore raw

PATCH v3 4/13 fsx: add support for writing constant instead of random data

In reply to Amir Goldstein

-g X: write character X instead of random generated data

This is useful to compare holes between good and bad files because hexdump of good and bad files compacts the contigious ranges of X and zeroes.

---
 ltp/fsx.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
ltp/fsx.c +14 -5
index 85fd50a..3510ace 100644
@@ -132,6 +132,7 @@ unsigned long	simulatedopcount = 0;	/* -b flag */
 int	closeprob = 0;			/* -c flag */
 int	debug = 0;			/* -d flag */
 unsigned long	debugstart = 0;		/* -D flag */
+char	filldata = 0;			/* -g flag */
 int	logid = 0;			/* -j flag */
 int	flush = 0;			/* -f flag */
 int	do_fsync = 0;			/* -y flag */
@@ -814,9 +815,13 @@ void
 gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size)
 {
 	while (size--) {
-		good_buf[offset] = testcalls % 256; 
-		if (offset % 2)
-			good_buf[offset] += original_buf[offset];
+		if (filldata) {
+			good_buf[offset] = filldata;
+		} else {
+			good_buf[offset] = testcalls % 256;
+			if (offset % 2)
+				good_buf[offset] += original_buf[offset];
+		}
 		offset++;
 	}
 }
@@ -1631,11 +1636,12 @@ void
 usage(void)
 {
 	fprintf(stdout, "usage: %s",
-		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
 	-b opnum: beginning operation number (default 1)\n\
 	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
 	-d: debug output for all operations\n\
 	-f flush and invalidate cache after I/O\n\
+	-g X: write character X instead of random generated data\n\
 	-i logdev: do integrity testing, logdev is the dm log writes device\n\
 	-j logid: prefix logs with this id\n\
 	-l flen: the upper bound on file size (default 262144)\n\
@@ -1873,7 +1879,7 @@ main(int argc, char **argv)
 	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
 	while ((ch = getopt_long(argc, argv,
-				 "b:c:dfi:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
+				 "b:c:dfg:i:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
 				 longopts, NULL)) != EOF)
 		switch (ch) {
 		case 'b':
@@ -1900,6 +1906,9 @@ main(int argc, char **argv)
 		case 'f':
 			flush = 1;
 			break;
+		case 'g':
+			filldata = *optarg;
+			break;
 		case 'i':
 			integrity = 1;
 			logdev = strdup(optarg);
Signature · 1 line
2.7.4
#5 lore raw

PATCH v3 5/13 fsx: add support for keeping existing file

In reply to Amir Goldstein

With fsxk -k, do not truncate existing file and use its size as upper bound on file size.

This is needed to prevent fsx from truncating the file on start of test when testing fsx on cloned files.

---
 ltp/fsx.c | 49 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 36 insertions(+), 13 deletions(-)
ltp/fsx.c +36 -13
index 3510ace..7a34577 100644
@@ -629,17 +629,18 @@ void
 check_trunc_hack(void)
 {
 	struct stat statbuf;
+	off_t offset = file_size + (off_t)100000;
 
-	if (ftruncate(fd, (off_t)0))
+	if (ftruncate(fd, file_size))
 		goto ftruncate_err;
-	if (ftruncate(fd, (off_t)100000))
+	if (ftruncate(fd, offset))
 		goto ftruncate_err;
 	fstat(fd, &statbuf);
-	if (statbuf.st_size != (off_t)100000) {
+	if (statbuf.st_size != offset) {
 		prt("no extend on truncate! not posix!\n");
 		exit(130);
 	}
-	if (ftruncate(fd, 0)) {
+	if (ftruncate(fd, file_size)) {
 ftruncate_err:
 		prterr("check_trunc_hack: ftruncate");
 		exit(131);
@@ -1636,7 +1637,7 @@ void
 usage(void)
 {
 	fprintf(stdout, "usage: %s",
-		"fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
+		"fsx [-dknqxAFLOWZ] [-b opnum] [-c Prob] [-g filldata] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\
 	-b opnum: beginning operation number (default 1)\n\
 	-c P: 1 in P chance of file close+open at each op (default infinity)\n\
 	-d: debug output for all operations\n\
@@ -1644,6 +1645,7 @@ usage(void)
 	-g X: write character X instead of random generated data\n\
 	-i logdev: do integrity testing, logdev is the dm log writes device\n\
 	-j logid: prefix logs with this id\n\
+	-k: do not truncate existing file and use its size as upper bound on file size\n\
 	-l flen: the upper bound on file size (default 262144)\n\
 	-m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\
 	-n: no verifications of file size\n\
@@ -1834,7 +1836,7 @@ __test_fallocate(int mode, const char *mode_str)
 #ifdef HAVE_LINUX_FALLOC_H
 	int ret = 0;
 	if (!lite) {
-		if (fallocate(fd, mode, 0, 1) && errno == EOPNOTSUPP) {
+		if (fallocate(fd, mode, file_size, 1) && errno == EOPNOTSUPP) {
 			if(!quiet)
 				fprintf(stderr,
 					"main: filesystem does not support "
@@ -1842,7 +1844,7 @@ __test_fallocate(int mode, const char *mode_str)
 					mode_str);
 		} else {
 			ret = 1;
-			if (ftruncate(fd, 0)) {
+			if (ftruncate(fd, file_size)) {
 				warn("main: ftruncate");
 				exit(132);
 			}
@@ -1866,6 +1868,7 @@ main(int argc, char **argv)
 	char goodfile[1024];
 	char logfile[1024];
 	struct stat statbuf;
+	int o_flags = O_RDWR|O_CREAT|O_TRUNC;
 
 	goodfile[0] = 0;
 	logfile[0] = 0;
@@ -1879,7 +1882,7 @@ main(int argc, char **argv)
 	setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */
 
 	while ((ch = getopt_long(argc, argv,
-				 "b:c:dfg:i:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
+				 "b:c:dfg:i:j:kl:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ",
 				 longopts, NULL)) != EOF)
 		switch (ch) {
 		case 'b':
@@ -1920,6 +1923,9 @@ main(int argc, char **argv)
 		case 'j':
 			logid = getnum(optarg, &endp);
 			break;
+		case 'k':
+			o_flags &= ~O_TRUNC;
+			break;
 		case 'l':
 			maxfilelen = getnum(optarg, &endp);
 			if (maxfilelen <= 0)
@@ -2007,6 +2013,7 @@ main(int argc, char **argv)
 			break;
 		case 'L':
 		        lite = 1;
+			o_flags &= ~(O_CREAT|O_TRUNC);
 			break;
 		case 'N':
 			numops = getnum(optarg, &endp);
@@ -2046,6 +2053,7 @@ main(int argc, char **argv)
 			break;
 		case 'Z':
 			o_direct = O_DIRECT;
+			o_flags |= O_DIRECT;
 			break;
 		case 255:  /* --record-ops */
 			if (optarg)
@@ -2089,8 +2097,7 @@ main(int argc, char **argv)
 	signal(SIGUSR2,	cleanup);
 
 	srandom(seed);
-	fd = open(fname,
-		O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC)|o_direct, 0666);
+	fd = open(fname, o_flags, 0666);
 	if (fd < 0) {
 		prterr(fname);
 		exit(91);
@@ -2150,9 +2157,10 @@ main(int argc, char **argv)
 		aio_setup();
 #endif
 
-	if (lite) {
+	if (!(o_flags & O_TRUNC)) {
 		off_t ret;
-		file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END);
+		file_size = maxfilelen = biggest = lseek(fd, (off_t)0, SEEK_END);
+		printf("file_size=%lu\n", file_size);
 		if (file_size == (off_t)-1) {
 			prterr(fname);
 			warn("main: lseek eof");
@@ -2189,8 +2197,23 @@ main(int argc, char **argv)
 					maxfilelen);
 			exit(98);
 		}
-	} else 
+	} else {
+		ssize_t ret, len = file_size;
+		off_t off = 0;
+
+		while (len > 0) {
+			ret = read(fd, good_buf + off, len);
+			if (ret == -1) {
+				prterr(fname);
+				warn("main: error on read");
+				exit(98);
+			}
+			len -= ret;
+			off += ret;
+		}
+
 		check_trunc_hack();
+	}
 
 	if (fallocate_calls)
 		fallocate_calls = test_fallocate(0);
Signature · 1 line
2.7.4
#6 lore raw

PATCH v3 6/13 log-writes: add replay-log program to replay dm-log-writes target

In reply to Amir Goldstein

Imported Josef Bacik's code from:
https://github.com/josefbacik/log-writes.git

Specialized program for replaying a write log that was recorded by device mapper log-writes target. The tools is used to perform crash consistency tests, allowing to run an arbitrary check tool (fsck) at specified checkpoints in the write log.

[Amir:]
- Add project Makefile and SOURCE files
- Document the replay-log auxiliary program
- Address review comments by Eryu Guan

---
 .gitignore                  |   1 +
 doc/auxiliary-programs.txt  |   8 +
 src/Makefile                |   2 +-
 src/log-writes/Makefile     |  23 +++
 src/log-writes/SOURCE       |   6 +
 src/log-writes/log-writes.c | 381 ++++++++++++++++++++++++++++++++++++++++++++
 src/log-writes/log-writes.h |  77 +++++++++
 src/log-writes/replay-log.c | 357 +++++++++++++++++++++++++++++++++++++++++
 8 files changed, 854 insertions(+), 1 deletion(-)
 create mode 100644 src/log-writes/Makefile
 create mode 100644 src/log-writes/SOURCE
 create mode 100644 src/log-writes/log-writes.c
 create mode 100644 src/log-writes/log-writes.h
 create mode 100644 src/log-writes/replay-log.c
.gitignore +1 -0
index 28fe84d..beb9504 100644
@@ -154,6 +154,7 @@
 /src/t_mmap_stale_pmd
 /src/t_mmap_cow_race
 /src/t_mmap_fallocate
+/src/log-writes/replay-log
 
 # dmapi/ binaries
 /dmapi/src/common/cmd/read_invis
doc/auxiliary-programs.txt +8 -0
index bcab453..de15832 100644
@@ -18,6 +18,7 @@ Contents:
  - af_unix		-- Create an AF_UNIX socket
  - dmerror		-- fault injection block device control
  - fsync-err		-- tests fsync error reporting after failed writeback
+ - log-writes/replay-log -- Replay log from device mapper log-writes target
  - open_by_handle	-- open_by_handle_at syscall exercise
  - stat_test		-- statx syscall exercise
  - t_dir_type		-- print directory entries and their file type
@@ -46,6 +47,13 @@ fsync-err
 	writeback and test that errors are reported during fsync and cleared
 	afterward.
 
+log-writes/replay-log
+
+	Specialized program for replaying a write log that was recorded by
+	device mapper log-writes target.  The tools is used to perform crash
+	consistency tests, allowing to run an arbitrary check tool (fsck) at
+	specified checkpoints in the write log.
+
 open_by_handle
 
 	The open_by_handle program exercises the open_by_handle_at() system
src/Makefile +1 -1
index b8aff49..7d1306b 100644
@@ -25,7 +25,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	attr-list-by-handle-cursor-test listxattr dio-interleaved t_dir_type \
 	dio-invalidate-cache stat_test t_encrypted_d_revalidate
 
-SUBDIRS =
+SUBDIRS = log-writes
 
 LLDLIBS = $(LIBATTR) $(LIBHANDLE) $(LIBACL) -lpthread
 
src/log-writes/Makefile new file +23 -0
new file mode 100644
index 0000000..d114177
@@ -0,0 +1,23 @@
+TOPDIR = ../..
+include $(TOPDIR)/include/builddefs
+
+TARGETS = replay-log
+
+CFILES = replay-log.c log-writes.c
+LDIRT = $(TARGETS)
+
+default: depend $(TARGETS)
+
+depend: .dep
+
+include $(BUILDRULES)
+
+$(TARGETS): $(CFILES)
+	@echo "    [CC]    $@"
+	$(Q)$(LTLINK) $(CFILES) -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
+
+install:
+	$(INSTALL) -m 755 -d $(PKG_LIB_DIR)/src/log-writes
+	$(INSTALL) -m 755 $(TARGETS) $(PKG_LIB_DIR)/src/log-writes
+
+-include .dep
src/log-writes/SOURCE new file +6 -0
new file mode 100644
index 0000000..d6d143c
@@ -0,0 +1,6 @@
+From:
+https://github.com/josefbacik/log-writes.git
+
+description	Helper code for dm-log-writes target
+owner	Josef Bacik <[email protected]>
+URL	https://github.com/josefbacik/log-writes.git
src/log-writes/log-writes.c new file +381 -0

381 lines not on this page · raw message

src/log-writes/log-writes.h new file +77 -0

77 lines not on this page · raw message

src/log-writes/replay-log.c new file +357 -0

357 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v3 7/13 replay-log: add validations for corrupt log entries

In reply to Amir Goldstein

Check for all zeros entry and for non zero padded entry and report log offset of corrupted log entry.

Also report log offsets with -v and -vv debug prints.

---
 src/log-writes/log-writes.c | 84 ++++++++++++++++++++++++++++++++++-----------
 src/log-writes/log-writes.h |  2 ++
 src/log-writes/replay-log.c |  7 ++--
 3 files changed, 70 insertions(+), 23 deletions(-)
src/log-writes/log-writes.c +64 -20
index a215fef..dbfeef7 100644
@@ -118,6 +118,26 @@ int log_discard(struct log *log, struct log_write_entry *entry)
 }
 
 /*
+ * @entry: entry to be replayed.
+ *
+ * @return: 1 if the entry is sane, 0 if it is invalid.
+ *
+ * Check if this is a sane log entry.
+ */
+int log_entry_valid(struct log_write_entry *entry)
+{
+	u64 flags = le64_to_cpu(entry->flags);
+
+	/* Suspect all zeroes entry */
+	if (!flags && !entry->nr_sectors)
+		return 0;
+	/* Suspect non zero padded entry */
+	if (flags != LOG_MARK_FLAG && entry->data[0] != 0)
+		return 0;
+	return 1;
+}
+
+/*
  * @log: the log we are replaying.
  * @entry: where we put the entry.
  * @read_data: read the entry data as well, entry must be log->sectorsize sized
@@ -146,24 +166,32 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 		fprintf(stderr, "Error reading entry: %d\n", errno);
 		return -1;
 	}
+	if (!log_entry_valid(entry)) {
+		fprintf(stderr, "Malformed entry @%llu\n",
+				log->cur_pos / log->sectorsize);
+		return -1;
+	}
 	log->cur_entry++;
 
 	size = le64_to_cpu(entry->nr_sectors) * log->sectorsize;
 	if (read_size < log->sectorsize) {
-		if (lseek(log->logfd,
-			  log->sectorsize - sizeof(struct log_write_entry),
-			  SEEK_CUR) == (off_t)-1) {
+		log->cur_pos = lseek(log->logfd,
+			log->sectorsize - sizeof(struct log_write_entry), SEEK_CUR);
+		if (log->cur_pos == (off_t)-1) {
 			fprintf(stderr, "Error seeking in log: %d\n", errno);
 			return -1;
 		}
+	} else {
+		log->cur_pos += read_size;
 	}
 
-	if (log_writes_verbose)
-		printf("replaying %d: sector %llu, size %llu, flags %llu\n",
-		       (int)log->cur_entry - 1,
+	if (log_writes_verbose) {
+		printf("replaying %d@%llu: sector %llu, size %llu, flags %llu\n",
+		       (int)log->cur_entry - 1, log->cur_pos / log->sectorsize,
 		       (unsigned long long)le64_to_cpu(entry->sector),
 		       (unsigned long long)size,
 		       (unsigned long long)le64_to_cpu(entry->flags));
+	}
 	if (!size)
 		return 0;
 
@@ -183,6 +211,7 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 		free(buf);
 		return -1;
 	}
+	log->cur_pos += size;
 
 	offset = le64_to_cpu(entry->sector) * log->sectorsize;
 	ret = pwrite(log->replayfd, buf, size, offset);
@@ -212,7 +241,8 @@ int log_seek_entry(struct log *log, u64 entry_num)
 	}
 
 	/* Skip the first sector containing the log super block */
-	if (lseek(log->logfd, log->sectorsize, SEEK_SET) == (off_t)-1) {
+	log->cur_pos = lseek(log->logfd, log->sectorsize, SEEK_SET);
+	if (log->cur_pos == (off_t)-1) {
 		fprintf(stderr, "Error seeking in file: %d\n", errno);
 		return -1;
 	}
@@ -229,9 +259,14 @@ int log_seek_entry(struct log *log, u64 entry_num)
 			fprintf(stderr, "Error reading entry: %d\n", errno);
 			return -1;
 		}
+		if (!log_entry_valid(&entry)) {
+			fprintf(stderr, "Malformed entry @%llu\n",
+					log->cur_pos / log->sectorsize);
+			return -1;
+		}
 		if (log_writes_verbose > 1)
-			printf("seek entry %d: %llu, size %llu, flags %llu\n",
-			       (int)i,
+			printf("seek entry %d@%llu: %llu, size %llu, flags %llu\n",
+			       (int)i, log->cur_pos / log->sectorsize,
 			       (unsigned long long)le64_to_cpu(entry.sector),
 			       (unsigned long long)le64_to_cpu(entry.nr_sectors),
 			       (unsigned long long)le64_to_cpu(entry.flags));
@@ -240,7 +275,8 @@ int log_seek_entry(struct log *log, u64 entry_num)
 		if (!(flags & LOG_DISCARD_FLAG))
 			seek_size += le64_to_cpu(entry.nr_sectors) *
 				log->sectorsize;
-		if (lseek(log->logfd, seek_size, SEEK_CUR) == (off_t)-1) {
+		log->cur_pos = lseek(log->logfd, seek_size, SEEK_CUR);
+		if (log->cur_pos == (off_t)-1) {
 			fprintf(stderr, "Error seeking in file: %d\n", errno);
 			return -1;
 		}
@@ -277,29 +313,37 @@ int log_seek_next_entry(struct log *log, struct log_write_entry *entry,
 		fprintf(stderr, "Error reading entry: %d\n", errno);
 		return -1;
 	}
+	if (!log_entry_valid(entry)) {
+		fprintf(stderr, "Malformed entry @%llu\n",
+				log->cur_pos / log->sectorsize);
+		return -1;
+	}
 	log->cur_entry++;
 
 	if (read_size < log->sectorsize) {
-		if (lseek(log->logfd,
-			  log->sectorsize - sizeof(struct log_write_entry),
-			  SEEK_CUR) == (off_t)-1) {
+		log->cur_pos = lseek(log->logfd,
+			log->sectorsize - sizeof(struct log_write_entry), SEEK_CUR);
+		if (log->cur_pos == (off_t)-1) {
 			fprintf(stderr, "Error seeking in log: %d\n", errno);
 			return -1;
 		}
+	} else {
+		log->cur_pos += read_size;
 	}
 	if (log_writes_verbose > 1)
-		printf("seek entry %d: %llu, size %llu, flags %llu\n",
-		       (int)log->cur_entry - 1,
+		printf("seek entry %d@%llu: %llu, size %llu, flags %llu\n",
+		       (int)log->cur_entry - 1, log->cur_pos / log->sectorsize,
 		       (unsigned long long)le64_to_cpu(entry->sector),
 		       (unsigned long long)le64_to_cpu(entry->nr_sectors),
 		       (unsigned long long)le64_to_cpu(entry->flags));
 
-	flags = le32_to_cpu(entry->flags);
-	read_size = le32_to_cpu(entry->nr_sectors) * log->sectorsize;
+	flags = le64_to_cpu(entry->flags);
+	read_size = le64_to_cpu(entry->nr_sectors) * log->sectorsize;
 	if (!read_size || (flags & LOG_DISCARD_FLAG))
 		return 0;
 
-	if (lseek(log->logfd, read_size, SEEK_CUR) == (off_t)-1) {
+	log->cur_pos = lseek(log->logfd, read_size, SEEK_CUR);
+	if (log->cur_pos == (off_t)-1) {
 		fprintf(stderr, "Error seeking in log: %d\n", errno);
 		return -1;
 	}
@@ -369,8 +413,8 @@ struct log *log_open(char *logfile, char *replayfile)
 	log->nr_entries = le64_to_cpu(super.nr_entries);
 	log->max_zero_size = 128 * 1024 * 1024;
 
-	if (lseek(log->logfd, log->sectorsize - sizeof(super), SEEK_CUR) ==
-	    (off_t) -1) {
+	log->cur_pos = lseek(log->logfd, log->sectorsize - sizeof(super), SEEK_CUR);
+	if (log->cur_pos == (off_t) -1) {
 		fprintf(stderr, "Error seeking to first entry: %d\n", errno);
 		log_free(log);
 		return NULL;
src/log-writes/log-writes.h +2 -0
index 6cadb66..c89b119 100644
@@ -50,6 +50,8 @@ struct log_write_entry {
 	__le64 nr_sectors;
 	__le64 flags;
 	__le64 data_len;
+	/* Read extra byte when seeking to verify that header is zero padded */
+	char data[1];
 };
 
 #define LOG_IGNORE_DISCARD (1 << 0)
src/log-writes/replay-log.c +4 -3
index c3de9c4..cf67931 100644
@@ -75,7 +75,7 @@ static int should_stop(struct log_write_entry *entry, u64 stop_flags,
 	u64 flags = le64_to_cpu(entry->flags);
 	int check_mark = (stop_flags & LOG_MARK_FLAG);
 	/* mark data begins after entry header */
-	char *buf = (char *)(entry + 1);
+	char *buf = entry->data;
 	/* entry buffer is padded with at least 1 zero after data_len */
 	u64 buflen = le64_to_cpu(entry->data_len) + 1;
 
@@ -293,8 +293,9 @@ int main(int argc, char **argv)
 			num_entries++;
 			if ((run_limit && num_entries == run_limit) ||
 			    should_stop(entry, stop_flags, end_mark)) {
-				printf("%llu\n",
-				       (unsigned long long)log->cur_entry - 1);
+				printf("%llu@%llu\n",
+				       (unsigned long long)log->cur_entry - 1,
+				       log->cur_pos / log->sectorsize);
 				log_free(log);
 				return 0;
 			}
Signature · 1 line
2.7.4
#8 lore raw

PATCH v3 8/13 replay-log: add support for replaying ops in target device sector range

In reply to Amir Goldstein

Using command line options --start-sector and --end-sector, only operations acting on the specified target device range will be replayed.

Single vebbose mode (-v) prints out only replayed operations. Double verbose mode (-vv) prints out also skipped operations.

---
 src/log-writes/log-writes.c | 37 +++++++++++++++++++++++++++++++++++--
 src/log-writes/log-writes.h |  2 ++
 src/log-writes/replay-log.c | 31 +++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)
src/log-writes/log-writes.c +35 -2
index dbfeef7..fab447a 100644
@@ -118,6 +118,27 @@ int log_discard(struct log *log, struct log_write_entry *entry)
 }
 
 /*
+ * @log: the log we are replaying.
+ * @entry: entry to be replayed.
+ *
+ * @return: 0 if we should replay the entry, > 0 if we should skip it.
+ *
+ * Should we skip the entry in our log or replay onto the replay device.
+ */
+int log_should_skip(struct log *log, struct log_write_entry *entry)
+{
+	u64 sector = le64_to_cpu(entry->sector);
+	u64 nr_sectors = le64_to_cpu(entry->nr_sectors);
+
+	if (!nr_sectors)
+		return 0;
+	if (sector + nr_sectors <= log->start_sector ||
+	    sector > log->end_sector)
+		return 1;
+	return 0;
+}
+
+/*
  * @entry: entry to be replayed.
  *
  * @return: 1 if the entry is sane, 0 if it is invalid.
@@ -157,6 +178,7 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 	char *buf;
 	ssize_t ret;
 	off_t offset;
+	int skip = 0;
 
 	if (log->cur_entry >= log->nr_entries)
 		return 1;
@@ -185,8 +207,10 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 		log->cur_pos += read_size;
 	}
 
-	if (log_writes_verbose) {
-		printf("replaying %d@%llu: sector %llu, size %llu, flags %llu\n",
+	skip = log_should_skip(log, entry);
+	if (log_writes_verbose > 1 || (log_writes_verbose && !skip)) {
+		printf("%s %d@%llu: sector %llu, size %llu, flags %llu\n",
+		       skip ? "skipping" : "replaying",
 		       (int)log->cur_entry - 1, log->cur_pos / log->sectorsize,
 		       (unsigned long long)le64_to_cpu(entry->sector),
 		       (unsigned long long)size,
@@ -199,6 +223,15 @@ int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
 	if (flags & LOG_DISCARD_FLAG)
 		return log_discard(log, entry);
 
+	if (skip) {
+		log->cur_pos = lseek(log->logfd, size, SEEK_CUR);
+		if (log->cur_pos == (off_t)-1) {
+			fprintf(stderr, "Error seeking in log: %d\n", errno);
+			return -1;
+		}
+		return 0;
+	}
+
 	buf = malloc(size);
 	if (!buf) {
 		fprintf(stderr, "Error allocating buffer %llu entry %llu\n", (unsigned long long)size, (unsigned long long)log->cur_entry - 1);
src/log-writes/log-writes.h +2 -0
index c89b119..14242ee 100644
@@ -62,6 +62,8 @@ struct log {
 	int replayfd;
 	unsigned long flags;
 	u64 sectorsize;
+	u64 start_sector;
+	u64 end_sector;
 	u64 nr_entries;
 	u64 cur_entry;
 	u64 max_zero_size;
src/log-writes/replay-log.c +31 -0
index cf67931..8457937 100644
@@ -20,6 +20,8 @@ enum option_indexes {
 	FSCK,
 	CHECK,
 	START_MARK,
+	START_SECTOR,
+	END_SECTOR,
 };
 
 static struct option long_options[] = {
@@ -37,6 +39,8 @@ static struct option long_options[] = {
 	{"fsck", required_argument, NULL, 0},
 	{"check", required_argument, NULL, 0},
 	{"start-mark", required_argument, NULL, 0},
+	{"start-sector", required_argument, NULL, 0},
+	{"end-sector", required_argument, NULL, 0},
 	{ NULL, 0, NULL, 0 },
 };
 
@@ -61,6 +65,12 @@ static void usage(void)
 		"--check\n");
 	fprintf(stderr, "\t--check [<number>|flush|fua] when to check the "
 		"file system, mush specify --fsck\n");
+	fprintf(stderr, "\t--start-sector <sector> - replay ops on region "
+		"from <sector> onto <device>\n");
+	fprintf(stderr, "\t--end-sector <sector> - replay ops on region "
+		"to <sector> onto <device>\n");
+	fprintf(stderr, "\t-v or --verbose - print replayed ops\n");
+	fprintf(stderr, "\t-vv - print also skipped ops\n");
 	exit(1);
 }
 
@@ -129,6 +139,8 @@ int main(int argc, char **argv)
 	struct log_write_entry *entry;
 	u64 stop_flags = 0;
 	u64 start_entry = 0;
+	u64 start_sector = 0;
+	u64 end_sector = -1ULL;
 	u64 run_limit = 0;
 	u64 num_entries = 0;
 	u64 check_number = 0;
@@ -249,6 +261,22 @@ int main(int argc, char **argv)
 				tmp = NULL;
 			}
 			break;
+		case START_SECTOR:
+			start_sector = strtoull(optarg, &tmp, 0);
+			if (tmp && *tmp != '\0') {
+				fprintf(stderr, "Invalid sector number\n");
+				exit(1);
+			}
+			tmp = NULL;
+			break;
+		case END_SECTOR:
+			end_sector = strtoull(optarg, &tmp, 0);
+			if (tmp && *tmp != '\0') {
+				fprintf(stderr, "Invalid sector number\n");
+				exit(1);
+			}
+			tmp = NULL;
+			break;
 		default:
 			usage();
 		}
@@ -266,6 +294,9 @@ int main(int argc, char **argv)
 	if (!discard)
 		log->flags |= LOG_IGNORE_DISCARD;
 
+	log->start_sector = start_sector;
+	log->end_sector = end_sector;
+
 	entry = malloc(log->sectorsize);
 	if (!entry) {
 		fprintf(stderr, "Couldn't allocate buffer\n");
Signature · 1 line
2.7.4
#9 lore raw

PATCH v3 9/13 fstests: add support for working with dm-log-writes target

In reply to Amir Goldstein

Cherry-picked the relevant common bits from commit 70d41e17164b in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

This patch adds the supporting code for using the dm-log-writes target. The dmlogwrites code is similar to the dmflakey code, it just gives us functions to build and tear down a dm-log-writes target. We add a new LOGWRITES_DEV variable to take in the device we will use as the log and add checks for that.

[Amir:]
- Removed unneeded _test_falloc_support
- Moved _require_log_writes to dmlogwrites
- Document _require_log_writes
- Address review comments by Eryu Guan

---
 README                       |  2 +
 common/dmlogwrites           | 94 ++++++++++++++++++++++++++++++++++++++++++++
 doc/requirement-checking.txt | 20 ++++++++++
 3 files changed, 116 insertions(+)
 create mode 100644 common/dmlogwrites
README +2 -0
index 9456fa7..4963d28 100644
@@ -91,6 +91,8 @@ Preparing system for tests:
              - set TEST_XFS_SCRUB=1 to have _check_xfs_filesystem run
                xfs_scrub -vd to scrub the filesystem metadata online before
                unmounting to run the offline check.
+             - setenv LOGWRITES_DEV to a block device to use for power fail
+               testing.
 
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
common/dmlogwrites new file +94 -0

94 lines not on this page · raw message

doc/requirement-checking.txt +20 -0
index 95d10e6..4e01b1f 100644
@@ -21,6 +21,10 @@ they have.  This is done with _require_<xxx> macros, which may take parameters.
 
 	_require_statx
 
+ (4) Device mapper requirement.
+
+	_require_dm_target
+	_require_log_writes
 
 ====================
 GENERAL REQUIREMENTS
@@ -102,3 +106,19 @@ _require_statx
 
      The test requires the use of the statx() system call and will be skipped
      if it isn't available in the kernel.
+
+
+==========================
+DEVICE MAPPER REQUIREMENTS
+==========================
+
+_require_dm_target <name>
+
+     The test requires the use of the device mapper target and will be skipped
+     if it isn't available in the kernel.
+
+_require_log_writes
+
+     The test requires the use of the device mapper target log-writes.
+     The test also requires the test program log-writes/replay-log is built
+     and will be skipped if either isn't available.
Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 10/13 fstests: crash consistency fsx test using dm-log-writes

In reply to Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +135 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+	local name=$1
+
+	# Now look for our files
+	for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+	do
+		local filename=$(basename $i)
+		local mark="${filename##*.}"
+		echo "checking $filename" >> $seqres.full
+		_log_writes_replay_log $filename
+		_scratch_mount
+		local expected_md5=$(_md5_checksum $i)
+		local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+		[ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
+		_scratch_unmount
+		_check_scratch_fs
+	done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)
+# Run fsx for a while
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
+done
+wait
+
+test_md5=()
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+done
+
+# Unmount the scratch dir and tear down the log writes target
+_log_writes_mark last
+_log_writes_unmount
+_log_writes_mark end
+_log_writes_remove
+_check_scratch_fs
+
+# check pre umount
+echo "checking pre umount" >> $seqres.full
+_log_writes_replay_log last
+_scratch_mount
+_scratch_unmount
+_check_scratch_fs
+
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	check_files testfile$j
+done
+
+# Check the end
+echo "checking post umount" >> $seqres.full
+_log_writes_replay_log end
+_scratch_mount
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+	[ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
+done
+_scratch_unmount
+_check_scratch_fs
+
+echo "Silence is golden"
+status=0
+exit
+
tests/generic/500.out new file +2 -0
new file mode 100644
index 0000000..883b2ca
@@ -0,0 +1,2 @@
+QA output created by 500
+Silence is golden
tests/generic/group +1 -0
index 1894de0..c857153 100644
@@ -457,3 +457,4 @@
 452 auto quick
 453 auto quick dir
 454 auto quick attr
+500 auto log replay
Signature · 1 line
2.7.4
#32 lore raw

PATCH v3 11/13 fstests: regression test for ext4 crash consistency bug

In reply to Amir Goldstein

This test is motivated by a bug found in ext4 during random crash consistency tests.

This test uses device mapper flakey target to demonstrate the bug found using device mapper log-writes target.

---
 tests/generic/501     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/501.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/generic/501
 create mode 100644 tests/generic/501.out
tests/generic/501 new file +80 -0
new file mode 100755
index 0000000..ccb513d
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test No. 501
+#
+# This test is motivated by a bug found in ext4 during random crash
+# consistency tests.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_cleanup_flakey
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmflakey
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_dm_target flakey
+_require_metadata_journaling $SCRATCH_DEV
+
+rm -f $seqres.full
+
+_scratch_mkfs >> $seqres.full 2>&1
+
+_init_flakey
+_mount_flakey
+
+fsxops=$tmp.fsxops
+cat <<EOF > $fsxops
+write 0x137dd 0xdc69 0x0
+fallocate 0xb531 0xb5ad 0x21446
+collapse_range 0x1c000 0x4000 0x21446
+write 0x3e5ec 0x1a14 0x21446
+zero_range 0x20fac 0x6d9c 0x40000 keep_size
+mapwrite 0x216ad 0x274f 0x40000
+EOF
+run_check $here/ltp/fsx -d --replay-ops $fsxops $SCRATCH_MNT/testfile
+
+_flakey_drop_and_remount
+_unmount_flakey
+_cleanup_flakey
+_check_scratch_fs
+
+echo "Silence is golden"
+
+status=0
+exit
tests/generic/501.out new file +2 -0
new file mode 100644
index 0000000..00133b6
@@ -0,0 +1,2 @@
+QA output created by 501
+Silence is golden
tests/generic/group +1 -0
index c857153..1e1b524 100644
@@ -458,3 +458,4 @@
 453 auto quick dir
 454 auto quick attr
 500 auto log replay
+501 auto quick metadata
Signature · 1 line
2.7.4
#34 lore raw

PATCH v3 12/13 fstests: crash consistency fsx test for cloned files

In reply to Amir Goldstein
---
 tests/generic/502     | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/502.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 145 insertions(+)
 create mode 100755 tests/generic/502
 create mode 100644 tests/generic/502.out
tests/generic/502 new file +142 -0
new file mode 100755
index 0000000..a15a311
@@ -0,0 +1,142 @@
+#! /bin/bash
+# FS QA Test No. 502
+#
+# Run fsx with log writes on cloned files to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_reflink
+_require_cp_reflink
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+	local name=$1
+
+	# Now look for our files
+	for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+	do
+		local filename=$(basename $i)
+		local mark="${filename##*.}"
+		echo "checking $filename" >> $seqres.full
+		_log_writes_replay_log $filename
+		_scratch_mount
+		local expected_md5=$(_md5_checksum $i)
+		local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+		[ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
+		_scratch_unmount
+		_check_scratch_fs
+	done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
+# write testfile index -1 to be cloned to testfile0
+$XFS_IO_PROG -f -c "pwrite -S 0xff 0 256k" -c "fsync" \
+	$SCRATCH_MNT/testfile-1 > /dev/null 2>&1
+
+NUM_FILES=10
+NUM_OPS=100
+FSX_OPTS="-N $NUM_OPS -d -k -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0 0 0 0 0 0 0)
+# Run fsx for a while
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	# clone the clone from prev iteration which has already mutated
+	cp --reflink $SCRATCH_MNT/testfile$((j-1)) $SCRATCH_MNT/testfile$j
+	run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
+done
+wait
+
+test_md5=()
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+done
+
+# Unmount the scratch dir and tear down the log writes target
+_log_writes_mark last
+_log_writes_unmount
+_log_writes_mark end
+_log_writes_remove
+_check_scratch_fs
+
+# check pre umount
+echo "checking pre umount" >> $seqres.full
+_log_writes_replay_log last
+_scratch_mount
+_scratch_unmount
+_check_scratch_fs
+
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	check_files testfile$j
+done
+
+# Check the end
+echo "checking post umount" >> $seqres.full
+_log_writes_replay_log end
+_scratch_mount
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+	[ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
+done
+
+echo "Silence is golden"
+status=0
+exit
+
tests/generic/502.out new file +2 -0
new file mode 100644
index 0000000..930f6d4
@@ -0,0 +1,2 @@
+QA output created by 502
+Silence is golden
tests/generic/group +1 -0
index 1e1b524..4324775 100644
@@ -459,3 +459,4 @@
 454 auto quick attr
 500 auto log replay
 501 auto quick metadata
+502 auto log replay clone
Signature · 1 line
2.7.4
#35 lore raw

PATCH v3 13/13 fstests: regression test for xfs leftover CoW extent error

In reply to Amir Goldstein
---
 tests/generic/503     | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/503.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 72 insertions(+)
 create mode 100755 tests/generic/503
 create mode 100644 tests/generic/503.out
tests/generic/503 new file +69 -0
new file mode 100755
index 0000000..ebda756
@@ -0,0 +1,69 @@
+#! /bin/bash
+# FS QA Test No. 503
+#
+# Regression test for xfs leftover CoW extents error
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+$XFS_IO_PROG -f -c "pwrite 0 0x40000" \
+	$SCRATCH_MNT/foo > /dev/null 2>&1
+
+cp --reflink $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+$XFS_IO_PROG -f -c "fzero -k 0x169f 0x387c" \
+		-c "fcollapse 0x29000 0xd000" \
+		-c "finsert 0 0x8000" \
+		-c "truncate 0x8000" \
+	$SCRATCH_MNT/foo > /dev/null 2>&1
+
+echo "Silence is golden"
+status=0
+exit
tests/generic/503.out new file +2 -0
new file mode 100644
index 0000000..6c1400a
@@ -0,0 +1,2 @@
+QA output created by 503
+Silence is golden
tests/generic/group +1 -0
index 4324775..7a9cd78 100644
@@ -460,3 +460,4 @@
 500 auto log replay
 501 auto quick metadata
 502 auto log replay clone
+503 auto quick clone
Signature · 1 line
2.7.4
#10 lore raw

Re: [PATCH v3 09/13] fstests: add support for working with dm-log-writes target

In reply to Amir Goldstein
Quoted 58 lines · Amir Goldstein

Cherry-picked the relevant common bits from commit 70d41e17164b in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

This patch adds the supporting code for using the dm-log-writes target. The dmlogwrites code is similar to the dmflakey code, it just gives us functions to build and tear down a dm-log-writes target. We add a new LOGWRITES_DEV variable to take in the device we will use as the log and add checks for that.

[Amir:]
- Removed unneeded _test_falloc_support
- Moved _require_log_writes to dmlogwrites
- Document _require_log_writes
- Address review comments by Eryu Guan

---
 README                       |  2 +
 common/dmlogwrites           | 94 ++++++++++++++++++++++++++++++++++++++++++++
 doc/requirement-checking.txt | 20 ++++++++++
 3 files changed, 116 insertions(+)
 create mode 100644 common/dmlogwrites
README +2 -0
index 9456fa7..4963d28 100644
@@ -91,6 +91,8 @@ Preparing system for tests:
              - set TEST_XFS_SCRUB=1 to have _check_xfs_filesystem run
                xfs_scrub -vd to scrub the filesystem metadata online before
                unmounting to run the offline check.
+             - setenv LOGWRITES_DEV to a block device to use for power fail
+               testing.
 
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
common/dmlogwrites new file +14 -0
new file mode 100644
index 0000000..592b047
@@ -0,0 +1,94 @@
+##/bin/bash
+#
+# Copyright (c) 2015 Facebook, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License

common/dmlogwrites line 24

Quoted 10 lines
common/dmlogwrites new file +10 -0
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#
+# common functions for setting up and tearing down a dm log-writes device
+
+echo $MOUNT_OPTIONS | grep -q dax
+if [ $? -eq 0 ]; then
+	_notrun "Cannot run tests with DAX on dmerror devices"
+fi

Sorry, I just realized that we can take use of _exclude_scratch_mount_option helper to do this, and I think we can move the check inside _require_log_writes() too.

common/dmlogwrites line 33

Quoted 9 lines
common/dmlogwrites new file +9 -0
+
+_require_log_writes()
+{
+	[ -z "$LOGWRITES_DEV" -o ! -b "$LOGWRITES_DEV" ] && \
+		_notrun "This test requires a valid \$LOGWRITES_DEV"
+
+	_require_dm_target log-writes
+	_require_test_program "log-writes/replay-log"
+}

Otherwise this looks good to me.

Thanks,
Eryu

#11 lore raw

Re: [PATCH v3 09/13] fstests: add support for working with dm-log-writes target

In reply to Amir Goldstein
Quoted 19 lines · Amir Goldstein

Cherry-picked the relevant common bits from commit 70d41e17164b in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

This patch adds the supporting code for using the dm-log-writes target. The dmlogwrites code is similar to the dmflakey code, it just gives us functions to build and tear down a dm-log-writes target. We add a new LOGWRITES_DEV variable to take in the device we will use as the log and add checks for that.

[Amir:]
- Removed unneeded _test_falloc_support
- Moved _require_log_writes to dmlogwrites
- Document _require_log_writes
- Address review comments by Eryu Guan

---

...

Quoted 1 line

+# _replay_log <mark>

One additional nit, this comment can be updated to reflect new name :)

common/dmlogwrites line 75

Quoted 4 lines
common/dmlogwrites new file +4 -0
+#
+# This replays the log contained on $LOGWRITES_DEV onto $SCRATCH_DEV upto the
+# mark passed in.
+_log_writes_replay_log()

Thanks,
Eryu

#13 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Amir Goldstein
Quoted 116 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +77 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+	local name=$1
+
+	# Now look for our files
+	for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+	do
+		local filename=$(basename $i)
+		local mark="${filename##*.}"
+		echo "checking $filename" >> $seqres.full
+		_log_writes_replay_log $filename
+		_scratch_mount
+		local expected_md5=$(_md5_checksum $i)
+		local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+		[ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
+		_scratch_unmount
+		_check_scratch_fs
+	done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+

tests/generic/500 line 87

Quoted 10 lines
tests/generic/500 new file +10 -0
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)

Hmm, is this array necessary? Why not pass 0 to -S directly in the commandline? And generic/502 follows the same pattern.

tests/generic/500 line 93

Quoted 6 lines
tests/generic/500 new file +6 -0
+# Run fsx for a while
+for j in `seq 0 $((NUM_FILES-1))`
+do
+	run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
+done
+wait

Thanks,
Eryu

#33 lore raw

Re: [PATCH v3 11/13] fstests: regression test for ext4 crash consistency bug

In reply to Amir Goldstein
Quoted 63 lines · Amir Goldstein

This test is motivated by a bug found in ext4 during random crash consistency tests.

This test uses device mapper flakey target to demonstrate the bug found using device mapper log-writes target.

---
 tests/generic/501     | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/501.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 83 insertions(+)
 create mode 100755 tests/generic/501
 create mode 100644 tests/generic/501.out
tests/generic/501 new file +42 -0
new file mode 100755
index 0000000..ccb513d
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test No. 501
+#
+# This test is motivated by a bug found in ext4 during random crash
+# consistency tests.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_cleanup_flakey
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks

tests/generic/501 line 52

Quoted 10 lines
tests/generic/501 new file +10 -0
+. ./common/rc
+. ./common/filter
+. ./common/dmflakey
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_dm_target flakey
+_require_metadata_journaling $SCRATCH_DEV

This should be moved after _scratch_mkfs, otherwise it's checking scratch device from previous test.

tests/generic/501 line 56

Quoted 4 lines
tests/generic/501 new file +4 -0
+
+rm -f $seqres.full
+
+_scratch_mkfs >> $seqres.full 2>&1

Thanks,
Eryu

Quoted 44 lines
tests/generic/501 new file +24 -0
+
+_init_flakey
+_mount_flakey
+
+fsxops=$tmp.fsxops
+cat <<EOF > $fsxops
+write 0x137dd 0xdc69 0x0
+fallocate 0xb531 0xb5ad 0x21446
+collapse_range 0x1c000 0x4000 0x21446
+write 0x3e5ec 0x1a14 0x21446
+zero_range 0x20fac 0x6d9c 0x40000 keep_size
+mapwrite 0x216ad 0x274f 0x40000
+EOF
+run_check $here/ltp/fsx -d --replay-ops $fsxops $SCRATCH_MNT/testfile
+
+_flakey_drop_and_remount
+_unmount_flakey
+_cleanup_flakey
+_check_scratch_fs
+
+echo "Silence is golden"
+
+status=0
+exit
tests/generic/501.out new file +2 -0
new file mode 100644
index 0000000..00133b6
@@ -0,0 +1,2 @@
+QA output created by 501
+Silence is golden
tests/generic/group +1 -0
index c857153..1e1b524 100644
@@ -458,3 +458,4 @@
 453 auto quick dir
 454 auto quick attr
 500 auto log replay
+501 auto quick metadata
Signature · 1 line
2.7.4
#36 lore raw

Re: [PATCH v3 13/13] fstests: regression test for xfs leftover CoW extent error

In reply to Amir Goldstein
Quoted 1 line · Amir Goldstein

Better to have some more descriptions or background information on this test, either in commit log or in test description.

Quoted 63 lines
---
 tests/generic/503     | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/503.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 72 insertions(+)
 create mode 100755 tests/generic/503
 create mode 100644 tests/generic/503.out
tests/generic/503 new file +49 -0
new file mode 100755
index 0000000..ebda756
@@ -0,0 +1,69 @@
+#! /bin/bash
+# FS QA Test No. 503
+#
+# Regression test for xfs leftover CoW extents error
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink

tests/generic/503 line 59

Quoted 10 lines
tests/generic/503 new file +10 -0
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+$XFS_IO_PROG -f -c "pwrite 0 0x40000" \
+	$SCRATCH_MNT/foo > /dev/null 2>&1
+
+cp --reflink $SCRATCH_MNT/foo $SCRATCH_MNT/bar

_cp_reflink

tests/generic/503 line 65

Quoted 6 lines
tests/generic/503 new file +6 -0
+
+$XFS_IO_PROG -f -c "fzero -k 0x169f 0x387c" \
+		-c "fcollapse 0x29000 0xd000" \
+		-c "finsert 0 0x8000" \
+		-c "truncate 0x8000" \
+	$SCRATCH_MNT/foo > /dev/null 2>&1

_require_xfs_io_command these commands first, fzero, fcollapse, finsert.

Above two nits apply to generic/502 too.

Thanks,
Eryu

Quoted 24 lines
tests/generic/503 new file +4 -0
+
+echo "Silence is golden"
+status=0
+exit
tests/generic/503.out new file +2 -0
new file mode 100644
index 0000000..6c1400a
@@ -0,0 +1,2 @@
+QA output created by 503
+Silence is golden
tests/generic/group +1 -0
index 4324775..7a9cd78 100644
@@ -460,3 +460,4 @@
 500 auto log replay
 501 auto quick metadata
 502 auto log replay clone
+503 auto quick clone
Signature · 1 line
2.7.4
#14 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Eryu Guan
Quoted 122 lines · Eryu Guan
Quoted 121 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +82 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1     # failure is the default!
+
+_cleanup()
+{
+     _log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+     local name=$1
+
+     # Now look for our files
+     for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+     do
+             local filename=$(basename $i)
+             local mark="${filename##*.}"
+             echo "checking $filename" >> $seqres.full
+             _log_writes_replay_log $filename
+             _scratch_mount
+             local expected_md5=$(_md5_checksum $i)
+             local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+             [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
+             _scratch_unmount
+             _check_scratch_fs
+     done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
Quoted 9 lines

tests/generic/500 line 87

Quoted 5 lines
tests/generic/500 new file +5 -0
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)

Hmm, is this array necessary? Why not pass 0 to -S directly in the commandline? And generic/502 follows the same pattern.

The reason for the array is trying to follow your guidelines for running the test:
- Normally test runs with random seed (for which the array is not needed) and every fsx process prints out the seed to the full log
- When test detects a failure, you want to retry the test with same seed numbers, but those are different seed numbers for every fsx process
- So the array is here to make setting those presets possible

#15 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 133 lines · Amir Goldstein
Quoted 122 lines · Eryu Guan
Quoted 121 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +82 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1     # failure is the default!
+
+_cleanup()
+{
+     _log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+     local name=$1
+
+     # Now look for our files
+     for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+     do
+             local filename=$(basename $i)
+             local mark="${filename##*.}"
+             echo "checking $filename" >> $seqres.full
+             _log_writes_replay_log $filename
+             _scratch_mount
+             local expected_md5=$(_md5_checksum $i)
+             local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+             [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
+             _scratch_unmount
+             _check_scratch_fs
+     done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
Quoted 9 lines

tests/generic/500 line 87

Quoted 5 lines
tests/generic/500 new file +5 -0
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)

Hmm, is this array necessary? Why not pass 0 to -S directly in the commandline? And generic/502 follows the same pattern.

Quoted 7 lines

The reason for the array is trying to follow your guidelines for running the test:
- Normally test runs with random seed (for which the array is not needed) and every fsx process prints out the seed to the full log
- When test detects a failure, you want to retry the test with same seed numbers, but those are different seed numbers for every fsx process
- So the array is here to make setting those presets possible

Yeah, an array makes debug easier. Then I think a comment about the debug usage of the array would be sufficient. Thanks!

Eryu

#37 lore raw

Re: [PATCH v3 13/13] fstests: regression test for xfs leftover CoW extent error

In reply to Eryu Guan
Quoted 5 lines · Eryu Guan
Quoted 1 line · Amir Goldstein

Better to have some more descriptions or background information on this test, either in commit log or in test description.

Sure, I had this info in the original patch posting, but forgot to update my branch.

Regarding test 501,503, they are both "dumb" test in the sense that they don't explain why the specific sequence of events cause the problem or why the specific set of random offset/length values are used.

Darrick has already analyzed the report and posted a fix for 503, which I tested.

Ted has not responded to the bug report yet.

I suggested in original posting that perhaps, more insight about the cause should be added to the test before merging and possibly a reference to the fix commit.

You may want to wait on the maintainers input about this bug report before merging, or not. After all the "dumb" test does fail and it is possible to "undumb" it after there is a fix upstream.

Quoted 84 lines
Quoted 64 lines
---
 tests/generic/503     | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/503.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 72 insertions(+)
 create mode 100755 tests/generic/503
 create mode 100644 tests/generic/503.out
tests/generic/503 new file +49 -0
new file mode 100755
index 0000000..ebda756
@@ -0,0 +1,69 @@
+#! /bin/bash
+# FS QA Test No. 503
+#
+# Regression test for xfs leftover CoW extents error
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1     # failure is the default!
+
+_cleanup()
+{
+     cd /
+     rm -f $tmp.*
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink

tests/generic/503 line 59

Quoted 10 lines
tests/generic/503 new file +10 -0
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+$XFS_IO_PROG -f -c "pwrite 0 0x40000" \
+     $SCRATCH_MNT/foo > /dev/null 2>&1
+
+cp --reflink $SCRATCH_MNT/foo $SCRATCH_MNT/bar

_cp_reflink

tests/generic/503 line 65

Quoted 6 lines
tests/generic/503 new file +6 -0
+
+$XFS_IO_PROG -f -c "fzero -k 0x169f 0x387c" \
+             -c "fcollapse 0x29000 0xd000" \
+             -c "finsert 0 0x8000" \
+             -c "truncate 0x8000" \
+     $SCRATCH_MNT/foo > /dev/null 2>&1
Quoted 4 lines

_require_xfs_io_command these commands first, fzero, fcollapse, finsert.

Above two nits apply to generic/502 too.

FYI, tests 501 uses fsx to replay events, so it does not require that fs actually supports fallocate/fcollapse, because fsx automatically disables fallocate ops that are not supported by fs.

Amir.

#16 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Eryu Guan
Quoted 18 lines · Eryu Guan
Quoted 10 lines
Quoted 9 lines

tests/generic/500 line 87

Quoted 5 lines
tests/generic/500 new file +5 -0
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)

Hmm, is this array necessary? Why not pass 0 to -S directly in the commandline? And generic/502 follows the same pattern.

Quoted 7 lines

The reason for the array is trying to follow your guidelines for running the test:
- Normally test runs with random seed (for which the array is not needed) and every fsx process prints out the seed to the full log
- When test detects a failure, you want to retry the test with same seed numbers, but those are different seed numbers for every fsx process
- So the array is here to make setting those presets possible

Quoted 3 lines

Yeah, an array makes debug easier. Then I think a comment about the debug usage of the array would be sufficient. Thanks!

FYI, I removed the array from generic/502, because it was never useful during debugging. I guess the randomness stems mostly from timing of forking the fsx processes in that test.

I reduced NUM_OPS in cloned files test to 10 in v4, because after a few holes and writes the clone is no longer a clone anyway.
I already found a seed value to reproduce a failure of generic/502 on xfs failures are still random, but on spinning disk, I get them every 2 test runs.

Amir.

#17 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

Quoted 69 lines
---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +55 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1       # failure is the default!
+
+_cleanup()
+{
+       _log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+       local name=$1
+
+       # Now look for our files

tests/generic/500 line 65

Quoted 10 lines
tests/generic/500 new file +10 -0
+       for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+       do
+               local filename=$(basename $i)
+               local mark="${filename##*.}"
+               echo "checking $filename" >> $seqres.full
+               _log_writes_replay_log $filename
+               _scratch_mount
+               local expected_md5=$(_md5_checksum $i)
+               local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+               [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"

One time, the test reported md5 mismatch on a file, but when I replayed the log to the same mark I found that md5 of the file is correct compared to the 'snapshot' file in test partition.

Quoted 32 lines
tests/generic/500 new file +32 -0
+               _scratch_unmount
+               _check_scratch_fs
+       done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)
+# Run fsx for a while
+for j in `seq 0 $((NUM_FILES-1))`
+do
+       run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
+done
+wait
+
+test_md5=()
+for j in `seq 0 $((NUM_FILES-1))`
+do

tests/generic/500 line 107

Quoted 10 lines
tests/generic/500 new file +10 -0
+       test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+done
+
+# Unmount the scratch dir and tear down the log writes target
+_log_writes_mark last
+_log_writes_unmount
+_log_writes_mark end
+_log_writes_remove
+_check_scratch_fs
+

Another time xfs_repair complained about dirty log right after _log_writes_remove
and I wasn't able to seek to the "end" mark. Log entries were valid a few entries
after the "last" mark.

This leads me to believe that perhaps dm-log-writes doesn't flush all its pending
log io before remove? Anyway, I added a "sync $LOGWRITES_DEV" call inside _log_writes_remove. Not sure if that helps or if that is required before removing the
target?

I will report if I see that the problem persists.
Thought? suggestions?

Thanks,
Amir.

#18 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Amir,

Just to throw in what I believe I've found about dm-log-writes (though Josef would know more about this as it's just what I've concluded after looking at the code): dm-log-writes logs at IO completion, meaning disks that ignore flush operations could exhibit bugs where there are none, and dm-log-writes does synchronous marks though this may not line up with the stream of IO operations (due to buffering) unless you just did a sync. The CrashMonkey team wanted to make something similar to the "mark" operation dm-log-writes has and we concluded that the only place we could guarantee a mark would line up with the stream of IO operations the user had performed was right after a call to sync as that would force cached updates to disk. If you call mark without a sync, then you could insert a mark after a write(2) returns, but before the delayed allocation for that write(2) actually allocates blocks and changes the extent tree on disk.

Quoted 186 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

Quoted 69 lines
---
 tests/generic/500     | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/500.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 138 insertions(+)
 create mode 100755 tests/generic/500
 create mode 100644 tests/generic/500.out
tests/generic/500 new file +55 -0
new file mode 100755
index 0000000..82f7a93
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 500
+#
+# Run fsx with log writes to verify power fail safeness.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Facebook. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+status=1       # failure is the default!
+
+_cleanup()
+{
+       _log_writes_cleanup
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmlogwrites
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch_nocheck
+_require_log_writes
+
+rm -f $seqres.full
+
+check_files()
+{
+       local name=$1
+
+       # Now look for our files

tests/generic/500 line 65

Quoted 10 lines
tests/generic/500 new file +10 -0
+       for i in $(find $SANITY_DIR -type f | grep $name | grep mark)
+       do
+               local filename=$(basename $i)
+               local mark="${filename##*.}"
+               echo "checking $filename" >> $seqres.full
+               _log_writes_replay_log $filename
+               _scratch_mount
+               local expected_md5=$(_md5_checksum $i)
+               local md5=$(_md5_checksum $SCRATCH_MNT/$name)
+               [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"

One time, the test reported md5 mismatch on a file, but when I replayed the log to the same mark I found that md5 of the file is correct compared to the 'snapshot' file in test partition.

Quoted 32 lines
tests/generic/500 new file +32 -0
+               _scratch_unmount
+               _check_scratch_fs
+       done
+}
+
+SANITY_DIR=$TEST_DIR/fsxtests
+rm -rf $SANITY_DIR
+mkdir $SANITY_DIR
+
+# Create the log
+_log_writes_init
+
+_log_writes_mkfs >> $seqres.full 2>&1
+
+# Log writes emulates discard support, turn it on for maximum crying.
+_log_writes_mount -o discard
+
+NUM_FILES=4
+NUM_OPS=200
+FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
+# Set random seeds for fsx runs (0 for timestamp + pid)
+seeds=(0 0 0 0)
+# Run fsx for a while
+for j in `seq 0 $((NUM_FILES-1))`
+do
+       run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
+done
+wait
+
+test_md5=()
+for j in `seq 0 $((NUM_FILES-1))`
+do

tests/generic/500 line 107

Quoted 10 lines
tests/generic/500 new file +10 -0
+       test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
+done
+
+# Unmount the scratch dir and tear down the log writes target
+_log_writes_mark last
+_log_writes_unmount
+_log_writes_mark end
+_log_writes_remove
+_check_scratch_fs
+

Another time xfs_repair complained about dirty log right after _log_writes_remove
and I wasn't able to seek to the "end" mark. Log entries were valid a few entries
after the "last" mark.

This leads me to believe that perhaps dm-log-writes doesn't flush all its pending
log io before remove? Anyway, I added a "sync $LOGWRITES_DEV" call inside _log_writes_remove. Not sure if that helps or if that is required before removing the
target?

I will report if I see that the problem persists.
Thought? suggestions?

Thanks,
Amir.
--
To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Amir Goldstein
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +2 -0
index 8b80a9ce9ea9..1c502930af5e 100644
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
 		   !atomic_read(&lc->pending_blocks));
 	kthread_stop(lc->log_kthread);
 
+	invalidate_bdev(lc->logdev->bdev);
+	invalidate_bdev(lc->dev->bdev);
 	WARN_ON(!list_empty(&lc->logging_blocks));
 	WARN_ON(!list_empty(&lc->unflushed_blocks));
 	dm_put_device(ti, lc->dev);
#19 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Ashlie Martinez
Quoted 17 lines · Ashlie Martinez

Amir,

Just to throw in what I believe I've found about dm-log-writes (though Josef would know more about this as it's just what I've concluded after looking at the code): dm-log-writes logs at IO completion, meaning disks that ignore flush operations could exhibit bugs where there are none, and dm-log-writes does synchronous marks though this may not line up with the stream of IO operations (due to buffering) unless you just did a sync. The CrashMonkey team wanted to make something similar to the "mark" operation dm-log-writes has and we concluded that the only place we could guarantee a mark would line up with the stream of IO operations the user had performed was right after a call to sync as that would force cached updates to disk. If you call mark without a sync, then you could insert a mark after a write(2) returns, but before the delayed allocation for that write(2) actually allocates blocks and changes the extent tree on disk.

Yeah dm-log-writes gladly hands you the loaded gun, it's your job to not shoot yourself with it. This fsx test is specifically set up to only do the mark _after_ a successful call of fsync(), which means that the mark will be after where we expect our data to be consistent. Thanks,

Josef

#21 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to Josef Bacik
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

Thanks,
Amir.

#22 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 68 lines · Amir Goldstein
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

Quoted 8 lines

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

That failure I'll lay at the feet of whatever fs you are testing ;). I'm glad my patch fixed the replay problem, I'll send that up. Thanks,

Josef

#23 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 72 lines · Josef Bacik
Quoted 71 lines · Amir Goldstein
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

Quoted 9 lines
Quoted 5 lines

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

That failure I'll lay at the feet of whatever fs you are testing ;). I'm glad my patch fixed the replay problem, I'll send that up. Thanks,

O oh!. You are implying that xfs fails plain fsx and nobody noticed. That is not where I would place my bet.

Let's wait and see what other testers find and what other incidents my test machine will find.

Cheers,
Amir.

#24 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 79 lines · Amir Goldstein
Quoted 78 lines · Josef Bacik
Quoted 76 lines · Amir Goldstein
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

Quoted 7 lines
Quoted 3 lines

That failure I'll lay at the feet of whatever fs you are testing ;). I'm glad my patch fixed the replay problem, I'll send that up. Thanks,

O oh!. You are implying that xfs fails plain fsx and nobody noticed. That is not where I would place my bet.

Why not? This is one of the only tests that runs multiple threads of fsx at the same time. dm-log-writes does nothing special with the actual target disk, it just clones the bio's as it gets them, sets the bdev for the normal device and sends them on their way, there's no reason to think we're breaking that. Furthermore fsx is in normal page cache mode, not O_DIRECT, so it's more likely something else is going wrong and not dm-log-writes, unless there is so little memory on the system that we are constantly reading cold-cache. Thanks,

Josef

#25 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 88 lines · Josef Bacik
Quoted 79 lines · Amir Goldstein
Quoted 78 lines · Josef Bacik
Quoted 76 lines · Amir Goldstein
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

Quoted 7 lines
Quoted 3 lines

That failure I'll lay at the feet of whatever fs you are testing ;). I'm glad my patch fixed the replay problem, I'll send that up. Thanks,

O oh!. You are implying that xfs fails plain fsx and nobody noticed. That is not where I would place my bet.

Quoted 8 lines

Why not? This is one of the only tests that runs multiple threads of fsx at the same time. dm-log-writes does nothing special with the actual target disk, it just clones the bio's as it gets them, sets the bdev for the normal device and sends them on their way, there's no reason to think we're breaking that. Furthermore fsx is in normal page cache mode, not O_DIRECT, so it's more likely something else is going wrong and not dm-log-writes, unless there is so little memory on the system that we are constantly reading cold-cache. Thanks,

Very well, I'll run the same test on bare xfs for comparison.

Amir.

#27 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to a message not in the archive
Quoted 108 lines · Amir Goldstein
Quoted 98 lines · Amir Goldstein
Quoted 88 lines · Josef Bacik
Quoted 79 lines · Amir Goldstein
Quoted 78 lines · Josef Bacik
Quoted 76 lines · Amir Goldstein
Quoted 56 lines · Josef Bacik
Quoted 28 lines · Amir Goldstein
Quoted 23 lines · Amir Goldstein

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

The test just runs some ops and exits, then finds all of the good buffers in the directory we provided and:
- replays up to the mark given
- mounts the file system and compares the md5sum
- unmounts and fsck's to check for metadata integrity

dm-log-writes will pretend to do discard and the replay-log tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

Quoted 2 lines
Quoted 9 lines

Josef,

As you know, this test is now merged to xfstest as generic/455. I have been running the test for a while on xfs and it occasionally reports inconsistencies which I try to investigate.

In some of the reports, it appears that dm-log-writes may be exhibiting a reliability issue (see below).

It's not a reliability issue, its a caching issue. dm-log-writes is just issuing bio's to the log device, and our destructor waits for all pending io blocks to complete before exiting, so unless I've missed how dm is destroying devices everything should be on disk.

However since we replay in userspace we are going through the blockdevice's pagecache, so we could have stale pages left in place which is screwing us up. Will you try this patch and see if it fixes the problem? Thanks,

Josef

drivers/md/dm-log-writes.c +0 -0
index 8b80a9ce9ea9..1c502930af5e 100644

drivers/md/dm-log-writes.c static void log_writes_dtr(struct dm_target *ti) · line 552

Quoted 8 lines
drivers/md/dm-log-writes.c +2 -0
@@ -545,6 +545,8 @@ static void log_writes_dtr(struct dm_target *ti)
                   !atomic_read(&lc->pending_blocks));
        kthread_stop(lc->log_kthread);
 
+       invalidate_bdev(lc->logdev->bdev);
+       invalidate_bdev(lc->dev->bdev);
        WARN_ON(!list_empty(&lc->logging_blocks));
        WARN_ON(!list_empty(&lc->unflushed_blocks));
        dm_put_device(ti, lc->dev);

Josef,

With your patch OR with my xfstest patch that adds "sync" I did not yet see another problem of garbage fs after _log_writes_remove.

I did however, encounter this error (failure to verify read data during fsx) from scratch/log-writes device (see attached full log).

I will keep running the test to collect more information.

Quoted 7 lines
Quoted 3 lines

That failure I'll lay at the feet of whatever fs you are testing ;). I'm glad my patch fixed the replay problem, I'll send that up. Thanks,

O oh!. You are implying that xfs fails plain fsx and nobody noticed. That is not where I would place my bet.

Quoted 8 lines

Why not? This is one of the only tests that runs multiple threads of fsx at the same time. dm-log-writes does nothing special with the actual target disk, it just clones the bio's as it gets them, sets the bdev for the normal device and sends them on their way, there's no reason to think we're breaking that. Furthermore fsx is in normal page cache mode, not O_DIRECT, so it's more likely something else is going wrong and not dm-log-writes, unless there is so little memory on the system that we are constantly reading cold-cache. Thanks,

Quoted 2 lines

Very well, I'll run the same test on bare xfs for comparison.

Well, what do you know.
xfs crashed and burned after 18 rounds of 455 on test partition. Same check fs error I blamed dm-log-writes for.

Darrick,

Quoted 8 lines

Attached the modified 455 test which runs fsx on test partition and full log (+ dmesg with nothing of interest AFAICT). xfs code is 4.14.0-rc8 + your patch
"xfs: log recovery should replay deferred ops in order"

The test was run on a 100G partition on a spinning disk.

Let me know what you think.

I didn't even get /that/ far; with 4.15-rc1 and a vanilla g/455 I see immediately:

[18395.236285] run fstests generic/457 at 2017-11-28 14:15:49
[18395.561112] XFS (sdf): Unmounting Filesystem
[18395.752713] XFS (sdf): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18395.753469] XFS (sdf): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18395.754259] XFS (sdf): Mounting V5 Filesystem
[18395.757525] XFS (sdf): Ending clean mount
[18395.796992] XFS (sdf): Unmounting Filesystem
[18395.949561] XFS (dm-0): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18395.950316] XFS (dm-0): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18395.951103] XFS (dm-0): Mounting V5 Filesystem
[18395.954946] XFS (dm-0): Ending clean mount
[18396.132701] XFS (dm-0): Unmounting Filesystem
[18396.309939] XFS (sdf): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18396.310913] XFS (sdf): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18396.311798] XFS (sdf): Mounting V5 Filesystem
[18396.330304] XFS (sdf): Starting recovery (logdev: internal)
[18396.334996] XFS (sdf): Metadata corruption detected at xfs_inode_buf_verify+0xc4/0x330 [xfs], xfs_inode block 0x80
[18396.336389] XFS (sdf): Unmount and run xfs_repair
[18396.336945] XFS (sdf): First 64 bytes of corrupted metadata buffer:
[18396.337679] ffffc90004080000: 00 4e 41 ed 03 01 00 00 00 00 00 00 00 00 00 00  .NA.............
[18396.338647] ffffc90004080010: 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00  ................
[18396.339576] ffffc90004080020: 00 00 00 00 00 00 00 00 5a 1d e0 16 0b 69 8a 10  ........Z....i..
[18396.340341] ffffc90004080030: 5a 1d e0 16 0b 69 8a 10 00 00 00 00 00 00 00 06  Z....i..........
[18396.341091] XFS (sdf): bad inode magic/vsn daddr 128 #0 (magic=4e)
[18396.341754] XFS (sdf): metadata I/O error: block 0x80 ("xlog_recover_do..(read#2)") error 117 numblks 32
[18396.343131] XFS (sdf): log mount/recovery failed: error -117
[18396.343852] XFS (sdf): log mount failed

Off by one in the inode verifier... am I supposed to have Josef's patch?

Also, fwiw I don't see any test failures (or interesting output) with your modified 455:

[19344.527290] run fstests generic/455 at 2017-11-28 14:31:38
[19344.948061] XFS (pmem4): Unmounting Filesystem
[19345.098299] XFS (dm-0): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19345.099328] XFS (dm-0): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19345.100427] XFS (dm-0): Mounting V5 Filesystem
[19345.105724] XFS (dm-0): Ending clean mount
[19345.476248] XFS (dm-0): Unmounting Filesystem
[19346.055840] XFS (pmem4): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.057092] XFS (pmem4): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.057883] XFS (pmem4): Mounting V5 Filesystem
[19346.059640] XFS (pmem4): Ending clean mount
[19346.084019] XFS (pmem4): Unmounting Filesystem
[19346.492297] XFS (pmem4): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.492950] XFS (pmem4): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.493865] XFS (pmem4): Mounting V5 Filesystem
[19346.495732] XFS (pmem4): Ending clean mount
[19346.556181] XFS (pmem4): Unmounting Filesystem
[19346.780951] XFS (pmem3): Unmounting Filesystem
[19346.857051] XFS (pmem3): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.858352] XFS (pmem3): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.859053] XFS (pmem3): Mounting V5 Filesystem
[19346.861319] XFS (pmem3): Ending clean mount
[19346.940162] XFS (pmem3): Unmounting Filesystem
[19346.980932] XFS (pmem3): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.981640] XFS (pmem3): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.982359] XFS (pmem3): Mounting V5 Filesystem
[19346.984765] XFS (pmem3): Ending clean mount
[19347.204449] XFS (pmem3): Unmounting Filesystem

I think it's supposed to cycle more than that, right?

--D

Quoted 2 lines

Amir.

#28 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

Quoted 1 line · Darrick J. Wong

On Tue, Nov 28, 2017 at 11:17:01PM +0200, Amir Goldstein wrote:

[...]

Quoted 11 lines
Quoted 11 lines

Well, what do you know.
xfs crashed and burned after 18 rounds of 455 on test partition. Same check fs error I blamed dm-log-writes for.

Darrick,

Attached the modified 455 test which runs fsx on test partition and full log (+ dmesg with nothing of interest AFAICT). xfs code is 4.14.0-rc8 + your patch
"xfs: log recovery should replay deferred ops in order"

Quoted 6 lines
Quoted 3 lines

The test was run on a 100G partition on a spinning disk.

Let me know what you think.

I didn't even get /that/ far; with 4.15-rc1 and a vanilla g/455 I see immediately:

You mean vanilla g/457?

Quoted 29 lines
[18395.236285] run fstests generic/457 at 2017-11-28 14:15:49
[18395.561112] XFS (sdf): Unmounting Filesystem
[18395.752713] XFS (sdf): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18395.753469] XFS (sdf): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18395.754259] XFS (sdf): Mounting V5 Filesystem
[18395.757525] XFS (sdf): Ending clean mount
[18395.796992] XFS (sdf): Unmounting Filesystem
[18395.949561] XFS (dm-0): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18395.950316] XFS (dm-0): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18395.951103] XFS (dm-0): Mounting V5 Filesystem
[18395.954946] XFS (dm-0): Ending clean mount
[18396.132701] XFS (dm-0): Unmounting Filesystem
[18396.309939] XFS (sdf): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[18396.310913] XFS (sdf): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[18396.311798] XFS (sdf): Mounting V5 Filesystem
[18396.330304] XFS (sdf): Starting recovery (logdev: internal)
[18396.334996] XFS (sdf): Metadata corruption detected at xfs_inode_buf_verify+0xc4/0x330 [xfs], xfs_inode block 0x80
[18396.336389] XFS (sdf): Unmount and run xfs_repair
[18396.336945] XFS (sdf): First 64 bytes of corrupted metadata buffer:
[18396.337679] ffffc90004080000: 00 4e 41 ed 03 01 00 00 00 00 00 00 00 00 00 00  .NA.............
[18396.338647] ffffc90004080010: 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00  ................
[18396.339576] ffffc90004080020: 00 00 00 00 00 00 00 00 5a 1d e0 16 0b 69 8a 10  ........Z....i..
[18396.340341] ffffc90004080030: 5a 1d e0 16 0b 69 8a 10 00 00 00 00 00 00 00 06  Z....i..........
[18396.341091] XFS (sdf): bad inode magic/vsn daddr 128 #0 (magic=4e)
[18396.341754] XFS (sdf): metadata I/O error: block 0x80 ("xlog_recover_do..(read#2)") error 117 numblks 32
[18396.343131] XFS (sdf): log mount/recovery failed: error -117
[18396.343852] XFS (sdf): log mount failed
Quoted 2 lines

Off by one in the inode verifier... am I supposed to have Josef's patch?

I donno. Josef's patch makes sense, but it only matters for cleaning logdev page cache
from stale data in between 2 different runs

Quoted 32 lines

Also, fwiw I don't see any test failures (or interesting output) with your modified 455:

[19344.527290] run fstests generic/455 at 2017-11-28 14:31:38
[19344.948061] XFS (pmem4): Unmounting Filesystem
[19345.098299] XFS (dm-0): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19345.099328] XFS (dm-0): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19345.100427] XFS (dm-0): Mounting V5 Filesystem
[19345.105724] XFS (dm-0): Ending clean mount
[19345.476248] XFS (dm-0): Unmounting Filesystem
[19346.055840] XFS (pmem4): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.057092] XFS (pmem4): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.057883] XFS (pmem4): Mounting V5 Filesystem
[19346.059640] XFS (pmem4): Ending clean mount
[19346.084019] XFS (pmem4): Unmounting Filesystem
[19346.492297] XFS (pmem4): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.492950] XFS (pmem4): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.493865] XFS (pmem4): Mounting V5 Filesystem
[19346.495732] XFS (pmem4): Ending clean mount
[19346.556181] XFS (pmem4): Unmounting Filesystem
[19346.780951] XFS (pmem3): Unmounting Filesystem
[19346.857051] XFS (pmem3): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.858352] XFS (pmem3): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.859053] XFS (pmem3): Mounting V5 Filesystem
[19346.861319] XFS (pmem3): Ending clean mount
[19346.940162] XFS (pmem3): Unmounting Filesystem
[19346.980932] XFS (pmem3): EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!
[19346.981640] XFS (pmem3): EXPERIMENTAL reflink feature enabled. Use at your own risk!
[19346.982359] XFS (pmem3): Mounting V5 Filesystem
[19346.984765] XFS (pmem3): Ending clean mount
[19347.204449] XFS (pmem3): Unmounting Filesystem
Quoted 2 lines

I think it's supposed to cycle more than that, right?

Usually yes. This time around I got it after 18 rounds, but sometimes it takes more than 100 rounds.
Modified 455 is much faster because it skips all the replays, so I can expedite the testing.
Also, since most of the failures I have seen were on the slow spinning disk, not sure you would get
them on pmem device.

I'll continue to bisect.

Amir.

#31 lore raw

Re: [PATCH v3 10/13] fstests: crash consistency fsx test using dm-log-writes

In reply to a message not in the archive
Quoted 28 lines · Amir Goldstein
Quoted 1 line · Amir Goldstein

On Wed, Nov 29, 2017 at 5:33 AM, Amir Goldstein <[email protected]> wrote:

[...]

Quoted 7 lines

So far I was able to determine that your patch
"xfs: log recovery should replay deferred ops in order" is NOT the cause of the problem.
This took some time, because at one point it took me 23 hr to get to the dirty log
in test partition with modified 455 (no dm-log-writes).

Quoted 7 lines

Attached metadump of corrupt test partition.
The xfs code this test was running with is v4.14-rc8.
I did not try to bisect any further because of the time it takes per commit.

Let me know if you need any other info or if you want me to run the test on my setup for specific patch and/or bisection points.

I figured out what was going on in my test setup. The answer was in the attached dmesg, but I overlooked it:

[33816.533286] ata3.00: failed command: FLUSH CACHE EXT
[33816.533294] ata3.00: cmd ea/00:00:00:00:00/00:00:00:00:00/a0 tag 21
                        res 40/00:00:20:44:ba/00:00:0c:00:00/40 Emask
0x10 (ATA bus error)
[33816.533300] ata3.00: status: { DRDY }
[33816.533309] ata3: hard resetting link
Quoted 3 lines

It appears that that test machine had a faulty SATA cable.

This is probably more cruel to fs than a dm-flakey/dm-log-writes test...

Not as bad as the time when I discovered that one of my UASP bridges was arbitrarily injecting 'USBUSBUSB' into bus transfers.

Quoted 1 line

Cable replaced. Back to sanity. Sorry for the noise.

:)

--D

Quoted 1 line

Amir.