* [xfstests PATCH v3] generic: add a partial pages zeroing out test
@ 2025-01-08 8:44 Zhang Yi
2025-01-08 16:56 ` Darrick J. Wong
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Zhang Yi @ 2025-01-08 8:44 UTC (permalink / raw)
To: fstests, zlang
Cc: linux-fsdevel, tytso, adilger.kernel, jack, willy, ojaswin,
djwong, yi.zhang, yi.zhang, chengzhihao1, yukuai3, yangerkun
From: Zhang Yi <yi.zhang@huawei.com>
This addresses a data corruption issue encountered during partial page
zeroing in ext4 which the block size is smaller than the page size [1].
Add a new test which is expanded upon generic/567, this test performs a
zeroing range test that spans two partial pages to cover this case, and
also generalize it to work for non-4k page sizes.
Link: https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/ [1]
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
v2->v3:
- Put the verifyfile in $SCRATCH_MNT and remove the overriding
_cleanup.
- Correct the test name.
v1->v2:
- Add a new test instead of modifying generic/567.
- Generalize the test to work for non-4k page sizes.
v2: https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
v1: https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
tests/generic/758 | 68 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/758.out | 3 ++
2 files changed, 71 insertions(+)
create mode 100755 tests/generic/758
create mode 100644 tests/generic/758.out
diff --git a/tests/generic/758 b/tests/generic/758
new file mode 100755
index 00000000..bf0a342b
--- /dev/null
+++ b/tests/generic/758
@@ -0,0 +1,68 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Huawei. All Rights Reserved.
+#
+# FS QA Test No. 758
+#
+# Test mapped writes against zero-range to ensure we get the data
+# correctly written. This can expose data corruption bugs on filesystems
+# where the block size is smaller than the page size.
+#
+# (generic/567 is a similar test but for punch hole.)
+#
+. ./common/preamble
+_begin_fstest auto quick rw zero
+
+# Import common functions.
+. ./common/filter
+
+_require_scratch
+_require_xfs_io_command "fzero"
+
+verifyfile=$SCRATCH_MNT/verifyfile
+testfile=$SCRATCH_MNT/testfile
+
+pagesz=$(getconf PAGE_SIZE)
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+_dump_files()
+{
+ echo "---- testfile ----"
+ _hexdump $testfile
+ echo "---- verifyfile --"
+ _hexdump $verifyfile
+}
+
+# Build verify file, the data in this file should be consistent with
+# that in the test file.
+$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
+ -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
+ $verifyfile | _filter_xfs_io >> /dev/null
+
+# Zero out straddling two pages to check that the mapped write after the
+# range-zeroing are correctly handled.
+$XFS_IO_PROG -t -f \
+ -c "pwrite -S 0x58 0 $((pagesz * 3))" \
+ -c "mmap -rw 0 $((pagesz * 3))" \
+ -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
+ -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
+ -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
+ -c "close" \
+$testfile | _filter_xfs_io > $seqres.full
+
+echo "==== Pre-Remount ==="
+if ! cmp -s $testfile $verifyfile; then
+ echo "Data does not match pre-remount."
+ _dump_files
+fi
+_scratch_cycle_mount
+echo "==== Post-Remount =="
+if ! cmp -s $testfile $verifyfile; then
+ echo "Data does not match post-remount."
+ _dump_files
+fi
+
+status=0
+exit
diff --git a/tests/generic/758.out b/tests/generic/758.out
new file mode 100644
index 00000000..d01c1959
--- /dev/null
+++ b/tests/generic/758.out
@@ -0,0 +1,3 @@
+QA output created by 758
+==== Pre-Remount ===
+==== Post-Remount ==
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [xfstests PATCH v3] generic: add a partial pages zeroing out test
2025-01-08 8:44 [xfstests PATCH v3] generic: add a partial pages zeroing out test Zhang Yi
@ 2025-01-08 16:56 ` Darrick J. Wong
2025-01-09 13:06 ` Ojaswin Mujoo
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2025-01-08 16:56 UTC (permalink / raw)
To: Zhang Yi
Cc: fstests, zlang, linux-fsdevel, tytso, adilger.kernel, jack, willy,
ojaswin, yi.zhang, chengzhihao1, yukuai3, yangerkun
On Wed, Jan 08, 2025 at 04:44:07PM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> This addresses a data corruption issue encountered during partial page
> zeroing in ext4 which the block size is smaller than the page size [1].
> Add a new test which is expanded upon generic/567, this test performs a
> zeroing range test that spans two partial pages to cover this case, and
> also generalize it to work for non-4k page sizes.
>
> Link: https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/ [1]
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
LGTM now, thanks for setting this up!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> v2->v3:
> - Put the verifyfile in $SCRATCH_MNT and remove the overriding
> _cleanup.
> - Correct the test name.
> v1->v2:
> - Add a new test instead of modifying generic/567.
> - Generalize the test to work for non-4k page sizes.
> v2: https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
> v1: https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
>
> tests/generic/758 | 68 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/758.out | 3 ++
> 2 files changed, 71 insertions(+)
> create mode 100755 tests/generic/758
> create mode 100644 tests/generic/758.out
>
> diff --git a/tests/generic/758 b/tests/generic/758
> new file mode 100755
> index 00000000..bf0a342b
> --- /dev/null
> +++ b/tests/generic/758
> @@ -0,0 +1,68 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Huawei. All Rights Reserved.
> +#
> +# FS QA Test No. 758
> +#
> +# Test mapped writes against zero-range to ensure we get the data
> +# correctly written. This can expose data corruption bugs on filesystems
> +# where the block size is smaller than the page size.
> +#
> +# (generic/567 is a similar test but for punch hole.)
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw zero
> +
> +# Import common functions.
> +. ./common/filter
> +
> +_require_scratch
> +_require_xfs_io_command "fzero"
> +
> +verifyfile=$SCRATCH_MNT/verifyfile
> +testfile=$SCRATCH_MNT/testfile
> +
> +pagesz=$(getconf PAGE_SIZE)
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +
> +_dump_files()
> +{
> + echo "---- testfile ----"
> + _hexdump $testfile
> + echo "---- verifyfile --"
> + _hexdump $verifyfile
> +}
> +
> +# Build verify file, the data in this file should be consistent with
> +# that in the test file.
> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + $verifyfile | _filter_xfs_io >> /dev/null
> +
> +# Zero out straddling two pages to check that the mapped write after the
> +# range-zeroing are correctly handled.
> +$XFS_IO_PROG -t -f \
> + -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "mmap -rw 0 $((pagesz * 3))" \
> + -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
> + -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
> + -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + -c "close" \
> +$testfile | _filter_xfs_io > $seqres.full
> +
> +echo "==== Pre-Remount ==="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match pre-remount."
> + _dump_files
> +fi
> +_scratch_cycle_mount
> +echo "==== Post-Remount =="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match post-remount."
> + _dump_files
> +fi
> +
> +status=0
> +exit
> diff --git a/tests/generic/758.out b/tests/generic/758.out
> new file mode 100644
> index 00000000..d01c1959
> --- /dev/null
> +++ b/tests/generic/758.out
> @@ -0,0 +1,3 @@
> +QA output created by 758
> +==== Pre-Remount ===
> +==== Post-Remount ==
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [xfstests PATCH v3] generic: add a partial pages zeroing out test
2025-01-08 8:44 [xfstests PATCH v3] generic: add a partial pages zeroing out test Zhang Yi
2025-01-08 16:56 ` Darrick J. Wong
@ 2025-01-09 13:06 ` Ojaswin Mujoo
2025-01-09 18:19 ` Zorro Lang
2025-01-10 5:52 ` Nirjhar Roy (IBM)
3 siblings, 0 replies; 6+ messages in thread
From: Ojaswin Mujoo @ 2025-01-09 13:06 UTC (permalink / raw)
To: Zhang Yi
Cc: fstests, zlang, linux-fsdevel, tytso, adilger.kernel, jack, willy,
djwong, yi.zhang, chengzhihao1, yukuai3, yangerkun
On Wed, Jan 08, 2025 at 04:44:07PM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> This addresses a data corruption issue encountered during partial page
> zeroing in ext4 which the block size is smaller than the page size [1].
> Add a new test which is expanded upon generic/567, this test performs a
> zeroing range test that spans two partial pages to cover this case, and
> also generalize it to work for non-4k page sizes.
>
> Link: https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/ [1]
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> v2->v3:
> - Put the verifyfile in $SCRATCH_MNT and remove the overriding
> _cleanup.
> - Correct the test name.
> v1->v2:
> - Add a new test instead of modifying generic/567.
> - Generalize the test to work for non-4k page sizes.
> v2: https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
> v1: https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
Feel free to add:
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Regards,
ojaswin
>
> tests/generic/758 | 68 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/758.out | 3 ++
> 2 files changed, 71 insertions(+)
> create mode 100755 tests/generic/758
> create mode 100644 tests/generic/758.out
>
> diff --git a/tests/generic/758 b/tests/generic/758
> new file mode 100755
> index 00000000..bf0a342b
> --- /dev/null
> +++ b/tests/generic/758
> @@ -0,0 +1,68 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Huawei. All Rights Reserved.
> +#
> +# FS QA Test No. 758
> +#
> +# Test mapped writes against zero-range to ensure we get the data
> +# correctly written. This can expose data corruption bugs on filesystems
> +# where the block size is smaller than the page size.
> +#
> +# (generic/567 is a similar test but for punch hole.)
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw zero
> +
> +# Import common functions.
> +. ./common/filter
> +
> +_require_scratch
> +_require_xfs_io_command "fzero"
> +
> +verifyfile=$SCRATCH_MNT/verifyfile
> +testfile=$SCRATCH_MNT/testfile
> +
> +pagesz=$(getconf PAGE_SIZE)
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +
> +_dump_files()
> +{
> + echo "---- testfile ----"
> + _hexdump $testfile
> + echo "---- verifyfile --"
> + _hexdump $verifyfile
> +}
> +
> +# Build verify file, the data in this file should be consistent with
> +# that in the test file.
> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + $verifyfile | _filter_xfs_io >> /dev/null
> +
> +# Zero out straddling two pages to check that the mapped write after the
> +# range-zeroing are correctly handled.
> +$XFS_IO_PROG -t -f \
> + -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "mmap -rw 0 $((pagesz * 3))" \
> + -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
> + -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
> + -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + -c "close" \
> +$testfile | _filter_xfs_io > $seqres.full
> +
> +echo "==== Pre-Remount ==="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match pre-remount."
> + _dump_files
> +fi
> +_scratch_cycle_mount
> +echo "==== Post-Remount =="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match post-remount."
> + _dump_files
> +fi
> +
> +status=0
> +exit
> diff --git a/tests/generic/758.out b/tests/generic/758.out
> new file mode 100644
> index 00000000..d01c1959
> --- /dev/null
> +++ b/tests/generic/758.out
> @@ -0,0 +1,3 @@
> +QA output created by 758
> +==== Pre-Remount ===
> +==== Post-Remount ==
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [xfstests PATCH v3] generic: add a partial pages zeroing out test
2025-01-08 8:44 [xfstests PATCH v3] generic: add a partial pages zeroing out test Zhang Yi
2025-01-08 16:56 ` Darrick J. Wong
2025-01-09 13:06 ` Ojaswin Mujoo
@ 2025-01-09 18:19 ` Zorro Lang
2025-01-10 2:05 ` Zhang Yi
2025-01-10 5:52 ` Nirjhar Roy (IBM)
3 siblings, 1 reply; 6+ messages in thread
From: Zorro Lang @ 2025-01-09 18:19 UTC (permalink / raw)
To: Zhang Yi
Cc: fstests, zlang, linux-fsdevel, tytso, adilger.kernel, jack, willy,
ojaswin, djwong, yi.zhang, chengzhihao1, yukuai3, yangerkun
On Wed, Jan 08, 2025 at 04:44:07PM +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> This addresses a data corruption issue encountered during partial page
> zeroing in ext4 which the block size is smaller than the page size [1].
> Add a new test which is expanded upon generic/567, this test performs a
> zeroing range test that spans two partial pages to cover this case, and
> also generalize it to work for non-4k page sizes.
>
> Link: https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/ [1]
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> v2->v3:
> - Put the verifyfile in $SCRATCH_MNT and remove the overriding
> _cleanup.
> - Correct the test name.
> v1->v2:
> - Add a new test instead of modifying generic/567.
> - Generalize the test to work for non-4k page sizes.
> v2: https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
> v1: https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
>
> tests/generic/758 | 68 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/758.out | 3 ++
> 2 files changed, 71 insertions(+)
> create mode 100755 tests/generic/758
> create mode 100644 tests/generic/758.out
>
> diff --git a/tests/generic/758 b/tests/generic/758
> new file mode 100755
> index 00000000..bf0a342b
> --- /dev/null
> +++ b/tests/generic/758
> @@ -0,0 +1,68 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Huawei. All Rights Reserved.
> +#
> +# FS QA Test No. 758
> +#
> +# Test mapped writes against zero-range to ensure we get the data
> +# correctly written. This can expose data corruption bugs on filesystems
> +# where the block size is smaller than the page size.
> +#
> +# (generic/567 is a similar test but for punch hole.)
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw zero
> +
> +# Import common functions.
> +. ./common/filter
> +
> +_require_scratch
> +_require_xfs_io_command "fzero"
> +
> +verifyfile=$SCRATCH_MNT/verifyfile
> +testfile=$SCRATCH_MNT/testfile
> +
> +pagesz=$(getconf PAGE_SIZE)
There's a common helper "_get_page_size" to do this.
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +
> +_dump_files()
> +{
> + echo "---- testfile ----"
> + _hexdump $testfile
> + echo "---- verifyfile --"
> + _hexdump $verifyfile
> +}
> +
> +# Build verify file, the data in this file should be consistent with
> +# that in the test file.
> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + $verifyfile | _filter_xfs_io >> /dev/null
????????
>> $seqres.full ?
> +
> +# Zero out straddling two pages to check that the mapped write after the
> +# range-zeroing are correctly handled.
> +$XFS_IO_PROG -t -f \
> + -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "mmap -rw 0 $((pagesz * 3))" \
> + -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
> + -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
> + -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + -c "close" \
> +$testfile | _filter_xfs_io > $seqres.full
^^
>> $seqres.full
I'll help to make above tiny changes when I merge it, others looks good
to me.
Reviewed-by: Zorro Lang <zlang@redhat.com>
> +
> +echo "==== Pre-Remount ==="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match pre-remount."
> + _dump_files
> +fi
> +_scratch_cycle_mount
> +echo "==== Post-Remount =="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match post-remount."
> + _dump_files
> +fi
> +
> +status=0
> +exit
> diff --git a/tests/generic/758.out b/tests/generic/758.out
> new file mode 100644
> index 00000000..d01c1959
> --- /dev/null
> +++ b/tests/generic/758.out
> @@ -0,0 +1,3 @@
> +QA output created by 758
> +==== Pre-Remount ===
> +==== Post-Remount ==
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [xfstests PATCH v3] generic: add a partial pages zeroing out test
2025-01-09 18:19 ` Zorro Lang
@ 2025-01-10 2:05 ` Zhang Yi
0 siblings, 0 replies; 6+ messages in thread
From: Zhang Yi @ 2025-01-10 2:05 UTC (permalink / raw)
To: Zorro Lang
Cc: fstests, zlang, linux-fsdevel, tytso, adilger.kernel, jack, willy,
ojaswin, djwong, yi.zhang, chengzhihao1, yukuai3, yangerkun
On 2025/1/10 2:19, Zorro Lang wrote:
> On Wed, Jan 08, 2025 at 04:44:07PM +0800, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.com>
>>
>> This addresses a data corruption issue encountered during partial page
>> zeroing in ext4 which the block size is smaller than the page size [1].
>> Add a new test which is expanded upon generic/567, this test performs a
>> zeroing range test that spans two partial pages to cover this case, and
>> also generalize it to work for non-4k page sizes.
>>
>> Link: https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/ [1]
>> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
>> ---
>> v2->v3:
>> - Put the verifyfile in $SCRATCH_MNT and remove the overriding
>> _cleanup.
>> - Correct the test name.
>> v1->v2:
>> - Add a new test instead of modifying generic/567.
>> - Generalize the test to work for non-4k page sizes.
>> v2: https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
>> v1: https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
>>
>> tests/generic/758 | 68 +++++++++++++++++++++++++++++++++++++++++++
>> tests/generic/758.out | 3 ++
>> 2 files changed, 71 insertions(+)
>> create mode 100755 tests/generic/758
>> create mode 100644 tests/generic/758.out
>>
>> diff --git a/tests/generic/758 b/tests/generic/758
>> new file mode 100755
>> index 00000000..bf0a342b
>> --- /dev/null
>> +++ b/tests/generic/758
>> @@ -0,0 +1,68 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Huawei. All Rights Reserved.
>> +#
>> +# FS QA Test No. 758
>> +#
>> +# Test mapped writes against zero-range to ensure we get the data
>> +# correctly written. This can expose data corruption bugs on filesystems
>> +# where the block size is smaller than the page size.
>> +#
>> +# (generic/567 is a similar test but for punch hole.)
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick rw zero
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +
>> +_require_scratch
>> +_require_xfs_io_command "fzero"
>> +
>> +verifyfile=$SCRATCH_MNT/verifyfile
>> +testfile=$SCRATCH_MNT/testfile
>> +
>> +pagesz=$(getconf PAGE_SIZE)
>
> There's a common helper "_get_page_size" to do this.
>
Ha, I missed this, thanks for point this out.
>> +
>> +_scratch_mkfs > /dev/null 2>&1
>> +_scratch_mount
>> +
>> +_dump_files()
>> +{
>> + echo "---- testfile ----"
>> + _hexdump $testfile
>> + echo "---- verifyfile --"
>> + _hexdump $verifyfile
>> +}
>> +
>> +# Build verify file, the data in this file should be consistent with
>> +# that in the test file.
>> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
>> + -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
>> + $verifyfile | _filter_xfs_io >> /dev/null
> ????????
> >> $seqres.full ?
I think both of these are okay, write to $seqres.full also looks fine
to me.
>
>> +
>> +# Zero out straddling two pages to check that the mapped write after the
>> +# range-zeroing are correctly handled.
>> +$XFS_IO_PROG -t -f \
>> + -c "pwrite -S 0x58 0 $((pagesz * 3))" \
>> + -c "mmap -rw 0 $((pagesz * 3))" \
>> + -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
>> + -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
>> + -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
>> + -c "close" \
>> +$testfile | _filter_xfs_io > $seqres.full
> ^^
> >> $seqres.full
>
> I'll help to make above tiny changes when I merge it, others looks good
> to me.
>
> Reviewed-by: Zorro Lang <zlang@redhat.com>
Thanks.
Yi.
>
>> +
>> +echo "==== Pre-Remount ==="
>> +if ! cmp -s $testfile $verifyfile; then
>> + echo "Data does not match pre-remount."
>> + _dump_files
>> +fi
>> +_scratch_cycle_mount
>> +echo "==== Post-Remount =="
>> +if ! cmp -s $testfile $verifyfile; then
>> + echo "Data does not match post-remount."
>> + _dump_files
>> +fi
>> +
>> +status=0
>> +exit
>> diff --git a/tests/generic/758.out b/tests/generic/758.out
>> new file mode 100644
>> index 00000000..d01c1959
>> --- /dev/null
>> +++ b/tests/generic/758.out
>> @@ -0,0 +1,3 @@
>> +QA output created by 758
>> +==== Pre-Remount ===
>> +==== Post-Remount ==
>> --
>> 2.39.2
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [xfstests PATCH v3] generic: add a partial pages zeroing out test
2025-01-08 8:44 [xfstests PATCH v3] generic: add a partial pages zeroing out test Zhang Yi
` (2 preceding siblings ...)
2025-01-09 18:19 ` Zorro Lang
@ 2025-01-10 5:52 ` Nirjhar Roy (IBM)
3 siblings, 0 replies; 6+ messages in thread
From: Nirjhar Roy (IBM) @ 2025-01-10 5:52 UTC (permalink / raw)
To: Zhang Yi, fstests, zlang
Cc: linux-fsdevel, tytso, adilger.kernel, jack, willy, ojaswin,
djwong, yi.zhang, chengzhihao1, yukuai3, yangerkun
On Wed, 2025-01-08 at 16:44 +0800, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> This addresses a data corruption issue encountered during partial
> page
> zeroing in ext4 which the block size is smaller than the page size
> [1].
> Add a new test which is expanded upon generic/567, this test performs
> a
> zeroing range test that spans two partial pages to cover this case,
> and
> also generalize it to work for non-4k page sizes.
>
> Link:
> https://lore.kernel.org/linux-ext4/20241220011637.1157197-2-yi.zhang@huaweicloud.com/
> [1]
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> v2->v3:
> - Put the verifyfile in $SCRATCH_MNT and remove the overriding
> _cleanup.
> - Correct the test name.
> v1->v2:
> - Add a new test instead of modifying generic/567.
> - Generalize the test to work for non-4k page sizes.
> v2:
> https://lore.kernel.org/fstests/20241225125120.1952219-1-yi.zhang@huaweicloud.com/
> v1:
> https://lore.kernel.org/fstests/20241223023930.2328634-1-yi.zhang@huaweicloud.com/
>
> tests/generic/758 | 68
> +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/758.out | 3 ++
> 2 files changed, 71 insertions(+)
> create mode 100755 tests/generic/758
> create mode 100644 tests/generic/758.out
>
> diff --git a/tests/generic/758 b/tests/generic/758
> new file mode 100755
> index 00000000..bf0a342b
> --- /dev/null
> +++ b/tests/generic/758
> @@ -0,0 +1,68 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Huawei. All Rights Reserved.
> +#
> +# FS QA Test No. 758
> +#
> +# Test mapped writes against zero-range to ensure we get the data
> +# correctly written. This can expose data corruption bugs on
> filesystems
> +# where the block size is smaller than the page size.
> +#
> +# (generic/567 is a similar test but for punch hole.)
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw zero
> +
> +# Import common functions.
> +. ./common/filter
> +
> +_require_scratch
> +_require_xfs_io_command "fzero"
> +
> +verifyfile=$SCRATCH_MNT/verifyfile
> +testfile=$SCRATCH_MNT/testfile
> +
> +pagesz=$(getconf PAGE_SIZE)
you can directly use _get_page_size() function in common/rc
pagesz=$(_get_page_size)
> +
> +_scratch_mkfs > /dev/null 2>&1
> +_scratch_mount
> +
> +_dump_files()
> +{
> + echo "---- testfile ----"
> + _hexdump $testfile
> + echo "---- verifyfile --"
> + _hexdump $verifyfile
> +}
> +
> +# Build verify file, the data in this file should be consistent with
> +# that in the test file.
> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "pwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + $verifyfile | _filter_xfs_io >> /dev/null
> +
> +# Zero out straddling two pages to check that the mapped write after
> the
> +# range-zeroing are correctly handled.
> +$XFS_IO_PROG -t -f \
> + -c "pwrite -S 0x58 0 $((pagesz * 3))" \
> + -c "mmap -rw 0 $((pagesz * 3))" \
> + -c "mwrite -S 0x5a $((pagesz / 2)) $((pagesz * 2))" \
> + -c "fzero $((pagesz / 2)) $((pagesz * 2))" \
> + -c "mwrite -S 0x59 $((pagesz / 2)) $((pagesz * 2))" \
> + -c "close" \
> +$testfile | _filter_xfs_io > $seqres.full
> +
> +echo "==== Pre-Remount ==="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match pre-remount."
> + _dump_files
Extremely minor: Maybe exit the test if data mismatch takes place pre-
mount since, post mount it will definitely mismatch right?
> +fi
> +_scratch_cycle_mount
> +echo "==== Post-Remount =="
> +if ! cmp -s $testfile $verifyfile; then
> + echo "Data does not match post-remount."
> + _dump_files
Minor: Maybe redirect the content of _dump_file to $seqres.full, just
to keep the stdout diff clean in case of mismatch?
--NR
> +fi
> +
> +status=0
> +exit
> diff --git a/tests/generic/758.out b/tests/generic/758.out
> new file mode 100644
> index 00000000..d01c1959
> --- /dev/null
> +++ b/tests/generic/758.out
> @@ -0,0 +1,3 @@
> +QA output created by 758
> +==== Pre-Remount ===
> +==== Post-Remount ==
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-10 5:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 8:44 [xfstests PATCH v3] generic: add a partial pages zeroing out test Zhang Yi
2025-01-08 16:56 ` Darrick J. Wong
2025-01-09 13:06 ` Ojaswin Mujoo
2025-01-09 18:19 ` Zorro Lang
2025-01-10 2:05 ` Zhang Yi
2025-01-10 5:52 ` Nirjhar Roy (IBM)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox