2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook. All Rights Reserved.
7 # Test swap file activation on multiple devices.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
30 _require_scratch_dev_pool 2
31 _require_scratch_swapfile
34 local sz=${1:-$(($(get_page_size) * 10))}
35 _format_swapfile "$SCRATCH_MNT/swap" "$sz"
36 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
37 swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
41 _scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1
47 _scratch_pool_mkfs -d dup -m dup >> $seqres.full 2>&1
52 echo "Single on multiple devices"
53 _scratch_pool_mkfs -d single -m raid1 -b $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
55 # Each device is only 1 GB, so 1.5 GB must be split across multiple devices.
56 cycle_swapfile $((3 * 1024 * 1024 * 1024 / 2))
59 echo "Single on one device"
60 _scratch_mkfs >> $seqres.full 2>&1
62 # Create the swap file, then add the device. That way we know it's all on one
64 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
65 scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
66 $BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT"
67 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
68 swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1