2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/110
7 # Test that sending and receiving snapshots across different filesystems works
8 # for full and incremental send operations.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -fr $send_files_dir
25 # get standard environment, filters and checks
29 # real QA test starts here
33 send_files_dir=$TEST_DIR/btrfs-test-$seq
36 rm -fr $send_files_dir
39 _scratch_mkfs >>$seqres.full 2>&1
43 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 32K" $SCRATCH_MNT/foo | _filter_xfs_io
45 # Create the first snapshot.
46 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
48 echo "File digest in the first filesystem, first snapshot:"
49 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
51 # Save send stream for this snapshot.
52 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/snap1
54 # Create a new filesystem and receive the snapshot.
56 _scratch_mkfs >>$seqres.full 2>&1
59 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
61 echo "File digest in the second filesystem, first snapshot:"
62 # Must match the digest we got in the first filesystem.
63 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
65 # Snapshot the first snapshot as rw, modify this new snapshot and then snapshot
66 # it as RO to use in a send operation (send requires RO snapshots).
67 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT/snap1 $SCRATCH_MNT/snap2_rw
69 $XFS_IO_PROG -c "pwrite -S 0xbb 4K 4K" \
70 $SCRATCH_MNT/snap2_rw/foo | _filter_xfs_io
72 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/snap2_rw \
75 echo "File digest in the second filesystem, second snapshot:"
76 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
78 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2.snap \
81 # Create a new filesystem and receive both the first snapshot, through the first
82 # send stream we created, and the second snapshot through the incremental send
83 # stream we just created. Verify this works and the file data is correct in both
86 _scratch_mkfs >>$seqres.full 2>&1
89 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
90 # Receiving the second snapshot used to fail because the send stream used an
91 # incorrect value for the clone sources uuid field - it used the uuid of
92 # snapshot 1, which is different on each filesystem, instead of the received
93 # uuid value, which is preserved across different filesystems.
94 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
96 echo "File digests in the third filesystem:"
97 # Must match the digests we got in the previous filesystems.
98 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
99 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch