fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] generic: add some mmap CoW tests
@ 2021-11-11  8:50 Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 01/13] generic: add mmap CoW test for ranges of two shared files Shiyang Ruan
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

This series is to add missing mmap CoW tests in three sets of testcases:
Set 1. CoW on shared blocks which are interleaving reflinked by two files.
  - P1:            add mmap test
Set 2. CoW a range covers shared blocks and multiple kind of unshared blocks of
   the destination file.
  - P2 ~ P6:       add mmap test
Set 3. CoW a range covers shared blocks and multiple kind of unshared blocks of
   the source file.
  - P11, P12:      add missing buffered-io and direct-io test for mixed blocks
  - P7 ~ P10, P13: add mmap test

Shiyang Ruan (13):
  generic: add mmap CoW test for ranges of two shared files
  generic: add mmap CoW test for regular&destination extents
  generic: add mmap CoW test for unwritten&destination extents
  generic: add mmap CoW test for holes&destination extents
  generic: add mmap CoW test for delalloc&destination extents
  generic: add mmap CoW test for mixed&destination extents
  generic: add mmap CoW test for regular&source extents
  generic: add mmap CoW test for unwritten&source extents
  generic: add mmap CoW test for holes&source extents
  generic: add mmap CoW test for delalloc&source extents
  generic: add buffered-io CoW test for mixed&source extents
  generic: add direct-io CoW test for mixed&source extents
  generic: add mmap CoW test for mixed&source extents

 common/reflink        | 63 +++++++++++++++++++++++++++++++++++++++
 tests/generic/909     | 69 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/909.out | 14 +++++++++
 tests/generic/910     | 59 ++++++++++++++++++++++++++++++++++++
 tests/generic/910.out | 12 ++++++++
 tests/generic/911     | 59 ++++++++++++++++++++++++++++++++++++
 tests/generic/911.out | 12 ++++++++
 tests/generic/912     | 59 ++++++++++++++++++++++++++++++++++++
 tests/generic/912.out | 12 ++++++++
 tests/generic/913     | 61 ++++++++++++++++++++++++++++++++++++++
 tests/generic/913.out | 12 ++++++++
 tests/generic/914     | 68 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/914.out | 12 ++++++++
 tests/generic/915     | 60 +++++++++++++++++++++++++++++++++++++
 tests/generic/915.out | 12 ++++++++
 tests/generic/916     | 62 ++++++++++++++++++++++++++++++++++++++
 tests/generic/916.out | 12 ++++++++
 tests/generic/917     | 62 ++++++++++++++++++++++++++++++++++++++
 tests/generic/917.out | 12 ++++++++
 tests/generic/918     | 64 +++++++++++++++++++++++++++++++++++++++
 tests/generic/918.out | 12 ++++++++
 tests/generic/919     | 66 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/919.out | 12 ++++++++
 tests/generic/920     | 66 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/920.out | 12 ++++++++
 tests/generic/921     | 67 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/921.out | 12 ++++++++
 27 files changed, 1043 insertions(+)
 create mode 100755 tests/generic/909
 create mode 100644 tests/generic/909.out
 create mode 100755 tests/generic/910
 create mode 100644 tests/generic/910.out
 create mode 100755 tests/generic/911
 create mode 100644 tests/generic/911.out
 create mode 100755 tests/generic/912
 create mode 100644 tests/generic/912.out
 create mode 100755 tests/generic/913
 create mode 100644 tests/generic/913.out
 create mode 100755 tests/generic/914
 create mode 100644 tests/generic/914.out
 create mode 100755 tests/generic/915
 create mode 100644 tests/generic/915.out
 create mode 100755 tests/generic/916
 create mode 100644 tests/generic/916.out
 create mode 100755 tests/generic/917
 create mode 100644 tests/generic/917.out
 create mode 100755 tests/generic/918
 create mode 100644 tests/generic/918.out
 create mode 100755 tests/generic/919
 create mode 100644 tests/generic/919.out
 create mode 100755 tests/generic/920
 create mode 100644 tests/generic/920.out
 create mode 100755 tests/generic/921
 create mode 100644 tests/generic/921.out

-- 
2.33.0




^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/13] generic: add mmap CoW test for ranges of two shared files
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 02/13] generic: add mmap CoW test for regular&destination extents Shiyang Ruan
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/909     | 69 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/909.out | 14 +++++++++
 2 files changed, 83 insertions(+)
 create mode 100755 tests/generic/909
 create mode 100644 tests/generic/909.out

