2 # FS QA Test No. btrfs/129
4 # Test that an incremental send operation does not prematurely issues rmdir
5 # operations under a particular scenario (the rmdir operation is sent before
6 # the target directory is empty).
8 #-----------------------------------------------------------------------
9 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
10 # Author: Filipe Manana <fdmanana@suse.com>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 rm -fr $send_files_dir
42 # get standard environment, filters and checks
46 # real QA test starts here
53 send_files_dir=$TEST_DIR/btrfs-test-$seq
56 rm -fr $send_files_dir
59 _scratch_mkfs >>$seqres.full 2>&1
63 mkdir $SCRATCH_MNT/tmp
64 mkdir $SCRATCH_MNT/del
65 mv $SCRATCH_MNT/tmp $SCRATCH_MNT/del
66 mkdir $SCRATCH_MNT/a/c
67 mkdir $SCRATCH_MNT/del/x
69 # Filesystem looks like:
79 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
81 # When inode 260 was processed, rename operations for it and for inode 258 were
82 # issued (the rename for inode 260 must happen before the rename for inode 258).
83 # Then immediately after issuing the rename operation for inode 258, and before
84 # inode 261 was processed, the send stream issued a rmdir operation for inode
85 # 260, which would make the receiver fail with the error ENOTEMPTY because inode
86 # 261 was not yet renamed, it was still a child of inode 260 at that time.
88 mv $SCRATCH_MNT/a/c $SCRATCH_MNT
89 mv $SCRATCH_MNT/del/x $SCRATCH_MNT/a
90 mv $SCRATCH_MNT/del/tmp $SCRATCH_MNT/c
91 rmdir $SCRATCH_MNT/del
93 # Filesystem now looks like:
100 # |--- tmp/ (ino 258)
102 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
104 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
105 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
106 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
108 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
109 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
112 # Now recreate the filesystem by receiving both send streams and verify we get
113 # the same content that the original filesystem had.
115 _scratch_mkfs >>$seqres.full 2>&1
118 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
119 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
120 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
121 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
123 echo "Silence is golden"