2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
5 # FS QA Test No. btrfs/054
7 # Regression test for a btrfs incremental send issue where the difference
8 # between the snapshots used by the incremental send consists of one of
11 # 1) First snapshot has a directory with name X and in the second snapshot
12 # that directory doesn't exist anymore but a subvolume/snapshot with
13 # the same name (X) exists;
15 # 2) First snapshot has a subvolume/snapshot with name X and in the second
16 # snapshot that subvolume/snapshot doesn't exist anymore (might have been
17 # replaced by a directory with the same name or not).
19 # This issue is fixed by the following linux kernel btrfs patches:
21 # Btrfs: send, don't error in the presence of subvols/snapshots
22 # Btrfs: set dead flag on the right root when destroying snapshot
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
34 rm -fr $send_files_dir
38 # get standard environment, filters and checks
43 # real QA test starts here
48 send_files_dir=$TEST_DIR/btrfs-test-$seq
51 rm -fr $send_files_dir
54 _scratch_mkfs >/dev/null 2>&1
57 mkdir $SCRATCH_MNT/testdir
58 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/first_subvol
60 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
62 # Replace the directory testdir with a subvolume that has the same name.
63 rmdir $SCRATCH_MNT/testdir
64 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/testdir
66 # Delete the subvolume first_subvol and create a directory with the same name.
67 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/first_subvol
68 mkdir $SCRATCH_MNT/first_subvol
70 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
72 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
73 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
79 _scratch_mkfs >/dev/null 2>&1
82 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
83 [ -e $SCRATCH_MNT/first_subvol ] && \
84 echo "Subvolume first_subvol was not supposed to be replicated by full send!"
86 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
87 [ -e $SCRATCH_MNT/testdir ] && \
88 echo "Directory testdir was supposed to be deleted after incremental send!"