xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / btrfs / 110
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/110
6 #
7 # Test that sending and receiving snapshots across different filesystems works
8 # for full and incremental send operations.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -fr $send_files_dir
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30 _supported_fs btrfs
31 _require_scratch
32
33 send_files_dir=$TEST_DIR/btrfs-test-$seq
34
35 rm -f $seqres.full
36 rm -fr $send_files_dir
37 mkdir $send_files_dir
38
39 _scratch_mkfs >>$seqres.full 2>&1
40 _scratch_mount
41
42 # Create a test file
43 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 32K" $SCRATCH_MNT/foo | _filter_xfs_io
44
45 # Create the first snapshot.
46 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
47
48 echo "File digest in the first filesystem, first snapshot:"
49 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
50
51 # Save send stream for this snapshot.
52 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/snap1
53
54 # Create a new filesystem and receive the snapshot.
55 _scratch_unmount
56 _scratch_mkfs >>$seqres.full 2>&1
57 _scratch_mount
58
59 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
60
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
64
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
68
69 $XFS_IO_PROG -c "pwrite -S 0xbb 4K 4K" \
70         $SCRATCH_MNT/snap2_rw/foo | _filter_xfs_io
71
72 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/snap2_rw \
73         $SCRATCH_MNT/snap2
74
75 echo "File digest in the second filesystem, second snapshot:"
76 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
77
78 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2.snap \
79         $SCRATCH_MNT/snap2
80
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
84 # snapshots.
85 _scratch_unmount
86 _scratch_mkfs >>$seqres.full 2>&1
87 _scratch_mount
88
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
95
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
100
101 status=0
102 exit