summaryrefslogtreecommitdiff
path: root/tests/btrfs/175
blob: 6f7832a5602f40827951b56dfcc5aba53a2ad7ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Facebook.  All Rights Reserved.
#
# FS QA Test 175
#
# Test swap file activation on multiple devices.
#
. ./common/preamble
_begin_fstest auto quick swap volume

. ./common/filter

_supported_fs btrfs
_require_scratch_dev_pool 2
_require_scratch_swapfile
_check_minimal_fs_size $((1024 * 1024 * 1024))

cycle_swapfile() {
	local sz=${1:-$(($(get_page_size) * 10))}
	_format_swapfile "$SCRATCH_MNT/swap" "$sz" > /dev/null
	swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
	swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
}

echo "RAID 1"
_scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1
_scratch_mount
cycle_swapfile
_scratch_unmount

echo "DUP"
_scratch_pool_mkfs -d dup -m dup >> $seqres.full 2>&1
_scratch_mount
cycle_swapfile
_scratch_unmount

echo "Single on multiple devices"
_scratch_pool_mkfs -d single -m raid1 -b $((1024 * 1024 * 1024)) >> $seqres.full 2>&1
_scratch_mount
# Each device is only 1 GB, so 1.5 GB must be split across multiple devices.
cycle_swapfile $((3 * 1024 * 1024 * 1024 / 2))
_scratch_unmount

echo "Single on one device"
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount
# Create the swap file, then add the device. That way we know it's all on one
# device.
_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > /dev/null
scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
$BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT"
swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1

status=0
exit