* [RFC PATCH 0/3] xfs: add memory failure tests for dax mode @ 2022-03-11 15:18 Shiyang Ruan 2022-03-11 15:18 ` [PATCH 1/3] xfs: add memory failure test " Shiyang Ruan ` (4 more replies) 0 siblings, 5 replies; 12+ messages in thread From: Shiyang Ruan @ 2022-03-11 15:18 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst This patchset is to verify whether memory failure mechanism still works with the dax-rmap feature[1]. With this feature, dax and reflink can be used together[2]. So, we also test it for reflinked files in filesystem mounted with dax option. [1] https://lore.kernel.org/linux-xfs/20220227120747.711169-1-ruansy.fnst@fujitsu.com/ [2] https://lore.kernel.org/linux-xfs/20210928062311.4012070-1-ruansy.fnst@fujitsu.com/ 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 | 154 ++++++++++++++++++++++++++++++++ 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, 333 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 -- 2.35.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] xfs: add memory failure test for dax mode 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan @ 2022-03-11 15:18 ` Shiyang Ruan 2022-04-27 18:05 ` Darrick J. Wong 2022-03-11 15:18 ` [PATCH 2/3] xfs: add memory failure test for dax&reflink mode Shiyang Ruan ` (3 subsequent siblings) 4 siblings, 1 reply; 12+ messages in thread From: Shiyang Ruan @ 2022-03-11 15:18 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst Make sure memory failure mechanism works when filesystem is mounted with dax option. Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> --- .gitignore | 1 + src/Makefile | 3 +- src/t_mmap_cow_memory_failure.c | 154 ++++++++++++++++++++++++++++++++ tests/xfs/900 | 48 ++++++++++ tests/xfs/900.out | 9 ++ 5 files changed, 214 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 diff --git a/.gitignore b/.gitignore index ba0c572b..1d26b28a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/src/Makefile b/src/Makefile index 111ce1d9..d702e200 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 \ diff --git a/src/t_mmap_cow_memory_failure.c b/src/t_mmap_cow_memory_failure.c new file mode 100644 index 00000000..e2266ced --- /dev/null +++ b/src/t_mmap_cow_memory_failure.c @@ -0,0 +1,154 @@ +// 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> + +#define KiB(a) ((a)*1024) +#define MiB(a) (KiB(a)*1024) + +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_posion(char *filename, off_t offset, size_t size, + off_t posionOffset, size_t posionSize) +{ + 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 posion...\n"); + error = madvise(map + posionOffset, posionSize, 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, *pPosionFile = NULL; + /* mmap range, in unit of 4KiB */ + size_t mmapSize = KiB(4); + off_t mmapOffset = 0; + /* posion range, in unit of 4KiB */ + size_t posionSize = KiB(4); + off_t posionOffset = 0; + int c; + pid_t pid; + + while ((c = getopt(argc, argv, "o::s::O::S::R:P:")) != -1) { + switch (c) { + // mmap offset, in unit of 4KiB + case 'o': + mmapOffset = atoi(optarg) * KiB(4); + break; + // mmap size + case 's': + mmapSize = atoi(optarg) * KiB(4); + break; + // madvice offset + case 'O': + posionOffset = atoi(optarg) * KiB(4); + break; + // madvice size + case 'S': + posionSize = atoi(optarg) * KiB(4); + break; + // filename for mmap read + case 'R': + pReadFile = optarg; + break; + // filename for posion read + case 'P': + pPosionFile = optarg; + break; + default: + printf("Unknown option: %c\n", c); + exit(1); + } + } + + if (!pReadFile || !pPosionFile) { + printf("Usage: \n" + " %s [-o mmapOffset] [-s mmapSize] [-O mmapOffset] [-S mmapSize] -R readFile -P posionFile\n", + basename(argv[0])); + exit(0); + } + if (posionSize < mmapSize) + mmapSize = posionSize; + + // 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 posion file */ + mmap_read_file_then_posion(pPosionFile, mmapOffset, mmapSize, + posionOffset, posionSize); + + 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); +} diff --git a/tests/xfs/900 b/tests/xfs/900 new file mode 100755 index 00000000..51529db5 --- /dev/null +++ b/tests/xfs/900 @@ -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 4k to cause page fault, and wait +# process2: mread 4k to cause page fault, then inject posion on this 4k 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 diff --git a/tests/xfs/900.out b/tests/xfs/900.out new file mode 100644 index 00000000..d861bf1f --- /dev/null +++ b/tests/xfs/900.out @@ -0,0 +1,9 @@ +QA output created by 900 +Format and mount +Create the original files +Inject memory failure (1 page) +Inject posion... +Process is killed by signal: 7 +Inject memory failure (2 pages) +Inject posion... +Process is killed by signal: 7 -- 2.35.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] xfs: add memory failure test for dax mode 2022-03-11 15:18 ` [PATCH 1/3] xfs: add memory failure test " Shiyang Ruan @ 2022-04-27 18:05 ` Darrick J. Wong 2022-04-27 18:15 ` Darrick J. Wong 0 siblings, 1 reply; 12+ messages in thread From: Darrick J. Wong @ 2022-04-27 18:05 UTC (permalink / raw) To: Shiyang Ruan; +Cc: fstests On Fri, Mar 11, 2022 at 11:18:14PM +0800, Shiyang Ruan wrote: > Make sure memory failure mechanism works when filesystem is mounted with > dax option. > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> > --- > .gitignore | 1 + > src/Makefile | 3 +- > src/t_mmap_cow_memory_failure.c | 154 ++++++++++++++++++++++++++++++++ > tests/xfs/900 | 48 ++++++++++ > tests/xfs/900.out | 9 ++ > 5 files changed, 214 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 > > diff --git a/.gitignore b/.gitignore > index ba0c572b..1d26b28a 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -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 > diff --git a/src/Makefile b/src/Makefile > index 111ce1d9..d702e200 100644 > --- a/src/Makefile > +++ b/src/Makefile > @@ -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 \ > diff --git a/src/t_mmap_cow_memory_failure.c b/src/t_mmap_cow_memory_failure.c > new file mode 100644 > index 00000000..e2266ced > --- /dev/null > +++ b/src/t_mmap_cow_memory_failure.c > @@ -0,0 +1,154 @@ > +// 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> > + > +#define KiB(a) ((a)*1024) > +#define MiB(a) (KiB(a)*1024) > + > +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_posion(char *filename, off_t offset, size_t size, Nit: "poison", not "posion". With that nit fixed, Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > + off_t posionOffset, size_t posionSize) > +{ > + 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 posion...\n"); > + error = madvise(map + posionOffset, posionSize, 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, *pPosionFile = NULL; > + /* mmap range, in unit of 4KiB */ > + size_t mmapSize = KiB(4); > + off_t mmapOffset = 0; > + /* posion range, in unit of 4KiB */ > + size_t posionSize = KiB(4); > + off_t posionOffset = 0; > + int c; > + pid_t pid; > + > + while ((c = getopt(argc, argv, "o::s::O::S::R:P:")) != -1) { > + switch (c) { > + // mmap offset, in unit of 4KiB > + case 'o': > + mmapOffset = atoi(optarg) * KiB(4); > + break; > + // mmap size > + case 's': > + mmapSize = atoi(optarg) * KiB(4); > + break; > + // madvice offset > + case 'O': > + posionOffset = atoi(optarg) * KiB(4); > + break; > + // madvice size > + case 'S': > + posionSize = atoi(optarg) * KiB(4); > + break; > + // filename for mmap read > + case 'R': > + pReadFile = optarg; > + break; > + // filename for posion read > + case 'P': > + pPosionFile = optarg; > + break; > + default: > + printf("Unknown option: %c\n", c); > + exit(1); > + } > + } > + > + if (!pReadFile || !pPosionFile) { > + printf("Usage: \n" > + " %s [-o mmapOffset] [-s mmapSize] [-O mmapOffset] [-S mmapSize] -R readFile -P posionFile\n", > + basename(argv[0])); > + exit(0); > + } > + if (posionSize < mmapSize) > + mmapSize = posionSize; > + > + // 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 posion file */ > + mmap_read_file_then_posion(pPosionFile, mmapOffset, mmapSize, > + posionOffset, posionSize); > + > + 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); > +} > diff --git a/tests/xfs/900 b/tests/xfs/900 > new file mode 100755 > index 00000000..51529db5 > --- /dev/null > +++ b/tests/xfs/900 > @@ -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 4k to cause page fault, and wait > +# process2: mread 4k to cause page fault, then inject posion on this 4k 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 > diff --git a/tests/xfs/900.out b/tests/xfs/900.out > new file mode 100644 > index 00000000..d861bf1f > --- /dev/null > +++ b/tests/xfs/900.out > @@ -0,0 +1,9 @@ > +QA output created by 900 > +Format and mount > +Create the original files > +Inject memory failure (1 page) > +Inject posion... > +Process is killed by signal: 7 > +Inject memory failure (2 pages) > +Inject posion... > +Process is killed by signal: 7 > -- > 2.35.1 > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] xfs: add memory failure test for dax mode 2022-04-27 18:05 ` Darrick J. Wong @ 2022-04-27 18:15 ` Darrick J. Wong 0 siblings, 0 replies; 12+ messages in thread From: Darrick J. Wong @ 2022-04-27 18:15 UTC (permalink / raw) To: Shiyang Ruan; +Cc: fstests On Wed, Apr 27, 2022 at 11:05:49AM -0700, Darrick J. Wong wrote: > On Fri, Mar 11, 2022 at 11:18:14PM +0800, Shiyang Ruan wrote: > > Make sure memory failure mechanism works when filesystem is mounted with > > dax option. > > > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> > > --- > > .gitignore | 1 + > > src/Makefile | 3 +- > > src/t_mmap_cow_memory_failure.c | 154 ++++++++++++++++++++++++++++++++ > > tests/xfs/900 | 48 ++++++++++ > > tests/xfs/900.out | 9 ++ > > 5 files changed, 214 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 > > > > diff --git a/.gitignore b/.gitignore > > index ba0c572b..1d26b28a 100644 > > --- a/.gitignore > > +++ b/.gitignore > > @@ -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 > > diff --git a/src/Makefile b/src/Makefile > > index 111ce1d9..d702e200 100644 > > --- a/src/Makefile > > +++ b/src/Makefile > > @@ -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 \ > > diff --git a/src/t_mmap_cow_memory_failure.c b/src/t_mmap_cow_memory_failure.c > > new file mode 100644 > > index 00000000..e2266ced > > --- /dev/null > > +++ b/src/t_mmap_cow_memory_failure.c > > @@ -0,0 +1,154 @@ > > +// 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> > > + > > +#define KiB(a) ((a)*1024) > > +#define MiB(a) (KiB(a)*1024) > > + > > +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_posion(char *filename, off_t offset, size_t size, > > Nit: "poison", not "posion". > > With that nit fixed, > Reviewed-by: Darrick J. Wong <djwong@kernel.org> I was a bit too hasty in sending this. RVB withdrawn. > > + off_t posionOffset, size_t posionSize) > > +{ > > + 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 posion...\n"); > > + error = madvise(map + posionOffset, posionSize, 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, *pPosionFile = NULL; > > + /* mmap range, in unit of 4KiB */ > > + size_t mmapSize = KiB(4); > > + off_t mmapOffset = 0; > > + /* posion range, in unit of 4KiB */ > > + size_t posionSize = KiB(4); I forgot that x64 isn't the only provider of fsdax now -- in theory, arm64 can do it, and they can have a 64k page size too. I think it's a bad idea to assume 4k page sizes for fsdax... > > + off_t posionOffset = 0; > > + int c; > > + pid_t pid; > > + > > + while ((c = getopt(argc, argv, "o::s::O::S::R:P:")) != -1) { > > + switch (c) { > > + // mmap offset, in unit of 4KiB > > + case 'o': > > + mmapOffset = atoi(optarg) * KiB(4); ...so if the -o/-s/-O/-S arguments are in units of pagecount, this really ought to be: long pagesize = sysconf(_SC_PAGESIZE); if (pagesize < 1) abort(); mmapSize = atoi(optarg) * pagesize; So that these tests can scale to any pagesize. --D > > + break; > > + // mmap size > > + case 's': > > + mmapSize = atoi(optarg) * KiB(4); > > + break; > > + // madvice offset > > + case 'O': > > + posionOffset = atoi(optarg) * KiB(4); > > + break; > > + // madvice size > > + case 'S': > > + posionSize = atoi(optarg) * KiB(4); > > + break; > > + // filename for mmap read > > + case 'R': > > + pReadFile = optarg; > > + break; > > + // filename for posion read > > + case 'P': > > + pPosionFile = optarg; > > + break; > > + default: > > + printf("Unknown option: %c\n", c); > > + exit(1); > > + } > > + } > > + > > + if (!pReadFile || !pPosionFile) { > > + printf("Usage: \n" > > + " %s [-o mmapOffset] [-s mmapSize] [-O mmapOffset] [-S mmapSize] -R readFile -P posionFile\n", > > + basename(argv[0])); > > + exit(0); > > + } > > + if (posionSize < mmapSize) > > + mmapSize = posionSize; > > + > > + // 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 posion file */ > > + mmap_read_file_then_posion(pPosionFile, mmapOffset, mmapSize, > > + posionOffset, posionSize); > > + > > + 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); > > +} > > diff --git a/tests/xfs/900 b/tests/xfs/900 > > new file mode 100755 > > index 00000000..51529db5 > > --- /dev/null > > +++ b/tests/xfs/900 > > @@ -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 4k to cause page fault, and wait > > +# process2: mread 4k to cause page fault, then inject posion on this 4k 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 > > diff --git a/tests/xfs/900.out b/tests/xfs/900.out > > new file mode 100644 > > index 00000000..d861bf1f > > --- /dev/null > > +++ b/tests/xfs/900.out > > @@ -0,0 +1,9 @@ > > +QA output created by 900 > > +Format and mount > > +Create the original files > > +Inject memory failure (1 page) > > +Inject posion... > > +Process is killed by signal: 7 > > +Inject memory failure (2 pages) > > +Inject posion... > > +Process is killed by signal: 7 > > -- > > 2.35.1 > > > > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] xfs: add memory failure test for dax&reflink mode 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan 2022-03-11 15:18 ` [PATCH 1/3] xfs: add memory failure test " Shiyang Ruan @ 2022-03-11 15:18 ` Shiyang Ruan 2022-04-27 18:07 ` Darrick J. Wong 2022-03-11 15:18 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan ` (2 subsequent siblings) 4 siblings, 1 reply; 12+ messages in thread From: Shiyang Ruan @ 2022-03-11 15:18 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst Verify that the dax-rmap feature works. Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> --- 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 diff --git a/tests/xfs/901 b/tests/xfs/901 new file mode 100755 index 00000000..a94a0c06 --- /dev/null +++ b/tests/xfs/901 @@ -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/posionfile >> $seqres.full +_scratch_cycle_mount "dax" + +echo "Inject memory failure (1 page)" +# create two processes: +# process1: mread 4k to cause page fault, and wait +# process2: mread 4k to cause page fault, then inject posion on this 4k page +$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/posionfile + +echo "Inject memory failure (2 pages)" +$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/posionfile + +_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 diff --git a/tests/xfs/901.out b/tests/xfs/901.out new file mode 100644 index 00000000..92d64846 --- /dev/null +++ b/tests/xfs/901.out @@ -0,0 +1,9 @@ +QA output created by 901 +Format and mount +Create the original files +Inject memory failure (1 page) +Inject posion... +Process is killed by signal: 7 +Inject memory failure (2 pages) +Inject posion... +Process is killed by signal: 7 -- 2.35.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] xfs: add memory failure test for dax&reflink mode 2022-03-11 15:18 ` [PATCH 2/3] xfs: add memory failure test for dax&reflink mode Shiyang Ruan @ 2022-04-27 18:07 ` Darrick J. Wong 0 siblings, 0 replies; 12+ messages in thread From: Darrick J. Wong @ 2022-04-27 18:07 UTC (permalink / raw) To: Shiyang Ruan; +Cc: fstests On Fri, Mar 11, 2022 at 11:18:15PM +0800, Shiyang Ruan wrote: > Verify that the dax-rmap feature works. > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> With the same 'posion' -> 'poison' fix applied, Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > --- > 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 > > diff --git a/tests/xfs/901 b/tests/xfs/901 > new file mode 100755 > index 00000000..a94a0c06 > --- /dev/null > +++ b/tests/xfs/901 > @@ -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/posionfile >> $seqres.full > +_scratch_cycle_mount "dax" > + > +echo "Inject memory failure (1 page)" > +# create two processes: > +# process1: mread 4k to cause page fault, and wait > +# process2: mread 4k to cause page fault, then inject posion on this 4k page > +$here/src/t_mmap_cow_memory_failure -s1 -S1 -R $testdir/testfile -P $testdir/posionfile > + > +echo "Inject memory failure (2 pages)" > +$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/posionfile > + > +_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 > diff --git a/tests/xfs/901.out b/tests/xfs/901.out > new file mode 100644 > index 00000000..92d64846 > --- /dev/null > +++ b/tests/xfs/901.out > @@ -0,0 +1,9 @@ > +QA output created by 901 > +Format and mount > +Create the original files > +Inject memory failure (1 page) > +Inject posion... > +Process is killed by signal: 7 > +Inject memory failure (2 pages) > +Inject posion... > +Process is killed by signal: 7 > -- > 2.35.1 > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan 2022-03-11 15:18 ` [PATCH 1/3] xfs: add memory failure test " Shiyang Ruan 2022-03-11 15:18 ` [PATCH 2/3] xfs: add memory failure test for dax&reflink mode Shiyang Ruan @ 2022-03-11 15:18 ` Shiyang Ruan 2022-04-27 18:16 ` Darrick J. Wong 2022-03-21 15:00 ` [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan 2022-04-27 6:22 ` Zorro Lang 4 siblings, 1 reply; 12+ messages in thread From: Shiyang Ruan @ 2022-03-11 15:18 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst Verify that dax-rmap works for both normal extent and shared extent. Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> --- 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 diff --git a/tests/xfs/902 b/tests/xfs/902 new file mode 100755 index 00000000..291d34fd --- /dev/null +++ b/tests/xfs/902 @@ -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=4096 +_pwrite_byte 0x61 0 $((blksz * nr)) $testdir/testfile >> $seqres.full +_pwrite_byte 0x62 0 $((blksz * nr)) $testdir/posionfile >> $seqres.full +seq 0 2 $((nr - 1)) | while read i; do + _reflink_range $testdir/testfile $((blksz * i)) \ + $testdir/posionfile $((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/posionfile + +echo "Inject memory failure (2 pages)" +# posion on reflinked page and not reflinked page +$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/posionfile + +_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 diff --git a/tests/xfs/902.out b/tests/xfs/902.out new file mode 100644 index 00000000..3c055d54 --- /dev/null +++ b/tests/xfs/902.out @@ -0,0 +1,9 @@ +QA output created by 902 +Format and mount +Create the original files +Inject memory failure (1 page) +Inject posion... +Process is killed by signal: 7 +Inject memory failure (2 pages) +Inject posion... +Process is killed by signal: 7 -- 2.35.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file 2022-03-11 15:18 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan @ 2022-04-27 18:16 ` Darrick J. Wong 0 siblings, 0 replies; 12+ messages in thread From: Darrick J. Wong @ 2022-04-27 18:16 UTC (permalink / raw) To: Shiyang Ruan; +Cc: fstests On Fri, Mar 11, 2022 at 11:18:16PM +0800, Shiyang Ruan wrote: > Verify that dax-rmap works for both normal extent and shared extent. > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> > --- > 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 > > diff --git a/tests/xfs/902 b/tests/xfs/902 > new file mode 100755 > index 00000000..291d34fd > --- /dev/null > +++ b/tests/xfs/902 > @@ -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=4096 And I guess while I'm whinging about not embedding the page size in the C source code, the test script shouldn't be doing that either. blksz=$(get_page_size) --D > +_pwrite_byte 0x61 0 $((blksz * nr)) $testdir/testfile >> $seqres.full > +_pwrite_byte 0x62 0 $((blksz * nr)) $testdir/posionfile >> $seqres.full > +seq 0 2 $((nr - 1)) | while read i; do > + _reflink_range $testdir/testfile $((blksz * i)) \ > + $testdir/posionfile $((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/posionfile > + > +echo "Inject memory failure (2 pages)" > +# posion on reflinked page and not reflinked page > +$here/src/t_mmap_cow_memory_failure -s2 -S2 -R $testdir/testfile -P $testdir/posionfile > + > +_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 > diff --git a/tests/xfs/902.out b/tests/xfs/902.out > new file mode 100644 > index 00000000..3c055d54 > --- /dev/null > +++ b/tests/xfs/902.out > @@ -0,0 +1,9 @@ > +QA output created by 902 > +Format and mount > +Create the original files > +Inject memory failure (1 page) > +Inject posion... > +Process is killed by signal: 7 > +Inject memory failure (2 pages) > +Inject posion... > +Process is killed by signal: 7 > -- > 2.35.1 > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 0/3] xfs: add memory failure tests for dax mode 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan ` (2 preceding siblings ...) 2022-03-11 15:18 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan @ 2022-03-21 15:00 ` Shiyang Ruan 2022-04-10 16:08 ` Eryu Guan 2022-04-27 6:22 ` Zorro Lang 4 siblings, 1 reply; 12+ messages in thread From: Shiyang Ruan @ 2022-03-21 15:00 UTC (permalink / raw) To: fstests ping... any comments? 在 2022/3/11 23:18, Shiyang Ruan 写道: > This patchset is to verify whether memory failure mechanism still works > with the dax-rmap feature[1]. With this feature, dax and reflink can be > used together[2]. So, we also test it for reflinked files in filesystem > mounted with dax option. > > [1] https://lore.kernel.org/linux-xfs/20220227120747.711169-1-ruansy.fnst@fujitsu.com/ > [2] https://lore.kernel.org/linux-xfs/20210928062311.4012070-1-ruansy.fnst@fujitsu.com/ > > 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 | 154 ++++++++++++++++++++++++++++++++ > 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, 333 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 > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 0/3] xfs: add memory failure tests for dax mode 2022-03-21 15:00 ` [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan @ 2022-04-10 16:08 ` Eryu Guan 0 siblings, 0 replies; 12+ messages in thread From: Eryu Guan @ 2022-04-10 16:08 UTC (permalink / raw) To: Shiyang Ruan; +Cc: fstests, linux-xfs On Mon, Mar 21, 2022 at 11:00:59PM +0800, Shiyang Ruan wrote: > ping... any comments? Sorry for the DELAY.. The tests look fine to me overall, but I'd like xfs folks to take a look at them as well. Thanks, Eryu > > 在 2022/3/11 23:18, Shiyang Ruan 写道: > > This patchset is to verify whether memory failure mechanism still works > > with the dax-rmap feature[1]. With this feature, dax and reflink can be > > used together[2]. So, we also test it for reflinked files in filesystem > > mounted with dax option. > > > > [1] https://lore.kernel.org/linux-xfs/20220227120747.711169-1-ruansy.fnst@fujitsu.com/ > > [2] https://lore.kernel.org/linux-xfs/20210928062311.4012070-1-ruansy.fnst@fujitsu.com/ > > > > 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 | 154 ++++++++++++++++++++++++++++++++ > > 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, 333 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 > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC PATCH 0/3] xfs: add memory failure tests for dax mode 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan ` (3 preceding siblings ...) 2022-03-21 15:00 ` [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan @ 2022-04-27 6:22 ` Zorro Lang 4 siblings, 0 replies; 12+ messages in thread From: Zorro Lang @ 2022-04-27 6:22 UTC (permalink / raw) To: linux-xfs; +Cc: fstests, Shiyang Ruan On Fri, Mar 11, 2022 at 11:18:13PM +0800, Shiyang Ruan wrote: > This patchset is to verify whether memory failure mechanism still works > with the dax-rmap feature[1]. With this feature, dax and reflink can be > used together[2]. So, we also test it for reflinked files in filesystem > mounted with dax option. > > [1] https://lore.kernel.org/linux-xfs/20220227120747.711169-1-ruansy.fnst@fujitsu.com/ > [2] https://lore.kernel.org/linux-xfs/20210928062311.4012070-1-ruansy.fnst@fujitsu.com/ > > 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 This patchset hang here for long time, the cases looks fine, can anyone familiar with DAX+XFS help to give it a double checking/reviewing :) Thanks, Zorro > > .gitignore | 1 + > src/Makefile | 3 +- > src/t_mmap_cow_memory_failure.c | 154 ++++++++++++++++++++++++++++++++ > 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, 333 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 > > -- > 2.35.1 > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/3] xfs: add memory failure tests for dax mode @ 2022-05-13 3:14 Shiyang Ruan 2022-05-13 3:14 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan 0 siblings, 1 reply; 12+ messages in thread From: Shiyang Ruan @ 2022-05-13 3:14 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst 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. [1] https://lore.kernel.org/linux-xfs/20220508143620.1775214-1-ruansy.fnst@fujitsu.com/ 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 -- 2.35.1 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file 2022-05-13 3:14 [PATCH v2 " Shiyang Ruan @ 2022-05-13 3:14 ` Shiyang Ruan 0 siblings, 0 replies; 12+ messages in thread From: Shiyang Ruan @ 2022-05-13 3:14 UTC (permalink / raw) To: fstests; +Cc: ruansy.fnst Verify that dax-rmap works for both normal extent and shared extent. Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> --- 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 diff --git a/tests/xfs/902 b/tests/xfs/902 new file mode 100755 index 00000000..85ae07a1 --- /dev/null +++ b/tests/xfs/902 @@ -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 diff --git a/tests/xfs/902.out b/tests/xfs/902.out new file mode 100644 index 00000000..3c055d54 --- /dev/null +++ b/tests/xfs/902.out @@ -0,0 +1,9 @@ +QA output created by 902 +Format and mount +Create the original files +Inject memory failure (1 page) +Inject posion... +Process is killed by signal: 7 +Inject memory failure (2 pages) +Inject posion... +Process is killed by signal: 7 -- 2.35.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-05-13 3:14 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-11 15:18 [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan 2022-03-11 15:18 ` [PATCH 1/3] xfs: add memory failure test " Shiyang Ruan 2022-04-27 18:05 ` Darrick J. Wong 2022-04-27 18:15 ` Darrick J. Wong 2022-03-11 15:18 ` [PATCH 2/3] xfs: add memory failure test for dax&reflink mode Shiyang Ruan 2022-04-27 18:07 ` Darrick J. Wong 2022-03-11 15:18 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan 2022-04-27 18:16 ` Darrick J. Wong 2022-03-21 15:00 ` [RFC PATCH 0/3] xfs: add memory failure tests for dax mode Shiyang Ruan 2022-04-10 16:08 ` Eryu Guan 2022-04-27 6:22 ` Zorro Lang 2022-05-13 3:14 [PATCH v2 " Shiyang Ruan 2022-05-13 3:14 ` [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Shiyang Ruan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.