xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / btrfs / 129
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/129
6 #
7 # Test that an incremental send operation does not prematurely issues rmdir
8 # operations under a particular scenario (the rmdir operation is sent before
9 # the target directory is empty).
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -fr $send_files_dir
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_test
33 _require_scratch
34 _require_fssum
35
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
37
38 rm -f $seqres.full
39 rm -fr $send_files_dir
40 mkdir $send_files_dir
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 mkdir $SCRATCH_MNT/a
46 mkdir $SCRATCH_MNT/tmp
47 mkdir $SCRATCH_MNT/del
48 mv $SCRATCH_MNT/tmp $SCRATCH_MNT/del
49 mkdir $SCRATCH_MNT/a/c
50 mkdir $SCRATCH_MNT/del/x
51
52 # Filesystem looks like:
53 #
54 # .                                                             (ino 256)
55 # |--- a/                                                       (ino 257)
56 # |    |--- c/                                                  (ino 260)
57 # |
58 # |--- del/                                                     (ino 259)
59 #       |--- tmp/                                               (ino 258)
60 #       |--- x/                                                 (ino 261)
61 #
62 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
63
64 # When inode 260 was processed, rename operations for it and for inode 258 were
65 # issued (the rename for inode 260 must happen before the rename for inode 258).
66 # Then immediately after issuing the rename operation for inode 258, and before
67 # inode 261 was processed, the send stream issued a rmdir operation for inode
68 # 260, which would make the receiver fail with the error ENOTEMPTY because inode
69 # 261 was not yet renamed, it was still a child of inode 260 at that time.
70 #
71 mv $SCRATCH_MNT/a/c $SCRATCH_MNT
72 mv $SCRATCH_MNT/del/x $SCRATCH_MNT/a
73 mv $SCRATCH_MNT/del/tmp $SCRATCH_MNT/c
74 rmdir $SCRATCH_MNT/del
75
76 # Filesystem now looks like:
77 #
78 # .                                                             (ino 256)
79 # |--- a/                                                       (ino 257)
80 # |    |--- x/                                                  (ino 261)
81 # |
82 # |--- c/                                                       (ino 260)
83 #      |--- tmp/                                                (ino 258)
84 #
85 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
86
87 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
88 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
89         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
90
91 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
92 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
93         $SCRATCH_MNT/mysnap2
94
95 # Now recreate the filesystem by receiving both send streams and verify we get
96 # the same content that the original filesystem had.
97 _scratch_unmount
98 _scratch_mkfs >>$seqres.full 2>&1
99 _scratch_mount
100
101 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
102 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
103 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
104 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
105
106 echo "Silence is golden"
107 status=0
108 exit