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
49 send_files_dir=$TEST_DIR/btrfs-test-$seq
52 rm -fr $send_files_dir
55 _scratch_mkfs >/dev/null 2>&1
58 mkdir $SCRATCH_MNT/testdir
59 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/first_subvol
61 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
63 # Replace the directory testdir with a subvolume that has the same name.
64 rmdir $SCRATCH_MNT/testdir
65 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/testdir
67 # Delete the subvolume first_subvol and create a directory with the same name.
68 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/first_subvol
69 mkdir $SCRATCH_MNT/first_subvol
71 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
73 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
74 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
80 _scratch_mkfs >/dev/null 2>&1
83 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
84 [ -e $SCRATCH_MNT/first_subvol ] && \
85 echo "Subvolume first_subvol was not supposed to be replicated by full send!"
87 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
88 [ -e $SCRATCH_MNT/testdir ] && \
89 echo "Directory testdir was supposed to be deleted after incremental send!"