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 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/006.out | 2 ++ 2 files changed, 62 insertions(+) create mode 100755 tests/ceph/006 create mode 100644 tests/ceph/006.out
tests/ceph/006 new file +60 -0
@@ -0,0 +1,60 @@ +#!/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 +. common/punch + +_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 5 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.
As far as I can see, git complains during applying the patch:
git am ./\[EXTERNAL\]\ \[PATCH\]\ ceph_006\:\ test\ snapshot\ data\ integrity\
after\ punch\ hole\ operations.mbox
Applying: ceph/006: test snapshot data integrity after punch hole operations .git/rebase-apply/patch:73: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
You need to add:
__________________
SUBMITTING PATCHES
__________________
Send patches to the fstests mailing list at [email protected].
Quoted 80 lines
Signed-off-by ethanwu <[email protected]>--- tests/ceph/006 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tests/ceph/006.out | 2 ++ 2 files changed, 62 insertions(+) create mode 100755 tests/ceph/006 create mode 100644 tests/ceph/006.outtests/ceph/006 new file +60
-0@@ -0,0 +1,60 @@ +#!/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 +. common/punch + +_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 +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
./check ceph/006
FSTYP -- ceph
PLATFORM -- Linux/x86_64 6.17.0-rc6+ #47 SMP PREEMPT_DYNAMIC Thu Sep 25
12:43:59 PDT 2025MKFS_OPTIONS -- <system>:/scratchMOUNT_OPTIONS -- -o name=admin <system>:/scratch /mnt/cephfs/scratch
ceph/006 8s
Ran: ceph/006
Passed all 1 tests
Thanks,
Slava.