generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 175
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 175
6 #
7 # Test swap file activation on multiple devices.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick swap volume
11
12 . ./common/filter
13
14 _supported_fs btrfs
15 _require_scratch_dev_pool 2
16 _require_scratch_swapfile
17 _check_minimal_fs_size $((1024 * 1024 * 1024))
18
19 cycle_swapfile() {
20         local sz=${1:-$(($(get_page_size) * 10))}
21         _format_swapfile "$SCRATCH_MNT/swap" "$sz" > /dev/null
22         swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
23         swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
24 }
25
26 echo "RAID 1"
27 _scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1
28 _scratch_mount
29 cycle_swapfile
30 _scratch_unmount
31
32 echo "DUP"
33 _scratch_pool_mkfs -d dup -m dup >> $seqres.full 2>&1
34 _scratch_mount
35 cycle_swapfile
36 _scratch_unmount
37
38 echo "Single on multiple devices"
39 _scratch_pool_mkfs -d single -m raid1 -b $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
40 _scratch_mount
41 # Each device is only 1 GB, so 1.5 GB must be split across multiple devices.
42 cycle_swapfile $((3 * 1024 * 1024 * 1024 / 2))
43 _scratch_unmount
44
45 echo "Single on one device"
46 _scratch_mkfs >> $seqres.full 2>&1
47 _scratch_mount
48 # Create the swap file, then add the device. That way we know it's all on one
49 # device.
50 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > /dev/null
51 scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
52 $BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT" >> $seqres.full
53 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
54 swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
55
56 status=0
57 exit