diff --git a/tests/generic/909 b/tests/generic/909
new file mode 100755
index 00000000..dc011eba
--- /dev/null
+++ b/tests/generic/909
@@ -0,0 +1,69 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/909.out b/tests/generic/909.out
new file mode 100644
index 00000000..8da48a79
--- /dev/null
+++ b/tests/generic/909.out
@@ -0,0 +1,14 @@
+QA output created by 909
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-909/file1
+b83f9394092e15bdcda585cd8e776dc6  SCRATCH_MNT/test-909/file2
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-909/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-909/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-909/file1
+b83f9394092e15bdcda585cd8e776dc6  SCRATCH_MNT/test-909/file2
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-909/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-909/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/13] generic: add mmap CoW test for regular&destination extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 01/13] generic: add mmap CoW test for ranges of two shared files Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 03/13] generic: add mmap CoW test for unwritten&destination extents Shiyang Ruan
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/910     | 59 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/910.out | 12 +++++++++
 2 files changed, 71 insertions(+)
 create mode 100755 tests/generic/910
 create mode 100644 tests/generic/910.out

diff --git a/tests/generic/910 b/tests/generic/910
new file mode 100755
index 00000000..4fef8e18
--- /dev/null
+++ b/tests/generic/910
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/910.out b/tests/generic/910.out
new file mode 100644
index 00000000..e3933a4b
--- /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
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-910/file1
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-910/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-910/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-910/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-910/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-910/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/13] generic: add mmap CoW test for unwritten&destination extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 01/13] generic: add mmap CoW test for ranges of two shared files Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 02/13] generic: add mmap CoW test for regular&destination extents Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 04/13] generic: add mmap CoW test for holes&destination extents Shiyang Ruan
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/911     | 59 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/911.out | 12 +++++++++
 2 files changed, 71 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..962a7dac
--- /dev/null
+++ b/tests/generic/911
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/911.out b/tests/generic/911.out
new file mode 100644
index 00000000..8e41bdf6
--- /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
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-911/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-911/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-911/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-911/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-911/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-911/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/13] generic: add mmap CoW test for holes&destination extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (2 preceding siblings ...)
  2021-11-11  8:50 ` [PATCH 03/13] generic: add mmap CoW test for unwritten&destination extents Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 05/13] generic: add mmap CoW test for delalloc&destination extents Shiyang Ruan
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/912     | 59 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/912.out | 12 +++++++++
 2 files changed, 71 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..53fc9e86
--- /dev/null
+++ b/tests/generic/912
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/912.out b/tests/generic/912.out
new file mode 100644
index 00000000..b00369b3
--- /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
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-912/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-912/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-912/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-912/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-912/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-912/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 05/13] generic: add mmap CoW test for delalloc&destination extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (3 preceding siblings ...)
  2021-11-11  8:50 ` [PATCH 04/13] generic: add mmap CoW test for holes&destination extents Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:50 ` [PATCH 06/13] generic: add mmap CoW test for mixed&destination extents Shiyang Ruan
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 accutally exists.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 common/reflink        |  3 +++
 tests/generic/913     | 61 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/913.out | 12 +++++++++
 3 files changed, 76 insertions(+)
 create mode 100755 tests/generic/913
 create mode 100644 tests/generic/913.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/913 b/tests/generic/913
new file mode 100755
index 00000000..c02886fa
--- /dev/null
+++ b/tests/generic/913
@@ -0,0 +1,61 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/913.out b/tests/generic/913.out
new file mode 100644
index 00000000..1f08400e
--- /dev/null
+++ b/tests/generic/913.out
@@ -0,0 +1,12 @@
+QA output created by 913
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-913/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-913/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-913/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-913/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-913/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-913/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 06/13] generic: add mmap CoW test for mixed&destination extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (4 preceding siblings ...)
  2021-11-11  8:50 ` [PATCH 05/13] generic: add mmap CoW test for delalloc&destination extents Shiyang Ruan
@ 2021-11-11  8:50 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 07/13] generic: add mmap CoW test for regular&source extents Shiyang Ruan
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:50 UTC (permalink / raw)
  To: fstests

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 accutally exists.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 common/reflink        |  3 ++
 tests/generic/914     | 68 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/914.out | 12 ++++++++
 3 files changed, 83 insertions(+)
 create mode 100755 tests/generic/914
 create mode 100644 tests/generic/914.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/914 b/tests/generic/914
