#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle. All Rights Reserved.
+#
# FS QA Test No. 497
#
# Test various swapfile activation oddities, having used fcollapse to
# create discontiguous ranges in the file.
#
-#-----------------------------------------------------------------------
-# Copyright (c) 2018 Oracle. All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#-----------------------------------------------------------------------
-
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
$CHATTR_PROG +C $swapfile >> $seqres.full 2>&1
"$here/src/mkswap" $swapfile >> $seqres.full
"$here/src/swapon" $swapfile 2>&1 | _filter_scratch
- swapoff $swapfile 2>> $seeqres.full
+ swapoff $swapfile 2>> $seqres.full
rm -f $swapfile
}
# Create a swap file with a large discontiguous range(?)
echo "large discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len * 2)) $swapfile >> $seqres.full
-old_sz="$(stat -c '%s' $swapfile)"
+old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse $((len / 2)) $len" $swapfile >> $seqres.full 2>&1
-new_sz="$(stat -c '%s' $swapfile)"
+new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi
# Create a swap file with a small discontiguous range(?)
echo "small discontig swap" | tee -a $seqres.full
_pwrite_byte 0x58 0 $((len + 1024)) $swapfile >> $seqres.full
-old_sz="$(stat -c '%s' $swapfile)"
+old_sz="$(_get_filesize $swapfile)"
$XFS_IO_PROG -c "fcollapse 66560 1024" $swapfile >> $seqres.full 2>&1
-new_sz="$(stat -c '%s' $swapfile)"
+new_sz="$(_get_filesize $swapfile)"
if [ $old_sz -gt $new_sz ]; then
swapfile_cycle $swapfile
fi