Skip to contentSkip to conversation

xfs: add memory failure tests for dax mode

PATCH Superseded Shiyang Ruan 3 participants 8 messages May 20, 2022 – Jul 29, 2022

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover xfs: add memory failure tests for dax mode

This patchset is to verify whether memory failure mechanism still works with the fsdax-rmap feature. With this feature, fsdax and reflink can be used together[1]. So, we also test it for reflinked files in filesystem mounted with dax option.

Memo: (quoted from v2[2]):

Quoted 5 lines

Never mind. I'd like to merge these tests after your kernel patchset about "Add reflink&dedupe support for fsdax" be merged at first. To avoid you might add/change something. And I need to see the test works on offical kernel at least, before merging it. So feel free to ping me, if I forget this patchset at that time

[1] https://lore.kernel.org/linux-xfs/[email protected]/
[2] https://lore.kernel.org/fstests/[email protected]/T/#mb0197877ad9f89e2de009572c02ac1cdd4f7c8a7

Changes since v2:
1. Fixed typo in .out files

Changes since v1:
1. Fixed typo
2. Use sysconf(_SC_PAGESIZE) as page size, instead of the fixed 4KiB
3. Use $(get_page_size) in testcase
4. Unify the style of comments => /* */

Shiyang Ruan (3):
xfs: add memory failure test for dax mode
xfs: add memory failure test for dax&reflink mode
xfs: add memory failure test for partly-reflinked&dax file

 .gitignore                      |   1 +
 src/Makefile                    |   3 +-
 src/t_mmap_cow_memory_failure.c | 157 ++++++++++++++++++++++++++++++++
 tests/xfs/900                   |  48 ++++++++++
 tests/xfs/900.out               |   9 ++
 tests/xfs/901                   |  49 ++++++++++
 tests/xfs/901.out               |   9 ++
 tests/xfs/902                   |  52 +++++++++++
 tests/xfs/902.out               |   9 ++
 9 files changed, 336 insertions(+), 1 deletion(-)
 create mode 100644 src/t_mmap_cow_memory_failure.c
 create mode 100755 tests/xfs/900
 create mode 100644 tests/xfs/900.out
 create mode 100755 tests/xfs/901
 create mode 100644 tests/xfs/901.out
 create mode 100755 tests/xfs/902
 create mode 100644 tests/xfs/902.out
Signature · 1 line
2.35.1
#1 lore raw

PATCH v3 1/3 xfs: add memory failure test for dax mode

Make sure memory failure mechanism works when filesystem is mounted with dax option.

---
 .gitignore                      |   1 +
 src/Makefile                    |   3 +-
 src/t_mmap_cow_memory_failure.c | 157 ++++++++++++++++++++++++++++++++
 tests/xfs/900                   |  48 ++++++++++
 tests/xfs/900.out               |   9 ++
 5 files changed, 217 insertions(+), 1 deletion(-)
 create mode 100644 src/t_mmap_cow_memory_failure.c
 create mode 100755 tests/xfs/900
 create mode 100644 tests/xfs/900.out
.gitignore +1 -0
index ba0c572b..1d26b28a 100644
@@ -146,6 +146,7 @@ tags
 /src/t_holes
 /src/t_immutable
 /src/t_mmap_collision
+/src/t_mmap_cow_memory_failure
 /src/t_mmap_cow_race
 /src/t_mmap_dio
 /src/t_mmap_fallocate
src/Makefile +2 -1
index 111ce1d9..d702e200 100644
@@ -18,7 +18,8 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	t_ext4_dax_journal_corruption t_ext4_dax_inline_corruption \
 	t_ofd_locks t_mmap_collision mmap-write-concurrent \
 	t_get_file_time t_create_short_dirs t_create_long_dirs t_enospc \
-	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale
+	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale \
+	t_mmap_cow_memory_failure
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
src/t_mmap_cow_memory_failure.c new file +157 -0

157 lines not on this page · raw message

tests/xfs/900 new file +48 -0

48 lines not on this page · raw message

tests/xfs/900.out new file +9 -0
new file mode 100644
index 00000000..d861bf1f
@@ -0,0 +1,9 @@
+QA output created by 900
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] xfs: add memory failure test for dax mode

Quoted 4 lines · Shiyang Ruan

