From patchwork Thu Nov 25 07:47:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638565 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 67ADDC433EF for ; Thu, 25 Nov 2021 07:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234057AbhKYHxW (ORCPT ); Thu, 25 Nov 2021 02:53:22 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:17619 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234555AbhKYHvR (ORCPT ); Thu, 25 Nov 2021 02:51:17 -0500 IronPort-Data: A9a23:bc+7R6uWDcYAyQG/oNeDBy/i7OfnVEpcMUV32f8akzHdYEJGY0x3mmZJUWGCO/qOa2fwc4h1O47k/EgC75HVydNnTAJsri5gHilAwSbnLY7Hdx+vZUt+DSFioHpPtpxYMp+ZRCwNZie0SiyFb/6x8hGQ6YnSHuClUbeeZ3goLeNZYHxJZSxLyrdRbrFA0YDR7zOl4bsekuWHULOX82cc3lE8t8pvnChSUMHa41v0iLCRicdj5zcyn1FNZH4WyDrYw3HQGuG4FcbiLwrPIS3Qw4/Xw/stIovNfrfTeUtMTKPQPBSVlzxdXK3Kbhpq/3R0i/hkcqFHLxo/ZzahxridzP1XqJW2UhZvMKvXhMwTThtZDzpje6ZB/dcrJFDm6JPDnhWYLCCEL/JGSRte0Zcj0uhsHWxV6ecwNj8AdFaAiviwzbb9TfNj7vnPhuGD0Jg34ykmlG+GS619B82rfkkD3vcAtB9YuyyENaq2ixIlVAdS IronPort-HdrOrdr: A9a23:LtkaN69uYvXtXhm7cVxuk+D2I+orL9Y04lQ7vn2ZhyY0TiTS/Pre5cjztCWE7wr5N0tQ++xoVJPvfZr8z+8M3WBzB8bHYOCFghrMEGlihbGSuAEIcheWnoVgPMxbAstD4arLYWSS4/ya3ODDKbwdKaG8gcaVbLvlvg1QpHpRBp2JUmxCZTqmLg== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890673" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 548204D138C6 for ; Thu, 25 Nov 2021 15:47:57 +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; Thu, 25 Nov 2021 15:47:56 +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; Thu, 25 Nov 2021 15:47:57 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:55 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 01/16] generic: add mmap CoW test for ranges of two shared files Date: Thu, 25 Nov 2021 15:47:37 +0800 Message-ID: <20211125074752.274176-2-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 548204D138C6.ADBB5 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents. (MMAP version of generic/185,183) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/900 | 69 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/900.out | 14 +++++++++ 2 files changed, 83 insertions(+) create mode 100755 tests/generic/900 create mode 100644 tests/generic/900.out diff --git a/tests/generic/900 b/tests/generic/900 new file mode 100755 index 00000000..de76cd00 --- /dev/null +++ b/tests/generic/900 @@ -0,0 +1,69 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 900 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents. (MMAP version of generic/185,183) +# - Create two files +# - Reflink the odd blocks of the first file into a third file. +# - Reflink the even blocks of the second file into the third file. +# - mmap CoW across the halfway mark. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full +_pwrite_byte 0x62 0 $filesize $testdir/file2 >> $seqres.full +seq 0 2 $((nr-1)) | while read f; do + _reflink_range $testdir/file1 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full + _pwrite_byte 0x61 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full +done +seq 1 2 $((nr-1)) | while read f; do + _reflink_range $testdir/file2 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full + _pwrite_byte 0x62 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full +done +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file2 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file2 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/900.out b/tests/generic/900.out new file mode 100644 index 00000000..b2569ab0 --- /dev/null +++ b/tests/generic/900.out @@ -0,0 +1,14 @@ +QA output created by 900 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-900/file1 +b83f9394092e15bdcda585cd8e776dc6 SCRATCH_MNT/test-900/file2 +d3959a68638c50af07f0258e032cb554 SCRATCH_MNT/test-900/file3 +d3959a68638c50af07f0258e032cb554 SCRATCH_MNT/test-900/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-900/file1 +b83f9394092e15bdcda585cd8e776dc6 SCRATCH_MNT/test-900/file2 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-900/file3 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-900/file3.chk From patchwork Thu Nov 25 07:47:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638569 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 4D4FCC433FE for ; Thu, 25 Nov 2021 07:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234384AbhKYHzV (ORCPT ); Thu, 25 Nov 2021 02:55:21 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:17619 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234396AbhKYHxU (ORCPT ); Thu, 25 Nov 2021 02:53:20 -0500 IronPort-Data: A9a23:YFUcDqw4/YyrircMdSB6t+crxCrEfRIJ4+MujC/XYbTApDMg3jBTxmFKUT2PPa2KZGamfYokboSy8UxU78XQm4AxHQtv/xmBbVoQ95OdWo7xwmQcns+qBpSaChohtq3yU/GYRCwPZiKa9kjF3oTJ9yEmjPjRHOekUYYoBwgqLeNaYHZ44f5cs75h6mJYqYDR7zKl4bsekeWGULOW82Ic3lYv1k62gEgHUMIeF98vlgdWifhj5DcynpSOZX4VDfnZw3DQGuG4EgMmLtsvwo1V/kuBl/ssItij1LjmcEwWWaOUNg+L4pZUc/H6xEEc+WppieBmXBYfQR4/ZzGhhc14zs5c85K2UhsBMLDOmfgGTl9TFCQW0ahuoeaYcSnn75PDp6HBWz62qxl0N2k4JpEV4fpsKX9B+OZeKz0XaB2HweWsz9qGpkNE7ig4BJCzetpB5Tc7lneEZcvKiKvrG83ijeK0Fh9q7iyWIcvjWg== IronPort-HdrOrdr: A9a23:rWZi36lMjYqiY3WKame1JQHLJ87pDfIC3DAbv31ZSRFFG/FwWfrPoBxRviWE8Qr5OUtQ/uxoV5PwI080maQa3WAxB8bbYOCEghrNEGgB1/qG/9XgcxeOjdK1vJ0IG8ND4bbLfDtHZLHBjDVQfexA/DD8ysqVbJ/lvhFQpF1RGttdBnxCZzpyryZNKzV7OQ== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890678" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 71F744D138C7 for ; Thu, 25 Nov 2021 15:47:57 +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; Thu, 25 Nov 2021 15:47:57 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:55 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 02/16] generic: add mmap CoW test for regular&destination extents Date: Thu, 25 Nov 2021 15:47:38 +0800 Message-ID: <20211125074752.274176-3-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 71F744D138C7.AF4B3 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents, some regular, some not. (MMAP version of generic/197,196) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/901 | 59 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/901.out | 12 +++++++++ 2 files changed, 71 insertions(+) create mode 100755 tests/generic/901 create mode 100644 tests/generic/901.out diff --git a/tests/generic/901 b/tests/generic/901 new file mode 100755 index 00000000..b9f4fbc0 --- /dev/null +++ b/tests/generic/901 @@ -0,0 +1,59 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 901 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, some regular, some not. +# (MMAP version of generic/197,196) +# - Create two files. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/901.out b/tests/generic/901.out new file mode 100644 index 00000000..c3983e87 --- /dev/null +++ b/tests/generic/901.out @@ -0,0 +1,12 @@ +QA output created by 901 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-901/file1 +d3959a68638c50af07f0258e032cb554 SCRATCH_MNT/test-901/file3 +d3959a68638c50af07f0258e032cb554 SCRATCH_MNT/test-901/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-901/file1 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-901/file3 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-901/file3.chk From patchwork Thu Nov 25 07:47:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638593 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 D63BAC433EF for ; Thu, 25 Nov 2021 07:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240032AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:17619 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243442AbhKYH5W (ORCPT ); Thu, 25 Nov 2021 02:57:22 -0500 IronPort-Data: A9a23:9ilqJ661n3ll57OGi4nuhAxRtCTFchMFZxGqfqrLsXjdYENS0DAAzWtKXj+BPP2OZmqmLtFyb4W+8UoEvZ/dzNRkSFY5pCpnJ55ogZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9bdANkVEmjfvRH+OmVbadUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH55wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tKNmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32RwEyIoXCheYcTwJFVSp5OMWq/ZeeeCfv4JTNnxaun3zEhq8G4FsNFYMD5utsHXpm6/MVMnYOYwqFiubwx6i0ItSALOxLwNLDZdtZ4y8/i2qCS6tOfHwKeI2Sjfcw4dv6rpsm8S7iWvck IronPort-HdrOrdr: A9a23:ohvOB65q9ofXVn3mmQPXwObXdLJyesId70hD6qm+c3xomofyrbHWoB17726StN9/YgBDpTntAse9qFLnhOZICOoqTNOftWvdyQ6VxIAL1/qY/9SIIUSXndK1vp0QEJSWf+edMbEVt6fHCXODeerIuOP3lpxA2d2utUuFNjsGV0nchD0XNjqm X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890683" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id BA42E4D138C8 for ; Thu, 25 Nov 2021 15:47:57 +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; Thu, 25 Nov 2021 15:47:56 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:56 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 03/16] generic: add mmap CoW test for unwritten&destination extents Date: Thu, 25 Nov 2021 15:47:39 +0800 Message-ID: <20211125074752.274176-4-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: BA42E4D138C8.A058B 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents, some unwritten, some not. (MMAP version of generic/189,188) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/902 | 59 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/902.out | 12 +++++++++ 2 files changed, 71 insertions(+) create mode 100755 tests/generic/902 create mode 100644 tests/generic/902.out diff --git a/tests/generic/902 b/tests/generic/902 new file mode 100755 index 00000000..457b039a --- /dev/null +++ b/tests/generic/902 @@ -0,0 +1,59 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 902 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, some unwritten, some not. +# (MMAP version of generic/189,188) +# - Create a file and fallocate a second file. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/902.out b/tests/generic/902.out new file mode 100644 index 00000000..bc951255 --- /dev/null +++ b/tests/generic/902.out @@ -0,0 +1,12 @@ +QA output created by 902 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-902/file1 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-902/file3 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-902/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-902/file1 +09101629908f9bdd5d178e7ce20bb1bb SCRATCH_MNT/test-902/file3 +09101629908f9bdd5d178e7ce20bb1bb SCRATCH_MNT/test-902/file3.chk From patchwork Thu Nov 25 07:47:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638589 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 1F3DFC4332F for ; Thu, 25 Nov 2021 07:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345324AbhKYH5W (ORCPT ); Thu, 25 Nov 2021 02:57:22 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49039 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1348600AbhKYHzW (ORCPT ); Thu, 25 Nov 2021 02:55:22 -0500 IronPort-Data: A9a23:HsyFyqkz8vygyMcAZWpfiLDo5gydJERdPkR7XQ2eYbTBsI5bpzIAyWodCGmPbPqMMTP2L95+b42woRlVsMXWzYViGlZr+CA2RRqmi+KfW43BcR2Y0wB+jyH7ZBs+qZ1YM7EsFehsJpPnjkrrYueJQUVUj/nSH+OlUrOcY0ideCc/IMsfoUM68wIGqt4w6TSJK1vlVeLa+6UzCnf8s9JHGj58B5a4lf9alK+aVAX0EbAJTasjUFf2zxH5BX+ETE27ByOQroJ8RoZWSwtfpYxV8F81/z91Yj+kur39NEMXQL/OJhXIgX1TM0SgqkEa4HVsjeBgb7xBAatUo2zhc9RZ0shEs4ehDwkvJbHklvkfUgVDDmd1OqguFLrveCHg4Z3LkR2cG5fr67A0ZK0sBqUW4fp6Gn1V3eIXJSpLbR2Zge+yhrWhRYFRam4LRCXwFNpH/Cg+kneCVrB7Ka0vip7ivbdwtArcTOgXdRoGW/ckVA== IronPort-HdrOrdr: A9a23:hqCXvqPsxmKeZ8BcTu+jsMiBIKoaSvp037Dk7SBMoVc/SL3gqynOpoV96faaskdyZJhNo7690Yi7MAvhHP1OkO0s1NWZLWzbUGrBFvAY0WKK+VSJcBEWndQttpuIBJITNDSfNzlHZLzBijVQa+xQpuVvrJrY/9s2tE0BcenWAJsO0ztE X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890682" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 0E8644D138CA for ; Thu, 25 Nov 2021 15:47:58 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:47:58 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:56 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 04/16] generic: add mmap CoW test for holes&destination extents Date: Thu, 25 Nov 2021 15:47:40 +0800 Message-ID: <20211125074752.274176-5-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 0E8644D138CA.A467A 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents, some holes, some not. (MMAP version of generic/191,190) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/903 | 59 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/903.out | 12 +++++++++ 2 files changed, 71 insertions(+) create mode 100755 tests/generic/903 create mode 100644 tests/generic/903.out diff --git a/tests/generic/903 b/tests/generic/903 new file mode 100755 index 00000000..d0de3f26 --- /dev/null +++ b/tests/generic/903 @@ -0,0 +1,59 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 903 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, some holes, some not. +# (MMAP version of generic/191,190) +# - Create a file and truncate a second file. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/903.out b/tests/generic/903.out new file mode 100644 index 00000000..bf57acc7 --- /dev/null +++ b/tests/generic/903.out @@ -0,0 +1,12 @@ +QA output created by 903 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-903/file1 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-903/file3 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-903/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-903/file1 +09101629908f9bdd5d178e7ce20bb1bb SCRATCH_MNT/test-903/file3 +09101629908f9bdd5d178e7ce20bb1bb SCRATCH_MNT/test-903/file3.chk From patchwork Thu Nov 25 07:47:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638571 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 7A7D2C433EF for ; Thu, 25 Nov 2021 07:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234396AbhKYHzW (ORCPT ); Thu, 25 Nov 2021 02:55:22 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49039 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234489AbhKYHxU (ORCPT ); Thu, 25 Nov 2021 02:53:20 -0500 IronPort-Data: A9a23:cmGNzKkXlxl8k2USS7zol0no5gydJERdPkR7XQ2eYbTBsI5bpzFUxmIbXmHTPP2CajD3L911a4uz/RkPuJeGnN4yGlRp+CA2RRqmi+KfW43BcR2Y0wB+jyH7ZBs+qZ1YM7EsFehsJpPnjkrrYueJQUVUj/nSH+OlUrOcY0ideCc/IMsfoUM68wIGqt4w6TSJK1vlVeLa+6UzCnf8s9JHGj58B5a4lf9alK+aVAX0EbAJTasjUFf2zxH5BX+ETE27ByOQroJ8RoZWSwtfpYxV8F81/z91Yj+kur39NEMXQL/OJhXIgX1TM0SgqkEa4HVsjeBgb7xBAatUo2zhc9RZ0shEs4ehDwkvJbHklvkfUgVDDmd1OqguFLrveCHg4Z3LkR2eG5fr67A0ZK0sBqUW4fp6Gn1V3eIXJSpLbR2Zge+yhrWhRYFRam4LRCXwFNpH/Cg+kneCVrB7Ka0vip7ivbdwtArcTOgTdRoGW/ckVA== IronPort-HdrOrdr: A9a23:YzLPC6rbeJFn4jXiF8c2vA8aV5oFeYIsimQD101hICG9vPb5qyjk985rrCMc6QxhP03I9urwWpVoLUmzyXdV2/hoAV7AZniDhILLFvAG0WPiqweQYBEWn9Q1vcxdmsNFeb7N5C9B4foSjjPYLz9b+rO6GdiT9IHjJitWPHtXgtpbgjuQt22gfXFLeA== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890680" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 631D34D138CE for ; Thu, 25 Nov 2021 15:47:58 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:47:58 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:56 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 05/16] generic: add mmap CoW test for delalloc&destination extents Date: Thu, 25 Nov 2021 15:47:41 +0800 Message-ID: <20211125074752.274176-6-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 631D34D138CE.A03C8 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents, some delalloc, some not. (MMAP version of generic/195,194) Also, add a check to make sure the delalloc block is accutally exist. Signed-off-by: Shiyang Ruan --- common/reflink | 3 +++ tests/generic/904 | 61 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/904.out | 12 +++++++++ 3 files changed, 76 insertions(+) create mode 100755 tests/generic/904 create mode 100644 tests/generic/904.out diff --git a/common/reflink b/common/reflink index ee60398e..38210673 100644 --- a/common/reflink +++ b/common/reflink @@ -296,6 +296,9 @@ _weave_reflink_holes_delalloc() { _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk done + # make sure we actually got delalloc block + $FILEFRAG_PROG -v $dfile 2>&1 | grep -q delalloc || \ + _notrun "test requires delayed allocation writes" } # Create a file of interleaved regular blocks and reflinked blocks diff --git a/tests/generic/904 b/tests/generic/904 new file mode 100755 index 00000000..69703d70 --- /dev/null +++ b/tests/generic/904 @@ -0,0 +1,61 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 904 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, some delalloc, some not. +# (MMAP version of generic/195,194) +# - Create a file. +# - Reflink the odd blocks of the first file into the second file. +# - Buffered write the even blocks of the second file. +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_weave_reflink_holes_delalloc $blksz $nr $testdir/file3 >> $seqres.full +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/904.out b/tests/generic/904.out new file mode 100644 index 00000000..cc993394 --- /dev/null +++ b/tests/generic/904.out @@ -0,0 +1,12 @@ +QA output created by 904 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-904/file1 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-904/file3 +fa50dba51826899c372464a153cb2117 SCRATCH_MNT/test-904/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-904/file1 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-904/file3 +55968a95dfc0120df4e8485576514320 SCRATCH_MNT/test-904/file3.chk From patchwork Thu Nov 25 07:47:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638587 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 EED41C433F5 for ; Thu, 25 Nov 2021 07:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344555AbhKYH5W (ORCPT ); Thu, 25 Nov 2021 02:57:22 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:61265 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1348426AbhKYHzV (ORCPT ); Thu, 25 Nov 2021 02:55:21 -0500 IronPort-Data: A9a23:J7pd+6yos3RtixNay5V6t+crxCrEfRIJ4+MujC/XYbTApGgg0WYFzWMaWG+OP/mMYGqnL9B+bYW290oPuZaGndIwHQtv/xmBbVoQ95OdWo7xwmQcns+qBpSaChohtq3yU/GYRCwPZiKa9kjF3oTJ9yEmjPjRHOekUYYoBwgqLeNaYHZ44f5cs75h6mJYqYDR7zKl4bsekeWGULOW82Ic3lYv1k62gEgHUMIeF98vlgdWifhj5DcynpSOZX4VDfnZw3DQGuG4EgMmLtsvwo1V/kuBl/ssItij1LjmcEwWWaOUNg+L4pZUc/H6xEEc+WppieBmXBYfQR4/ZzGhhc14zs5c85K2UhsBMLDOmfgGTl9TFCQW0ahuoeaYcSnn75PMp6HBWz62qxl0N2k4JpEV4fpsKX9B+OZeKz0XaB2HweWsz9qGpkNE7ig4BJCzetpB5Tc7lneEZcvKiKvrG83ijeK0Fh9q7iyWIcvjWg== IronPort-HdrOrdr: A9a23:L/zcI6AinysoHwPlHemC55DYdb4zR+YMi2TDGXoQdfQfGfbo7vxG/c5rsiMc5wxhOk3I9ervBECgewKlyXcX2/h0AV7BZniChIOoRLsSlrcKqgeIc0bDH4VmpMRdmt9FZOEYY2IasS+B2mOF+q4bsb+6GfyT9J3jJgxWID2D1spbgDtENg== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890677" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id C83844D138D3 for ; Thu, 25 Nov 2021 15:47:58 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:47:59 +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; Thu, 25 Nov 2021 15:47:59 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:57 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 06/16] generic: add mmap CoW test for mixed&destination extents Date: Thu, 25 Nov 2021 15:47:42 +0800 Message-ID: <20211125074752.274176-7-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: C83844D138D3.A06B0 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 Ensuring that copy on write in mmap mode works when the CoW range originally covers multiple extents, mixed with reflinked, unwritten, hole, regular and delalloc blocks. (MMAP version of generic/200,199) Also, add a check to make sure the delalloc block is accutally exist. Signed-off-by: Shiyang Ruan --- common/reflink | 3 ++ tests/generic/905 | 68 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/905.out | 12 ++++++++ 3 files changed, 83 insertions(+) create mode 100755 tests/generic/905 create mode 100644 tests/generic/905.out diff --git a/common/reflink b/common/reflink index 38210673..84173d59 100644 --- a/common/reflink +++ b/common/reflink @@ -362,6 +362,9 @@ _weave_reflink_rainbow_delalloc() { _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk done + # make sure we actually got delalloc block + $FILEFRAG_PROG -v $dfile 2>&1 | grep -q delalloc || \ + _notrun "test requires delayed allocation writes" } # Make the source file have interleaved regular blocks and reflinked blocks diff --git a/tests/generic/905 b/tests/generic/905 new file mode 100755 index 00000000..56cdcd27 --- /dev/null +++ b/tests/generic/905 @@ -0,0 +1,68 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 905 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, mixed with reflinked, unwritten, +# hole, regular and delalloc blocks. +# (MMAP version of generic/200,199) +# - Create a file with the following repeating sequence of blocks: +# 1. reflinked +# 2. unwritten +# 3. hole +# 4. regular block +# 5. delalloc +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone punch + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" +_require_xfs_io_command "fpunch" +_require_cp_reflink +_require_odirect + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full +# now cow +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file3.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file3.chk | _filter_scratch + +# success, all done +status=0 diff --git a/tests/generic/905.out b/tests/generic/905.out new file mode 100644 index 00000000..6fb0be5f --- /dev/null +++ b/tests/generic/905.out @@ -0,0 +1,12 @@ +QA output created by 905 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-905/file1 +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-905/file3 +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-905/file3.chk +mmap CoW across the transition +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-905/file1 +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-905/file3 +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-905/file3.chk From patchwork Thu Nov 25 07:47:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638585 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 DEA6BC433EF for ; Thu, 25 Nov 2021 07:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240621AbhKYH5V (ORCPT ); Thu, 25 Nov 2021 02:57:21 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:17619 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1348481AbhKYHzV (ORCPT ); Thu, 25 Nov 2021 02:55:21 -0500 IronPort-Data: A9a23:QGKQZayKeOO8ho3ZSyF6t+crxCrEfRIJ4+MujC/XYbTApG4lgzQCnGdOXjjSafeIazOhf4twaI+y/RtT6paHzNc3HQtv/xmBbVoQ95OdWo7xwmQcns+qBpSaChohtq3yU/GYRCwPZiKa9kjF3oTJ9yEmjPjRHOekUYYoBwgqLeNaYHZ44f5cs75h6mJYqYDR7zKl4bsekeWGULOW82Ic3lYv1k62gEgHUMIeF98vlgdWifhj5DcynpSOZX4VDfnZw3DQGuG4EgMmLtsvwo1V/kuBl/ssItij1LjmcEwWWaOUNg+L4pZUc/H6xEEc+WppieBmXBYfQR4/ZzGhhc14zs5c85K2UhsBMLDOmfgGTl9TFCQW0ahuoeaYcSnn75PCp6HBWz62qxl0N2k4JpEV4fpsKX9B+OZeKz0XaB2HweWsz9qGpkNE7ig4BJCzetpB5Tc7lneEZcvKiKvrG83ijeK0Fh9t7iyWIcvjWg== IronPort-HdrOrdr: A9a23:aRBe4KoSENUrInQioHrBLu8aV5oFeYIsimQD101hICG9vPb5qyjk985rrCMc6QxhP03I9urwWpVoLUmzyXdV2/hoAV7AZniDhILLFvAG0WPiqweQYBEWn9Q1vcxdmsNFeb7N5C9B4foSjjPYLz9b+rO6GdiT9IHjJitWPHtXgtpbgjuQt22gfXFLeA== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890679" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id E23894D138D4 for ; Thu, 25 Nov 2021 15:47:58 +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; Thu, 25 Nov 2021 15:47:59 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:57 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 07/16] generic: add mmap CoW test for regular&source extents Date: Thu, 25 Nov 2021 15:47:43 +0800 Message-ID: <20211125074752.274176-8-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: E23894D138D4.AF11E 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 Ensuring that copy on write in mmap mode to the source file when the CoW range covers regular unshared and regular shared blocks. (MMAP version of generic/284,287) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/906 | 60 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/906.out | 12 +++++++++ 2 files changed, 72 insertions(+) create mode 100755 tests/generic/906 create mode 100644 tests/generic/906.out diff --git a/tests/generic/906 b/tests/generic/906 new file mode 100755 index 00000000..953348e8 --- /dev/null +++ b/tests/generic/906 @@ -0,0 +1,60 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 906 +# +# Ensuring that copy on write in mmap mode to the source file when the +# CoW range covers regular unshared and regular shared blocks. +# (MMAP version of generic/284,287) +# - Create two files. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW the first file across the halfway mark, starting with the +# regular extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/906.out b/tests/generic/906.out new file mode 100644 index 00000000..4949769b --- /dev/null +++ b/tests/generic/906.out @@ -0,0 +1,12 @@ +QA output created by 906 +Format and mount +Create the original files +Compare files +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-906/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-906/file3 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-906/file1.chk +mmap CoW across the transition +Compare files +2dc2b131303b2f70ddb480778caac8b7 SCRATCH_MNT/test-906/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-906/file3 +2dc2b131303b2f70ddb480778caac8b7 SCRATCH_MNT/test-906/file1.chk From patchwork Thu Nov 25 07:47:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638567 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 AA23DC433F5 for ; Thu, 25 Nov 2021 07:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348514AbhKYHzU (ORCPT ); Thu, 25 Nov 2021 02:55:20 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:61265 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234384AbhKYHxU (ORCPT ); Thu, 25 Nov 2021 02:53:20 -0500 IronPort-Data: A9a23:SAwUe6oadlD6ZoW2V0+Zv5jSEsBeBmIEZxIvgKrLsJaIsI5as4F+vjBLWWqEaK2MajamftogYN6/9kgGu5/VytFkTAE/rH0wQiMRo6IpJ/zDcB6oYHn6wu4v7a5fx5xHLIGGdajYd1eEzvuWGuWn/SYUOZ2gHOKmUbedYH0pHGeIdQ964f5ds79g6mJXqYjha++9kYuaT/z3YDdJ6RYtWo4nw/7rRCdUgRjHkGhwUmrSyhx8lAS2e3E9VPrzLEwqRpfyatE88uWSH44vwFwll1418SvBCvv9+lr6WkYMBLDPPwmSkWcQUK+n6vRAjnVqlP9la7xHMgEK49mKt4kZJNFlr4G5Txw4eKPKg/g1XQRaEj1lIOtN/7qvzX2X6JXMnxyeLSSyqxlpJARsVWECwc55Gn1D7uADAC4CYwrFhO+sxr+/DO52iawewGPDVG8Ekig4i2iHUrB9GtaeK5gmLORwhF8Y7v2i196FDybBVQdSUQ== IronPort-HdrOrdr: A9a23:rjkJb6ndWVWuUDvrw8dba3ysVe3pDfIC3DAbv31ZSRFFG/FwWfrPoBxRviWE8Qr5OUtQ/uxoV5PwI080maQa3WAxB8bbYOCEghrNEGgB1/qG/9XgcxeOjdK1vJ0IG8ND4bbLfDtHZLHBjDVQfexA/DD8ysqVbJ/lvhFQpF1RGttdBnxCZzpyryZNKzV7OQ== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890676" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 3CF574D138E2 for ; Thu, 25 Nov 2021 15:47:59 +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; Thu, 25 Nov 2021 15:47:57 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:57 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 08/16] generic: add mmap CoW test for unwritten&source extents Date: Thu, 25 Nov 2021 15:47:44 +0800 Message-ID: <20211125074752.274176-9-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 3CF574D138E2.A0BB9 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 Ensuring that copy on write in mmap mode to the source file when the CoW range covers unwritten and regular shared blocks. (MMAP version of generic/289,290) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/907 | 62 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/907.out | 12 +++++++++ 2 files changed, 74 insertions(+) create mode 100755 tests/generic/907 create mode 100644 tests/generic/907.out diff --git a/tests/generic/907 b/tests/generic/907 new file mode 100755 index 00000000..61c9293a --- /dev/null +++ b/tests/generic/907 @@ -0,0 +1,62 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 907 +# +# Ensuring that copy on write in mmap mode to the source file when the +# CoW range covers unwritten and regular shared blocks. +# (MMAP version of generic/289,290) +# - Create two files. +# - fallocate the first file. +# - Write the odd blocks of the first file. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW the first file across the halfway mark, starting with the +# regular extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/907.out b/tests/generic/907.out new file mode 100644 index 00000000..c18b849c --- /dev/null +++ b/tests/generic/907.out @@ -0,0 +1,12 @@ +QA output created by 907 +Format and mount +Create the original files +Compare files +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-907/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-907/file3 +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-907/file1.chk +mmap CoW across the transition +Compare files +e8cf59797f0b3758c8878c368bb4cf7e SCRATCH_MNT/test-907/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-907/file3 +e8cf59797f0b3758c8878c368bb4cf7e SCRATCH_MNT/test-907/file1.chk From patchwork Thu Nov 25 07:47:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638591 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 8AD97C433F5 for ; Thu, 25 Nov 2021 07:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239504AbhKYH7J (ORCPT ); Thu, 25 Nov 2021 02:59:09 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:34883 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240032AbhKYH5S (ORCPT ); Thu, 25 Nov 2021 02:57:18 -0500 IronPort-Data: A9a23:0mF6aK6yZcVLh+i8C5CznAxRtCTFchMFZxGqfqrLsXjdYENS1DUEnDcYWWuPa/bbZWTyc49wPonj9E1SsZfcy4VjTVE5pCpnJ55ogZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9bdANkVEmjfvRH+OmVbadUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH55wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tKNmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32RwEyIoXCheYcTwJFVSp5OMWq/ZeeeCfv4JTNnxGun3zEhq8G4FsNFYMD5utsHXpm6/MVMnYOYwqFiubwx6i0ItSALOxLwNLDZdtZ4y8/i2qCS6tOfHwKeI2Sjfcw4dv6rpsm8S7iWvck IronPort-HdrOrdr: A9a23:bNE46Kg7uhv0jW1BFRrAYSZmonBQXvQji2hC6mlwRA09TyVXraCTdL9x726MtN9xYgBGpTnuAtjjfZqxz/BICKgqTM+ftWrdyQ+VxeNZnO7fKzyJIVyEygc1784JGJSWY+eAbmSS+vyX3ODXKbcdKaO8mpxA/d2uqUuFETsaEZ2IlD0VNu4neXcYeDV7 X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890684" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:47:59 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 84F8A4D138C7 for ; Thu, 25 Nov 2021 15:47:59 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:48:00 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:57 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 09/16] generic: add mmap CoW test for holes&source extents Date: Thu, 25 Nov 2021 15:47:45 +0800 Message-ID: <20211125074752.274176-10-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 84F8A4D138C7.A06C1 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 Ensuring that copy on write in mmap mode to the source file when the CoW range covers holes and regular shared blocks. (MMAP version of generic/291,292) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/908 | 62 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/908.out | 12 +++++++++ 2 files changed, 74 insertions(+) create mode 100755 tests/generic/908 create mode 100644 tests/generic/908.out diff --git a/tests/generic/908 b/tests/generic/908 new file mode 100755 index 00000000..ad8de699 --- /dev/null +++ b/tests/generic/908 @@ -0,0 +1,62 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 908 +# +# Ensuring that copy on write in mmap mode to the source file when the +# CoW range covers holes and regular shared blocks. +# (MMAP version of generic/291,292) +# - Create two files. +# - Truncate the first file. +# - Write the odd blocks of the first file. +# - Reflink the odd blocks of the first file into the second file. +# - mmap CoW the first file across the halfway mark, starting with the +# regular extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/908.out b/tests/generic/908.out new file mode 100644 index 00000000..c8c670ac --- /dev/null +++ b/tests/generic/908.out @@ -0,0 +1,12 @@ +QA output created by 908 +Format and mount +Create the original files +Compare files +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-908/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-908/file3 +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-908/file1.chk +mmap CoW across the transition +Compare files +e8cf59797f0b3758c8878c368bb4cf7e SCRATCH_MNT/test-908/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-908/file3 +e8cf59797f0b3758c8878c368bb4cf7e SCRATCH_MNT/test-908/file1.chk From patchwork Thu Nov 25 07:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638599 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 70BDAC433EF for ; Thu, 25 Nov 2021 07:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239137AbhKYIBK (ORCPT ); Thu, 25 Nov 2021 03:01:10 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:34883 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239621AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 IronPort-Data: A9a23:yMI+mq23gdtOTuw7wvbD5c9zkn2cJEfYwER7XOPLsXnJh28lg2MGzWQdUWHTb67eMTfxfNFzaISw90gAucWDxt82QQE+nZ1PZygU8JKaX7x1DatR0xu6d5SFFAQ+hyknQoGowPscEzmM+X9BDpC79SMljPjSG+KlYAL5EnsZqTFMGX5JZS1Ly7ZRbr5A2bBVMivV0T/Ai5S31GyNh1aYBlkpB5er83uDihhdVAQw5TTSbdgT1LPXeuJ84Jg3fcldJFOgKmVY83LTegrN8F251juxExYFAdXjnKv5c1ERX/jZOg3mZnh+AvDk20Yd4HdplPtT2Pk0MC+7jx2Tgtl308QLu5qrVS8nI6/NhP8AFRJfFkmSOIUfoeCXcCDh4JD7I0ruNiGEL+9VJE8tIYAD5v1fH25D77obJSoLYxTFgPi5qI9X4MEEat8LdZGtZd1A/Co7i2yxMBrveribK42i2DOS9GtYahhyIMvj IronPort-HdrOrdr: A9a23:DUmK26AyKvVLVDrlHemC55DYdb4zR+YMi2TDGXoQdfQfGfbo7vxG/c5rsiMc5wxhOk3I9ervBECgewKlyXcX2/h0AV7BZniChIOoRLsSlrcKqgeIc0bDH4VmpMRdmt9FZOEYY2IasS+B2mOF+q4bsb+6GfyT9J3jJgxWID2D1spbgDtENg== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890694" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id F3F6A4D12A9D for ; Thu, 25 Nov 2021 15:47:59 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:48:00 +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; Thu, 25 Nov 2021 15:48:00 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:58 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 10/16] generic: add mmap CoW test for delalloc&source extents Date: Thu, 25 Nov 2021 15:47:46 +0800 Message-ID: <20211125074752.274176-11-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: F3F6A4D12A9D.A4916 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 Ensuring that copy on write in mmap mode to the source file when the CoW range covers delalloc blocks and regular shared blocks. (MMAP version of generic/293,295) Signed-off-by: Shiyang Ruan --- common/reflink | 3 ++ tests/generic/909 | 64 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/909.out | 12 ++++++++ 3 files changed, 79 insertions(+) create mode 100755 tests/generic/909 create mode 100644 tests/generic/909.out diff --git a/common/reflink b/common/reflink index 84173d59..e304ddc8 100644 --- a/common/reflink +++ b/common/reflink @@ -431,4 +431,7 @@ _sweave_reflink_holes_delalloc() { _pwrite_byte 0x64 $((blksz * i)) $blksz $sfile _pwrite_byte 0x64 $((blksz * i)) $blksz $sfile.chk done + # make sure we actually got delalloc block + $FILEFRAG_PROG -v $sfile 2>&1 | grep -q delalloc || \ + _notrun "test requires delayed allocation writes" } diff --git a/tests/generic/909 b/tests/generic/909 new file mode 100755 index 00000000..ef1233ea --- /dev/null +++ b/tests/generic/909 @@ -0,0 +1,64 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 909 +# +# Ensuring that copy on write in mmap mode to the source file when the +# CoW range covers delalloc blocks and regular shared blocks. +# (MMAP version of generic/293,295) +# - Create two files. +# - Truncate the first file. +# - Write the odd blocks of the first file. +# - Reflink the odd blocks of the first file into the second file. +# - Write the even blocks of the first file. +# - mmap CoW the first file across the halfway mark, starting with the +# regular extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_sweave_reflink_holes_delalloc $blksz $nr $testdir/file1 >> $seqres.full +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/generic/909.out b/tests/generic/909.out new file mode 100644 index 00000000..4f9a5d33 --- /dev/null +++ b/tests/generic/909.out @@ -0,0 +1,12 @@ +QA output created by 909 +Format and mount +Create the original files +Compare files +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-909/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-909/file3 +b8a8a88d4c143f79900c4b4e79aa3e37 SCRATCH_MNT/test-909/file1.chk +mmap CoW across the transition +Compare files +35e2170e14665b780c6dec328d6a263b SCRATCH_MNT/test-909/file1 +ce2023f765eba19677517c511886d5c9 SCRATCH_MNT/test-909/file3 +35e2170e14665b780c6dec328d6a263b SCRATCH_MNT/test-909/file1.chk From patchwork Thu Nov 25 07:47:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638601 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 A54C0C433F5 for ; Thu, 25 Nov 2021 07:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240021AbhKYIBK (ORCPT ); Thu, 25 Nov 2021 03:01:10 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:17619 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240121AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 IronPort-Data: A9a23:fYrVYqB/yL+IwBVW/zXhw5YqxClBgxIJ4g17XOLfDQfrhThx0zNWz2JJCjrVPf/eNzOje4wkbY++9UoEuMSAx9UxeLYW3SszFioV86IpJjg4wn/YZnrUdouaJK5ex512huLocYZkERcwmj/3auK49CAmiPnRLlbBILWs1h5ZFFYMpBgJ2UoLd94R2uaEsPDha++/kYqaT/73ZDdJ7wVJ3lc8sMpvnv/AUMPa41v0tnRmDRxCUcS3e3M9VPrzLonpR5f0rxU9IwK0ewrD5OnREmLx9BFrBM6nk6rgbwsBRbu60Qqm0yIQAvb9xEMZ4HFaPqUTbZLwbW9NljyPhME3xtNWqbS+VAUoIrbR3u8aVnG0FgknZPIWqeeZcCPXXcu7iheun2HX6/t1EEwtIZYw5Ol6GydN+OYeJTRLaQqM799aaprTpvJE35xldZe0ethE/CwI8N0QNt5+KbirfkkAzYMwMO8Mu/1z IronPort-HdrOrdr: A9a23:YV2ru6skSgmwcpnX23wlZwr27skDWNV00zEX/kB9WHVpmwKj9/xH158gpGbJYVcqKRYdcL+7Scu9qB/nm6KdwLNhRYtKPzOW3FdATrsSiLcLwlXbalbDH4dmvM8KT0EUMqySMbEMt6rHCWeDcurIuuPszEnRv5a5854wd3ARV0ga1WpE4rvxKCJLeDU= X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890693" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 360EE4D138C3 for ; Thu, 25 Nov 2021 15:48:00 +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; Thu, 25 Nov 2021 15:47:58 +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; Thu, 25 Nov 2021 15:48:00 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:58 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 11/16] generic: add buffered-io CoW test for mixed&source extents Date: Thu, 25 Nov 2021 15:47:47 +0800 Message-ID: <20211125074752.274176-12-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 360EE4D138C3.AFE06 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 Ensuring that copy on write in buffered mode works when the CoW range originally covers multiple extents, mixed with reflinked, unwritten, hole, regular and delalloc blocks. Signed-off-by: Shiyang Ruan --- common/reflink | 54 +++++++++++++++++++++++++++++++++++ tests/generic/910 | 66 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/910.out | 12 ++++++++ 3 files changed, 132 insertions(+) create mode 100755 tests/generic/910 create mode 100644 tests/generic/910.out diff --git a/common/reflink b/common/reflink index e304ddc8..cca43393 100644 --- a/common/reflink +++ b/common/reflink @@ -435,3 +435,57 @@ _sweave_reflink_holes_delalloc() { $FILEFRAG_PROG -v $sfile 2>&1 | grep -q delalloc || \ _notrun "test requires delayed allocation writes" } + +# Create a file of interleaved holes, unwritten blocks, regular blocks, and +# reflinked blocks +_sweave_reflink_rainbow() { + blksz=$1 + nr=$2 + sfile=$3 + dfile=$4 + + $XFS_IO_PROG -f -c "truncate $((blksz * nr))" $sfile + _pwrite_byte 0x00 0 $((blksz * nr)) $sfile.chk + _pwrite_byte 0x61 0 $((blksz * nr)) $dfile + seq 0 5 $((nr - 1)) | while read i; do + _pwrite_byte 0x61 $((blksz * i)) $blksz $sfile + _pwrite_byte 0x61 $((blksz * i)) $blksz $sfile.chk + done + # 0 blocks are reflinked + seq 0 5 $((nr - 1)) | while read i; do + _reflink_range $sfile $((blksz * i)) $dfile $((blksz * i)) $blksz + _pwrite_byte 0x61 $((blksz * i)) $blksz $sfile.chk + done + # 1 blocks are unwritten + seq 1 5 $((nr - 1)) | while read i; do + $XFS_IO_PROG -f -c "falloc $((blksz * i)) $blksz" $sfile + _pwrite_byte 0x00 $((blksz * i)) $blksz $sfile.chk + done + # 2 blocks are holes + seq 2 5 $((nr - 1)) | while read i; do + _pwrite_byte 0x00 $((blksz * i)) $blksz $sfile.chk + done + # 3 blocks are regular + seq 3 5 $((nr - 1)) | while read i; do + _pwrite_byte 0x71 $((blksz * i)) $blksz $sfile + _pwrite_byte 0x71 $((blksz * i)) $blksz $sfile.chk + done + # 4 blocks will be delalloc later +} + +# For a file created with _sweave_reflink_rainbow, fill the holes with delalloc +# extents +_sweave_reflink_rainbow_delalloc() { + blksz=$1 + nr=$2 + dfile=$3 + + # 4 blocks are delalloc (do later) + seq 4 5 $((nr - 1)) | while read i; do + _pwrite_byte 0x62 $((blksz * i)) $blksz $sfile + _pwrite_byte 0x62 $((blksz * i)) $blksz $sfile.chk + done + # make sure we actually got delalloc block + $FILEFRAG_PROG -v $sfile 2>&1 | grep -q delalloc || \ + _notrun "test requires delayed allocation writes" +} diff --git a/tests/generic/910 b/tests/generic/910 new file mode 100755 index 00000000..8d731a2d --- /dev/null +++ b/tests/generic/910 @@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 910 +# +# Ensuring that copy on write in buffered mode works when the CoW +# range originally covers multiple extents, mixed with reflinked, unwritten, +# hole, regular and delalloc blocks. +# - Create a file with the following repeating sequence of blocks: +# 1. reflinked +# 2. unwritten +# 3. hole +# 4. regular block +# 5. delalloc +# - CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone punch + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" +_require_xfs_io_command "fpunch" +_require_cp_reflink +_require_odirect + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_sweave_reflink_rainbow_delalloc $blksz $nr $testdir/file1 >> $seqres.full +# now cow +$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full +_pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 diff --git a/tests/generic/910.out b/tests/generic/910.out new file mode 100644 index 00000000..12956584 --- /dev/null +++ b/tests/generic/910.out @@ -0,0 +1,12 @@ +QA output created by 910 +Format and mount +Create the original files +Compare files +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-910/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-910/file3 +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-910/file1.chk +CoW across the transition +Compare files +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-910/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-910/file3 +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-910/file1.chk From patchwork Thu Nov 25 07:47:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638605 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 DAFB0C433FE for ; Thu, 25 Nov 2021 07:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347767AbhKYIBL (ORCPT ); Thu, 25 Nov 2021 03:01:11 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:61265 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240138AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 IronPort-Data: A9a23:gPVvEqMaIzr1DQTvrR25lcFynXyQoLVcMsFnjC/WdQO5hjgrgzxRnGNMCGCFafzfZTD0L4siPIiw80wD6JbQm99gGjLY11k3ESsS9pCt6fd1j6vIF3rLaJWFFSqL1u1GAjX7BJ1yHiC0SiuFaOC79CAlj/zQH9IQNcafUsxPbV49IMseoUI78wIJqtYAbemRW2thi/uryyHsEAPNNwpPD44hw/nrRCWDExjFkGhwUlQWPZintbJF/pUfJMp3yaqZdxMUTmTId9NWSdovzJnhlo/Y1xwrTN24kLfnaVBMSbnXVeSMoiMOHfH83V4Z/Wpvuko4HKN0hUN/kSiAmctgjttLroCYRxorP7HXhaIWVBww/yRWZPQZqO6ffynl2SCU5wicG5f2+N1gF107JpED0vh4DHsI9vECLj0JKBeZiIqLLBiTIgV3rp17apC1Y8VE4Tc9pQw1xM0OGfjrK5gmL/cEtNvouv1zIA== IronPort-HdrOrdr: A9a23:4dVjmKoUX263roehSOYyAqQaV5oFeYIsimQD101hICG9vPb5qyjk985rrCMc6QxhP03I9urwWpVoLUmzyXdV2/hoAV7AZniDhILLFvAG0WPiqweQYBEWn9Q1vcxdmsNFeb7N5C9B4foSjjPYLz9b+rO6GdiT9IHjJitWPHtXgtpbgjuQt22gfXFLeA== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890692" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 4E6A44D138C4 for ; Thu, 25 Nov 2021 15:48:00 +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; Thu, 25 Nov 2021 15:48:00 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:58 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 12/16] generic: add direct-io CoW test for mixed&source extents Date: Thu, 25 Nov 2021 15:47:48 +0800 Message-ID: <20211125074752.274176-13-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 4E6A44D138C4.AF44B 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 Ensuring that copy on write in buffered mode works when the CoW range originally covers multiple extents, mixed with reflinked, unwritten, hole, regular and delalloc blocks. Signed-off-by: Shiyang Ruan --- tests/generic/911 | 66 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/911.out | 12 ++++++++ 2 files changed, 78 insertions(+) create mode 100755 tests/generic/911 create mode 100644 tests/generic/911.out diff --git a/tests/generic/911 b/tests/generic/911 new file mode 100755 index 00000000..57de8754 --- /dev/null +++ b/tests/generic/911 @@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 911 +# +# Ensuring that copy on write in direct-io mode works when the CoW +# range originally covers multiple extents, mixed with reflinked, unwritten, +# hole, regular and delalloc blocks. +# - Create a file with the following repeating sequence of blocks: +# 1. reflinked +# 2. unwritten +# 3. hole +# 4. regular block +# 5. delalloc +# - directio CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone punch + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" +_require_xfs_io_command "fpunch" +_require_cp_reflink +_require_odirect + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "directio CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_sweave_reflink_rainbow_delalloc $blksz $nr $testdir/file1 >> $seqres.full +# now cow +$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full +_pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 diff --git a/tests/generic/911.out b/tests/generic/911.out new file mode 100644 index 00000000..e098fe3c --- /dev/null +++ b/tests/generic/911.out @@ -0,0 +1,12 @@ +QA output created by 911 +Format and mount +Create the original files +Compare files +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-911/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-911/file3 +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-911/file1.chk +directio CoW across the transition +Compare files +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-911/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-911/file3 +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-911/file1.chk From patchwork Thu Nov 25 07:47:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638613 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 B5D10C433F5 for ; Thu, 25 Nov 2021 08:00:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237060AbhKYIDL (ORCPT ); Thu, 25 Nov 2021 03:03:11 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:34883 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239621AbhKYIBL (ORCPT ); Thu, 25 Nov 2021 03:01:11 -0500 IronPort-Data: A9a23:cVVOEaizfmMcnHrK8DilrhMmX161fBIKZh0ujC45NGQNrF6WrkUEnWROWGuFPa7eZDf3fdslaITj8hlVsZPRztdmSVE9+Xw8FHgiRejtX4rAdhiqV8+xwmwvdGo+toNGLICowPkcFhcwnT/wdOi+xZVA/fvQHOOlUbSZYnkZqTJME0/NtzoywobVvaY42bBVMyvV0T/Di5W31G2NglaYAUpIg063ky6Didyp0N8uUvPSUtgQ1LPWvyF94JvyvshdJVOgKmVfNrbSq+ouUNiEEm3lExcFUrtJk57wdAsEX7zTIROTzHFRXsBOgDAb/mprjPl9b6FaNC+7iB3Q9zx14M9QvJqrWEEnOLbQsOoAURhECDw4NqpDkFPCCSHm7pzClxOXLRMAxN0rVinaJ7Yw9P1rDHpS7tQGJz0XKBOOneS7xPS8UOYEuyiJBKEHJ6tG4jc5k26fVq1gHPj+r2zxzYcw9F8NagpmQ54yv/YkVAc= IronPort-HdrOrdr: A9a23:FQ3Lkqw85Dz7GQLmYSdTKrPwAr1zdoMgy1knxilNoNJuEvBx3KuV7Y0mPH7P+VEssR4b6LK90cW7L0801KQFmbX5Xo3SODUO2lHYSb2L7OPZskbd8kTFn4Y36U4KSdkcNDSGNzRHZKjBgTVQaexL/DD+ytHPuQ6D9QYWcegQUcxdB7oTMGmmLnE= X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890696" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 965704D12A8B for ; Thu, 25 Nov 2021 15:48:00 +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; Thu, 25 Nov 2021 15:47:59 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:58 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 13/16] generic: add mmap CoW test for mixed&source extents Date: Thu, 25 Nov 2021 15:47:49 +0800 Message-ID: <20211125074752.274176-14-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 965704D12A8B.ADDE2 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 Ensuring that copy on write in buffered mode works when the CoW range originally covers multiple extents, mixed with reflinked, unwritten, hole, regular and delalloc blocks. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/912 | 67 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/912.out | 12 ++++++++ 2 files changed, 79 insertions(+) create mode 100755 tests/generic/912 create mode 100644 tests/generic/912.out diff --git a/tests/generic/912 b/tests/generic/912 new file mode 100755 index 00000000..4f0d94dd --- /dev/null +++ b/tests/generic/912 @@ -0,0 +1,67 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 912 +# +# Ensuring that copy on write in mmap mode works when the CoW +# range originally covers multiple extents, mixed with reflinked, unwritten, +# hole, regular and delalloc blocks. +# - Create a file with the following repeating sequence of blocks: +# 1. reflinked +# 2. unwritten +# 3. hole +# 4. regular block +# 5. delalloc +# - mmap CoW across the halfway mark, starting with the unwritten extent. +# - Check that the files are now different where we say they're different. +# +. ./common/preamble +_begin_fstest auto quick clone punch + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_xfs_io_command "falloc" +_require_xfs_io_command "fpunch" +_require_cp_reflink +_require_odirect + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +echo "Create the original files" +blksz=65536 +nr=64 +filesize=$((blksz * nr)) +_sweave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +echo "mmap CoW across the transition" +cowoff=$((filesize / 4)) +cowsz=$((filesize / 2)) +_sweave_reflink_rainbow_delalloc $blksz $nr $testdir/file1 >> $seqres.full +# now cow +mmapsz=$((cowoff + cowsz)) +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1 >> $seqres.full +_mwrite_byte 0x63 $cowoff $cowsz $mmapsz $testdir/file1.chk >> $seqres.full +_scratch_cycle_mount + +echo "Compare files" +md5sum $testdir/file1 | _filter_scratch +md5sum $testdir/file3 | _filter_scratch +md5sum $testdir/file1.chk | _filter_scratch + +# success, all done +status=0 diff --git a/tests/generic/912.out b/tests/generic/912.out new file mode 100644 index 00000000..32f25a1d --- /dev/null +++ b/tests/generic/912.out @@ -0,0 +1,12 @@ +QA output created by 912 +Format and mount +Create the original files +Compare files +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-912/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-912/file3 +6366fd359371414186688a0ef6988893 SCRATCH_MNT/test-912/file1.chk +mmap CoW across the transition +Compare files +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-912/file1 +bdbcf02ee0aa977795a79d25fcfdccb1 SCRATCH_MNT/test-912/file3 +26aa3a0749b867ec58363c8539ee5471 SCRATCH_MNT/test-912/file1.chk From patchwork Thu Nov 25 07:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638595 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 5909DC433FE for ; Thu, 25 Nov 2021 07:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234489AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:61265 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244238AbhKYH5W (ORCPT ); Thu, 25 Nov 2021 02:57:22 -0500 IronPort-Data: A9a23:ypiJ16hJdmjxuTvHIekIa4D/X161fBIKZh0ujC45NGQNrF6WrkUEymAaUWrSPvzYYGf0ctsgbdm+8UsC6pDQm4dkSVQ++Hw8FHgiRejtX4rAdhiqV8+xwmwvdGo+toNGLICowPkcFhcwnT/wdOi+xZVA/fvQHOOlUbSZYnkZqTJME0/NtzoywobVvaY42bBVMyvV0T/Di5W31G2NglaYAUpIg063ky6Didyp0N8uUvPSUtgQ1LPWvyF94JvyvshdJVOgKmVfNrbSq+ouUNiEEm3lExcFUrtJk57wdAsEX7zTIROTzHFRXsBOgDAb/mprjPl9b6FaNC+7iB3Q9zx14M9QvJqrWEEnOLbQsOoAURhECDw4NqpDkFPCCSHm7pzClxOXKhMAxN0rVinaJ7Yw9P1rDHpS7tQGJz0XKBOOneS7xPS8UOYEuyiJBKEHJ6tG4jc5k26fVq1gHPj+r2zxzYcw9F8NagpmRJ4yv/YkVAc= IronPort-HdrOrdr: A9a23:L1L6nKpWcV4UHijv3wNS2VAaV5oFeYIsimQD101hICG9vPb5qyjk985rrCMc6QxhP03I9urwWpVoLUmzyXdV2/hoAV7AZniDhILLFvAG0WPiqweQYBEWn9Q1vcxdmsNFeb7N5C9B4foSjjPYLz9b+rO6GdiT9IHjJitWPHtXgtpbgjuQt22gfXFLeA== X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890691" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id DF0F04D138C5 for ; Thu, 25 Nov 2021 15:48:00 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:48:01 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:59 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 14/16] generic: add race test between reflink and mmap read Date: Thu, 25 Nov 2021 15:47:50 +0800 Message-ID: <20211125074752.274176-15-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: DF0F04D138C5.AF7F3 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 Test for races or FS corruption between reflink and mmap reading the target file. (MMAP version of generic/164,165) Signed-off-by: Shiyang Ruan --- common/reflink | 11 +++++++ tests/generic/913 | 72 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/913.out | 5 +++ 3 files changed, 88 insertions(+) create mode 100755 tests/generic/913 create mode 100644 tests/generic/913.out diff --git a/common/reflink b/common/reflink index cca43393..7b94864e 100644 --- a/common/reflink +++ b/common/reflink @@ -186,6 +186,17 @@ _read_range() { $XFS_IO_PROG $xfs_io_args -f -c "pread -q -v $offset $len" "$file" | cut -d ' ' -f '3-18' } +# Prints a range of a file as a hex dump +_mread_range() { + file="$1" + offset="$2" + len="$3" + xfs_io_args="$4" + + $XFS_IO_PROG $xfs_io_args -f -c "mmap -rw 0 $((offset + len))" \ + -c "mread -v $offset $len" "$file" | cut -d ' ' -f '3-18' +} + # Compare ranges of two files _compare_range() { file1="$1" diff --git a/tests/generic/913 b/tests/generic/913 new file mode 100755 index 00000000..f709c36c --- /dev/null +++ b/tests/generic/913 @@ -0,0 +1,72 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 913 +# +# Test for races or FS corruption between reflink and mmap reading the +# target file. (MMAP version of generic/164,165) +# +. ./common/preamble +_begin_fstest auto clone + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_cp_reflink + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +finished_file=/tmp/finished +rm -rf $finished_file +mkdir $testdir + +loops=512 +nr_loops=$((loops - 1)) +blksz=65536 + +echo "Initialize files" +echo >> $seqres.full +_pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full +_pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full +_cp_reflink $testdir/file1 $testdir/file3 +_scratch_cycle_mount + +fbytes() { + egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)' +} + +reader() { + while [ ! -e $finished_file ]; do + _mread_range $testdir/file3 0 $((loops * blksz)) | fbytes + done +} + +echo "Reflink and mmap reread the files!" +reader & +for i in `seq 1 2`; do + seq $nr_loops -1 0 | while read i; do + _reflink_range $testdir/file1 $((i * blksz)) \ + $testdir/file3 $((i * blksz)) $blksz >> $seqres.full + [ $? -ne 0 ] && break + done + seq $nr_loops -1 0 | while read i; do + _reflink_range $testdir/file2 $((i * blksz)) \ + $testdir/file3 $((i * blksz)) $blksz >> $seqres.full + [ $? -ne 0 ] && break + done +done +echo "Finished reflinking" +touch $finished_file +wait + +# success, all done +status=0 +exit diff --git a/tests/generic/913.out b/tests/generic/913.out new file mode 100644 index 00000000..a34df6ce --- /dev/null +++ b/tests/generic/913.out @@ -0,0 +1,5 @@ +QA output created by 913 +Format and mount +Initialize files +Reflink and mmap reread the files! +Finished reflinking From patchwork Thu Nov 25 07:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638603 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 1A317C4332F for ; Thu, 25 Nov 2021 07:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240138AbhKYIBL (ORCPT ); Thu, 25 Nov 2021 03:01:11 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49039 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240174AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 IronPort-Data: A9a23:eYVhH62M27iCL7QhRvbD5c9zkn2cJEfYwER7XOPLsXnJ3Wt2hGRWn2RLDziGbqvfZjP8eYtzO4+2/U8P7MPczNQ2QQE+nZ1PZygU8JKaX7x1DatR0xu6d5SFFAQ+hyknQoGowPscEzmM+X9BDpC79SMljPjSG+KlYAL5EnsZqTFMGX5JZS1Ly7ZRbr5A2bBVMivV0T/Ai5S31GyNh1aYBlkpB5er83uDihhdVAQw5TTSbdgT1LPXeuJ84Jg3fcldJFOgKmVY83LTegrN8F251juxExYFAdXjnKv5c1ERX/jZOg3mZnh+AvDk20Yd4HdplPtT2Pk0MC+7jx2Tgtl308QLu5qrVS8nI6/NhP8AFRJfFkmSOIUfoeCXcCDh4JP7I0ruNiGEL+9VJE8tIYAD5v1fH25D77obJSoLYxTFgPi5qI9X4MEEat8LdZGtZd1A/Co7i2yxMBrveribK42i2DOS9GlYahhyIMvj IronPort-HdrOrdr: A9a23:MZ0u06F8ywT0ASQvpLqExseALOsnbusQ8zAXPo5KKSC8Oaej5rmTdZUgpHjJYVkqKRMdcLy7VpVoYEmsjaKdgrNhWYtKPjOW3VdBLelZnPDfKlTbckWUygc379YCT0EIMrHN5DZB7PoSmjPTLz9Z+qjgzEn1v5al854Xd2xXgxwK1WhENjo= X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890697" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 2D4D54D138C6 for ; Thu, 25 Nov 2021 15:48:01 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:48:01 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:59 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 15/16] generic: add race test that mmap write to source of reflink Date: Thu, 25 Nov 2021 15:47:51 +0800 Message-ID: <20211125074752.274176-16-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 2D4D54D138C6.AEDED 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 Test for races or FS corruption when mmap writing to a file that's also the source of a reflink operation. (MMAP version of generic/167,166) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/914 | 64 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/914.out | 4 +++ 2 files changed, 68 insertions(+) create mode 100755 tests/generic/914 create mode 100644 tests/generic/914.out diff --git a/tests/generic/914 b/tests/generic/914 new file mode 100755 index 00000000..c51c44c7 --- /dev/null +++ b/tests/generic/914 @@ -0,0 +1,64 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 914 +# +# Test for races or FS corruption when mmap writing to a file that's also +# the source of a reflink operation. (MMAP version of generic/167,166) +# +. ./common/preamble +_begin_fstest auto clone + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink +_require_cp_reflink + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +finished_file=/tmp/finished +rm -rf $finished_file +mkdir $testdir + +loops=1024 +nr_loops=$((loops - 1)) +blksz=65536 + +echo "Initialize file" +echo >> $seqres.full +_pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full +_scratch_cycle_mount + +# Snapshot creator... +snappy() { + n=0 + while [ ! -e $finished_file ]; do + out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)" + res=$? + echo "$out" | grep -q "No space left" && break + test -n "$out" && echo "$out" + test $res -ne 0 && break + n=$((n + 1)) + done +} + +echo "Snapshot a file undergoing mmap rewrite" +snappy & +seq $nr_loops -1 0 | while read i; do + $XFS_IO_PROG -f -c "mmap -rw $((i * blksz)) $blksz" \ + -c "mwrite -S 0x63 $((i * blksz)) $blksz" $testdir/file1 >> $seqres.full +done +touch $finished_file +wait + +# success, all done +status=0 +exit diff --git a/tests/generic/914.out b/tests/generic/914.out new file mode 100644 index 00000000..1472055f --- /dev/null +++ b/tests/generic/914.out @@ -0,0 +1,4 @@ +QA output created by 914 +Format and mount +Initialize file +Snapshot a file undergoing mmap rewrite From patchwork Thu Nov 25 07:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12638597 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 14631C4332F for ; Thu, 25 Nov 2021 07:56:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240234AbhKYH7K (ORCPT ); Thu, 25 Nov 2021 02:59:10 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:49039 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1345451AbhKYH5X (ORCPT ); Thu, 25 Nov 2021 02:57:23 -0500 IronPort-Data: A9a23:dgcWuK534oPUMlGSP/rtWAxRtCTFchMFZxGqfqrLsXjdYENShD0OyWUXCz/TP/qMNzCnLdh+aInkoBhUupCHzNQ3G1c5pCpnJ55ogZCbXIzGdC8cHM8zwvXrFRsht4NHAjX5BJhcokT0+1H9bdANkVEmjfvRH+OmVbadUsxMbVQMpBkJ2EsLd9ER0tYAbeiRW2thiPuqyyHtEAbNNw1cbgr435m+RCZH55wejt+3UmsWPpintHeG/5Uc4Ql2yauZdxMUSaEMdgK2qnqq8V23wo/Z109F5tKNmbC9fFAIQ6LJIE6FjX8+t6qK20AE/3JtlP1gcqd0hUR/0l1lm/hr1dxLro32RwEyIoXCheYcTwJFVSp5OMWq/ZeeeCfv4JTNnhCun3zEhq8G4FsNFYMD5utsHXpm6/MVMnYOYwqFiubwx6i0ItSALOxLwNLDZdtZ4y8/i2qCS6tOfHwKeI2Sjfcw4dv6rpwm8S7iWvck IronPort-HdrOrdr: A9a23:u+ApZKHr0fyXf6x3pLqExseALOsnbusQ8zAXPo5KKSC8Oaej5rmTdZUgpHjJYVkqKRMdcLy7VpVoYEmsjaKdgrNhWYtKPjOW3VdBLelZnPDfKlTbckWUygc379YCT0EIMrHN5DZB7PoSmjPTLz9Z+qjgzEn1v5al854Xd2xXgxwK1WhENjo= X-IronPort-AV: E=Sophos;i="5.87,262,1631548800"; d="scan'208";a="117890695" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Nov 2021 15:48:05 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id A17F54D138C7 for ; Thu, 25 Nov 2021 15:48:01 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 25 Nov 2021 15:48:01 +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; Thu, 25 Nov 2021 15:48:02 +0800 Received: from irides.mr.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; Thu, 25 Nov 2021 15:47:59 +0800 From: Shiyang Ruan To: Subject: [PATCH v2 16/16] generic: add race test that mmap write to target of reflink Date: Thu, 25 Nov 2021 15:47:52 +0800 Message-ID: <20211125074752.274176-17-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> References: <20211125074752.274176-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: A17F54D138C7.AFAB0 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 Test for races or FS corruption when mmap writing to a file that's also the target of a reflink operation. (MMAP version of generic/168,170) Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- tests/generic/915 | 64 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/915.out | 4 +++ 2 files changed, 68 insertions(+) create mode 100755 tests/generic/915 create mode 100644 tests/generic/915.out diff --git a/tests/generic/915 b/tests/generic/915 new file mode 100755 index 00000000..365f304c --- /dev/null +++ b/tests/generic/915 @@ -0,0 +1,64 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# FS QA Test No. 915 +# +# Test for races or FS corruption when mmap writing to a file that's also +# the target of a reflink operation. (MMAP version of generic/168,170) +# +. ./common/preamble +_begin_fstest auto clone + +_register_cleanup "_cleanup" BUS + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_require_scratch_reflink + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +finished_file=/tmp/finished +rm -rf $finished_file +mkdir $testdir + +loops=1024 +nr_loops=$((loops - 1)) +blksz=65536 + +echo "Initialize files" +echo >> $seqres.full +_pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full +_pwrite_byte 0x62 0 $((loops * blksz)) $testdir/file2 >> $seqres.full +_scratch_cycle_mount + +# mmap overwriter... +overwrite() { + while [ ! -e $finished_file ]; do + seq $nr_loops -1 0 | while read i; do + $XFS_IO_PROG -f -c "mmap -rw $((i * blksz)) $blksz" \ + -c "mwrite -S 0x63 $((i * blksz)) $blksz" $testdir/file2 >> $seqres.full + done + done +} + +echo "Reflink and mmap write the target" +overwrite & +seq 1 10 | while read j; do + seq 0 $nr_loops | while read i; do + _reflink_range $testdir/file1 $((i * blksz)) \ + $testdir/file2 $((i * blksz)) $blksz >> $seqres.full + [ $? -ne 0 ] && exit + done +done +touch $finished_file +wait + +# success, all done +status=0 +exit diff --git a/tests/generic/915.out b/tests/generic/915.out new file mode 100644 index 00000000..4e77847b --- /dev/null +++ b/tests/generic/915.out @@ -0,0 +1,4 @@ +QA output created by 915 +Format and mount +Initialize files +Reflink and mmap write the target