All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] generic: add a couple of MMAP CoW tests
@ 2021-11-05  4:52 Shiyang Ruan
  2021-11-05  4:52 ` [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

There is a set of CoW tests which is to 
  > Check what happens if we BufferedIO/DIO CoW blocks 2-4 of a page's worth
  > of blocks when the second block is a regular/unwritten/hole/delalloc/all
  > block.
I think a test of MMAP CoW is also needed for these kind of testsets.  So,
add MMAP CoW for each case.

Shiyang Ruan (5):
  generic/xxx: Add MMAP CoW test for 'regular' case
  generic/xxx: Add MMAP CoW test for 'unwritten' case
  generic/xxx: Add MMAP CoW test for 'hole' case
  generic/xxx: Add MMAP CoW test for 'delalloc' case
  generic/xxx: Add MMAP CoW test for 'all' case

 tests/generic/900     |  75 +++++++++++++++++++++++
 tests/generic/900.out |   6 ++
 tests/generic/901     |  76 ++++++++++++++++++++++++
 tests/generic/901.out |   6 ++
 tests/generic/902     |  70 ++++++++++++++++++++++
 tests/generic/902.out |   6 ++
 tests/generic/903     |  76 ++++++++++++++++++++++++
 tests/generic/903.out |   6 ++
 tests/generic/904     | 135 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/904.out |  82 +++++++++++++++++++++++++
 10 files changed, 538 insertions(+)
 create mode 100755 tests/generic/900
 create mode 100644 tests/generic/900.out
 create mode 100755 tests/generic/901
 create mode 100644 tests/generic/901.out
 create mode 100755 tests/generic/902
 create mode 100644 tests/generic/902.out
 create mode 100755 tests/generic/903
 create mode 100644 tests/generic/903.out
 create mode 100755 tests/generic/904
 create mode 100644 tests/generic/904.out

-- 
2.33.0




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

* [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
@ 2021-11-05  4:52 ` Shiyang Ruan
  2021-11-05 16:15   ` Darrick J. Wong
  2021-11-05  4:52 ` [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a regular block.  (MMAP version of generic/205,206)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/900     | 75 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/900.out |  6 ++++
 2 files changed, 81 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..c56d9acf
--- /dev/null
+++ b/tests/generic/900
@@ -0,0 +1,75 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
+# the second block is a regular block.  (MMAP version of generic/205,206)
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Override the default cleanup function.
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.* $testdir
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_scratch_reflink
+
+pagesz=$(getconf PAGE_SIZE)
+blksz=$((pagesz / 4))
+
+echo "Format and mount"
+_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+real_blksz=$(_get_file_block_size $testdir)
+test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
+
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
+
+_pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
+_pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
+
+_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
+
+_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/900.out b/tests/generic/900.out
new file mode 100644
index 00000000..2abfd789
--- /dev/null
+++ b/tests/generic/900.out
@@ -0,0 +1,6 @@
+QA output created by 900
+Format and mount
+Create the original files
+Compare files
+CoW and unmount
+Compare files
-- 
2.33.0




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

* [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
  2021-11-05  4:52 ` [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
@ 2021-11-05  4:52 ` Shiyang Ruan
  2021-11-05 16:20   ` Darrick J. Wong
  2021-11-05  4:52 ` [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a unwritten block.  (MMAP version of generic/216,217)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/901     | 76 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/901.out |  6 ++++
 2 files changed, 82 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..46459815
--- /dev/null
+++ b/tests/generic/901
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
+# the second block is a unwritten block.  (MMAP version of generic/216,217)
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Override the default cleanup function.
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.* $testdir
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+pagesz=$(getconf PAGE_SIZE)
+blksz=$((pagesz / 4))
+
+echo "Format and mount"
+_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+real_blksz=$(_get_file_block_size $testdir)
+test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
+
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
+
+$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $testdir/file2 >> $seqres.full
+_pwrite_byte 0x00 $blksz $blksz $testdir/file2.chk >> $seqres.full
+
+$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
+_pwrite_byte 0x00 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
+
+_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/901.out b/tests/generic/901.out
new file mode 100644
index 00000000..07b9b433
--- /dev/null
+++ b/tests/generic/901.out
@@ -0,0 +1,6 @@
+QA output created by 901
+Format and mount
+Create the original files
+Compare files
+CoW and unmount
+Compare files
-- 
2.33.0




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

* [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
  2021-11-05  4:52 ` [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
  2021-11-05  4:52 ` [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
@ 2021-11-05  4:52 ` Shiyang Ruan
  2021-11-05 16:40   ` Darrick J. Wong
  2021-11-05  4:52 ` [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a hole.  (MMAP version of generic/218,220)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/902     | 70 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/902.out |  6 ++++
 2 files changed, 76 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..a0992fc8
--- /dev/null
+++ b/tests/generic/902
@@ -0,0 +1,70 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
+# the second block is a hole.  (MMAP version of generic/218,220)
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Override the default cleanup function.
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.* $testdir
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+pagesz=$(getconf PAGE_SIZE)
+blksz=$((pagesz / 4))
+
+echo "Format and mount"
+_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+real_blksz=$(_get_file_block_size $testdir)
+test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
+
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
+
+_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/902.out b/tests/generic/902.out
new file mode 100644
index 00000000..4fb8b6cb
--- /dev/null
+++ b/tests/generic/902.out
@@ -0,0 +1,6 @@
+QA output created by 902
+Format and mount
+Create the original files
+Compare files
+CoW and unmount
+Compare files
-- 
2.33.0




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

* [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
                   ` (2 preceding siblings ...)
  2021-11-05  4:52 ` [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
@ 2021-11-05  4:52 ` Shiyang Ruan
  2021-11-05 16:42   ` Darrick J. Wong
  2021-11-05  4:52 ` [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
  2021-11-07 13:31 ` [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Eryu Guan
  5 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is delalloc.  (MMAP version of generic/222,227)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/903     | 76 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/903.out |  6 ++++
 2 files changed, 82 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..c55c4c71
--- /dev/null
+++ b/tests/generic/903
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
+# the second block is delalloc.  (MMAP version of generic/222,227)
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Override the default cleanup function.
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.* $testdir
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+pagesz=$(getconf PAGE_SIZE)
+blksz=$((pagesz / 4))
+
+echo "Format and mount"
+_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+real_blksz=$(_get_file_block_size $testdir)
+test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
+
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
+
+_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+echo "CoW and unmount"
+_pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
+_pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
+
+_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
+_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
+
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
+cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/903.out b/tests/generic/903.out
new file mode 100644
index 00000000..cfeeb11c
--- /dev/null
+++ b/tests/generic/903.out
@@ -0,0 +1,6 @@
+QA output created by 903
+Format and mount
+Create the original files
+Compare files
+CoW and unmount
+Compare files
-- 
2.33.0




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

* [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
                   ` (3 preceding siblings ...)
  2021-11-05  4:52 ` [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
@ 2021-11-05  4:52 ` Shiyang Ruan
  2021-11-05 16:49   ` Darrick J. Wong
  2021-11-07 13:31 ` [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Eryu Guan
  5 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-05  4:52 UTC (permalink / raw)
  To: fstests

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the surrounding blocks vary between unwritten/regular/delalloc/hole.
(MMAP version of generic/229,238)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/904     | 135 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/904.out |  82 +++++++++++++++++++++++++
 2 files changed, 217 insertions(+)
 create mode 100755 tests/generic/904
 create mode 100644 tests/generic/904.out

diff --git a/tests/generic/904 b/tests/generic/904
new file mode 100755
index 00000000..c1cca379
--- /dev/null
+++ b/tests/generic/904
@@ -0,0 +1,135 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# FS QA Test No. xxx
+#
+# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
+# the surrounding blocks vary between unwritten/regular/delalloc/hole.
+# (MMAP version of generic/229,238)
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Override the default cleanup function.
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.* $testdir
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+pagesz=$(getconf PAGE_SIZE)
+blksz=$((pagesz / 4))
+
+echo "Format and mount"
+_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+real_blksz=$(_get_file_block_size $testdir)
+test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
+
+runtest() {
+	echo "runtest $1 $2"
+	b2=$1
+	b4=$2
+	dir=$3
+
+	echo "Create the original files"
+	mkdir -p $dir
+	_pwrite_byte 0x61 0 $pagesz $dir/file1 >> $seqres.full
+
+	$XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2 >> $seqres.full
+	$XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2.chk >> $seqres.full
+
+	case $b2 in
+	"regular")
+		_pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
+		_pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
+		;;
+	"unwritten")
+		$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $dir/file2 >> $seqres.full
+		_pwrite_byte 0x00 $blksz $blksz $dir/file2.chk >> $seqres.full
+		;;
+	"hole")
+		;;
+	esac
+
+	case $b4 in
+	"regular")
+		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
+		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
+		;;
+	"unwritten")
+		$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $dir/file2 >> $seqres.full
+		_pwrite_byte 0x00 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
+		;;
+	"hole")
+		;;
+	esac
+
+	_reflink_range $dir/file1 $blksz $dir/file2 $((blksz * 2)) $blksz >> $seqres.full
+	_pwrite_byte 0x61 $((blksz * 2)) $blksz $dir/file2.chk >> $seqres.full
+	_scratch_cycle_mount
+
+	echo "Compare files"
+	cmp -s $dir/file1 $dir/file2 && echo "file1 and file2 should not match."
+	cmp -s $dir/file2 $dir/file2.chk || echo "file2 and file2.chk don't match."
+
+	echo "CoW and unmount"
+	if [ $b2 = "delalloc" ]; then
+		_pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
+		_pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
+	fi
+
+	if [ $b4 = "delalloc" ]; then
+		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
+		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
+	fi
+
+	$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+        -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2 >> $seqres.full
+	$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
+        -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2.chk >> $seqres.full
+	_scratch_cycle_mount
+
+	echo "Compare files"
+	cmp -s $dir/file1 $dir/file2 && echo "file1 and file2 should not match."
+	cmp -s $dir/file2 $dir/file2.chk || echo "file2 and file2.chk don't match."
+}
+
+runtest regular delalloc "$testdir/r-d"
+runtest regular unwritten "$testdir/r-u"
+runtest regular hole "$testdir/r-h"
+runtest regular regular "$testdir/r-r"
+
+runtest hole delalloc "$testdir/h-d"
+runtest hole unwritten "$testdir/h-u"
+runtest hole hole "$testdir/h-h"
+runtest hole regular "$testdir/h-r"
+
+runtest unwritten delalloc "$testdir/u-d"
+runtest unwritten unwritten "$testdir/u-u"
+runtest unwritten hole "$testdir/u-h"
+runtest unwritten regular "$testdir/u-r"
+
+runtest delalloc delalloc "$testdir/d-d"
+runtest delalloc unwritten "$testdir/d-u"
+runtest delalloc hole "$testdir/d-h"
+runtest delalloc regular "$testdir/d-r"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/904.out b/tests/generic/904.out
new file mode 100644
index 00000000..f84bbe6d
--- /dev/null
+++ b/tests/generic/904.out
@@ -0,0 +1,82 @@
+QA output created by 904
+Format and mount
+runtest regular delalloc
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest regular unwritten
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest regular hole
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest regular regular
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest hole delalloc
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest hole unwritten
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest hole hole
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest hole regular
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest unwritten delalloc
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest unwritten unwritten
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest unwritten hole
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest unwritten regular
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest delalloc delalloc
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest delalloc unwritten
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest delalloc hole
+Create the original files
+Compare files
+CoW and unmount
+Compare files
+runtest delalloc regular
+Create the original files
+Compare files
+CoW and unmount
+Compare files
-- 
2.33.0




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

* Re: [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case
  2021-11-05  4:52 ` [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
@ 2021-11-05 16:15   ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:15 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:18PM +0800, Shiyang Ruan wrote:
> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> the second block is a regular block.  (MMAP version of generic/205,206)
> 
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>

Looks good to me.  Sorry I overlooked this back when I was writing all
the reflink tests. :/

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/generic/900     | 75 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/900.out |  6 ++++
>  2 files changed, 81 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..c56d9acf
> --- /dev/null
> +++ b/tests/generic/900
> @@ -0,0 +1,75 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# FS QA Test No. xxx
> +#
> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> +# the second block is a regular block.  (MMAP version of generic/205,206)
> +#
> +# This test is dependent on the system page size, so we cannot use md5 in
> +# the golden output; we can only compare to a check file.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +    cd /
> +    rm -rf $tmp.* $testdir
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_require_scratch_reflink
> +
> +pagesz=$(getconf PAGE_SIZE)
> +blksz=$((pagesz / 4))
> +
> +echo "Format and mount"
> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +real_blksz=$(_get_file_block_size $testdir)
> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> +
> +echo "Create the original files"
> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
> +
> +_pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
> +
> +_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
> +
> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +echo "CoW and unmount"
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/900.out b/tests/generic/900.out
> new file mode 100644
> index 00000000..2abfd789
> --- /dev/null
> +++ b/tests/generic/900.out
> @@ -0,0 +1,6 @@
> +QA output created by 900
> +Format and mount
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> -- 
> 2.33.0
> 
> 
> 

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

* Re: [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case
  2021-11-05  4:52 ` [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
@ 2021-11-05 16:20   ` Darrick J. Wong
  2021-11-08  6:18     ` Shiyang Ruan
  0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:20 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:19PM +0800, Shiyang Ruan wrote:
> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> the second block is a unwritten block.  (MMAP version of generic/216,217)
> 
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> ---
>  tests/generic/901     | 76 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/901.out |  6 ++++
>  2 files changed, 82 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..46459815
> --- /dev/null
> +++ b/tests/generic/901
> @@ -0,0 +1,76 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# FS QA Test No. xxx
> +#
> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> +# the second block is a unwritten block.  (MMAP version of generic/216,217)
> +#
> +# This test is dependent on the system page size, so we cannot use md5 in
> +# the golden output; we can only compare to a check file.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +    cd /
> +    rm -rf $tmp.* $testdir
> +}

Oh, something I didn't notice with the previous patch -- this exact
_cleanup function is now provided by common/preamble as a default.  If
you don't have anything to add to the cleanup process, then you can omit
this definition.

With that fixed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D


> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +pagesz=$(getconf PAGE_SIZE)
> +blksz=$((pagesz / 4))
> +
> +echo "Format and mount"
> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +real_blksz=$(_get_file_block_size $testdir)
> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> +
> +echo "Create the original files"
> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x00 $blksz $blksz $testdir/file2.chk >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x00 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
> +
> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +echo "CoW and unmount"
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/901.out b/tests/generic/901.out
> new file mode 100644
> index 00000000..07b9b433
> --- /dev/null
> +++ b/tests/generic/901.out
> @@ -0,0 +1,6 @@
> +QA output created by 901
> +Format and mount
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> -- 
> 2.33.0
> 
> 
> 

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

* Re: [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case
  2021-11-05  4:52 ` [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
@ 2021-11-05 16:40   ` Darrick J. Wong
  2021-11-08  6:33     ` Shiyang Ruan
  0 siblings, 1 reply; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:40 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:20PM +0800, Shiyang Ruan wrote:
> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> the second block is a hole.  (MMAP version of generic/218,220)
> 
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> ---
>  tests/generic/902     | 70 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/902.out |  6 ++++
>  2 files changed, 76 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..a0992fc8
> --- /dev/null
> +++ b/tests/generic/902
> @@ -0,0 +1,70 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# FS QA Test No. xxx
> +#
> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> +# the second block is a hole.  (MMAP version of generic/218,220)
> +#
> +# This test is dependent on the system page size, so we cannot use md5 in
> +# the golden output; we can only compare to a check file.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +    cd /
> +    rm -rf $tmp.* $testdir
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +pagesz=$(getconf PAGE_SIZE)
> +blksz=$((pagesz / 4))
> +
> +echo "Format and mount"
> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +real_blksz=$(_get_file_block_size $testdir)
> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> +
> +echo "Create the original files"
> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
> +
> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +echo "CoW and unmount"
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount

One thing I noticed about the last two tests is that since you only
write to the two shared blocks in the middle of the page, the fs could
very well ignore the holes in the first and last block when it's
handling the page fault.  XFS/iomap will (iirc) allocate those two holes
at writeback time and flush the whole thing to disk, but that isn't a
guaranteed behavior.

So I think the point of this test is to make sure that COW does the
right thing on a bs<ps filesystem such that the adjoining blocks don't
end up with garbage in them, right?  And we don't care what allocation
decisions the fs makes, so long as the read()able contents are what we
expect, right?

If that's correct,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/902.out b/tests/generic/902.out
> new file mode 100644
> index 00000000..4fb8b6cb
> --- /dev/null
> +++ b/tests/generic/902.out
> @@ -0,0 +1,6 @@
> +QA output created by 902
> +Format and mount
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> -- 
> 2.33.0
> 
> 
> 

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

* Re: [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case
  2021-11-05  4:52 ` [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
@ 2021-11-05 16:42   ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:42 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:21PM +0800, Shiyang Ruan wrote:
> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> the second block is delalloc.  (MMAP version of generic/222,227)
> 
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> ---
>  tests/generic/903     | 76 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/903.out |  6 ++++
>  2 files changed, 82 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..c55c4c71
> --- /dev/null
> +++ b/tests/generic/903
> @@ -0,0 +1,76 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# FS QA Test No. xxx
> +#
> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> +# the second block is delalloc.  (MMAP version of generic/222,227)
> +#
> +# This test is dependent on the system page size, so we cannot use md5 in
> +# the golden output; we can only compare to a check file.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +    cd /
> +    rm -rf $tmp.* $testdir
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +pagesz=$(getconf PAGE_SIZE)
> +blksz=$((pagesz / 4))
> +
> +echo "Format and mount"
> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +real_blksz=$(_get_file_block_size $testdir)
> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> +
> +echo "Create the original files"
> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
> +
> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +echo "CoW and unmount"
> +_pwrite_byte 0x61 $blksz $blksz $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x61 $blksz $blksz $testdir/file2.chk >> $seqres.full
> +
> +_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2 >> $seqres.full
> +_pwrite_byte 0x61 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full

Does this need to check the block mapping to make sure that blocks 1 and
3 are actually delalloc reservations?  There are certain xfs configs
(such as extent size hints) that disable delalloc.

--D

> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/903.out b/tests/generic/903.out
> new file mode 100644
> index 00000000..cfeeb11c
> --- /dev/null
> +++ b/tests/generic/903.out
> @@ -0,0 +1,6 @@
> +QA output created by 903
> +Format and mount
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> -- 
> 2.33.0
> 
> 
> 

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

* Re: [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case
  2021-11-05  4:52 ` [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
@ 2021-11-05 16:49   ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-05 16:49 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:22PM +0800, Shiyang Ruan wrote:
> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> the surrounding blocks vary between unwritten/regular/delalloc/hole.
> (MMAP version of generic/229,238)
> 
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> ---
>  tests/generic/904     | 135 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/904.out |  82 +++++++++++++++++++++++++
>  2 files changed, 217 insertions(+)
>  create mode 100755 tests/generic/904
>  create mode 100644 tests/generic/904.out
> 
> diff --git a/tests/generic/904 b/tests/generic/904
> new file mode 100755
> index 00000000..c1cca379
> --- /dev/null
> +++ b/tests/generic/904
> @@ -0,0 +1,135 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# FS QA Test No. xxx
> +#
> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> +# the surrounding blocks vary between unwritten/regular/delalloc/hole.
> +# (MMAP version of generic/229,238)
> +#
> +# This test is dependent on the system page size, so we cannot use md5 in
> +# the golden output; we can only compare to a check file.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +    cd /
> +    rm -rf $tmp.* $testdir
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +pagesz=$(getconf PAGE_SIZE)
> +blksz=$((pagesz / 4))
> +
> +echo "Format and mount"
> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +real_blksz=$(_get_file_block_size $testdir)
> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> +
> +runtest() {
> +	echo "runtest $1 $2"
> +	b2=$1
> +	b4=$2
> +	dir=$3
> +
> +	echo "Create the original files"
> +	mkdir -p $dir
> +	_pwrite_byte 0x61 0 $pagesz $dir/file1 >> $seqres.full
> +
> +	$XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2 >> $seqres.full
> +	$XFS_IO_PROG -f -c "truncate $pagesz" $dir/file2.chk >> $seqres.full
> +
> +	case $b2 in
> +	"regular")
> +		_pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
> +		;;
> +	"unwritten")
> +		$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x00 $blksz $blksz $dir/file2.chk >> $seqres.full
> +		;;
> +	"hole")
> +		;;
> +	esac
> +
> +	case $b4 in
> +	"regular")
> +		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
> +		;;
> +	"unwritten")
> +		$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x00 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
> +		;;
> +	"hole")
> +		;;
> +	esac
> +
> +	_reflink_range $dir/file1 $blksz $dir/file2 $((blksz * 2)) $blksz >> $seqres.full
> +	_pwrite_byte 0x61 $((blksz * 2)) $blksz $dir/file2.chk >> $seqres.full
> +	_scratch_cycle_mount
> +
> +	echo "Compare files"
> +	cmp -s $dir/file1 $dir/file2 && echo "file1 and file2 should not match."
> +	cmp -s $dir/file2 $dir/file2.chk || echo "file2 and file2.chk don't match."
> +
> +	echo "CoW and unmount"
> +	if [ $b2 = "delalloc" ]; then
> +		_pwrite_byte 0x61 $blksz $blksz $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x61 $blksz $blksz $dir/file2.chk >> $seqres.full
> +	fi
> +
> +	if [ $b4 = "delalloc" ]; then
> +		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2 >> $seqres.full
> +		_pwrite_byte 0x61 $((blksz * 3)) $blksz $dir/file2.chk >> $seqres.full
> +	fi
> +
> +	$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +        -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2 >> $seqres.full
> +	$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> +        -c "pwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $dir/file2.chk >> $seqres.full
> +	_scratch_cycle_mount
> +
> +	echo "Compare files"
> +	cmp -s $dir/file1 $dir/file2 && echo "file1 and file2 should not match."
> +	cmp -s $dir/file2 $dir/file2.chk || echo "file2 and file2.chk don't match."
> +}
> +
> +runtest regular delalloc "$testdir/r-d"
> +runtest regular unwritten "$testdir/r-u"
> +runtest regular hole "$testdir/r-h"
> +runtest regular regular "$testdir/r-r"

How does regular-regular differ from the first test in the series?

(And the same for unwritten-unwritten, etc.)

--D

> +
> +runtest hole delalloc "$testdir/h-d"
> +runtest hole unwritten "$testdir/h-u"
> +runtest hole hole "$testdir/h-h"
> +runtest hole regular "$testdir/h-r"
> +
> +runtest unwritten delalloc "$testdir/u-d"
> +runtest unwritten unwritten "$testdir/u-u"
> +runtest unwritten hole "$testdir/u-h"
> +runtest unwritten regular "$testdir/u-r"
> +
> +runtest delalloc delalloc "$testdir/d-d"
> +runtest delalloc unwritten "$testdir/d-u"
> +runtest delalloc hole "$testdir/d-h"
> +runtest delalloc regular "$testdir/d-r"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/904.out b/tests/generic/904.out
> new file mode 100644
> index 00000000..f84bbe6d
> --- /dev/null
> +++ b/tests/generic/904.out
> @@ -0,0 +1,82 @@
> +QA output created by 904
> +Format and mount
> +runtest regular delalloc
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest regular unwritten
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest regular hole
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest regular regular
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest hole delalloc
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest hole unwritten
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest hole hole
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest hole regular
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest unwritten delalloc
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest unwritten unwritten
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest unwritten hole
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest unwritten regular
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest delalloc delalloc
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest delalloc unwritten
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest delalloc hole
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> +runtest delalloc regular
> +Create the original files
> +Compare files
> +CoW and unmount
> +Compare files
> -- 
> 2.33.0
> 
> 
> 

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

* Re: [PATCH v2 0/5] generic: add a couple of MMAP CoW tests
  2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
                   ` (4 preceding siblings ...)
  2021-11-05  4:52 ` [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
@ 2021-11-07 13:31 ` Eryu Guan
  2021-11-08  6:25   ` Shiyang Ruan
  5 siblings, 1 reply; 16+ messages in thread
From: Eryu Guan @ 2021-11-07 13:31 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Fri, Nov 05, 2021 at 12:52:17PM +0800, Shiyang Ruan wrote:
> There is a set of CoW tests which is to 
>   > Check what happens if we BufferedIO/DIO CoW blocks 2-4 of a page's worth
>   > of blocks when the second block is a regular/unwritten/hole/delalloc/all
>   > block.
> I think a test of MMAP CoW is also needed for these kind of testsets.  So,
> add MMAP CoW for each case.
> 
> Shiyang Ruan (5):
>   generic/xxx: Add MMAP CoW test for 'regular' case
>   generic/xxx: Add MMAP CoW test for 'unwritten' case
>   generic/xxx: Add MMAP CoW test for 'hole' case
>   generic/xxx: Add MMAP CoW test for 'delalloc' case
>   generic/xxx: Add MMAP CoW test for 'all' case

Thanks for all these tests!

You could remove the 'xxx' part from patch summary, and for new tests
you don't have to write the specific test seq number in summary,
something like below is fine

   generic: add mmap CoW test for 'regular' case

As test seq number will always change on commit, there's no need to keep
such a place holder.

Thanks,
Eryu

> 
>  tests/generic/900     |  75 +++++++++++++++++++++++
>  tests/generic/900.out |   6 ++
>  tests/generic/901     |  76 ++++++++++++++++++++++++
>  tests/generic/901.out |   6 ++
>  tests/generic/902     |  70 ++++++++++++++++++++++
>  tests/generic/902.out |   6 ++
>  tests/generic/903     |  76 ++++++++++++++++++++++++
>  tests/generic/903.out |   6 ++
>  tests/generic/904     | 135 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/904.out |  82 +++++++++++++++++++++++++
>  10 files changed, 538 insertions(+)
>  create mode 100755 tests/generic/900
>  create mode 100644 tests/generic/900.out
>  create mode 100755 tests/generic/901
>  create mode 100644 tests/generic/901.out
>  create mode 100755 tests/generic/902
>  create mode 100644 tests/generic/902.out
>  create mode 100755 tests/generic/903
>  create mode 100644 tests/generic/903.out
>  create mode 100755 tests/generic/904
>  create mode 100644 tests/generic/904.out
> 
> -- 
> 2.33.0
> 
> 

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

* Re: [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case
  2021-11-05 16:20   ` Darrick J. Wong
@ 2021-11-08  6:18     ` Shiyang Ruan
  2021-11-08 18:08       ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-08  6:18 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests



在 2021/11/6 0:20, Darrick J. Wong 写道:
> On Fri, Nov 05, 2021 at 12:52:19PM +0800, Shiyang Ruan wrote:
>> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
>> the second block is a unwritten block.  (MMAP version of generic/216,217)
>>
>> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
>> ---
>>   tests/generic/901     | 76 +++++++++++++++++++++++++++++++++++++++++++
>>   tests/generic/901.out |  6 ++++
>>   2 files changed, 82 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..46459815
>> --- /dev/null
>> +++ b/tests/generic/901
>> @@ -0,0 +1,76 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +#
>> +# FS QA Test No. xxx
>> +#
>> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
>> +# the second block is a unwritten block.  (MMAP version of generic/216,217)
>> +#
>> +# This test is dependent on the system page size, so we cannot use md5 in
>> +# the golden output; we can only compare to a check file.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick clone
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> +    cd /
>> +    rm -rf $tmp.* $testdir
>> +}
> 
> Oh, something I didn't notice with the previous patch -- this exact
> _cleanup function is now provided by common/preamble as a default.  If
> you don't have anything to add to the cleanup process, then you can omit
> this definition.

We created a testdir here but the default _cleanup doesn't remove it, so 
I think this overrided cleanup is needed.

--
Thanks,
Ruan.

> 
> With that fixed,
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
> 
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +. ./common/reflink
>> +
>> +# real QA test starts here
>> +_require_scratch_reflink
>> +_require_xfs_io_command "falloc"
>> +
>> +pagesz=$(getconf PAGE_SIZE)
>> +blksz=$((pagesz / 4))
>> +
>> +echo "Format and mount"
>> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
>> +_scratch_mount >> $seqres.full 2>&1
>> +
>> +testdir=$SCRATCH_MNT/test-$seq
>> +mkdir $testdir
>> +
>> +real_blksz=$(_get_file_block_size $testdir)
>> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
>> +
>> +echo "Create the original files"
>> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
>> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $testdir/file2 >> $seqres.full
>> +_pwrite_byte 0x00 $blksz $blksz $testdir/file2.chk >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
>> +_pwrite_byte 0x00 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
>> +
>> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
>> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
>> +_scratch_cycle_mount
>> +
>> +echo "Compare files"
>> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
>> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
>> +
>> +echo "CoW and unmount"
>> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
>> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
>> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
>> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
>> +_scratch_cycle_mount
>> +
>> +echo "Compare files"
>> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
>> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/generic/901.out b/tests/generic/901.out
>> new file mode 100644
>> index 00000000..07b9b433
>> --- /dev/null
>> +++ b/tests/generic/901.out
>> @@ -0,0 +1,6 @@
>> +QA output created by 901
>> +Format and mount
>> +Create the original files
>> +Compare files
>> +CoW and unmount
>> +Compare files
>> -- 
>> 2.33.0
>>
>>
>>



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

* Re: [PATCH v2 0/5] generic: add a couple of MMAP CoW tests
  2021-11-07 13:31 ` [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Eryu Guan
@ 2021-11-08  6:25   ` Shiyang Ruan
  0 siblings, 0 replies; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-08  6:25 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests



在 2021/11/7 21:31, Eryu Guan 写道:
> On Fri, Nov 05, 2021 at 12:52:17PM +0800, Shiyang Ruan wrote:
>> There is a set of CoW tests which is to
>>    > Check what happens if we BufferedIO/DIO CoW blocks 2-4 of a page's worth
>>    > of blocks when the second block is a regular/unwritten/hole/delalloc/all
>>    > block.
>> I think a test of MMAP CoW is also needed for these kind of testsets.  So,
>> add MMAP CoW for each case.
>>
>> Shiyang Ruan (5):
>>    generic/xxx: Add MMAP CoW test for 'regular' case
>>    generic/xxx: Add MMAP CoW test for 'unwritten' case
>>    generic/xxx: Add MMAP CoW test for 'hole' case
>>    generic/xxx: Add MMAP CoW test for 'delalloc' case
>>    generic/xxx: Add MMAP CoW test for 'all' case
> 
> Thanks for all these tests!
> 
> You could remove the 'xxx' part from patch summary, and for new tests
> you don't have to write the specific test seq number in summary,
> something like below is fine
> 
>     generic: add mmap CoW test for 'regular' case
> 
> As test seq number will always change on commit, there's no need to keep
> such a place holder.

Got it.  Thanks.

--
Ruan
> 
> Thanks,
> Eryu
> 
>>
>>   tests/generic/900     |  75 +++++++++++++++++++++++
>>   tests/generic/900.out |   6 ++
>>   tests/generic/901     |  76 ++++++++++++++++++++++++
>>   tests/generic/901.out |   6 ++
>>   tests/generic/902     |  70 ++++++++++++++++++++++
>>   tests/generic/902.out |   6 ++
>>   tests/generic/903     |  76 ++++++++++++++++++++++++
>>   tests/generic/903.out |   6 ++
>>   tests/generic/904     | 135 ++++++++++++++++++++++++++++++++++++++++++
>>   tests/generic/904.out |  82 +++++++++++++++++++++++++
>>   10 files changed, 538 insertions(+)
>>   create mode 100755 tests/generic/900
>>   create mode 100644 tests/generic/900.out
>>   create mode 100755 tests/generic/901
>>   create mode 100644 tests/generic/901.out
>>   create mode 100755 tests/generic/902
>>   create mode 100644 tests/generic/902.out
>>   create mode 100755 tests/generic/903
>>   create mode 100644 tests/generic/903.out
>>   create mode 100755 tests/generic/904
>>   create mode 100644 tests/generic/904.out
>>
>> -- 
>> 2.33.0
>>
>>



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

* Re: [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case
  2021-11-05 16:40   ` Darrick J. Wong
@ 2021-11-08  6:33     ` Shiyang Ruan
  0 siblings, 0 replies; 16+ messages in thread
From: Shiyang Ruan @ 2021-11-08  6:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests



在 2021/11/6 0:40, Darrick J. Wong 写道:
> On Fri, Nov 05, 2021 at 12:52:20PM +0800, Shiyang Ruan wrote:
>> Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
>> the second block is a hole.  (MMAP version of generic/218,220)
>>
>> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
>> ---
>>   tests/generic/902     | 70 +++++++++++++++++++++++++++++++++++++++++++
>>   tests/generic/902.out |  6 ++++
>>   2 files changed, 76 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..a0992fc8
>> --- /dev/null
>> +++ b/tests/generic/902
>> @@ -0,0 +1,70 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +#
>> +# FS QA Test No. xxx
>> +#
>> +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
>> +# the second block is a hole.  (MMAP version of generic/218,220)
>> +#
>> +# This test is dependent on the system page size, so we cannot use md5 in
>> +# the golden output; we can only compare to a check file.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick clone
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> +    cd /
>> +    rm -rf $tmp.* $testdir
>> +}
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +. ./common/reflink
>> +
>> +# real QA test starts here
>> +_require_scratch_reflink
>> +_require_xfs_io_command "falloc"
>> +
>> +pagesz=$(getconf PAGE_SIZE)
>> +blksz=$((pagesz / 4))
>> +
>> +echo "Format and mount"
>> +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
>> +_scratch_mount >> $seqres.full 2>&1
>> +
>> +testdir=$SCRATCH_MNT/test-$seq
>> +mkdir $testdir
>> +
>> +real_blksz=$(_get_file_block_size $testdir)
>> +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
>> +
>> +echo "Create the original files"
>> +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
>> +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
>> +
>> +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
>> +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
>> +_scratch_cycle_mount
>> +
>> +echo "Compare files"
>> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
>> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
>> +
>> +echo "CoW and unmount"
>> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
>> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
>> +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
>> +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
>> +_scratch_cycle_mount
> 
> One thing I noticed about the last two tests is that since you only
> write to the two shared blocks in the middle of the page, the fs could
> very well ignore the holes in the first and last block when it's
> handling the page fault.  XFS/iomap will (iirc) allocate those two holes
> at writeback time and flush the whole thing to disk, but that isn't a
> guaranteed behavior.

I noticed this too.

> 
> So I think the point of this test is to make sure that COW does the
> right thing on a bs<ps filesystem such that the adjoining blocks don't
> end up with garbage in them, right?  And we don't care what allocation
> decisions the fs makes, so long as the read()able contents are what we
> expect, right?

Yes, this is the purpose of this set of tests, including BufferedIO, 
DIO, MMAP operations.

> 
> If that's correct,
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>

Thanks.


--
Ruan.

> 
> --D
> 
>> +
>> +echo "Compare files"
>> +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
>> +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/generic/902.out b/tests/generic/902.out
>> new file mode 100644
>> index 00000000..4fb8b6cb
>> --- /dev/null
>> +++ b/tests/generic/902.out
>> @@ -0,0 +1,6 @@
>> +QA output created by 902
>> +Format and mount
>> +Create the original files
>> +Compare files
>> +CoW and unmount
>> +Compare files
>> -- 
>> 2.33.0
>>
>>
>>



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

* Re: [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case
  2021-11-08  6:18     ` Shiyang Ruan
@ 2021-11-08 18:08       ` Darrick J. Wong
  0 siblings, 0 replies; 16+ messages in thread
From: Darrick J. Wong @ 2021-11-08 18:08 UTC (permalink / raw)
  To: Shiyang Ruan; +Cc: fstests

On Mon, Nov 08, 2021 at 02:18:34PM +0800, Shiyang Ruan wrote:
> 
> 
> 在 2021/11/6 0:20, Darrick J. Wong 写道:
> > On Fri, Nov 05, 2021 at 12:52:19PM +0800, Shiyang Ruan wrote:
> > > Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> > > the second block is a unwritten block.  (MMAP version of generic/216,217)
> > > 
> > > Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
> > > ---
> > >   tests/generic/901     | 76 +++++++++++++++++++++++++++++++++++++++++++
> > >   tests/generic/901.out |  6 ++++
> > >   2 files changed, 82 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..46459815
> > > --- /dev/null
> > > +++ b/tests/generic/901
> > > @@ -0,0 +1,76 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +#
> > > +# FS QA Test No. xxx
> > > +#
> > > +# See what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
> > > +# the second block is a unwritten block.  (MMAP version of generic/216,217)
> > > +#
> > > +# This test is dependent on the system page size, so we cannot use md5 in
> > > +# the golden output; we can only compare to a check file.
> > > +#
> > > +. ./common/preamble
> > > +_begin_fstest auto quick clone
> > > +
> > > +# Override the default cleanup function.
> > > +_cleanup()
> > > +{
> > > +    cd /
> > > +    rm -rf $tmp.* $testdir
> > > +}
> > 
> > Oh, something I didn't notice with the previous patch -- this exact
> > _cleanup function is now provided by common/preamble as a default.  If
> > you don't have anything to add to the cleanup process, then you can omit
> > this definition.
> 
> We created a testdir here but the default _cleanup doesn't remove it, so I
> think this overrided cleanup is needed.

It's never necessary to clean things off the scratch fs because the next
test to use the scratch device will reformat it as desired.

--D

> --
> Thanks,
> Ruan.
> 
> > 
> > With that fixed,
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > 
> > --D
> > 
> > 
> > > +
> > > +# Import common functions.
> > > +. ./common/filter
> > > +. ./common/reflink
> > > +
> > > +# real QA test starts here
> > > +_require_scratch_reflink
> > > +_require_xfs_io_command "falloc"
> > > +
> > > +pagesz=$(getconf PAGE_SIZE)
> > > +blksz=$((pagesz / 4))
> > > +
> > > +echo "Format and mount"
> > > +_scratch_mkfs_blocksized $blksz > $seqres.full 2>&1
> > > +_scratch_mount >> $seqres.full 2>&1
> > > +
> > > +testdir=$SCRATCH_MNT/test-$seq
> > > +mkdir $testdir
> > > +
> > > +real_blksz=$(_get_file_block_size $testdir)
> > > +test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
> > > +
> > > +echo "Create the original files"
> > > +_pwrite_byte 0x61 0 $pagesz $testdir/file1 >> $seqres.full
> > > +
> > > +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2 >> $seqres.full
> > > +$XFS_IO_PROG -f -c "truncate $pagesz" $testdir/file2.chk >> $seqres.full
> > > +
> > > +$XFS_IO_PROG -f -c "falloc -k $blksz $blksz" $testdir/file2 >> $seqres.full
> > > +_pwrite_byte 0x00 $blksz $blksz $testdir/file2.chk >> $seqres.full
> > > +
> > > +$XFS_IO_PROG -f -c "falloc -k $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
> > > +_pwrite_byte 0x00 $((blksz * 3)) $blksz $testdir/file2.chk >> $seqres.full
> > > +
> > > +_reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 2)) $blksz >> $seqres.full
> > > +_pwrite_byte 0x61 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
> > > +_scratch_cycle_mount
> > > +
> > > +echo "Compare files"
> > > +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> > > +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> > > +
> > > +echo "CoW and unmount"
> > > +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> > > +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2 >> $seqres.full
> > > +$XFS_IO_PROG -f -c "mmap 0 $pagesz" \
> > > +    -c "mwrite -S 0x63 $((blksz + 17)) $((blksz * 3 - 34))" $testdir/file2.chk >> $seqres.full
> > > +_scratch_cycle_mount
> > > +
> > > +echo "Compare files"
> > > +cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match."
> > > +cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk don't match."
> > > +
> > > +# success, all done
> > > +status=0
> > > +exit
> > > diff --git a/tests/generic/901.out b/tests/generic/901.out
> > > new file mode 100644
> > > index 00000000..07b9b433
> > > --- /dev/null
> > > +++ b/tests/generic/901.out
> > > @@ -0,0 +1,6 @@
> > > +QA output created by 901
> > > +Format and mount
> > > +Create the original files
> > > +Compare files
> > > +CoW and unmount
> > > +Compare files
> > > -- 
> > > 2.33.0
> > > 
> > > 
> > > 
> 
> 

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

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

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05  4:52 [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
2021-11-05  4:52 ` [PATCH v2 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
2021-11-05 16:15   ` Darrick J. Wong
2021-11-05  4:52 ` [PATCH v2 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
2021-11-05 16:20   ` Darrick J. Wong
2021-11-08  6:18     ` Shiyang Ruan
2021-11-08 18:08       ` Darrick J. Wong
2021-11-05  4:52 ` [PATCH v2 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
2021-11-05 16:40   ` Darrick J. Wong
2021-11-08  6:33     ` Shiyang Ruan
2021-11-05  4:52 ` [PATCH v2 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
2021-11-05 16:42   ` Darrick J. Wong
2021-11-05  4:52 ` [PATCH v2 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
2021-11-05 16:49   ` Darrick J. Wong
2021-11-07 13:31 ` [PATCH v2 0/5] generic: add a couple of MMAP CoW tests Eryu Guan
2021-11-08  6:25   ` Shiyang Ruan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.