2 # FS QA Test No. btrfs/054
4 # Regression test for a btrfs incremental send issue where the difference
5 # between the snapshots used by the incremental send consists of one of
8 # 1) First snapshot has a directory with name X and in the second snapshot
9 # that directory doesn't exist anymore but a subvolume/snapshot with
10 # the same name (X) exists;
12 # 2) First snapshot has a subvolume/snapshot with name X and in the second
13 # snapshot that subvolume/snapshot doesn't exist anymore (might have been
14 # replaced by a directory with the same name or not).
16 # This issue is fixed by the following linux kernel btrfs patches:
18 # Btrfs: send, don't error in the presence of subvols/snapshots
19 # Btrfs: set dead flag on the right root when destroying snapshot
21 #-----------------------------------------------------------------------
22 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
24 # This program is free software; you can redistribute it and/or
25 # modify it under the terms of the GNU General Public License as
26 # published by the Free Software Foundation.
28 # This program is distributed in the hope that it would be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 # GNU General Public License for more details.
33 # You should have received a copy of the GNU General Public License
34 # along with this program; if not, write the Free Software Foundation,
35 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 #-----------------------------------------------------------------------
40 seqres=$RESULT_DIR/$seq
41 echo "QA output created by $seq"
44 status=1 # failure is the default!
45 trap "_cleanup; exit \$status" 0 1 2 3 15
49 rm -fr $send_files_dir
53 # get standard environment, filters and checks
58 # real QA test starts here
65 send_files_dir=$TEST_DIR/btrfs-test-$seq
68 rm -fr $send_files_dir
71 _scratch_mkfs >/dev/null 2>&1
74 mkdir $SCRATCH_MNT/testdir
75 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/first_subvol
77 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
79 # Replace the directory testdir with a subvolume that has the same name.
80 rmdir $SCRATCH_MNT/testdir
81 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/testdir
83 # Delete the subvolume first_subvol and create a directory with the same name.
84 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/first_subvol
85 mkdir $SCRATCH_MNT/first_subvol
87 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
89 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
90 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap2 -p $SCRATCH_MNT/mysnap1 \
91 -f $send_files_dir/2.snap
96 _scratch_mkfs >/dev/null 2>&1
99 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
100 [ -e $SCRATCH_MNT/first_subvol ] && \
101 echo "Subvolume first_subvol was not supposed to be replicated by full send!"
103 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
104 [ -e $SCRATCH_MNT/testdir ] && \
105 echo "Directory testdir was supposed to be deleted after incremental send!"