2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/128
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).
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -fr $send_files_dir
25 # get standard environment, filters and checks
29 # real QA test starts here
35 send_files_dir=$TEST_DIR/btrfs-test-$seq
38 rm -fr $send_files_dir
41 _scratch_mkfs >>$seqres.full 2>&1
45 mkdir $SCRATCH_MNT/tmp
46 mkdir $SCRATCH_MNT/del
47 mv $SCRATCH_MNT/tmp $SCRATCH_MNT/del
48 mkdir $SCRATCH_MNT/a/c
49 mkdir $SCRATCH_MNT/del/x
50 mkdir $SCRATCH_MNT/del/y
52 # Filesystem looks like:
63 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
65 # It used to be that when attempting to issue an rmdir operation for inode 259,
66 # the kernel allocated an orphan_dir_info structure so that later after doing
67 # the delayed rename operation for inode 258 (which happened once inode 260 was
68 # renamed) it would check if it could finally issue a rmdir instruction for
69 # inode 259. If it couldn't, it would not release the previously allocated
70 # orphan_dir_info structure immediately. Instead it would only release it once
71 # it finished the send stream and it would emit a warning in dmesg/syslog.
73 mv $SCRATCH_MNT/a/c $SCRATCH_MNT
74 mv $SCRATCH_MNT/del/x $SCRATCH_MNT/a
75 mv $SCRATCH_MNT/del/y $SCRATCH_MNT/a
76 mv $SCRATCH_MNT/del/tmp $SCRATCH_MNT/c
77 rmdir $SCRATCH_MNT/del
79 # Filesystem now looks like:
89 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
91 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
92 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
93 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
95 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
96 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
99 # Now recreate the filesystem by receiving both send streams and verify we get
100 # the same content that the original filesystem had.
102 _scratch_mkfs >>$seqres.full 2>&1
105 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
106 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
107 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
108 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
110 echo "Silence is golden"