Make sure memory failure mechanism works when filesystem is mounted with dax option.

Looks like this is in good enough shape to merge,

--D

Quoted 274 lines
---
 .gitignore                      |   1 +
 src/Makefile                    |   3 +-
 src/t_mmap_cow_memory_failure.c | 157 ++++++++++++++++++++++++++++++++
 tests/xfs/900                   |  48 ++++++++++
 tests/xfs/900.out               |   9 ++
 5 files changed, 217 insertions(+), 1 deletion(-)
 create mode 100644 src/t_mmap_cow_memory_failure.c
 create mode 100755 tests/xfs/900
 create mode 100644 tests/xfs/900.out
.gitignore +1 -0
index ba0c572b..1d26b28a 100644
@@ -146,6 +146,7 @@ tags
 /src/t_holes
 /src/t_immutable
 /src/t_mmap_collision
+/src/t_mmap_cow_memory_failure
 /src/t_mmap_cow_race
 /src/t_mmap_dio
 /src/t_mmap_fallocate
src/Makefile +2 -1
index 111ce1d9..d702e200 100644
@@ -18,7 +18,8 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	t_ext4_dax_journal_corruption t_ext4_dax_inline_corruption \
 	t_ofd_locks t_mmap_collision mmap-write-concurrent \
 	t_get_file_time t_create_short_dirs t_create_long_dirs t_enospc \
-	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale
+	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale \
+	t_mmap_cow_memory_failure
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
src/t_mmap_cow_memory_failure.c new file +157 -0
new file mode 100644
index 00000000..4b2c1b8a
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022 Fujitsu Corporation. */
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <semaphore.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/sem.h>
+#include <time.h>
+#include <unistd.h>
+
+sem_t *sem;
+
+void sigbus_handler(int signal)
+{
+	printf("Process is killed by signal: %d\n", signal);
+	sem_post(sem);
+}
+
+void mmap_read_file(char *filename, off_t offset, size_t size)
+{
+	int fd;
+	char *map, *dummy;
+	struct timespec ts;
+
+	fd = open(filename, O_RDWR);
+	map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, offset);
+	dummy = malloc(size);
+
+	/* make sure page fault happens */
+	memcpy(dummy, map, size);
+
+	/* ready */
+	sem_post(sem);
+
+	usleep(200000);
+
+	clock_gettime(CLOCK_REALTIME, &ts);
+	ts.tv_sec += 3;
+	/* wait for injection done */
+	sem_timedwait(sem, &ts);
+
+	free(dummy);
+	munmap(map, size);
+	close(fd);
+}
+
+void mmap_read_file_then_poison(char *filename, off_t offset, size_t size,
+		off_t poisonOffset, size_t poisonSize)
+{
+	int fd, error;
+	char *map, *dummy;
+
+	/* wait for parent preparation done */
+	sem_wait(sem);
+
+	fd = open(filename, O_RDWR);
+	map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, offset);
+	dummy = malloc(size);
+
+	/* make sure page fault happens */
+	memcpy(dummy, map, size);
+
+	printf("Inject poison...\n");
+	error = madvise(map + poisonOffset, poisonSize, MADV_HWPOISON);
+	if (error)
+		printf("madvise() has fault: %d, errno: %d\n", error, errno);
+
+	free(dummy);
+	munmap(map, size);
+	close(fd);
+}
+
+int main(int argc, char *argv[])
+{
+	char *pReadFile = NULL, *pPoisonFile = NULL;
+	size_t mmapSize, poisonSize;
+	off_t mmapOffset = 0, poisonOffset = 0;
+	long pagesize = sysconf(_SC_PAGESIZE);
+	int c;
+	pid_t pid;
+
+	if (pagesize < 1) {
+		fprintf(stderr, "sysconf(_SC_PAGESIZE): failed to get page size\n");
+		abort();
+	}
+
+	/* default mmap / poison size, in unit of System Page Size */
+	mmapSize = poisonSize = pagesize;
+
+	while ((c = getopt(argc, argv, "o::s::O::S::R:P:")) != -1) {
+		switch (c) {
+		/* mmap offset */
+		case 'o':
+			mmapOffset = atoi(optarg) * pagesize;
+			break;
+		/* mmap size */
+		case 's':
+			mmapSize = atoi(optarg) * pagesize;
+			break;
+		/* madvice offset */
+		case 'O':
+			poisonOffset = atoi(optarg) * pagesize;
+			break;
+		/* madvice size */
+		case 'S':
+			poisonSize = atoi(optarg) * pagesize;
+			break;
+		/* filename for mmap read */
+		case 'R':
+			pReadFile = optarg;
+			break;
+		/* filename for poison read */
+		case 'P':
+			pPoisonFile = optarg;
+			break;
+		default:
+			printf("Unknown option: %c\n", c);
+			exit(1);
+		}
+	}
+
+	if (!pReadFile || !pPoisonFile) {
+		printf("Usage: \n"
+		       "  %s [-o mmapOffset] [-s mmapSize] [-O mmapOffset] [-S mmapSize] -R readFile -P poisonFile\n"
+		       "  (offset and size are both in unit of System Page Size: %ld)\n",
+				basename(argv[0]), pagesize);
+		exit(0);
+	}
+	if (poisonSize < mmapSize)
+		mmapSize = poisonSize;
+
+	/* fork and mmap files */
+	pid = fork();
+	if (pid == 0) {
+		/* handle SIGBUS */
+		signal(SIGBUS, sigbus_handler);
+		sem = sem_open("sync", O_CREAT, 0666, 0);
+
+		/* mread & do memory failure on poison file */
+		mmap_read_file_then_poison(pPoisonFile, mmapOffset, mmapSize,
+				poisonOffset, poisonSize);
+
+		sem_close(sem);
+	} else {
+		sem = sem_open("sync", O_CREAT, 0666, 0);
+
+		/* mread read file, wait for child process to be killed */
+		mmap_read_file(pReadFile, mmapOffset, mmapSize);
+		sem_close(sem);
+	}
+	exit(0);
+}
tests/xfs/900 new file +48 -0
new file mode 100755
index 00000000..da11230a
@@ -0,0 +1,48 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 900
+#
+# Test memory failure mechanism when dax enabled
+#
+. ./common/preamble
+_begin_fstest auto quick dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+filesize=65536
+_pwrite_byte 0x61 0 $filesize $testdir/testfile >> $seqres.full
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+# create two processes:
+#  process1: mread 1 page to cause page fault, and wait
+#  process2: mread 1 page to cause page fault, then inject poison on this page
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/testfile
+
+echo "Inject memory failure (2 pages)"
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/testfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/900.out new file +9 -0
new file mode 100644
index 00000000..d861bf1f
@@ -0,0 +1,9 @@
+QA output created by 900
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
#3 lore raw

