4 # Check if btrfs send can handle large deduped file, whose file extents
5 # are all pointing to one extent.
6 # Such file structure will cause quite large pressure to any operation which
7 # iterates all backref of one extent.
8 # And unfortunately, btrfs send is one of these operations, and will cause
9 # softlock or OOM on systems with small memory(<4G).
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
49 # remove previous $seqres.full before test
52 # real QA test starts here
54 # Modify as appropriate.
58 _require_scratch_reflink
60 _scratch_mkfs > /dev/null 2>&1
63 nr_extents=$((4096 * $LOAD_FACTOR))
65 # Use 128K blocksize, the default value of both deduperemove or
67 blocksize=$((128 * 1024))
68 file=$SCRATCH_MNT/foobar
70 # create the initial file, whose file extents are all point to one extent
71 _pwrite_byte 0xcdcdcdcd 0 $blocksize $file | _filter_xfs_io
73 for i in $(seq 1 $(($nr_extents - 1))); do
74 _reflink_range $file 0 $file $(($i * $blocksize)) $blocksize \
78 # create a RO snapshot, so we can send out the snapshot
79 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/ro_snap
81 # send out the subvolume, and it will either:
82 # 1) OOM since memory is allocated inside a O(n^3) loop
83 # 2) Softlock since time consuming backref walk is called without scheduling.
84 # the send destination is not important, just send will cause the problem
85 _run_btrfs_util_prog send $SCRATCH_MNT/ro_snap > /dev/null 2>&1