2 # FS QA Test No. btrfs/152
4 # Test that incremental send/receive operations don't corrupt metadata when
7 #-----------------------------------------------------------------------
9 # Copyright (c) 2017 NETGEAR, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
44 # real QA test starts here
51 _scratch_mkfs >>$seqres.full 2>&1
55 $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
57 # Create 2 source and 4 destination subvolumes
58 for subvol in subvol1 subvol2 recv1_1 recv1_2 recv2_1 recv2_2; do
59 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/$subvol | _filter_scratch
61 mkdir $SCRATCH_MNT/subvol{1,2}/.snapshots
62 touch $SCRATCH_MNT/subvol{1,2}/foo
64 # Create base snapshots and send them
65 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol1 \
66 $SCRATCH_MNT/subvol1/.snapshots/1 | _filter_scratch
67 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol2 \
68 $SCRATCH_MNT/subvol2/.snapshots/1 | _filter_scratch
69 for recv in recv1_1 recv1_2 recv2_1 recv2_2; do
70 $BTRFS_UTIL_PROG send $SCRATCH_MNT/subvol1/.snapshots/1 2> /dev/null | \
71 $BTRFS_UTIL_PROG receive $SCRATCH_MNT/${recv} | _filter_scratch
74 # Now do 10 loops of concurrent incremental send/receives
75 for i in `seq 1 10`; do
79 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol1 \
80 $SCRATCH_MNT/subvol1/.snapshots/${curr} > /dev/null
81 ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol1/.snapshots/${prev} \
82 $SCRATCH_MNT/subvol1/.snapshots/${curr} 2> /dev/null | \
83 $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv1_1) > /dev/null &
84 ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol1/.snapshots/${prev} \
85 $SCRATCH_MNT/subvol1/.snapshots/${curr} 2> /dev/null | \
86 $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv1_2) > /dev/null &
88 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol2 \
89 $SCRATCH_MNT/subvol2/.snapshots/${curr} > /dev/null
90 ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol2/.snapshots/${prev} \
91 $SCRATCH_MNT/subvol2/.snapshots/${curr} 2> /dev/null | \
92 $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv2_1) > /dev/null &
93 ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol2/.snapshots/${prev} \
94 $SCRATCH_MNT/subvol2/.snapshots/${curr} 2> /dev/null | \
95 $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv2_2) > /dev/null &