ceph/006: test snapshot data integrity after punch hole operations
PATCH 1/1 ceph/006: test snapshot data integrity after punch hole operations
Add test to verify that Ceph snapshots preserve original file data when the live file is modified with punch hole operations. The test creates a file, takes a snapshot, punches multiple holes in the original file, then verifies the snapshot data remains unchanged.
--- tests/ceph/006 | 58 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/006.out | 2 ++ 2 files changed, 60 insertions(+) create mode 100755 tests/ceph/006 create mode 100644 tests/ceph/006.out
tests/ceph/006 new file +58 -0
@@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Synology All Rights Reserved. +# +# FS QA Test No. ceph/006 +# +# Test that snapshot data remains intact after punch hole operations +# on the original file. +# +. ./common/preamble +_begin_fstest auto quick snapshot + +. common/filter + +_require_test +_require_xfs_io_command "pwrite" +_require_xfs_io_command "fpunch" +_exclude_test_mount_option "test_dummy_encryption" + +# TODO: Update with final commit SHA when merged +_fixed_by_kernel_commit 1b7b474b3a78 \ + "ceph: fix snapshot context missing in ceph_zero_partial_object" + +workdir=$TEST_DIR/test-$seq +snapdir=$workdir/.snap/snap1 +rmdir $snapdir 2>/dev/null +rm -rf $workdir +mkdir $workdir + +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1048576" $workdir/foo > /dev/null + +mkdir $snapdir + +original_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +# Punch several holes of various sizes at different offsets +$XFS_IO_PROG -c "fpunch 0 4096" $workdir/foo +$XFS_IO_PROG -c "fpunch 16384 8192" $workdir/foo +$XFS_IO_PROG -c "fpunch 65536 16384" $workdir/foo +$XFS_IO_PROG -c "fpunch 262144 32768" $workdir/foo +$XFS_IO_PROG -c "fpunch 1024000 4096" $workdir/foo + +# Make sure we don't read from cache +echo 3 > /proc/sys/vm/drop_caches + +snapshot_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +if [ "$original_md5" != "$snapshot_md5" ]; then + echo "FAIL: Snapshot data changed after punch hole operations" + echo "Original md5sum: $original_md5" + echo "Snapshot md5sum: $snapshot_md5" +fi + +echo "Silence is golden" + +# success, all done +status=0 +exit
tests/ceph/006.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 006 +Silence is golden
Signature · 4 lines
2.43.0 Disclaimer: The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.
Quoted 83 lines · ethanwu
Add test to verify that Ceph snapshots preserve original file data when the live file is modified with punch hole operations. The test creates a file, takes a snapshot, punches multiple holes in the original file, then verifies the snapshot data remains unchanged.
Signed-off-by ethanwu <[email protected]>--- tests/ceph/006 | 58 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/006.out | 2 ++ 2 files changed, 60 insertions(+) create mode 100755 tests/ceph/006 create mode 100644 tests/ceph/006.outtests/ceph/006 new file +58
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Synology All Rights Reserved. +# +# FS QA Test No. ceph/006 +# +# Test that snapshot data remains intact after punch hole operations +# on the original file. +# +. ./common/preamble +_begin_fstest auto quick snapshot + +. common/filter + +_require_test +_require_xfs_io_command "pwrite" +_require_xfs_io_command "fpunch" +_exclude_test_mount_option "test_dummy_encryption" + +# TODO: Update with final commit SHA when merged +_fixed_by_kernel_commit 1b7b474b3a78 \ + "ceph: fix snapshot context missing in ceph_zero_partial_object" + +workdir=$TEST_DIR/test-$seq +snapdir=$workdir/.snap/snap1 +rmdir $snapdir 2>/dev/null +rm -rf $workdir +mkdir $workdir + +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1048576" $workdir/foo > /dev/null + +mkdir $snapdir + +original_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +# Punch several holes of various sizes at different offsets +$XFS_IO_PROG -c "fpunch 0 4096" $workdir/foo +$XFS_IO_PROG -c "fpunch 16384 8192" $workdir/foo +$XFS_IO_PROG -c "fpunch 65536 16384" $workdir/foo +$XFS_IO_PROG -c "fpunch 262144 32768" $workdir/foo +$XFS_IO_PROG -c "fpunch 1024000 4096" $workdir/foo + +# Make sure we don't read from cache +echo 3 > /proc/sys/vm/drop_caches + +snapshot_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +if [ "$original_md5" != "$snapshot_md5" ]; then + echo "FAIL: Snapshot data changed after punch hole operations" + echo "Original md5sum: $original_md5" + echo "Snapshot md5sum: $snapshot_md5" +fi + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/006.out new file +0
-0
tests/ceph/006.out line 2
Quoted 2 lines
tests/ceph/006.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 006 +Silence is golden
One idea has crossed my mind. I think we need to check somehow that snapshots support has been enabled. Otherwise, I believe that test will fail. But it will be better to inform about necessity to enable the snapshots support.
Thanks,
Slava.
A message that is not in the archive (sent off-list or not yet received): d6b17cbb-3504-4c3c-9f31-35c538248503@Mail
Quoted 108 lines · ethanwu
Viacheslav Dubeyko <Slava. Dubeyko@ ibm. com> 於 2025-10-01 02: 24 寫道: On Tue, 2025-09-30 at 15: 57 +0800, ethanwu wrote: > Add test to verify that Ceph snapshots preserve original file data > when the live file is modified with punch
Viacheslav Dubeyko <[email protected]> 於 2025-10-01 02:24 寫道:Quoted 91 lines · ethanwu
Quoted 83 lines
Add test to verify that Ceph snapshots preserve original file data when the live file is modified with punch hole operations. The test creates a file, takes a snapshot, punches multiple holes in the original file, then verifies the snapshot data remains unchanged.
Signed-off-by ethanwu <[email protected]>---
tests/ceph/006 | 58 ++++++++++++++++++++++++++++++++++++++++++++++
tests/ceph/006.out | 2 ++2 files changed, 60 insertions(+)create mode 100755 tests/ceph/006
create mode 100644 tests/ceph/006.outtests/ceph/006 new file +58
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Synology All Rights Reserved. +# +# FS QA Test No. ceph/006 +# +# Test that snapshot data remains intact after punch hole operations +# on the original file. +# +. ./common/preamble +_begin_fstest auto quick snapshot + +. common/filter + +_require_test +_require_xfs_io_command "pwrite" +_require_xfs_io_command "fpunch" +_exclude_test_mount_option "test_dummy_encryption" + +# TODO: Update with final commit SHA when merged +_fixed_by_kernel_commit 1b7b474b3a78 \ + "ceph: fix snapshot context missing in ceph_zero_partial_object" + +workdir=$TEST_DIR/test-$seq +snapdir=$workdir/.snap/snap1 +rmdir $snapdir 2>/dev/null +rm -rf $workdir +mkdir $workdir + +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1048576" $workdir/foo > /dev/null + +mkdir $snapdir + +original_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +# Punch several holes of various sizes at different offsets +$XFS_IO_PROG -c "fpunch 0 4096" $workdir/foo +$XFS_IO_PROG -c "fpunch 16384 8192" $workdir/foo +$XFS_IO_PROG -c "fpunch 65536 16384" $workdir/foo +$XFS_IO_PROG -c "fpunch 262144 32768" $workdir/foo +$XFS_IO_PROG -c "fpunch 1024000 4096" $workdir/foo + +# Make sure we don't read from cache +echo 3 > /proc/sys/vm/drop_caches + +snapshot_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +if [ "$original_md5" != "$snapshot_md5" ]; then + echo "FAIL: Snapshot data changed after punch hole operations" + echo "Original md5sum: $original_md5" + echo "Snapshot md5sum: $snapshot_md5" +fi + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/006.out new file +0
-0tests/ceph/006.out line 2
Quoted 2 lines
tests/ceph/006.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 006 +Silence is goldenOne idea has crossed my mind. I think we need to check somehow that snapshots support has been enabled. Otherwise, I believe that test will fail. But it will be better to inform about necessity to enable the snapshots support.
Quoted 2 lines
Thanks,
Slava.OK, I'll add the following into common/ceph
(quoted diff) +7
-0+# this test requires ceph snapshot support +_require_ceph_snapshot() +{ + local test_snapdir="$TEST_DIR/.snap/test_snap_$$" + mkdir "$test_snapdir" 2>/dev/null || _notrun "Ceph snapshots not supported (requires fs flag 'allow_snaps' and client auth capability 'snap')" + rmdir "$test_snapdir" +}
Quoted 7 lines
and add
+_require_ceph_snapshot
in ceph/006
is this check and error message clear enough?
Looks good. I believe it looks reasonably enough. :)
Thanks,
Slava.
Quoted 88 lines · Viacheslav Dubeyko
Quoted 87 lines · ethanwu
Viacheslav Dubeyko <Slava. Dubeyko@ ibm. com> 於 2025-10-01 02: 24 寫道: On Tue, 2025-09-30 at 15: 57 +0800, ethanwu wrote: > Add test to verify that Ceph snapshots preserve original file data > when the live file is modified with punch
Viacheslav Dubeyko <[email protected]> 於 2025-10-01 02:24 寫道:Quoted 82 lines · ethanwu
Quoted 81 lines
Add test to verify that Ceph snapshots preserve original file data when the live file is modified with punch hole operations. The test creates a file, takes a snapshot, punches multiple holes in the original file, then verifies the snapshot data remains unchanged.
Signed-off-by ethanwu <[email protected]>---
tests/ceph/006 | 58 ++++++++++++++++++++++++++++++++++++++++++++++
tests/ceph/006.out | 2 ++2 files changed, 60 insertions(+)create mode 100755 tests/ceph/006
create mode 100644 tests/ceph/006.outtests/ceph/006 new file +58
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Synology All Rights Reserved. +# +# FS QA Test No. ceph/006 +# +# Test that snapshot data remains intact after punch hole operations +# on the original file. +# +. ./common/preamble +_begin_fstest auto quick snapshot + +. common/filter + +_require_test +_require_xfs_io_command "pwrite" +_require_xfs_io_command "fpunch" +_exclude_test_mount_option "test_dummy_encryption" + +# TODO: Update with final commit SHA when merged +_fixed_by_kernel_commit 1b7b474b3a78 \ + "ceph: fix snapshot context missing in ceph_zero_partial_object" + +workdir=$TEST_DIR/test-$seq +snapdir=$workdir/.snap/snap1 +rmdir $snapdir 2>/dev/null +rm -rf $workdir +mkdir $workdir + +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1048576" $workdir/foo > /dev/null + +mkdir $snapdir + +original_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +# Punch several holes of various sizes at different offsets +$XFS_IO_PROG -c "fpunch 0 4096" $workdir/foo +$XFS_IO_PROG -c "fpunch 16384 8192" $workdir/foo +$XFS_IO_PROG -c "fpunch 65536 16384" $workdir/foo +$XFS_IO_PROG -c "fpunch 262144 32768" $workdir/foo +$XFS_IO_PROG -c "fpunch 1024000 4096" $workdir/foo + +# Make sure we don't read from cache +echo 3 > /proc/sys/vm/drop_caches + +snapshot_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +if [ "$original_md5" != "$snapshot_md5" ]; then + echo "FAIL: Snapshot data changed after punch hole operations" + echo "Original md5sum: $original_md5" + echo "Snapshot md5sum: $snapshot_md5" +fi + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/006.out new file +0
-1--- /dev/null
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tests/ceph/006.out line 2
Quoted 4 lines
+++ b/tests/ceph/006.out
tests/ceph/006.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 006 +Silence is goldenOne idea has crossed my mind. I think we need to check somehow that snapshots support has been enabled. Otherwise, I believe that test will fail. But it will be better to inform about necessity to enable the snapshots support.
Weird, not sure why I didn't get this email ...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Thanks,
Slava.
Quoted 8 lines
Review
Quoted 8 lines
OK, I'll add the following into common/ceph
(quoted diff) +6
-0+# this test requires ceph snapshot support +_require_ceph_snapshot() +{ + local test_snapdir="$TEST_DIR/.snap/test_snap_$$" + mkdir "$test_snapdir" 2>/dev/null || _notrun "Ceph snapshots not supported (requires fs flag 'allow_snaps' and client auth capability 'snap')" + rmdir "$test_snapdir"
So ".snap" directory is a ceph specific directory for snapshot. Sorry, I never used ceph, I'm wondering, if ceph snapshot feature isn't supported, users can't create any directory with "." prefix, or only can't create ".snap" in ceph? Due to ".snap" directory can be created in general filesystems (no special meaning):
$ mkdir .snap $ ls -ld .snap drwxr-xr-x. 2 zorro zorro 6 Oct 2 15:09 .snap $ rm -rf .snap
Thanks,
Zorro
Quoted 13 lines
Quoted 8 lines
+}
and add
+_require_ceph_snapshot
in ceph/006
is this check and error message clear enough?Looks good. I believe it looks reasonably enough. :)
Thanks,
Slava.
Quoted 7 lines · ethanwu
Add test to verify that Ceph snapshots preserve original file data when the live file is modified with punch hole operations. The test creates a file, takes a snapshot, punches multiple holes in the original file, then verifies the snapshot data remains unchanged.
Signed-off-by ethanwu <[email protected]>---
Thanks for the new test case from ceph list :) I have two questions about this patch (see below...)
Quoted 15 lines
tests/ceph/006 | 58 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/006.out | 2 ++ 2 files changed, 60 insertions(+) create mode 100755 tests/ceph/006 create mode 100644 tests/ceph/006.outtests/ceph/006 new file +3
-0@@ -0,0 +1,58 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2025 Synology All Rights Reserved.
tests/ceph/006 line 13
Quoted 10 lines
tests/ceph/006 new file +10
-0+# +# FS QA Test No. ceph/006 +# +# Test that snapshot data remains intact after punch hole operations +# on the original file. +# +. ./common/preamble +_begin_fstest auto quick snapshot + +. common/filter
I didn't see you use any filter helpers, this might not needed :)
tests/ceph/006 line 22
Quoted 9 lines
tests/ceph/006 new file +9
-0+ +_require_test +_require_xfs_io_command "pwrite" +_require_xfs_io_command "fpunch" +_exclude_test_mount_option "test_dummy_encryption" + +# TODO: Update with final commit SHA when merged +_fixed_by_kernel_commit 1b7b474b3a78 \ + "ceph: fix snapshot context missing in ceph_zero_partial_object"
This test case uncovers a ceph known issue, but I didn't find any ceph specific test steps in this case, so how about move this case to be a generic test case (in tests/generic/ directory) ?
Quoted 9 lines
tests/ceph/006 new file +9
-0+ +workdir=$TEST_DIR/test-$seq +snapdir=$workdir/.snap/snap1 +rmdir $snapdir 2>/dev/null +rm -rf $workdir +mkdir $workdir + +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1048576" $workdir/foo > /dev/null +
tests/ceph/006 line 41
Quoted 10 lines
tests/ceph/006 new file +10
-0+mkdir $snapdir + +original_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +# Punch several holes of various sizes at different offsets +$XFS_IO_PROG -c "fpunch 0 4096" $workdir/foo +$XFS_IO_PROG -c "fpunch 16384 8192" $workdir/foo +$XFS_IO_PROG -c "fpunch 65536 16384" $workdir/foo +$XFS_IO_PROG -c "fpunch 262144 32768" $workdir/foo +$XFS_IO_PROG -c "fpunch 1024000 4096" $workdir/foo
We're used to 4k block size by default, but now the LBS(large block size) is more and more popularizes, so if you can reproduce this bug after replace above 4k with 64k, how about using bigger hole size.
Quoted 31 lines
tests/ceph/006 new file +17
-0+ +# Make sure we don't read from cache +echo 3 > /proc/sys/vm/drop_caches + +snapshot_md5=$(md5sum $snapdir/foo | cut -d' ' -f1) + +if [ "$original_md5" != "$snapshot_md5" ]; then + echo "FAIL: Snapshot data changed after punch hole operations" + echo "Original md5sum: $original_md5" + echo "Snapshot md5sum: $snapshot_md5" +fi + +echo "Silence is golden" + +# success, all done +status=0 +exittests/ceph/006.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 006 +Silence is goldenSignature · 4 lines
2.43.0 Disclaimer: The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.