Re: [PATCH v3 1/3] xfs: add memory failure test for dax mode

Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Shiyang Ruan

Make sure memory failure mechanism works when filesystem is mounted with dax option.

Looks like this is in good enough shape to merge,

Thanks Darrick, I think it's time to merge this patchset now, I'll do that in next fstests release.

Thanks,
Zorro

Quoted 278 lines

--D

Quoted 274 lines
---
 .gitignore                      |   1 +
 src/Makefile                    |   3 +-
 src/t_mmap_cow_memory_failure.c | 157 ++++++++++++++++++++++++++++++++
 tests/xfs/900                   |  48 ++++++++++
 tests/xfs/900.out               |   9 ++
 5 files changed, 217 insertions(+), 1 deletion(-)
 create mode 100644 src/t_mmap_cow_memory_failure.c
 create mode 100755 tests/xfs/900
 create mode 100644 tests/xfs/900.out
.gitignore +1 -0
index ba0c572b..1d26b28a 100644
@@ -146,6 +146,7 @@ tags
 /src/t_holes
 /src/t_immutable
 /src/t_mmap_collision
+/src/t_mmap_cow_memory_failure
 /src/t_mmap_cow_race
 /src/t_mmap_dio
 /src/t_mmap_fallocate
src/Makefile +2 -1
index 111ce1d9..d702e200 100644
@@ -18,7 +18,8 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	t_ext4_dax_journal_corruption t_ext4_dax_inline_corruption \
 	t_ofd_locks t_mmap_collision mmap-write-concurrent \
 	t_get_file_time t_create_short_dirs t_create_long_dirs t_enospc \
-	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale
+	t_mmap_writev_overlap checkpoint_journal mmap-rw-fault allocstale \
+	t_mmap_cow_memory_failure
 
 LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
src/t_mmap_cow_memory_failure.c new file +157 -0
new file mode 100644
index 00000000..4b2c1b8a
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2022 Fujitsu Corporation. */
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <semaphore.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/sem.h>
+#include <time.h>
+#include <unistd.h>
+
+sem_t *sem;
+
+void sigbus_handler(int signal)
+{
+	printf("Process is killed by signal: %d\n", signal);
+	sem_post(sem);
+}
+
+void mmap_read_file(char *filename, off_t offset, size_t size)
+{
+	int fd;
+	char *map, *dummy;
+	struct timespec ts;
+
+	fd = open(filename, O_RDWR);
+	map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, offset);
+	dummy = malloc(size);
+
+	/* make sure page fault happens */
+	memcpy(dummy, map, size);
+
+	/* ready */
+	sem_post(sem);
+
+	usleep(200000);
+
+	clock_gettime(CLOCK_REALTIME, &ts);
+	ts.tv_sec += 3;
+	/* wait for injection done */
+	sem_timedwait(sem, &ts);
+
+	free(dummy);
+	munmap(map, size);
+	close(fd);
+}
+
+void mmap_read_file_then_poison(char *filename, off_t offset, size_t size,
+		off_t poisonOffset, size_t poisonSize)
+{
+	int fd, error;
+	char *map, *dummy;
+
+	/* wait for parent preparation done */
+	sem_wait(sem);
+
+	fd = open(filename, O_RDWR);
+	map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, offset);
+	dummy = malloc(size);
+
+	/* make sure page fault happens */
+	memcpy(dummy, map, size);
+
+	printf("Inject poison...\n");
+	error = madvise(map + poisonOffset, poisonSize, MADV_HWPOISON);
+	if (error)
+		printf("madvise() has fault: %d, errno: %d\n", error, errno);
+
+	free(dummy);
+	munmap(map, size);
+	close(fd);
+}
+
+int main(int argc, char *argv[])
+{
+	char *pReadFile = NULL, *pPoisonFile = NULL;
+	size_t mmapSize, poisonSize;
+	off_t mmapOffset = 0, poisonOffset = 0;
+	long pagesize = sysconf(_SC_PAGESIZE);
+	int c;
+	pid_t pid;
+
+	if (pagesize < 1) {
+		fprintf(stderr, "sysconf(_SC_PAGESIZE): failed to get page size\n");
+		abort();
+	}
+
+	/* default mmap / poison size, in unit of System Page Size */
+	mmapSize = poisonSize = pagesize;
+
+	while ((c = getopt(argc, argv, "o::s::O::S::R:P:")) != -1) {
+		switch (c) {
+		/* mmap offset */
+		case 'o':
+			mmapOffset = atoi(optarg) * pagesize;
+			break;
+		/* mmap size */
+		case 's':
+			mmapSize = atoi(optarg) * pagesize;
+			break;
+		/* madvice offset */
+		case 'O':
+			poisonOffset = atoi(optarg) * pagesize;
+			break;
+		/* madvice size */
+		case 'S':
+			poisonSize = atoi(optarg) * pagesize;
+			break;
+		/* filename for mmap read */
+		case 'R':
+			pReadFile = optarg;
+			break;
+		/* filename for poison read */
+		case 'P':
+			pPoisonFile = optarg;
+			break;
+		default:
+			printf("Unknown option: %c\n", c);
+			exit(1);
+		}
+	}
+
+	if (!pReadFile || !pPoisonFile) {
+		printf("Usage: \n"
+		       "  %s [-o mmapOffset] [-s mmapSize] [-O mmapOffset] [-S mmapSize] -R readFile -P poisonFile\n"
+		       "  (offset and size are both in unit of System Page Size: %ld)\n",
+				basename(argv[0]), pagesize);
+		exit(0);
+	}
+	if (poisonSize < mmapSize)
+		mmapSize = poisonSize;
+
+	/* fork and mmap files */
+	pid = fork();
+	if (pid == 0) {
+		/* handle SIGBUS */
+		signal(SIGBUS, sigbus_handler);
+		sem = sem_open("sync", O_CREAT, 0666, 0);
+
+		/* mread & do memory failure on poison file */
+		mmap_read_file_then_poison(pPoisonFile, mmapOffset, mmapSize,
+				poisonOffset, poisonSize);
+
+		sem_close(sem);
+	} else {
+		sem = sem_open("sync", O_CREAT, 0666, 0);
+
+		/* mread read file, wait for child process to be killed */
+		mmap_read_file(pReadFile, mmapOffset, mmapSize);
+		sem_close(sem);
+	}
+	exit(0);
+}
tests/xfs/900 new file +48 -0
new file mode 100755
index 00000000..da11230a
@@ -0,0 +1,48 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 900
+#
+# Test memory failure mechanism when dax enabled
+#
+. ./common/preamble
+_begin_fstest auto quick dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+filesize=65536
+_pwrite_byte 0x61 0 $filesize $testdir/testfile >> $seqres.full
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+# create two processes:
+#  process1: mread 1 page to cause page fault, and wait
+#  process2: mread 1 page to cause page fault, then inject poison on this page
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/testfile
+
+echo "Inject memory failure (2 pages)"
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/testfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/900.out new file +9 -0
new file mode 100644
index 00000000..d861bf1f
@@ -0,0 +1,9 @@
+QA output created by 900
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
#4 lore raw

