generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 084
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/084
6 #
7 # Test for incremental send where the difference between the parent and send
8 # snapshots is that for a subtree with the same path in both snapshots (p1/p2),
9 # the root directories were swapped.
10 #
11 # This issue was fixed by the following linux kernel btrfs patch:
12 #
13 #   Btrfs: incremental send, clear name from cache after orphanization
14 #
15 . ./common/preamble
16 _begin_fstest auto quick send
17
18 # Override the default cleanup function.
19 _cleanup()
20 {
21         rm -fr $send_files_dir
22         rm -f $tmp.*
23 }
24
25 # Import common functions.
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs btrfs
30 _require_scratch
31 _require_fssum
32
33 send_files_dir=$TEST_DIR/btrfs-test-$seq
34
35 rm -fr $send_files_dir
36 mkdir $send_files_dir
37
38 _scratch_mkfs >>$seqres.full 2>&1
39 _scratch_mount
40
41 mkdir -p $SCRATCH_MNT/data/n1/n2/p1/p2
42 mkdir $SCRATCH_MNT/data/n4
43 mkdir -p $SCRATCH_MNT/data/p1/p2
44
45 # Filesystem looks like:
46 #
47 # .                                       (ino 256)
48 # |---- data                              (ino 257)
49 #         |---- n1/                       (ino 258)
50 #         |     |---- n2/                 (ino 259)
51 #         |           |---- p1/           (ino 260)
52 #         |                 |---- p2/     (ino 261)
53 #         |
54 #         |---- n4/                       (ino 262)
55 #         |---- p1/                       (ino 263)
56 #               |---- p2/                 (ino 264)
57 #
58 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
59
60 # Now move directories around such that for the subtrees with the path "p1/p2"
61 # we end up swapping the parents, that is, inode 263 becomes the parent of
62 # inode 261 and inode 260 becomes the parent of inode 264. This makes the send
63 # stream orphanize the inodes 263 and 264, and we want to verify the respective
64 # rename operations don't fail, that they don't use incorrect paths.
65 mv $SCRATCH_MNT/data/p1/p2 $SCRATCH_MNT/data
66 mv $SCRATCH_MNT/data/n1/n2/p1/p2 $SCRATCH_MNT/data/p1
67 mv $SCRATCH_MNT/data/p2 $SCRATCH_MNT/data/n1/n2/p1
68 mv $SCRATCH_MNT/data/n1/n2 $SCRATCH_MNT/data/p1
69 mv $SCRATCH_MNT/data/p1 $SCRATCH_MNT/data/n4
70 mv $SCRATCH_MNT/data/n4/p1/n2/p1 $SCRATCH_MNT/data
71
72 # Filesystem now looks like:
73 #
74 # .                                       (ino 256)
75 # |---- data                              (ino 257)
76 #         |---- n1/                       (ino 258)
77 #         |---- n4/                       (ino 262)
78 #         |     |---- p1/                 (ino 263)
79 #         |           |---- n2/           (ino 259)
80 #         |           |---- p2/           (ino 261)
81 #         |
82 #         |---- p1/                       (ino 260)
83 #               |---- p2/                 (ino 264)
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