[PATCH] fstests: btrfs: test incremental send for changed reference paths

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: BingJing Chang <bingjingc@xxxxxxxxxxxx>

Normally btrfs stores reference paths in an array of ref items. However,
items for the same parent directory can not exceed the size of a leaf. So
btrfs also store the rest of them in extended ref items alternatively.

In this test, it creates a large number of links under a directory
causing the reference paths stored in these two ways as the parent
snapshot. And it deletes and recreates just an amount of them that can be
stored within an array of ref items as the send snapshot. Test that an
incremental send operation correctly issues link/unlink operations only
against new/deleted reference paths, or the receive operation will fail
due to a link on an existed path.

This currently fails on btrfs but is fixed by a kernel patch with the
following subject:

  "btrfs: send: fix sending link commands for existing file paths"

Signed-off-by: BingJing Chang <bingjingc@xxxxxxxxxxxx>
---
 tests/btrfs/272     | 65 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/272.out |  2 ++
 2 files changed, 67 insertions(+)
 create mode 100755 tests/btrfs/272
 create mode 100644 tests/btrfs/272.out

diff --git a/tests/btrfs/272 b/tests/btrfs/272
new file mode 100755
index 00000000..a362d943
--- /dev/null
+++ b/tests/btrfs/272
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 BingJing Chang.
+#
+# FS QA Test No. btrfs/272
+#
+# Regression test for btrfs incremental send issue where a link instruction
+# is sent against an existed file, causing btrfs receive to fail.
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#   btrfs: send: fix sending link commands for existing file paths
+#
+. ./common/preamble
+_begin_fstest auto quick send
+
+tmp=`mktemp -d`
+
+# Override the default cleanup function.
+_cleanup()
+{
+	rm -rf $tmp
+}
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_require_test
+_require_scratch
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/vol
+
+# create a file and 2000 hard links to the same inode
+touch $SCRATCH_MNT/vol/foo
+for i in {1..2000}; do
+	link $SCRATCH_MNT/vol/foo $SCRATCH_MNT/vol/$i
+done
+
+# take a snapshot for a parent snapshot
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/vol $SCRATCH_MNT/snap1
+
+# remove 2000 hard links and re-create the last 1000 links
+for i in {1..2000}; do
+	rm $SCRATCH_MNT/vol/$i
+done
+for i in {1001..2000}; do
+	link $SCRATCH_MNT/vol/foo $SCRATCH_MNT/vol/$i
+done
+
+# take another one for a send snapshot
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/vol $SCRATCH_MNT/snap2
+
+mkdir $SCRATCH_MNT/receive_dir
+_run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 -f $tmp/diff.snap \
+	$SCRATCH_MNT/snap2
+_run_btrfs_util_prog receive -f $tmp/diff.snap $SCRATCH_MNT/receive_dir
+_scratch_unmount
+
+echo "Silence is golden"
+status=0 ; exit
diff --git a/tests/btrfs/272.out b/tests/btrfs/272.out
new file mode 100644
index 00000000..c18563ad
--- /dev/null
+++ b/tests/btrfs/272.out
@@ -0,0 +1,2 @@
+QA output created by 272
+Silence is golden
-- 
2.37.1




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux