btrfs/139: require 2GB scratch dev
[xfstests-dev.git] / tests / btrfs / 039
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/039
6 #
7 # Regression test for a btrfs incremental send issue related to renaming of
8 # directories. If at the time of the initial send we have a directory that is
9 # a child of a directory with a higher inode number, and then later after the
10 # initial full send we rename both the child and parent directories, but
11 # without moving any of them, a subsequent incremental send would produce a
12 # rename instruction for the child directory that pointed to an invalid path.
13 # This made the btrfs receive operation fail.
14 #
15 # This issue is fixed by the following linux kernel btrfs patch:
16 #
17 #   Btrfs: incremental send, fix invalid path after dir rename
18 #
19 seq=`basename $0`
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
22
23 tmp=`mktemp -d`
24 status=1        # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 _cleanup()
28 {
29     rm -fr $tmp
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35
36 # real QA test starts here
37 _supported_fs btrfs
38 _supported_os Linux
39 _require_scratch
40 _require_fssum
41
42 rm -f $seqres.full
43
44 _scratch_mkfs >/dev/null 2>&1
45 _scratch_mount
46
47 mkdir -p $SCRATCH_MNT/a/b
48 mkdir $SCRATCH_MNT/d
49 mkdir $SCRATCH_MNT/a/b/c
50 mv $SCRATCH_MNT/d $SCRATCH_MNT/a/b/c
51 mkdir $SCRATCH_MNT/e
52 mkdir -p $SCRATCH_MNT/a/b/f/g
53 mv $SCRATCH_MNT/e $SCRATCH_MNT/a/b/f/g
54
55 # Filesystem looks like:
56 #
57 # .                      (ino 256)
58 # |-- a                  (ino 257)
59 #     |-- b              (ino 258)
60 #         |-- c          (ino 260)
61 #         |   |-- d      (ino 259)
62 #         |
63 #         |-- f          (ino 262)
64 #             |-- g      (ino 263)
65 #                 |-- e  (ino 261)
66
67 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
68
69 mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/a/b/x
70 mv $SCRATCH_MNT/a/b/x/d $SCRATCH_MNT/a/b/x/y
71 mv $SCRATCH_MNT/a/b/f $SCRATCH_MNT/a/b/w
72 mv $SCRATCH_MNT/a/b/w/g/e $SCRATCH_MNT/a/b/w/g/z
73
74 # Filesystem now looks like:
75 #
76 # .                      (ino 256)
77 # |-- a                  (ino 257)
78 #     |-- b              (ino 258)
79 #         |-- x          (ino 260)
80 #         |   |-- y      (ino 259)
81 #         |
82 #         |-- w          (ino 262)
83 #             |-- g      (ino 263)
84 #                 |-- z  (ino 261)
85
86 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
87
88 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
89 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
90         $SCRATCH_MNT/mysnap2
91
92 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
93 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
94         $SCRATCH_MNT/mysnap2
95
96 _scratch_unmount
97 _check_btrfs_filesystem $SCRATCH_DEV
98
99 _scratch_mkfs >/dev/null 2>&1
100 _scratch_mount
101
102 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
103 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
104
105 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
106 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
107
108 _scratch_unmount
109 _check_btrfs_filesystem $SCRATCH_DEV
110
111 status=0
112 exit