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
64 send_files_dir=$TEST_DIR/btrfs-test-$seq
67 rm -fr $send_files_dir
70 _scratch_mkfs >/dev/null 2>&1
73 mkdir $SCRATCH_MNT/testdir
74 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/first_subvol
76 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
78 # Replace the directory testdir with a subvolume that has the same name.
79 rmdir $SCRATCH_MNT/testdir
80 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/testdir
82 # Delete the subvolume first_subvol and create a directory with the same name.
83 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/first_subvol
84 mkdir $SCRATCH_MNT/first_subvol
86 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
88 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
89 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap2 -p $SCRATCH_MNT/mysnap1 \
90 -f $send_files_dir/2.snap
95 _scratch_mkfs >/dev/null 2>&1
98 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
99 [ -e $SCRATCH_MNT/first_subvol ] && \
100 echo "Subvolume first_subvol was not supposed to be replicated by full send!"
102 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
103 [ -e $SCRATCH_MNT/testdir ] && \
104 echo "Directory testdir was supposed to be deleted after incremental send!"