From patchwork Fri Mar 11 15:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12778222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AD40C433F5 for ; Fri, 11 Mar 2022 15:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245606AbiCKPTw (ORCPT ); Fri, 11 Mar 2022 10:19:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiCKPTv (ORCPT ); Fri, 11 Mar 2022 10:19:51 -0500 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C32831B01A7 for ; Fri, 11 Mar 2022 07:18:46 -0800 (PST) IronPort-Data: A9a23:hWRtla615TbKv1jWiVUlVQxRtCTFchMFZxGqfqrLsXjdYENShTQEnWEeXjvXaK2IYWv1f9BzYIq19EIOvZWEzIIyHQM5pCpnJ55ogZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9YtANkVEmjfvSHuCkUbadUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH55wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tKNmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32RwEyIoXCheYcTwJFVSp5OMWq/ZeeeyLi7JbMlBKun3zEhq8G4FsNFYMD5utsHXpm6/MVMnYOYwqFiubwx6i0ItSALOxLwNLDZdtZ4y8/i2qCS6tOfHwKeI2Sjfcw4dv6rpwm8S7iWvck IronPort-HdrOrdr: A9a23:bgdtIaCjOSryiIblHelK55DYdb4zR+YMi2TC1yhKKCC9Ffbo7vxG/c5rrSMc5wxhO03I9eruBEDEewK5yXcX2/h2AV7BZniFhILAFugLhuGOrwEIWReOkdK1vp0BT0ERMrPN5CBB/KPHCReDYqod6ejC4Ka1nv3f0nsoaQlrbptr5wB/Bh3zKDwNeCB2QYo+CIGH5tdK4x6peXEsZMy9AXUfG8fZodmjruOaXTc2Qw4g9BKVjS6lrJrzEx2j1B8YVD9VhZcOmFK16DDE2g== X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="122552737" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Mar 2022 23:18:25 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id BA8DA4D169FF for ; Fri, 11 Mar 2022 23:18:19 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 11 Mar 2022 23:18:19 +0800 Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 11 Mar 2022 23:18:20 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 11 Mar 2022 23:18:18 +0800 From: Shiyang Ruan To: CC: Subject: [PATCH 1/3] xfs: add memory failure test for dax mode Date: Fri, 11 Mar 2022 23:18:14 +0800 Message-ID: <20220311151816.2174870-2-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> References: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: BA8DA4D169FF.A3F15 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Make sure memory failure mechanism works when filesystem is mounted with dax option. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- .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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 From patchwork Fri Mar 11 15:18:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12778220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FEFDC433F5 for ; Fri, 11 Mar 2022 15:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234386AbiCKPTs (ORCPT ); Fri, 11 Mar 2022 10:19:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiCKPTr (ORCPT ); Fri, 11 Mar 2022 10:19:47 -0500 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 13F2E1AF8E3 for ; Fri, 11 Mar 2022 07:18:43 -0800 (PST) IronPort-Data: A9a23:XRad16PJW7MRL8XvrR25lcFynXyQoLVcMsFnjC/WdQG80zl01GNUxmRJCGzXaaveNjP1fd4lb9i09h8CvsOAm99gGjLY11k3ESsS9pCt6fd1j6vIF3rLaJWFFSqL1u1GAjX7BJ1yHi+0SiuFaOC79yEmjfjQH9IQNcafUsxPbV49IMseoUI78wIJqtYAbemRW2thi/uryyHsEAPNNwpPD44hw/nrRCWDExjFkGhwUlQWPZintbJF/pUfJMp3yaqZdxMUTmTId9NWSdovzJnhlo/Y1xwrTN24kLfnaVBMSbnXVeSMoiMOHfH83V4Z/Wpvuko4HKN0hUN/kSiAmctgjttLroCYRxorP7HXhaIWVBww/yRWZPccpeKdfiPi2SCU5wicG5f2+N1gF107JpED0vh4DHsI9vECLj0JKBeZiIqLLBiTIgV3rp17apC1Y8VE4Tc9pQw1xM0OGfjrK5gmL/cCtNvouv1zIA== IronPort-HdrOrdr: A9a23:k1z6rau+CQyuP7i9xtByYMEk7skDktV00zEX/kB9WHVpmszxra6TdZMgpHnJYVcqKQgdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79YFT0EUMrzN5DZB4voSmDPIcerI3uP3jZyAtKPPyWt3VwF2Z+VF5wd9MAySFUp7X2B9dOEEPavZ9sxavCChZHhSSsy6A0MOV+/Fq8aOu4nhZXc9dmQawTjLnTW186T7DhTd+h8fVglEybAk/XOAsyGR3NTaj82G X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="122552735" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Mar 2022 23:18:25 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id C3E304D16FD1 for ; Fri, 11 Mar 2022 23:18:19 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 11 Mar 2022 23:18:21 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 11 Mar 2022 23:18:18 +0800 From: Shiyang Ruan To: CC: Subject: [PATCH 2/3] xfs: add memory failure test for dax&reflink mode Date: Fri, 11 Mar 2022 23:18:15 +0800 Message-ID: <20220311151816.2174870-3-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> References: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: C3E304D16FD1.A0745 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Verify that the dax-rmap feature works. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- 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 From patchwork Fri Mar 11 15:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12778221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 131DBC433EF for ; Fri, 11 Mar 2022 15:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238469AbiCKPTu (ORCPT ); Fri, 11 Mar 2022 10:19:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiCKPTu (ORCPT ); Fri, 11 Mar 2022 10:19:50 -0500 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 669AA1B01A0 for ; Fri, 11 Mar 2022 07:18:45 -0800 (PST) IronPort-Data: A9a23:tz2/KK7cQpHe7OKkPrtXTAxRtCTFchMFZxGqfqrLsXjdYENS0zRWmjEYWW7Taf+DMzagfdBwbIy+o0MO7cLTy9c3SVA5pCpnJ55ogZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9YtANkVEmjfvSHuCkUbadUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH55wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tKNmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32RwEyIoXCheYcTwJFVSp5OMWq/ZeeeyLi7JbMlBOun3zEhq8G4FsNFYMD5utsHXpm6/MVMnYOYwqFiubwx6i0ItSALOxLwNLDZdtZ4y8/i2qCS6tOfHwKeI2Sjfcw4dv6rpwm8S7iWvck IronPort-HdrOrdr: A9a23:Ji83Xqqc4nT4Owz0FSF5kPQaV5rPeYIsimQD101hICG8cqSj+fxG+85rsyMc6QxhIU3I9urhBEDtex/hHNtOkOws1NSZLW7bUQmTXeJfBOLZqlWKcUDDH6xmpMNdmsNFaeEYY2IUsS+D2njbLz8/+qj7zImYwffZ02x2TRxnL4Vp7wJCAA6dFUFsLTM2fqYRJd6N4NZdvTq8dTAyZsS/PHMMWO/OvJnlj5TjCCR2fSIP2U2fiy+y8r7mH1y91hcaaTlGxrAv6izkvmXCl92ej80= X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="122552736" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Mar 2022 23:18:25 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 1B72C4D16FD3 for ; Fri, 11 Mar 2022 23:18:20 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 11 Mar 2022 23:18:19 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 11 Mar 2022 23:18:19 +0800 From: Shiyang Ruan To: CC: Subject: [PATCH 3/3] xfs: add memory failure test for partly-reflinked&dax file Date: Fri, 11 Mar 2022 23:18:16 +0800 Message-ID: <20220311151816.2174870-4-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> References: <20220311151816.2174870-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 1B72C4D16FD3.AD7CA X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Verify that dax-rmap works for both normal extent and shared extent. Signed-off-by: Shiyang Ruan --- 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