blob: 8bf856ae9e8d28a0eb00668537dbb93e5e1b1501 (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Facebook. All Rights Reserved.
#
# FS QA Test 174
#
# Test restrictions on operations that can be done on an active swap file
# specific to Btrfs.
#
. ./common/preamble
_begin_fstest auto quick swap
. ./common/filter
_supported_fs btrfs
_require_scratch_swapfile
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount
$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/swapvol" >> $seqres.full
swapfile="$SCRATCH_MNT/swapvol/swap"
_format_swapfile "$swapfile" $(($(get_page_size) * 10))
swapon "$swapfile"
# Turning off nocow doesn't do anything because the file is not empty, not
# because the file is a swap file, but make sure this works anyways.
echo "Disable nocow"
$CHATTR_PROG -C "$swapfile"
$LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
# Compression we reject outright.
echo "Enable compression"
$CHATTR_PROG +c "$swapfile" 2>&1 | grep -o "Invalid argument while setting flags"
$LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
echo "Snapshot"
$BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/swapvol" \
"$SCRATCH_MNT/swapsnap" 2>&1 | grep -o "Text file busy"
echo "Defrag"
# We pass the -c (compress) flag to force defrag even if the file isn't
# fragmented.
$BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"
swapoff "$swapfile"
_scratch_unmount
status=0
exit
|