PATCH v3 2/3 xfs: add memory failure test for dax&reflink mode

In reply to Shiyang Ruan

Verify that the dax-rmap feature works.

---
 tests/xfs/901     | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/901.out |  9 +++++++++
 2 files changed, 58 insertions(+)
 create mode 100755 tests/xfs/901
 create mode 100644 tests/xfs/901.out
tests/xfs/901 new file +49 -0
new file mode 100755
index 00000000..26c1581e
@@ -0,0 +1,49 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 901
+#
+# Test memory failure mechanism when dax and reflink working together
+#
+. ./common/preamble
+_begin_fstest auto quick clone dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+filesize=65536
+_pwrite_byte 0x61 0 $filesize $testdir/testfile >> $seqres.full
+_cp_reflink $testdir/testfile $testdir/poisonfile >> $seqres.full
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+# create two processes:
+#  process1: mread 1 page to cause page fault, and wait
+#  process2: mread 1 page to cause page fault, then inject poison on this page
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/poisonfile
+
+echo "Inject memory failure (2 pages)"
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/poisonfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/901.out new file +9 -0
new file mode 100644
index 00000000..92d64846
@@ -0,0 +1,9 @@
+QA output created by 901
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
#5 lore raw

PATCH v3 3/3 xfs: add memory failure test for partly-reflinked&dax file

In reply to Shiyang Ruan

Verify that dax-rmap works for both normal extent and shared extent.

---
 tests/xfs/902     | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/902.out |  9 ++++++++
 2 files changed, 61 insertions(+)
 create mode 100755 tests/xfs/902
 create mode 100644 tests/xfs/902.out
tests/xfs/902 new file +52 -0
new file mode 100755
index 00000000..85ae07a1
@@ -0,0 +1,52 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 902
+#
+# Test memory failure mechanism when dax and reflink working together
+#   test for partly reflinked file
+#
+. ./common/preamble
+_begin_fstest auto quick clone dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+nr=16
+blksz=$(get_page_size)
+_pwrite_byte 0x61 0 $((blksz * nr)) $testdir/testfile >> $seqres.full
+_pwrite_byte 0x62 0 $((blksz * nr)) $testdir/poisonfile >> $seqres.full
+seq 0 2 $((nr - 1)) | while read i; do
+	_reflink_range $testdir/testfile $((blksz * i)) \
+		$testdir/poisonfile $((blksz * i)) $blksz >> $seqres.full
+done
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/poisonfile
+
+echo "Inject memory failure (2 pages)"
+# poison on reflinked page and not reflinked page
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/poisonfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/902.out new file +9 -0
new file mode 100644
index 00000000..3c055d54
@@ -0,0 +1,9 @@
+QA output created by 902
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
Reviewed-by on v3 3/3
#6 lore raw

Re: [PATCH v3 3/3] xfs: add memory failure test for partly-reflinked&dax file

Quoted 3 lines · Shiyang Ruan

Verify that dax-rmap works for both normal extent and shared extent.

LGTM,

--D

