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
34 send_files_dir=$TEST_DIR/btrfs-test-$seq
37 rm -fr $send_files_dir
40 _scratch_mkfs >>$seqres.full 2>&1
44 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 32K" $SCRATCH_MNT/foo | _filter_xfs_io
46 # Create the first snapshot.
47 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
49 echo "File digest in the first filesystem, first snapshot:"
50 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
52 # Save send stream for this snapshot.
53 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/snap1
55 # Create a new filesystem and receive the snapshot.
57 _scratch_mkfs >>$seqres.full 2>&1
60 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
62 echo "File digest in the second filesystem, first snapshot:"
63 # Must match the digest we got in the first filesystem.
64 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
66 # Snapshot the first snapshot as rw, modify this new snapshot and then snapshot
67 # it as RO to use in a send operation (send requires RO snapshots).
68 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT/snap1 $SCRATCH_MNT/snap2_rw
70 $XFS_IO_PROG -c "pwrite -S 0xbb 4K 4K" \
71 $SCRATCH_MNT/snap2_rw/foo | _filter_xfs_io
73 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/snap2_rw \
76 echo "File digest in the second filesystem, second snapshot:"
77 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
79 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2.snap \
82 # Create a new filesystem and receive both the first snapshot, through the first
83 # send stream we created, and the second snapshot through the incremental send
84 # stream we just created. Verify this works and the file data is correct in both
87 _scratch_mkfs >>$seqres.full 2>&1
90 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
91 # Receiving the second snapshot used to fail because the send stream used an
92 # incorrect value for the clone sources uuid field - it used the uuid of
93 # snapshot 1, which is different on each filesystem, instead of the received
94 # uuid value, which is preserved across different filesystems.
95 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
97 echo "File digests in the third filesystem:"
98 # Must match the digests we got in the previous filesystems.
99 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
100 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch