common: kill _supported_os
[xfstests-dev.git] / tests / btrfs / 130
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
4 #
5 # FS QA Test 130
6 #
7 # Check if btrfs send can handle large deduped file, whose file extents
8 # are all pointing to one extent.
9 # Such file structure will cause quite large pressure to any operation which
10 # iterates all backref of one extent.
11 # And unfortunately, btrfs send is one of these operations, and will cause
12 # softlock or OOM on systems with small memory(<4G).
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/reflink
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs btrfs
41 _require_scratch
42 _require_scratch_reflink
43
44 _scratch_mkfs > /dev/null 2>&1
45 _scratch_mount
46
47 nr_extents=$((256 * $LOAD_FACTOR))
48
49 # Use 128K blocksize, the default value of both deduperemove or
50 # inband dedupe
51 blocksize=$((128 * 1024))
52 file=$SCRATCH_MNT/foobar
53
54 echo LOAD_FACTOR=$LOAD_FACTOR nr_extents=$nr_extents blocksize=$blocksize >> $seqres.full
55
56 # create the initial file, whose file extents are all point to one extent
57 _pwrite_byte 0xcdcdcdcd 0 $blocksize  $file | _filter_xfs_io
58
59 for i in $(seq 1 $(($nr_extents - 1))); do
60         _reflink_range $file 0 $file $(($i * $blocksize)) $blocksize \
61                 >> $seqres.full 2>&1
62 done
63
64 # create a RO snapshot, so we can send out the snapshot
65 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/ro_snap
66
67 # send out the subvolume, and it will either:
68 # 1) OOM since memory is allocated inside a O(n^3) loop
69 # 2) Softlock since time consuming backref walk is called without scheduling.
70 # the send destination is not important, just send will cause the problem
71 echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null" >> $seqres.full
72 $BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null 2>>$seqres.full
73
74 # success, all done
75 status=0
76 exit