* [PATCH 0/5] generic: add a couple of MMAP CoW tests
@ 2021-11-05 3:41 Shiyang Ruan
2021-11-05 3:41 ` [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:41 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] 8+ messages in thread
* [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
@ 2021-11-05 3:41 ` Shiyang Ruan
2021-11-05 3:49 ` Darrick J. Wong
2021-11-05 3:41 ` [PATCH 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:41 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..b608e314
--- /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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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] 8+ messages in thread
* [PATCH 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
2021-11-05 3:41 ` [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
@ 2021-11-05 3:41 ` Shiyang Ruan
2021-11-05 3:41 ` [PATCH 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:41 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..2aae5f6d
--- /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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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] 8+ messages in thread
* [PATCH 3/5] generic/xxx: Add MMAP CoW test for 'hole' case
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
2021-11-05 3:41 ` [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
2021-11-05 3:41 ` [PATCH 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
@ 2021-11-05 3:41 ` Shiyang Ruan
2021-11-05 3:41 ` [PATCH 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
2021-11-05 3:42 ` [PATCH 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
4 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:41 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..3fbf6143
--- /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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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] 8+ messages in thread
* [PATCH 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
` (2 preceding siblings ...)
2021-11-05 3:41 ` [PATCH 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
@ 2021-11-05 3:41 ` Shiyang Ruan
2021-11-05 3:42 ` [PATCH 5/5] generic/xxx: Add MMAP CoW test for 'all' case Shiyang Ruan
4 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:41 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..1e76fc9b
--- /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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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 || _fail "file1 and file2 don't match."
+cmp -s $testdir/file2 $testdir/file2.chk || _fail "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] 8+ messages in thread
* [PATCH 5/5] generic/xxx: Add MMAP CoW test for 'all' case
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
` (3 preceding siblings ...)
2021-11-05 3:41 ` [PATCH 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
@ 2021-11-05 3:42 ` Shiyang Ruan
4 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 3:42 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..dee6df4e
--- /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 || _fail "file1 and file2 don't match."
+ cmp -s $dir/file2 $dir/file2.chk || _fail "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 || _fail "file1 and file2 don't match."
+ cmp -s $dir/file2 $dir/file2.chk || _fail "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] 8+ messages in thread
* Re: [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case
2021-11-05 3:41 ` [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
@ 2021-11-05 3:49 ` Darrick J. Wong
2021-11-05 4:04 ` Shiyang Ruan
0 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-11-05 3:49 UTC (permalink / raw)
To: Shiyang Ruan; +Cc: fstests
On Fri, Nov 05, 2021 at 11:41:56AM +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>
> ---
> 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..b608e314
> --- /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 || _fail "file1 and file2 don't match."
not-or? Is this the logical equivalent of:
cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match"
> +cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
Also, for non-fatal failures, please use echo instead of _fail; the
discrepancy will be flagged as test failure(s) by the golden output
comparison.
> +
> +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 || _fail "file1 and file2 don't match."
> +cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
Same here.
--D
> +
> +# 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] 8+ messages in thread
* Re: [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case
2021-11-05 3:49 ` Darrick J. Wong
@ 2021-11-05 4:04 ` Shiyang Ruan
0 siblings, 0 replies; 8+ messages in thread
From: Shiyang Ruan @ 2021-11-05 4:04 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: fstests
在 2021/11/5 11:49, Darrick J. Wong 写道:
> On Fri, Nov 05, 2021 at 11:41:56AM +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>
>> ---
>> 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..b608e314
>> --- /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 || _fail "file1 and file2 don't match."
>
> not-or? Is this the logical equivalent of:
>
> cmp -s $testdir/file1 $testdir/file2 && echo "file1 and file2 should not match"
The logic is same. I was thinking that it's easy for us to understand
that it is supposed to be not equal with a '!' in the head of the line.
The echo message needs to be changed as your suggestion.
>
>> +cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
>
> Also, for non-fatal failures, please use echo instead of _fail; the
> discrepancy will be flagged as test failure(s) by the golden output
> comparison.
Understood. I'll fix all this problems in this series.
--
Thanks,
Ruan.
>
>> +
>> +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 || _fail "file1 and file2 don't match."
>> +cmp -s $testdir/file2 $testdir/file2.chk || _fail "file2 and file2.chk don't match."
>
> Same here.
>
> --D
>
>> +
>> +# 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] 8+ messages in thread
end of thread, other threads:[~2021-11-05 4:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 3:41 [PATCH 0/5] generic: add a couple of MMAP CoW tests Shiyang Ruan
2021-11-05 3:41 ` [PATCH 1/5] generic/xxx: Add MMAP CoW test for 'regular' case Shiyang Ruan
2021-11-05 3:49 ` Darrick J. Wong
2021-11-05 4:04 ` Shiyang Ruan
2021-11-05 3:41 ` [PATCH 2/5] generic/xxx: Add MMAP CoW test for 'unwritten' case Shiyang Ruan
2021-11-05 3:41 ` [PATCH 3/5] generic/xxx: Add MMAP CoW test for 'hole' case Shiyang Ruan
2021-11-05 3:41 ` [PATCH 4/5] generic/xxx: Add MMAP CoW test for 'delalloc' case Shiyang Ruan
2021-11-05 3:42 ` [PATCH 5/5] generic/xxx: Add MMAP CoW test for 'all' case 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).