new file mode 100755
index 00000000..211f6f26
--- /dev/null
+++ b/tests/generic/914
@@ -0,0 +1,68 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/914.out b/tests/generic/914.out
new file mode 100644
index 00000000..a8118a02
--- /dev/null
+++ b/tests/generic/914.out
@@ -0,0 +1,12 @@
+QA output created by 914
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-914/file1
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-914/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-914/file3.chk
+mmap CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-914/file1
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-914/file3
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-914/file3.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/13] generic: add mmap CoW test for regular&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (5 preceding siblings ...)
  2021-11-11  8:50 ` [PATCH 06/13] generic: add mmap CoW test for mixed&destination extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 08/13] generic: add mmap CoW test for unwritten&source extents Shiyang Ruan
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/915     | 60 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/915.out | 12 +++++++++
 2 files changed, 72 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..2829a190
--- /dev/null
+++ b/tests/generic/915
@@ -0,0 +1,60 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/915.out b/tests/generic/915.out
new file mode 100644
index 00000000..178fc665
--- /dev/null
+++ b/tests/generic/915.out
@@ -0,0 +1,12 @@
+QA output created by 915
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-915/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-915/file3
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-915/file1.chk
+mmap CoW across the transition
+Compare files
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-915/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-915/file3
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-915/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 08/13] generic: add mmap CoW test for unwritten&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (6 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 07/13] generic: add mmap CoW test for regular&source extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 09/13] generic: add mmap CoW test for holes&source extents Shiyang Ruan
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/916     | 62 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/916.out | 12 +++++++++
 2 files changed, 74 insertions(+)
 create mode 100755 tests/generic/916
 create mode 100644 tests/generic/916.out

diff --git a/tests/generic/916 b/tests/generic/916
new file mode 100755
index 00000000..0e5d532d
--- /dev/null
+++ b/tests/generic/916
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/916.out b/tests/generic/916.out
new file mode 100644
index 00000000..3a34410f
--- /dev/null
+++ b/tests/generic/916.out
@@ -0,0 +1,12 @@
+QA output created by 916
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-916/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-916/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-916/file1.chk
+mmap CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-916/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-916/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-916/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/13] generic: add mmap CoW test for holes&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (7 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 08/13] generic: add mmap CoW test for unwritten&source extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 10/13] generic: add mmap CoW test for delalloc&source extents Shiyang Ruan
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/917     | 62 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/917.out | 12 +++++++++
 2 files changed, 74 insertions(+)
 create mode 100755 tests/generic/917
 create mode 100644 tests/generic/917.out

diff --git a/tests/generic/917 b/tests/generic/917
new file mode 100755
index 00000000..74e5d345
--- /dev/null
+++ b/tests/generic/917
@@ -0,0 +1,62 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/917.out b/tests/generic/917.out
new file mode 100644
index 00000000..13c77935
--- /dev/null
+++ b/tests/generic/917.out
@@ -0,0 +1,12 @@
+QA output created by 917
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-917/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-917/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-917/file1.chk
+mmap CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-917/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-917/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-917/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/13] generic: add mmap CoW test for delalloc&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (8 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 09/13] generic: add mmap CoW test for holes&source extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 11/13] generic: add buffered-io CoW test for mixed&source extents Shiyang Ruan
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 common/reflink        |  3 ++
 tests/generic/918     | 64 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/918.out | 12 ++++++++
 3 files changed, 79 insertions(+)
 create mode 100755 tests/generic/918
 create mode 100644 tests/generic/918.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/918 b/tests/generic/918
new file mode 100755
index 00000000..f7767a8e
--- /dev/null
+++ b/tests/generic/918
@@ -0,0 +1,64 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/918.out b/tests/generic/918.out
new file mode 100644
index 00000000..465ade08
--- /dev/null
+++ b/tests/generic/918.out
@@ -0,0 +1,12 @@
+QA output created by 918
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-918/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-918/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-918/file1.chk
+mmap CoW across the transition
+Compare files
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-918/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-918/file3
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-918/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 11/13] generic: add buffered-io CoW test for mixed&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (9 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 10/13] generic: add mmap CoW test for delalloc&source extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 12/13] generic: add direct-io " Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 13/13] generic: add mmap " Shiyang Ruan
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 common/reflink        | 54 +++++++++++++++++++++++++++++++++++
 tests/generic/919     | 66 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/919.out | 12 ++++++++
 3 files changed, 132 insertions(+)
 create mode 100755 tests/generic/919
 create mode 100644 tests/generic/919.out

diff --git a/common/reflink b/common/reflink
index e304ddc8..85b586cb 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 _weave_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/919 b/tests/generic/919
new file mode 100755
index 00000000..932c98d7
--- /dev/null
+++ b/tests/generic/919
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/919.out b/tests/generic/919.out
new file mode 100644
index 00000000..a8eb7d6b
--- /dev/null
+++ b/tests/generic/919.out
@@ -0,0 +1,12 @@
+QA output created by 919
+Format and mount
+Create the original files
+Compare files
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-919/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-919/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-919/file1.chk
+CoW across the transition
+Compare files
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-919/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-919/file3
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-919/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 12/13] generic: add direct-io CoW test for mixed&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (10 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 11/13] generic: add buffered-io CoW test for mixed&source extents Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  2021-11-11  8:51 ` [PATCH 13/13] generic: add mmap " Shiyang Ruan
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/920     | 66 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/920.out | 12 ++++++++
 2 files changed, 78 insertions(+)
 create mode 100755 tests/generic/920
 create mode 100644 tests/generic/920.out

