generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
15 _begin_fstest auto quick clone send
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/reflink
20
21 # real QA test starts here
22
23 # Modify as appropriate.
24 _supported_fs btrfs
25 _require_scratch
26 _require_scratch_reflink
27
28 _scratch_mkfs > /dev/null 2>&1
29 _scratch_mount
30
31 nr_extents=$((256 * $LOAD_FACTOR))
32
33 # Use 128K blocksize, the default value of both deduperemove or
34 # inband dedupe
35 blocksize=$((128 * 1024))
36 file=$SCRATCH_MNT/foobar
37
38 echo LOAD_FACTOR=$LOAD_FACTOR nr_extents=$nr_extents blocksize=$blocksize >> $seqres.full
39
40 # create the initial file, whose file extents are all point to one extent
41 _pwrite_byte 0xcdcdcdcd 0 $blocksize  $file | _filter_xfs_io
42
43 for i in $(seq 1 $(($nr_extents - 1))); do
44         _reflink_range $file 0 $file $(($i * $blocksize)) $blocksize \
45                 >> $seqres.full 2>&1
46 done
47
48 # create a RO snapshot, so we can send out the snapshot
49 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/ro_snap
50
51 # send out the subvolume, and it will either:
52 # 1) OOM since memory is allocated inside a O(n^3) loop
53 # 2) Softlock since time consuming backref walk is called without scheduling.
54 # the send destination is not important, just send will cause the problem
55 echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null" >> $seqres.full
56 $BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null 2>>$seqres.full
57
58 # success, all done
59 status=0
60 exit