2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook. All Rights Reserved.
7 # Test swap file activation on multiple devices.
10 _begin_fstest auto quick swap volume
15 _require_scratch_dev_pool 2
16 _require_scratch_swapfile
17 _check_minimal_fs_size $((1024 * 1024 * 1024))
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
27 _scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1
33 _scratch_pool_mkfs -d dup -m dup >> $seqres.full 2>&1
38 echo "Single on multiple devices"
39 _scratch_pool_mkfs -d single -m raid1 -b $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
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))
45 echo "Single on one device"
46 _scratch_mkfs >> $seqres.full 2>&1
48 # Create the swap file, then add the device. That way we know it's all on one
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