generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 128
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/128
6 #
7 # Test that, under a particular scenario, an incremental send operation does
8 # not leak memory (which used to emit a warning in dmesg/syslog).
9 #
10 . ./common/preamble
11 _begin_fstest auto quick send
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         rm -fr $send_files_dir
18         rm -f $tmp.*
19 }
20
21 # Import common functions.
22 . ./common/filter
23
24 # real QA test starts here
25 _supported_fs btrfs
26 _require_test
27 _require_scratch
28 _require_fssum
29
30 send_files_dir=$TEST_DIR/btrfs-test-$seq
31
32 rm -fr $send_files_dir
33 mkdir $send_files_dir
34
35 _scratch_mkfs >>$seqres.full 2>&1
36 _scratch_mount
37
38 mkdir $SCRATCH_MNT/a
39 mkdir $SCRATCH_MNT/tmp
40 mkdir $SCRATCH_MNT/del
41 mv $SCRATCH_MNT/tmp $SCRATCH_MNT/del
42 mkdir $SCRATCH_MNT/a/c
43 mkdir $SCRATCH_MNT/del/x
44 mkdir $SCRATCH_MNT/del/y
45
46 # Filesystem looks like:
47 #
48 # .                                                             (ino 256)
49 # |--- a/                                                       (ino 257)
50 # |    |--- c/                                                  (ino 260)
51 # |
52 # |--- del/                                                     (ino 259)
53 #       |--- tmp/                                               (ino 258)
54 #       |--- x/                                                 (ino 261)
55 #       |--- y/                                                 (ino 262)
56 #
57 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
58
59 # It used to be that when attempting to issue an rmdir operation for inode 259,
60 # the kernel allocated an orphan_dir_info structure so that later after doing
61 # the delayed rename operation for inode 258 (which happened once inode 260 was
62 # renamed) it would check if it could finally issue a rmdir instruction for
63 # inode 259. If it couldn't, it would not release the previously allocated
64 # orphan_dir_info structure immediately. Instead it would only release it once
65 # it finished the send stream and it would emit a warning in dmesg/syslog.
66 #
67 mv $SCRATCH_MNT/a/c $SCRATCH_MNT
68 mv $SCRATCH_MNT/del/x $SCRATCH_MNT/a
69 mv $SCRATCH_MNT/del/y $SCRATCH_MNT/a
70 mv $SCRATCH_MNT/del/tmp $SCRATCH_MNT/c
71 rmdir $SCRATCH_MNT/del
72
73 # Filesystem now looks like:
74 #
75 # .                                                             (ino 256)
76 # |--- a/                                                       (ino 257)
77 # |    |--- x/                                                  (ino 261)
78 # |    |--- y/                                                  (ino 262)
79 # |
80 # |--- c/                                                       (ino 260)
81 #      |--- tmp/                                                (ino 258)
82 #
83 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
84
85 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
86 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
87         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
88
89 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
90 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
91         $SCRATCH_MNT/mysnap2
92
93 # Now recreate the filesystem by receiving both send streams and verify we get
94 # the same content that the original filesystem had.
95 _scratch_unmount
96 _scratch_mkfs >>$seqres.full 2>&1
97 _scratch_mount
98
99 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
100 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
101 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
102 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
103
104 echo "Silence is golden"
105 status=0
106 exit