diff --git a/tests/generic/920 b/tests/generic/920
new file mode 100755
index 00000000..ec533e37
--- /dev/null
+++ b/tests/generic/920
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/920.out b/tests/generic/920.out
new file mode 100644
index 00000000..e499460c
--- /dev/null
+++ b/tests/generic/920.out
@@ -0,0 +1,12 @@
+QA output created by 920
+Format and mount
+Create the original files
+Compare files
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-920/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-920/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-920/file1.chk
+directio CoW across the transition
+Compare files
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-920/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-920/file3
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-920/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 13/13] generic: add mmap CoW test for mixed&source extents
  2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
                   ` (11 preceding siblings ...)
  2021-11-11  8:51 ` [PATCH 12/13] generic: add direct-io " Shiyang Ruan
@ 2021-11-11  8:51 ` Shiyang Ruan
  12 siblings, 0 replies; 14+ messages in thread
From: Shiyang Ruan @ 2021-11-11  8:51 UTC (permalink / raw)
  To: fstests

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 <ruansy.fnst@fujitsu.com>
---
 tests/generic/921     | 67 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/921.out | 12 ++++++++
 2 files changed, 79 insertions(+)
 create mode 100755 tests/generic/921
 create mode 100644 tests/generic/921.out

diff --git a/tests/generic/921 b/tests/generic/921
new file mode 100755
index 00000000..7c463143
--- /dev/null
+++ b/tests/generic/921
@@ -0,0 +1,67 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# 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/921.out b/tests/generic/921.out
new file mode 100644
index 00000000..3405a4df
--- /dev/null
+++ b/tests/generic/921.out
@@ -0,0 +1,12 @@
+QA output created by 921
+Format and mount
+Create the original files
+Compare files
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-921/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-921/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-921/file1.chk
+mmap CoW across the transition
+Compare files
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-921/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-921/file3
+26aa3a0749b867ec58363c8539ee5471  SCRATCH_MNT/test-921/file1.chk
-- 
2.33.0




^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-11-11  8:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  8:50 [PATCH 00/13] generic: add some mmap CoW tests Shiyang Ruan
2021-11-11  8:50 ` [PATCH 01/13] generic: add mmap CoW test for ranges of two shared files Shiyang Ruan
2021-11-11  8:50 ` [PATCH 02/13] generic: add mmap CoW test for regular&destination extents Shiyang Ruan
2021-11-11  8:50 ` [PATCH 03/13] generic: add mmap CoW test for unwritten&destination extents Shiyang Ruan
2021-11-11  8:50 ` [PATCH 04/13] generic: add mmap CoW test for holes&destination extents Shiyang Ruan
2021-11-11  8:50 ` [PATCH 05/13] generic: add mmap CoW test for delalloc&destination extents Shiyang Ruan
2021-11-11  8:50 ` [PATCH 06/13] generic: add mmap CoW test for mixed&destination extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 07/13] generic: add mmap CoW test for regular&source extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 08/13] generic: add mmap CoW test for unwritten&source extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 09/13] generic: add mmap CoW test for holes&source extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 10/13] generic: add mmap CoW test for delalloc&source extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 11/13] generic: add buffered-io CoW test for mixed&source extents Shiyang Ruan
2021-11-11  8:51 ` [PATCH 12/13] generic: add direct-io " Shiyang Ruan
2021-11-11  8:51 ` [PATCH 13/13] generic: add mmap " Shiyang Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).