mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
btrfs: test invalid operations on a swap file
Btrfs forbids some operations which should not be done on a swap file. Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
|||||||
|
#! /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.
|
||||||
|
#
|
||||||
|
seq=`basename $0`
|
||||||
|
seqres=$RESULT_DIR/$seq
|
||||||
|
echo "QA output created by $seq"
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
tmp=/tmp/$$
|
||||||
|
status=1 # failure is the default!
|
||||||
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||||
|
|
||||||
|
_cleanup()
|
||||||
|
{
|
||||||
|
cd /
|
||||||
|
rm -f $tmp.*
|
||||||
|
}
|
||||||
|
|
||||||
|
. ./common/rc
|
||||||
|
. ./common/filter
|
||||||
|
|
||||||
|
rm -f $seqres.full
|
||||||
|
|
||||||
|
_supported_fs btrfs
|
||||||
|
_supported_os Linux
|
||||||
|
_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 "Text file busy"
|
||||||
|
$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
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
QA output created by 174
|
||||||
|
Disable nocow
|
||||||
|
SCRATCH_MNT/swapvol/swap No_COW
|
||||||
|
Enable compression
|
||||||
|
Text file busy
|
||||||
|
SCRATCH_MNT/swapvol/swap No_COW
|
||||||
|
Snapshot
|
||||||
|
Text file busy
|
||||||
|
Defrag
|
||||||
|
Text file busy
|
||||||
@@ -176,3 +176,4 @@
|
|||||||
171 auto quick qgroup
|
171 auto quick qgroup
|
||||||
172 auto quick punch
|
172 auto quick punch
|
||||||
173 auto quick swap
|
173 auto quick swap
|
||||||
|
174 auto quick swap
|
||||||
|
|||||||
Reference in New Issue
Block a user