Quoted 85 lines
---
 tests/xfs/902     | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/902.out |  9 ++++++++
 2 files changed, 61 insertions(+)
 create mode 100755 tests/xfs/902
 create mode 100644 tests/xfs/902.out
tests/xfs/902 new file +52 -0
new file mode 100755
index 00000000..85ae07a1
@@ -0,0 +1,52 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 902
+#
+# Test memory failure mechanism when dax and reflink working together
+#   test for partly reflinked file
+#
+. ./common/preamble
+_begin_fstest auto quick clone dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+nr=16
+blksz=$(get_page_size)
+_pwrite_byte 0x61 0 $((blksz * nr)) $testdir/testfile >> $seqres.full
+_pwrite_byte 0x62 0 $((blksz * nr)) $testdir/poisonfile >> $seqres.full
+seq 0 2 $((nr - 1)) | while read i; do
+	_reflink_range $testdir/testfile $((blksz * i)) \
+		$testdir/poisonfile $((blksz * i)) $blksz >> $seqres.full
+done
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/poisonfile
+
+echo "Inject memory failure (2 pages)"
+# poison on reflinked page and not reflinked page
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/poisonfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/902.out new file +9 -0
new file mode 100644
index 00000000..3c055d54
@@ -0,0 +1,9 @@
+QA output created by 902
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1
#7 lore raw

Re: [PATCH v3 3/3] xfs: add memory failure test for partly-reflinked&dax file

In reply to Shiyang Ruan
Quoted 16 lines · Shiyang Ruan

Verify that dax-rmap works for both normal extent and shared extent.

---
 tests/xfs/902     | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/902.out |  9 ++++++++
 2 files changed, 61 insertions(+)
 create mode 100755 tests/xfs/902
 create mode 100644 tests/xfs/902.out
tests/xfs/902 new file +0 -0
new file mode 100755
index 00000000..85ae07a1

tests/xfs/902 line 8

Quoted 8 lines
tests/xfs/902 new file +8 -0
@@ -0,0 +1,52 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. 902
+#
+# Test memory failure mechanism when dax and reflink working together
+#   test for partly reflinked file
+#

Hi Shiyang,

I'd like to merge this patchset now, but I just noticed these 3 new cases doesn't have Copyright announce, so I hope to double check with you that if you intend to drop Copyright line?

If so, I'll merge directly, or please tell me what Copyright do you want to use, or send a new version with your Copyright (and RVB from Darrick).

Thanks,
Zorro

Quoted 64 lines
tests/xfs/902 new file +44 -0
+. ./common/preamble
+_begin_fstest auto quick clone dax
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_check_dmesg
+_require_scratch_reflink
+_require_xfs_scratch_rmapbt
+_require_scratch_dax_mountopt "dax"
+_require_test_program "t_mmap_cow_memory_failure"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount "-o dax" >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original files"
+nr=16
+blksz=$(get_page_size)
+_pwrite_byte 0x61 0 $((blksz * nr)) $testdir/testfile >> $seqres.full
+_pwrite_byte 0x62 0 $((blksz * nr)) $testdir/poisonfile >> $seqres.full
+seq 0 2 $((nr - 1)) | while read i; do
+	_reflink_range $testdir/testfile $((blksz * i)) \
+		$testdir/poisonfile $((blksz * i)) $blksz >> $seqres.full
+done
+_scratch_cycle_mount "dax"
+
+echo "Inject memory failure (1 page)"
+$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/poisonfile
+
+echo "Inject memory failure (2 pages)"
+# poison on reflinked page and not reflinked page
+$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/poisonfile
+
+_check_dmesg_for "Sending SIGBUS to t_mmap_cow_memo" || echo "Memory failure didn't kill the process"
+_check_dmesg_for "recovery action for dax page: Recovered" || echo "Failured page didn't recovered"
+
+# success, all done
+status=0
tests/xfs/902.out new file +9 -0
new file mode 100644
index 00000000..3c055d54
@@ -0,0 +1,9 @@
+QA output created by 902
+Format and mount
+Create the original files
+Inject memory failure (1 page)
+Inject poison...
+Process is killed by signal: 7
+Inject memory failure (2 pages)
+Inject poison...
+Process is killed by signal: 7
Signature · 1 line
2.35.1