xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 044
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/044
6 #
7 # Regression test for a btrfs incremental send issue where under certain
8 # scenarios invalid paths for utimes, chown and chmod operations were sent
9 # to the send stream, causing btrfs receive to fail.
10 #
11 # If a directory had a move/rename operation delayed, and none of its parent
12 # directories, except for the immediate one, had delayed move/rename operations,
13 # after processing the directory's references, the incremental send code would
14 # issue invalid paths for utimes, chown and chmod operations.
15 #
16 # This issue is fixed by the following linux kernel btrfs patch:
17 #
18 #   Btrfs: fix send issuing outdated paths for utimes, chown and chmod
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 tmp=`mktemp -d`
25 status=1        # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 _cleanup()
29 {
30     rm -fr $tmp
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36
37 # real QA test starts here
38 _supported_fs btrfs
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 umask 0
48 mkdir -p $SCRATCH_MNT/a/b/c/d/e
49 mkdir $SCRATCH_MNT/a/b/c/f
50 echo 'ola ' > $SCRATCH_MNT/a/b/c/d/e/file.txt
51 chmod 0777 $SCRATCH_MNT/a/b/c/d/e
52
53 # Filesystem looks like:
54 #
55 # .                                   (ino 256)
56 # |-- a/                              (ino 257)
57 #     |-- b/                          (ino 258)
58 #         |-- c/                      (ino 259)
59 #             |-- d/                  (ino 260)
60 #             |   |-- e/              (ino 261)
61 #             |       |-- file.txt    (ino 262)
62 #             |
63 #             |-- f/                  (ino 263)
64
65 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
66
67 echo 'mundo' >> $SCRATCH_MNT/a/b/c/d/e/file.txt
68 mv $SCRATCH_MNT/a/b/c/d/e/file.txt $SCRATCH_MNT/a/b/c/d/e/file2.txt
69 mv $SCRATCH_MNT/a/b/c/f $SCRATCH_MNT/a/b/f2
70 mv $SCRATCH_MNT/a/b/c/d/e $SCRATCH_MNT/a/b/f2/e2
71 mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/a/b/c2
72 mv $SCRATCH_MNT/a/b/c2/d $SCRATCH_MNT/a/b/c2/d2
73 chmod 0700 $SCRATCH_MNT/a/b/f2/e2
74
75 # Filesystem now looks like:
76 #
77 # .                              (ino 256)
78 # |-- a/                         (ino 257)
79 #     |-- b/                     (ino 258)
80 #         |-- c2/                (ino 259)
81 #         |   |-- d2/            (ino 260)
82 #         |
83 #         |-- f2/                (ino 263)
84 #             |-- e2             (ino 261)
85 #                 |-- file2.txt  (ino 263)
86
87 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
88
89 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
90 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
91         $SCRATCH_MNT/mysnap2
92
93 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
94 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
95         $SCRATCH_MNT/mysnap2
96
97 _check_scratch_fs
98
99 _scratch_unmount
100 _scratch_mkfs >/dev/null 2>&1
101 _scratch_mount
102
103 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
104 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1
105
106 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
107 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2
108
109 status=0
110 exit