mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
xfstests: introduce a common directory
Introduce a top level common directory and move all the common.* files into it. Because there is now a directory named common, the prefix can be dropped from all the files. Convert all the tests to use this new directory for including common files. for f in common.*; do \ git mv `echo -n "$f " ; echo $f | sed -e 's;n\.;n/;'` \ done Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Phil White <pwhite@sgi.com> [rjohnston@sgi.com reworked for TOT changes] Signed-off-by: Rich Johnston <rjohnston@sgi.com>
This commit is contained in:
committed by
Rich Johnston
parent
401680a11c
commit
8c4905a42e
+208
@@ -0,0 +1,208 @@
|
||||
##/bin/bash
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright (c) 2000-2004 Silicon Graphics, Inc. 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; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will 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 to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA
|
||||
#
|
||||
# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
|
||||
# Mountain View, CA 94043, USA, or: http://www.sgi.com
|
||||
#-----------------------------------------------------------------------
|
||||
# common extended attribute and ACL support
|
||||
|
||||
# pick three unused user/group ids, store them as $acl[1-3]
|
||||
#
|
||||
_acl_setup_ids()
|
||||
{
|
||||
eval `(_cat_passwd; _cat_group) | awk -F: '
|
||||
{ ids[$3]=1 }
|
||||
END {
|
||||
j=1
|
||||
for(i=1; i<1000000 && j<=3;i++){
|
||||
if (! (i in ids)) {
|
||||
printf "acl%d=%d;", j, i;
|
||||
j++
|
||||
}
|
||||
}
|
||||
}'`
|
||||
}
|
||||
|
||||
# filter for the acl ids selected above
|
||||
#
|
||||
_acl_filter_id()
|
||||
{
|
||||
sed \
|
||||
-e "s/u:$acl1/u:id1/" \
|
||||
-e "s/u:$acl2/u:id2/" \
|
||||
-e "s/u:$acl3/u:id3/" \
|
||||
-e "s/g:$acl1/g:id1/" \
|
||||
-e "s/g:$acl2/g:id2/" \
|
||||
-e "s/g:$acl3/g:id3/" \
|
||||
-e "s/ $acl1 / id1 /" \
|
||||
-e "s/ $acl2 / id2 /" \
|
||||
-e "s/ $acl3 / id3 /"
|
||||
}
|
||||
|
||||
# filtered ls
|
||||
#
|
||||
_acl_ls()
|
||||
{
|
||||
_ls_l -n $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
|
||||
}
|
||||
|
||||
#
|
||||
_acl_list()
|
||||
{
|
||||
_file1=$1
|
||||
|
||||
if [ $HOSTOS = "IRIX" ]; then
|
||||
ls -dD $_file1 | _acl_filter_id
|
||||
else
|
||||
chacl -l $_file1 | _acl_filter_id
|
||||
fi
|
||||
}
|
||||
|
||||
# create an ACL with n ACEs in it
|
||||
#
|
||||
_create_n_aces()
|
||||
{
|
||||
let n=$1-4
|
||||
acl='u::rwx,g::rwx,o::rwx,m::rwx' # 4 ace acl start
|
||||
while [ $n -ne 0 ]; do
|
||||
acl="$acl,u:$n:rwx"
|
||||
let n=$n-1
|
||||
done
|
||||
echo $acl
|
||||
}
|
||||
|
||||
# filter user ace names to user ids
|
||||
#
|
||||
_filter_aces()
|
||||
{
|
||||
tmp_file=`mktemp /tmp/ace.XXXXXX`
|
||||
|
||||
(_cat_passwd; _cat_group) > $tmp_file
|
||||
|
||||
$AWK_PROG -v tmpfile=$tmp_file '
|
||||
BEGIN {
|
||||
FS=":"
|
||||
while ( getline <tmpfile > 0 ) {
|
||||
idlist[$1] = $3
|
||||
}
|
||||
}
|
||||
/^user/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
|
||||
/^u/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
|
||||
/^default:user/ { if ($3 in idlist) sub($3, idlist[$3]); print; next}
|
||||
{print}
|
||||
'
|
||||
rm -f $tmp_file
|
||||
}
|
||||
|
||||
_filter_aces_notypes()
|
||||
{
|
||||
tr '\[' '\012' | tr ']' '\012' | tr ',' '\012' | _filter_aces|\
|
||||
sed -e 's/u:/user:/' -e 's/g:/group:/' -e 's/o:/other:/' -e 's/m:/mask:/'
|
||||
}
|
||||
|
||||
_require_acls()
|
||||
{
|
||||
if [ ! -x /bin/chacl -a ! -x /usr/bin/chacl -a ! -x /sbin/chacl ]; then
|
||||
_notrun "chacl command not found"
|
||||
fi
|
||||
|
||||
#
|
||||
# Test if chacl is able to list ACLs on the target filesystems. On really
|
||||
# old kernels the system calls might not be implemented at all, but the
|
||||
# more common case is that the tested filesystem simply doesn't support
|
||||
# ACLs.
|
||||
#
|
||||
touch $TEST_DIR/syscalltest
|
||||
chacl -l $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
|
||||
cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
|
||||
|
||||
if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
|
||||
_notrun "kernel does not support ACLs"
|
||||
fi
|
||||
if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
|
||||
_notrun "ACLs not supported by this filesystem type: $FSTYP"
|
||||
fi
|
||||
|
||||
rm -f $TEST_DIR/syscalltest.out
|
||||
}
|
||||
|
||||
_list_acl()
|
||||
{
|
||||
file=$1
|
||||
|
||||
ls -dD $file | _acl_filter_id
|
||||
}
|
||||
|
||||
_require_attrs()
|
||||
{
|
||||
[ -n $ATTR_PROG ] || _notrun "attr command not found"
|
||||
[ -n $GETFATTR_PROG ] || _notrun "getfattr command not found"
|
||||
[ -n $SETFATTR_PROG ] || _notrun "setfattr command not found"
|
||||
|
||||
#
|
||||
# Test if chacl is able to write an attribute on the target filesystems.
|
||||
# On really old kernels the system calls might not be implemented at all,
|
||||
# but the more common case is that the tested filesystem simply doesn't
|
||||
# support attributes. Note that we can't simply list attributes as
|
||||
# various security modules generate synthetic attributes not actually
|
||||
# stored on disk.
|
||||
#
|
||||
touch $TEST_DIR/syscalltest
|
||||
attr -s "user.xfstests" -V "attr" $TEST_DIR > $TEST_DIR/syscalltest.out 2>&1
|
||||
cat $TEST_DIR/syscalltest.out >> $RESULT_DIR/$seq.full
|
||||
|
||||
if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
|
||||
_notrun "kernel does not support attrs"
|
||||
fi
|
||||
if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
|
||||
_notrun "attrs not supported by this filesystem type: $FSTYP"
|
||||
fi
|
||||
|
||||
rm -f $TEST_DIR/syscalltest.out
|
||||
}
|
||||
|
||||
# getfattr -R returns info in readdir order which varies from fs to fs.
|
||||
# This sorts the output by filename
|
||||
_sort_getfattr_output()
|
||||
{
|
||||
awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS=''
|
||||
}
|
||||
|
||||
# set maximum total attr space based on fs type
|
||||
if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" ]; then
|
||||
MAX_ATTRS=1000
|
||||
else # Assume max ~1 block of attrs
|
||||
BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
|
||||
# user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead
|
||||
let MAX_ATTRS=$BLOCK_SIZE/40
|
||||
fi
|
||||
|
||||
export MAX_ATTRS
|
||||
|
||||
# Set max attr value size based on fs type
|
||||
if [ "$FSTYP" == "xfs" -o "$FSTYP" == "udf" -o "$FSTYP" == "btrfs" ]; then
|
||||
MAX_ATTRVAL_SIZE=64
|
||||
else # Assume max ~1 block of attrs
|
||||
BLOCK_SIZE=`stat -f $TEST_DIR | grep "Block size" | cut -d " " -f3`
|
||||
# leave a little overhead
|
||||
let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256
|
||||
fi
|
||||
|
||||
export MAX_ATTRVAL_SIZE
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# setup and check for config parameters, and in particular
|
||||
#
|
||||
# EMAIL - email of the script runner.
|
||||
# TEST_DIR - scratch test directory that is in an already
|
||||
# mounted XFS file system, needs to be be world
|
||||
# writeable
|
||||
# TEST_DEV - device for file system containing TEST_DIR
|
||||
#
|
||||
# and optionally:
|
||||
# SCRATCH_DEV - device you can make a scratch file system on
|
||||
# SCRATCH_MNT - mount point for scratch file system
|
||||
# SCRATCH_LOGDEV - scratch log device for external log testing
|
||||
# SCRATCH_RTDEV - scratch rt dev
|
||||
# TEST_LOGDEV - test log device for external log testing
|
||||
# TEST_RTDEV - test rt dev
|
||||
# TAPE_DEV - the tape device for the xfsdump tests
|
||||
# RMT_TAPE_DEV - the remote tape device for the xfsdump tests
|
||||
# RMT_IRIXTAPE_DEV- the IRIX remote tape device for the xfsdump tests
|
||||
# RMT_TAPE_USER - remote user for tape device
|
||||
#
|
||||
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
|
||||
# below or a separate local configuration file can be used (using
|
||||
# the HOST_OPTIONS variable).
|
||||
# - This script is shared by the stress test system and the auto-qa
|
||||
# system
|
||||
# - TEST_DEV & TEST_DIR must be assigned.
|
||||
# - this script shouldn't make any assertions about filesystem
|
||||
# validity or mountedness.
|
||||
#
|
||||
|
||||
# all tests should use a common language setting to prevent golden
|
||||
# output mismatches.
|
||||
export LANG=C
|
||||
|
||||
# Warning: don't put freeware before /usr/bsd on IRIX coz you'll
|
||||
# get the wrong hostname and set your system name to -s :)
|
||||
[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
|
||||
[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
|
||||
PATH=".:$PATH"
|
||||
|
||||
HOST=`hostname -s`
|
||||
HOSTOS=`uname -s`
|
||||
[ "$HOSTOS" = "IRIX64" ] && HOSTOS="IRIX"
|
||||
|
||||
MODULAR=0 # using XFS as a module or not
|
||||
BOOT="/boot" # install target for kernels
|
||||
export EXTRA=${EXTRA:=xfs-qa}
|
||||
|
||||
# general parameters (mainly for auto-qa)
|
||||
SOAK_PROC=3 # -p option to fsstress
|
||||
SOAK_STRESS=10000 # -n option to fsstress
|
||||
SOAK_PASSES=-1 # count of repetitions of fsstress (while soaking)
|
||||
EMAIL=root@localhost # where auto-qa will send its status messages
|
||||
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
|
||||
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
|
||||
export BENCH_PASSES=${BENCH_PASSES:=5}
|
||||
export XFS_MKFS_OPTIONS=${XFS_MKFS_OPTIONS:=-bsize=4096}
|
||||
export TIME_FACTOR=${TIME_FACTOR:=1}
|
||||
export LOAD_FACTOR=${LOAD_FACTOR:=1}
|
||||
export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"}
|
||||
|
||||
export PWD=`pwd`
|
||||
#export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
|
||||
export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
|
||||
export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
|
||||
|
||||
# $1 = prog to look for, $2* = default pathnames if not found in $PATH
|
||||
set_prog_path()
|
||||
{
|
||||
p=`which $1 2> /dev/null`
|
||||
if [ -n "$p" -a -x "$p" ]; then
|
||||
echo $p
|
||||
return 0
|
||||
fi
|
||||
p=$1
|
||||
|
||||
shift
|
||||
for f; do
|
||||
if [ -x $f ]; then
|
||||
echo $f
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
return 1
|
||||
}
|
||||
|
||||
# Handle mkfs.btrfs which does (or does not) require -f to overwrite
|
||||
set_btrfs_mkfs_prog_path_with_opts()
|
||||
{
|
||||
p=`set_prog_path mkfs.btrfs`
|
||||
if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
|
||||
echo "$p -f"
|
||||
else
|
||||
echo $p
|
||||
fi
|
||||
}
|
||||
|
||||
_fatal()
|
||||
{
|
||||
echo "$*"
|
||||
status=1
|
||||
exit 1
|
||||
}
|
||||
|
||||
export MKFS_PROG="`set_prog_path mkfs`"
|
||||
[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
|
||||
|
||||
export MOUNT_PROG="`set_prog_path mount`"
|
||||
[ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
|
||||
|
||||
export UMOUNT_PROG="`set_prog_path umount`"
|
||||
[ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
|
||||
|
||||
export FSSTRESS_PROG="`set_prog_path fsstress $PWD/ltp/fsstress`"
|
||||
[ "$FSSTRESS_PROG" = "" ] && _fatal "fsstress not found"
|
||||
|
||||
export PERL_PROG="`set_prog_path perl`"
|
||||
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
|
||||
|
||||
export AWK_PROG="`set_prog_path awk`"
|
||||
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
|
||||
|
||||
export SED_PROG="`set_prog_path sed`"
|
||||
[ "$SED_PROG" = "" ] && _fatal "sed not found"
|
||||
|
||||
export BC_PROG="`set_prog_path bc`"
|
||||
[ "$BC_PROG" = "" ] && _fatal "bc not found"
|
||||
|
||||
export PS_ALL_FLAGS="-ef"
|
||||
|
||||
export DF_PROG="`set_prog_path df`"
|
||||
[ "$DF_PROG" = "" ] && _fatal "df not found"
|
||||
[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T"
|
||||
|
||||
export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
|
||||
export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
|
||||
export XFS_CHECK_PROG="`set_prog_path xfs_check`"
|
||||
export XFS_DB_PROG="`set_prog_path xfs_db`"
|
||||
export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
|
||||
export XFS_IO_PROG="`set_prog_path xfs_io`"
|
||||
export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
|
||||
export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
|
||||
export __XFSDUMP_PROG="`set_prog_path xfsdump`"
|
||||
export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
|
||||
export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
|
||||
export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
|
||||
export GETFATTR_PROG="`set_prog_path getfattr`"
|
||||
export SETFATTR_PROG="`set_prog_path setfattr`"
|
||||
export ATTR_PROG="`set_prog_path attr`"
|
||||
export QUOTA_PROG="`set_prog_path quota`"
|
||||
export XFS_QUOTA_PROG="`set_prog_path xfs_quota`"
|
||||
export KILLALL_PROG="`set_prog_path killall`"
|
||||
export INDENT_PROG="`set_prog_path indent`"
|
||||
export XFS_COPY_PROG="`set_prog_path xfs_copy`"
|
||||
export FSTRIM_PROG="`set_prog_path fstrim`"
|
||||
export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
|
||||
export FIO_PROG="`set_prog_path fio`"
|
||||
export FILEFRAG_PROG="`set_prog_path filefrag`"
|
||||
export E4DEFRAG_PROG="`set_prog_path e4defrag`"
|
||||
export LOGGER_PROG="`set_prog_path logger`"
|
||||
|
||||
# Generate a comparable xfsprogs version number in the form of
|
||||
# major * 10000 + minor * 100 + release
|
||||
#
|
||||
# $ xfs_db -V
|
||||
# xfs_db version 2.9.7
|
||||
#
|
||||
# so, 2.9.7 = 20907
|
||||
_version=`$XFS_DB_PROG -V | $AWK_PROG '
|
||||
/version/ {
|
||||
if (split($3,ver,".") == 3)
|
||||
print (ver[1] * 10000) + (ver[2] * 100) + ver[3];
|
||||
}'`
|
||||
[ -z "$_version" ] && _fatal "xfsprogs version cannot be found"
|
||||
export XFSPROGS_VERSION="$_version"
|
||||
|
||||
case "$HOSTOS" in
|
||||
IRIX*)
|
||||
export MKFS_XFS_PROG="`set_prog_path mkfs_xfs`"
|
||||
export MKFS_UDF_PROG="`set_prog_path mkfs_udf`"
|
||||
export XFS_FSR_PROG="`set_prog_path /usr/etc/fsr_xfs`"
|
||||
export MKFS_NFS_PROG="false"
|
||||
;;
|
||||
Linux)
|
||||
export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
|
||||
export MKFS_UDF_PROG="`set_prog_path mkudffs`"
|
||||
export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
|
||||
export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
|
||||
export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
|
||||
export MKFS_NFS_PROG="false"
|
||||
;;
|
||||
esac
|
||||
|
||||
known_hosts()
|
||||
{
|
||||
[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
|
||||
|
||||
[ -f /etc/xfsqa.config ] && . /etc/xfsqa.config
|
||||
[ -f $HOST_CONFIG_DIR/$HOST ] && . $HOST_CONFIG_DIR/$HOST
|
||||
[ -f $HOST_CONFIG_DIR/$HOST.config ] && . $HOST_CONFIG_DIR/$HOST.config
|
||||
|
||||
# Mandatory Config values.
|
||||
MC=""
|
||||
[ -z "$EMAIL" ] && MC="$MC EMAIL"
|
||||
[ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
|
||||
[ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
|
||||
|
||||
if [ -n "$MC" ]; then
|
||||
echo "Warning: need to define parameters for host $HOST"
|
||||
echo " or set variables:"
|
||||
echo " $MC"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f "$HOST_OPTIONS" ]; then
|
||||
. "$HOST_OPTIONS"
|
||||
else
|
||||
known_hosts
|
||||
fi
|
||||
|
||||
echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
|
||||
if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
|
||||
echo "common.config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$TEST_DIR" ]; then
|
||||
echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev
|
||||
# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility
|
||||
if [ ! -z "$SCRATCH_DEV_POOL" ]; then
|
||||
if [ ! -z "$SCRATCH_DEV" ]; then
|
||||
echo "common.config: Error: \$SCRATCH_DEV should be unset when \$SCRATCH_DEV_POOL is set"
|
||||
exit 1
|
||||
fi
|
||||
SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
|
||||
SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
|
||||
fi
|
||||
|
||||
echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
|
||||
if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
|
||||
echo "common.config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a NFS filesystem"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then
|
||||
echo "common.config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
@@ -0,0 +1,71 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2009 Eric Sandeen
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Functions useful for defragmentation tests
|
||||
#
|
||||
|
||||
_require_defrag()
|
||||
{
|
||||
case "$FSTYP" in
|
||||
xfs)
|
||||
DEFRAG_PROG="$XFS_FSR_PROG"
|
||||
;;
|
||||
ext4|ext4dev)
|
||||
DEFRAG_PROG="$E4DEFRAG_PROG"
|
||||
;;
|
||||
btrfs)
|
||||
DEFRAG_PROG="$BTRFS_UTIL_PROG filesystem defragment"
|
||||
;;
|
||||
*)
|
||||
_notrun "defragmentation not supported for fstype \"$FSTYP\""
|
||||
;;
|
||||
esac
|
||||
|
||||
_require_command $DEFRAG_PROG
|
||||
_require_command $FILEFRAG_PROG
|
||||
}
|
||||
|
||||
_extent_count()
|
||||
{
|
||||
$FILEFRAG_PROG $1 | awk '{print $2}'
|
||||
$FILEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
|
||||
}
|
||||
|
||||
# Defrag file, check it, and remove it.
|
||||
_defrag()
|
||||
{
|
||||
echo -n "Before: "
|
||||
_extent_count $1
|
||||
CSUM_BEFORE=`md5sum $1`
|
||||
STAT_BEFORE=`stat -c "a: %x m: %y c: %z" $1`
|
||||
$DEFRAG_PROG -v $1 >> $RESULT_DIR/$seq.full 2>&1
|
||||
_scratch_remount
|
||||
STAT_AFTER=`stat -c "a: %x m: %y c: %z" $1`
|
||||
CSUM_AFTER=`md5sum $1`
|
||||
echo -n "After: "
|
||||
_extent_count $1
|
||||
if [ "$CSUM_BEFORE" != "$CSUM_AFTER" ]; then
|
||||
_fail "file checksum changed post-defrag ($CSUM_BEFORE/$CSUM_AFTER)"
|
||||
fi
|
||||
if [ "$STAT_BEFORE" != "$STAT_AFTER" ]; then
|
||||
_fail "file timestamps changed post-defrag:\n$STAT_BEFORE\n$STAT_AFTER"
|
||||
fi
|
||||
rm -f $1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2006 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# dmapi functions
|
||||
#
|
||||
|
||||
# Commands relitive to dmapi qa
|
||||
|
||||
DMAPI_QASUITE1_DIR=$here/dmapi/src/suite1/
|
||||
DMAPI_QASUITE2_DIR=$here/dmapi/src/suite2/
|
||||
DMAPI_COMMON_DIR=$here/dmapi/src/common/
|
||||
|
||||
DMAPI_LS_TO_COPY_PATH=$DMAPI_QASUITE2_DIR/bindir/ls_to_copy
|
||||
|
||||
_dmapi_scratch_mount () {
|
||||
if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
|
||||
`echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
|
||||
#already got dmapi options set
|
||||
_scratch_mount
|
||||
dmapi_mount_result=$?
|
||||
else
|
||||
_scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
|
||||
dmapi_mount_result=$?
|
||||
fi
|
||||
|
||||
if [ $dmapi_mount_result -ne 0 ] ; then
|
||||
_notrun "Assuming DMAPI modules are not loaded"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+1537
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,229 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2007 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# Core of filestreams tests.
|
||||
#
|
||||
|
||||
_check_filestreams_support()
|
||||
{
|
||||
local irix_timeout_sysvar="xfs_mfstream_timeout"
|
||||
local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
|
||||
local streams_avail=""
|
||||
if [ "$HOSTOS" == "IRIX" ]; then
|
||||
# check for the filestreams timeout systune variable in irix
|
||||
streams_avail=`systune $irix_timeout_sysvar 2>&1 |
|
||||
perl -ne 'if (/'$irix_timeout_sysvar'\s+=\s+\d+/) {print "true"}'`
|
||||
else
|
||||
# check for the filestreams timeout proc entry in linux
|
||||
[ -f $linux_timeout_procvar ] && streams_avail="true"
|
||||
fi
|
||||
|
||||
if [ "$streams_avail" == "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
_set_stream_timeout_centisecs()
|
||||
{
|
||||
local new_timeout_csecs=$1
|
||||
local irix_timeout_sysvar="xfs_mfstream_timeout"
|
||||
local linux_timeout_procvar="/proc/sys/fs/xfs/filestream_centisecs"
|
||||
if [ "$HOSTOS" == "IRIX" ]; then
|
||||
echo y | systune -r $irix_timeout_sysvar $new_timeout_csecs >/dev/null
|
||||
else
|
||||
echo $new_timeout_csecs > $linux_timeout_procvar
|
||||
fi
|
||||
}
|
||||
|
||||
_do_stream()
|
||||
{
|
||||
local directory_name=$1
|
||||
local files=$2
|
||||
local file_size=$3
|
||||
local bsize=$4
|
||||
local iflag=$5
|
||||
local dio=$6
|
||||
local blocks_in_file=`expr $file_size / $bsize`
|
||||
|
||||
mkdir $directory_name
|
||||
if [ "$iflag" = "1" -a "$HOSTOS" != "IRIX" ]; then
|
||||
$XFS_IO_PROG -x -c "chattr +S" $directory_name \
|
||||
|| _fail "chattr of filestream flag"
|
||||
fi
|
||||
cd $directory_name
|
||||
|
||||
local dd_cmd=""
|
||||
if [ "$HOSTOS" == "IRIX" ]; then
|
||||
# for irix use lmdd
|
||||
dd_cmd="lmdd"
|
||||
[ "$dio" = "1" ] && dd_cmd="$dd_cmd odirect=1"
|
||||
else
|
||||
# for linux use dd
|
||||
dd_cmd="dd"
|
||||
[ "$dio" = "1" ] && dd_cmd="$dd_cmd oflag=direct"
|
||||
fi
|
||||
dd_cmd="$dd_cmd if=/dev/zero bs=${bsize} count=${blocks_in_file}"
|
||||
|
||||
local i=1
|
||||
while [ $i -le $files ]; do
|
||||
$dd_cmd of=frame-${i} 2>&1 | grep -v records | grep -v secs
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
}
|
||||
|
||||
_filter_agno()
|
||||
{
|
||||
# the ag number is in column 4 of xfs_bmap output
|
||||
perl -ne '
|
||||
$ag = (split /\s+/)[4] ;
|
||||
if ($ag =~ /\d+/) {print "$ag "} ;
|
||||
'
|
||||
}
|
||||
|
||||
_get_stream_ags()
|
||||
{
|
||||
local directory_name=$1
|
||||
local stream_ags=`xfs_bmap -vp ${directory_name}/* | _filter_agno`
|
||||
echo $stream_ags
|
||||
}
|
||||
|
||||
_check_for_dupes()
|
||||
{
|
||||
# check for duplicate numbers between two space seperated vars
|
||||
local num_str_one=$1
|
||||
local num_str_two=$2
|
||||
|
||||
local this_num_one
|
||||
local this_num_two
|
||||
for this_num_one in $num_str_one; do
|
||||
for this_num_two in $num_str_two; do
|
||||
if [ "$this_num_one" == "$this_num_two" ]; then
|
||||
echo "duplicate AG $this_num_one found" \
|
||||
>> $RESULT_DIR/$seq.full
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
_test_streams() {
|
||||
|
||||
echo "# testing $* ...."
|
||||
local agcount="$1"
|
||||
local agsize="$2" # in MB
|
||||
local stream_count="$3"
|
||||
local stream_files="$4"
|
||||
local stream_file_size=`expr $5 \* 1024 \* 1024`
|
||||
local use_iflag="$6"
|
||||
local use_directio="$7"
|
||||
local expected_result="$8" # "fail" if failure is expected
|
||||
|
||||
local size=`expr $agsize \* 1024 \* 1024 \* $agcount`
|
||||
_scratch_mkfs_xfs -dsize=$size,agcount=$agcount >/dev/null 2>&1 \
|
||||
|| _fail "mkfs failed"
|
||||
|
||||
if [ "$use_iflag" = "0" -o "$HOSTOS" == "IRIX" ]; then
|
||||
# mount using filestreams mount option
|
||||
_scratch_mount "-o filestreams" \
|
||||
|| _fail "filestreams mount failed"
|
||||
else
|
||||
# test will set inode flag
|
||||
_scratch_mount || _fail "mount failed"
|
||||
fi
|
||||
|
||||
cd $SCRATCH_MNT
|
||||
|
||||
# start $stream_count streams
|
||||
# each stream writes ($stream_files x $stream_file_size)M
|
||||
echo "# streaming"
|
||||
local stream_pids=""
|
||||
local stream_index=1
|
||||
while [ $stream_index -le $stream_count ]; do
|
||||
_do_stream stream${stream_index}-dir $stream_files \
|
||||
$stream_file_size 1048576 $use_iflag $use_directio &
|
||||
stream_pids="$stream_pids $!"
|
||||
stream_index=`expr $stream_index + 1`
|
||||
done
|
||||
|
||||
# wait for streams to finish
|
||||
# XXX wait here not needed? -dgc
|
||||
wait $stream_pids
|
||||
|
||||
# sync the buffered streams out in parallel
|
||||
# _get_stream_ags does a xfs_bmap which syncs delayed allocations
|
||||
echo "# sync AGs..."
|
||||
local ag_sync_pids=""
|
||||
stream_index=1
|
||||
while [ $stream_index -le $stream_count ]; do
|
||||
_get_stream_ags stream${stream_index}-dir > /dev/null 2>&1 &
|
||||
ag_sync_pids="$ag_sync_pids $!"
|
||||
stream_index=`expr $stream_index + 1`
|
||||
done
|
||||
|
||||
# wait for syncs to finish
|
||||
wait $ag_sync_pids
|
||||
|
||||
# confirm streams are in seperate AGs
|
||||
echo "# checking stream AGs..."
|
||||
local this_stream_ags=""
|
||||
local ags_seen=""
|
||||
local num_streams_with_matching_ags=0
|
||||
stream_index=1
|
||||
while [ $stream_index -le $stream_count ]; do
|
||||
this_stream_ags=`_get_stream_ags stream${stream_index}-dir`
|
||||
echo "stream $stream_index AGs: $this_stream_ags" >> $RESULT_DIR/$seq.full
|
||||
_check_for_dupes "$ags_seen" "$this_stream_ags"
|
||||
if [ $? -ne 0 ]; then
|
||||
# this stream is not in seperate AGs to previous streams
|
||||
num_streams_with_matching_ags=`expr $num_streams_with_matching_ags + 1`
|
||||
fi
|
||||
ags_seen="$ags_seen $this_stream_ags"
|
||||
stream_index=`expr $stream_index + 1`
|
||||
done
|
||||
|
||||
_cleanup_streams_umount
|
||||
if [ "$expected_result" != "fail" ]; then
|
||||
if [ $num_streams_with_matching_ags -eq 0 ]; then
|
||||
# all streams in seperate AGs, as expected
|
||||
echo "+ passed, streams are in seperate AGs"
|
||||
else
|
||||
# streams with matching AGs, should be seperate
|
||||
_fail "- failed, $num_streams_with_matching_ags streams with matching AGs"
|
||||
fi
|
||||
else
|
||||
# expecting streams to have overlapped
|
||||
if [ $num_streams_with_matching_ags -eq 0 ]; then
|
||||
# all streams in seperate AGs, should have overlapped
|
||||
_fail "- streams are in seperate AGs, expected _matching_"
|
||||
else
|
||||
# streams with matching AGs, as expected
|
||||
echo "+ expected failure, matching AGs"
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
_cleanup_streams_umount()
|
||||
{
|
||||
cd /
|
||||
rm -rf ${SCRATCH_MNT}/stream*
|
||||
umount $SCRATCH_DEV 2>/dev/null
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2000-2001 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# standard filters
|
||||
#
|
||||
|
||||
# Checks that given_value is in range of correct_value +/- tolerance.
|
||||
# Tolerance can be an absolute value or a percentage of the correct value
|
||||
# (see examples with tolerances below).
|
||||
# Outputs suitable message to stdout if it's not in range.
|
||||
#
|
||||
# A verbose option, -v, may be used as the LAST argument
|
||||
#
|
||||
# e.g.
|
||||
# foo: 0.0298 = 0.03 +/- 5%
|
||||
# _within_tolerance "foo" 0.0298 0.03 5%
|
||||
#
|
||||
# foo: 0.0298 = 0.03 +/- 0.01
|
||||
# _within_tolerance "foo" 0.0298 0.03 0.01
|
||||
#
|
||||
# foo: 0.0298 = 0.03 -0.01 +0.002
|
||||
# _within_tolerance "foo" 0.0298 0.03 0.01 0.002
|
||||
#
|
||||
# foo: verbose output of 0.0298 = 0.03 +/- 5%
|
||||
# _within_tolerance "foo" 0.0298 0.03 5% -v
|
||||
_within_tolerance()
|
||||
{
|
||||
_name=$1
|
||||
_given_val=$2
|
||||
_correct_val=$3
|
||||
_mintol=$4
|
||||
_maxtol=$_mintol
|
||||
_verbose=0
|
||||
_debug=false
|
||||
|
||||
# maxtol arg is optional
|
||||
# verbose arg is optional
|
||||
if [ $# -ge 5 ]
|
||||
then
|
||||
if [ "$5" = "-v" ]
|
||||
then
|
||||
_verbose=1
|
||||
else
|
||||
_maxtol=$5
|
||||
fi
|
||||
fi
|
||||
if [ $# -ge 6 ]
|
||||
then
|
||||
[ "$6" = "-v" ] && _verbose=1
|
||||
fi
|
||||
|
||||
# find min with or without %
|
||||
_mintolerance=`echo $_mintol | sed -e 's/%//'`
|
||||
if [ $_mintol = $_mintolerance ]
|
||||
then
|
||||
_min=`echo "scale=5; $_correct_val-$_mintolerance" | bc`
|
||||
else
|
||||
_min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc`
|
||||
fi
|
||||
|
||||
# find max with or without %
|
||||
_maxtolerance=`echo $_maxtol | sed -e 's/%//'`
|
||||
if [ $_maxtol = $_maxtolerance ]
|
||||
then
|
||||
_max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc`
|
||||
else
|
||||
_max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc`
|
||||
fi
|
||||
|
||||
$_debug && echo "min = $_min"
|
||||
$_debug && echo "max = $_max"
|
||||
|
||||
cat <<EOF >$tmp.bc.1
|
||||
scale=5;
|
||||
if ($_min <= $_given_val) 1;
|
||||
if ($_min > $_given_val) 0;
|
||||
EOF
|
||||
|
||||
cat <<EOF >$tmp.bc.2
|
||||
scale=5;
|
||||
if ($_given_val <= $_max) 1;
|
||||
if ($_given_val > $_max) 0;
|
||||
EOF
|
||||
|
||||
_above_min=`bc <$tmp.bc.1`
|
||||
_below_max=`bc <$tmp.bc.2`
|
||||
|
||||
rm -f $tmp.bc.[12]
|
||||
|
||||
_in_range=`expr $_above_min \& $_below_max`
|
||||
|
||||
# fix up min, max precision for output
|
||||
# can vary for 5.3, 6.2
|
||||
|
||||
# remove any trailing zeroes from min, max if they have fractional parts
|
||||
_min=`echo $_min | sed -e '/\./s/0*$//' -e 's/\.$//'`
|
||||
_max=`echo $_max | sed -e '/\./s/0*$//' -e 's/\.$//'`
|
||||
|
||||
if [ $_in_range -eq 1 ]
|
||||
then
|
||||
[ $_verbose -eq 1 ] && echo $_name is in range
|
||||
return 0
|
||||
else
|
||||
[ $_verbose -eq 1 ] && echo $_name has value of $_given_val
|
||||
[ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ctime(3) dates
|
||||
#
|
||||
_filter_date()
|
||||
{
|
||||
sed \
|
||||
-e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
|
||||
}
|
||||
|
||||
# prints filtered output on stdout, values (use eval) on stderr
|
||||
#
|
||||
_filter_mkfs()
|
||||
{
|
||||
set -
|
||||
perl -ne '
|
||||
if (/^meta-data=([\w,|\/.-]+)\s+isize=(\d+)\s+agcount=(\d+), agsize=(\d+) blks/) {
|
||||
print STDERR "ddev=$1\nisize=$2\nagcount=$3\nagsize=$4\n";
|
||||
print STDOUT "meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks\n";
|
||||
}
|
||||
if (/^\s+=\s+sectsz=(\d+)\s+attr=(\d+)/) {
|
||||
print STDERR "sectsz=$1\nattr=$2\n";
|
||||
}
|
||||
if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
|
||||
print STDERR "dbsize=$1\ndblocks=$2\nimaxpct=$3\n";
|
||||
print STDOUT "data = bsize=XXX blocks=XXX, imaxpct=PCT\n";
|
||||
}
|
||||
if (/^\s+=\s+sunit=(\d+)\s+swidth=(\d+) blks/) {
|
||||
print STDERR "sunit=$1\nswidth=$2\nunwritten=1\n";
|
||||
print STDOUT " = sunit=XXX swidth=XXX, unwritten=X\n";
|
||||
}
|
||||
if (/^naming\s+=version\s+(\d+)\s+bsize=(\d+)/) {
|
||||
print STDERR "dirversion=$1\ndirbsize=$2\n";
|
||||
print STDOUT "naming =VERN bsize=XXX\n";
|
||||
}
|
||||
if (/^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+),\s+version=(\d+)/ ||
|
||||
/^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+)/) {
|
||||
print STDERR "ldev=\"$1\"\nlbsize=$2\nlblocks=$3\nlversion=$4\n";
|
||||
print STDOUT "log =LDEV bsize=XXX blocks=XXX\n";
|
||||
}
|
||||
if (/^\s+=\s+sectsz=(\d+)\s+sunit=(\d+) blks/) {
|
||||
print STDERR "logsectsz=$1\nlogsunit=$2\n\n";
|
||||
}
|
||||
if (/^realtime\s+=([\w|\/.-]+)\s+extsz=(\d+)\s+blocks=(\d+), rtextents=(\d+)/) {
|
||||
print STDERR "rtdev=$1\nrtextsz=$2\nrtblocks=$3\nrtextents=$4\n";
|
||||
print STDOUT "realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX\n";
|
||||
}'
|
||||
}
|
||||
|
||||
|
||||
# prints the bits we care about in growfs
|
||||
#
|
||||
_filter_growfs()
|
||||
{
|
||||
perl -ne '
|
||||
if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
|
||||
print "xfs_growfs --BlockSize=$1 --Blocks=$2\n";
|
||||
}
|
||||
elsif (/^data/) {
|
||||
print;
|
||||
}'
|
||||
}
|
||||
|
||||
_filter_dd()
|
||||
{
|
||||
$AWK_PROG '
|
||||
/records in/ { next }
|
||||
/records out/ { next }
|
||||
/No space left on device/ { print " !!! disk full (expected)"
|
||||
next }
|
||||
{ print " *** " $0 }
|
||||
'
|
||||
}
|
||||
|
||||
common_line_filter()
|
||||
{
|
||||
perl -ne 'if (/.*:(.*)/) {
|
||||
if ( "$last_line" ne "$1" ) { print "$_"; $first_match=1; }
|
||||
elsif ( $first_match==1 ) { print "*\n"; $first_match=0; }
|
||||
$last_line="$1";
|
||||
}
|
||||
else {
|
||||
print $_; $last_line=$_;
|
||||
}'
|
||||
}
|
||||
|
||||
_filter_xfs_io()
|
||||
{
|
||||
sed -e "s/[0-9/.]* [GMKiBbytes]*, [0-9]* ops\; [0-9/:. sec]* ([inf0-9/.]* [EPGMKiBbytes]*\/sec and [inf0-9/.]* ops\/sec)/XXX Bytes, X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/"
|
||||
}
|
||||
|
||||
_filter_xfs_io_unique()
|
||||
{
|
||||
common_line_filter | _filter_xfs_io
|
||||
}
|
||||
|
||||
_filter_test_dir()
|
||||
{
|
||||
sed -e "s,$TEST_DEV,TEST_DEV,g" -e "s,$TEST_DIR,TEST_DIR,g"
|
||||
}
|
||||
|
||||
_filter_scratch()
|
||||
{
|
||||
sed -e "s,$SCRATCH_DEV,SCRATCH_DEV,g" \
|
||||
-e "s,$SCRATCH_MNT,SCRATCH_MNT,g" \
|
||||
-e "/.use_space/d"
|
||||
}
|
||||
|
||||
# Turn any device in the scratch pool into SCRATCH_DEV
|
||||
_filter_scratch_pool()
|
||||
{
|
||||
FILTER_STRINGS=`echo $SCRATCH_DEV_POOL | sed -e 's/\s\+/\\\|/g'`
|
||||
sed -e "s,$FILTER_STRINGS,SCRATCH_DEV,g"
|
||||
}
|
||||
|
||||
_filter_spaces()
|
||||
{
|
||||
sed -e 's/ [ ]*/ /g'
|
||||
}
|
||||
|
||||
# Account for different "ln" failure messages
|
||||
_filter_ln()
|
||||
{
|
||||
sed -e "s,\(creating symbolic link .*\) to .*: ,\1," \
|
||||
-e "s,failed to create,creating,"
|
||||
}
|
||||
|
||||
# If given an arg, filter *that* UUID string
|
||||
# Otherwise look for something that looks like a generic UUID
|
||||
_filter_uuid()
|
||||
{
|
||||
if [ ! -z $1 ]; then
|
||||
UUID=$1
|
||||
sed -e "s/\(uuid:\) $UUID/\1 <EXACTUUID>/i"
|
||||
else
|
||||
sed -e "s/\(uuid:\) *[0-9a-f-][0-9a-f-]*/\1 <UUID>/i"
|
||||
fi
|
||||
}
|
||||
|
||||
# Filter out sizes like 6.14MB etc
|
||||
_filter_size()
|
||||
{
|
||||
sed -e "s/[0-9\.]\+\s\?[b|k|m|g|t][b]\?/<SIZE>/ig"
|
||||
}
|
||||
|
||||
# Convert string read from stdin like 128K to bytes and print it to stdout
|
||||
_filter_size_to_bytes()
|
||||
{
|
||||
read size
|
||||
suffix=${size:${#size}-1}
|
||||
mul=1
|
||||
case $suffix in
|
||||
k|K) mul=1024 ;;
|
||||
m|M) mul=$((1024*1024)) ;;
|
||||
g|G) mul=$((1024*1024*1024)) ;;
|
||||
t|T) mul=$((1024*1024*1024*1024)) ;;
|
||||
esac
|
||||
echo $((${size:0:${#size}-1}*$mul))
|
||||
}
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
@@ -0,0 +1,60 @@
|
||||
# Filters for btrfs command output
|
||||
|
||||
. ./common.filter.btrfs
|
||||
|
||||
# Some, but not all, commands emit "Btrfs <version>"
|
||||
_filter_btrfs_version()
|
||||
{
|
||||
sed -e "s/^Btrfs.*//g"
|
||||
}
|
||||
|
||||
_filter_devid()
|
||||
{
|
||||
sed -e "s/\(devid\s\+\)[0-9]\+/\1 <DEVID>/g"
|
||||
}
|
||||
|
||||
# If passed a number as first arg, filter that number of devices
|
||||
# If passed a UUID as second arg, filter that exact UUID
|
||||
_filter_btrfs_filesystem_show()
|
||||
{
|
||||
if [ ! -z $1 ]; then
|
||||
NUMDEVS=$1
|
||||
NUM_SUBST="<EXACTNUM>"
|
||||
else
|
||||
NUMDEVS="[0-9]\+"
|
||||
NUM_SUBST="<NUM>"
|
||||
fi
|
||||
|
||||
UUID=""
|
||||
if [ ! -z $2 ]; then
|
||||
UUID=$2
|
||||
fi
|
||||
|
||||
# the uniq collapses all device lines into 1
|
||||
_filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
|
||||
_filter_size | _filter_btrfs_version | _filter_devid | \
|
||||
sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
|
||||
uniq
|
||||
}
|
||||
|
||||
# This eliminates all numbers, and shows only unique lines,
|
||||
# to accomodate a varying nr. of devices.
|
||||
# If given an argument, make sure we saw that many devices
|
||||
# in total.
|
||||
_filter_btrfs_device_stats()
|
||||
{
|
||||
if [ ! -z $1 ]; then
|
||||
NUMDEVS=$1
|
||||
UNIQ_OPT="-c"
|
||||
else
|
||||
NUMDEVS="thiswillnotmatch"
|
||||
UNIQ_OPT=""
|
||||
fi
|
||||
|
||||
_filter_scratch | _filter_scratch_pool | \
|
||||
sed -e "s/[0-9]\+$/<NUM>/g" | sort | uniq $UNIQ_OPT | \
|
||||
sed -e "s/$NUMDEVS /<NUMDEVS> /g"
|
||||
}
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
+475
@@ -0,0 +1,475 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2000-2002 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# common routines for log testing
|
||||
# Created by dxm@sgi.com & tes@sgi.com
|
||||
#
|
||||
|
||||
fulldir=$RESULT_DIR/$seq.fulldir
|
||||
rm -rf $fulldir
|
||||
|
||||
_cleanup_logfiles()
|
||||
{
|
||||
if [ $status -eq 0 ]; then
|
||||
# don't keep these files around unless something went wrong
|
||||
rm -rf $fulldir
|
||||
fi
|
||||
}
|
||||
|
||||
_full()
|
||||
{
|
||||
echo "" >>$RESULT_DIR/$seq.full
|
||||
echo "*** $* ***" >>$RESULT_DIR/$seq.full
|
||||
echo "" >>$RESULT_DIR/$seq.full
|
||||
}
|
||||
|
||||
_echofull()
|
||||
{
|
||||
echo "" | tee -a $RESULT_DIR/$seq.full
|
||||
echo "*** $* ***" | tee -a $RESULT_DIR/$seq.full
|
||||
echo "" | tee -a $RESULT_DIR/$seq.full
|
||||
}
|
||||
|
||||
# Handle the operations which get split over Log Record
|
||||
# boundaries.
|
||||
# Oper (379)..... flags: CONTINUE
|
||||
# ...
|
||||
# Oper (0)....... flags: WAS_CONT END
|
||||
#
|
||||
# or
|
||||
#
|
||||
# Oper (379)..... flags: none
|
||||
# ...
|
||||
# Oper (0)....... flags: none
|
||||
#
|
||||
_filter_opnum()
|
||||
{
|
||||
$AWK_PROG '
|
||||
BEGIN {
|
||||
debug = 0
|
||||
}
|
||||
/^Oper/ && debug {
|
||||
printf "line = %s\n", $0
|
||||
}
|
||||
/^Oper/ {
|
||||
was_cont = 0
|
||||
}
|
||||
/^Oper/ && /flags: CONTINUE/ {
|
||||
# this will be the first op of split region
|
||||
$9 = "none" # overwrite CONTINUE flags
|
||||
print
|
||||
print "Not printing rest"
|
||||
was_cont = 1
|
||||
next
|
||||
}
|
||||
/^Oper/ && /flags: WAS_CONT END/ {
|
||||
# this will be the last op of split region
|
||||
# skip over was-continued op
|
||||
# we assume there can be only 1
|
||||
was_cont = 1
|
||||
next
|
||||
}
|
||||
(was_cont == 1) {
|
||||
# skip over any continued op stuff
|
||||
next
|
||||
}
|
||||
{print}
|
||||
'
|
||||
}
|
||||
|
||||
#
|
||||
# Filter out things that can change
|
||||
# We have complexities which change when log is sync'ed at different
|
||||
# times.
|
||||
# Example1: DATA FORK EXTENTS
|
||||
# These will not show up if inode is sync'ed sooner
|
||||
# /DATA FORK EXTENTS/d;
|
||||
# /INODE:/s/flags:0x5/flags:0x1/g;
|
||||
# define XFS_ILOG_CORE 0x001 /* log standard inode fields */
|
||||
# define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
|
||||
#
|
||||
#
|
||||
|
||||
_filter_logprint()
|
||||
{
|
||||
_fix_malloc |\
|
||||
sed '
|
||||
s/ver:[0-9]/ver:<VERS>/;
|
||||
s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
|
||||
s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
|
||||
s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
|
||||
s/log file: \".*\"/log device: <DEVICE>/;
|
||||
s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
|
||||
s/length: [0-9][0-9]*/length: <LENGTH>/;
|
||||
s/length: [0-9][0-9]*/length: <LENGTH>/;
|
||||
s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
|
||||
s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
|
||||
s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
|
||||
s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
|
||||
s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
|
||||
s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
|
||||
s/blkno: *[0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
|
||||
s/blkno: *[0-9][0-9]*/blkno: <BLKNO>/g;
|
||||
s/boff: [0-9][0-9]*/boff: <BOFF>/g;
|
||||
s/len: *[0-9][0-9]*/len:<LEN>/g;
|
||||
/BUF:/s/[ ]*flags:.*$//;
|
||||
/zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
|
||||
/cleared blocks/d;
|
||||
/log tail/s/[0-9][0-9]*/<COUNT>/g;
|
||||
s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
|
||||
s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
|
||||
s/block [0-9][0-9]*/block <BLOCK>/;
|
||||
s/icount: *[0-9][0-9]* *ifree: *[0-9][0-9]* *fdblks: *[0-9][0-9]* *frext: *[0-9][0-9]*/icount:<COUNT> ifree:<FREE> fdblks:<BLOCKS> frext:<COUNT>/;
|
||||
s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
|
||||
s/1st: *[0-9][0-9]* *last: *[0-9][0-9]* *cnt: *[0-9][0-9]* *freeblks: *[0-9][0-9]* *longest: *[0-9][0-9]*/1st:<NUM> last:<NUM> cnt:<COUNT> freeblks:<COUNT> longest:<NUM>/;
|
||||
s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
|
||||
/flushiter:/d;
|
||||
/version:/,/h_size:/d;
|
||||
/override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
|
||||
/^---*/d;
|
||||
/^===*/d;
|
||||
/^~~~*/d;
|
||||
/extended-header/d;
|
||||
/LOG REC AT LSN/d;
|
||||
/DATA FORK EXTENTS/d;
|
||||
s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
|
||||
s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
|
||||
s/#regs: *[1-9][0-9]*/#regs:R/;
|
||||
/INODE:/s/flags:0x5/flags:0x1/g;
|
||||
s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
|
||||
/^[ ]*$/d;
|
||||
s/ */ /g;
|
||||
s/ $//;
|
||||
s/newino: 0x[0-9a-f]*$/newino: <INO>/g
|
||||
s/newino:0x[0-9a-f]*$/newino:<INO>/g
|
||||
s/ino: 0x[0-9a-f]* flags:/ino: <INO> flags:/g
|
||||
s/ino:0x[0-9a-f]* flags:/ino:<INO> flags:/g
|
||||
s/onlink:[0-9][0-9]*/onlink:<ONLINK>/;
|
||||
s/gen:-*[0-9][0-9]*/gen:<GEN>/;
|
||||
s/gen 0x[0-9a-f][0-9a-f]*/gen <GEN>/;
|
||||
'|\
|
||||
awk '
|
||||
# collapse BUF DATA group into 1 line
|
||||
# for Oper data this can be over separate operations...ughh
|
||||
/BUF DATA/ {
|
||||
if (!buf_data) { # 1st one
|
||||
if (oper) {
|
||||
print oper
|
||||
oper = 0
|
||||
}
|
||||
print
|
||||
}
|
||||
buf_data = 1
|
||||
oper = 0 # wont need it now
|
||||
next
|
||||
}
|
||||
/^Oper/ {
|
||||
# store it as we dont know if 2nd BUF DATA is to follow
|
||||
if (oper) {
|
||||
print oper
|
||||
}
|
||||
oper = $0
|
||||
next
|
||||
}
|
||||
/^TRANS/ && dummy_rec == 1 {
|
||||
# start printing again - dummy transaction over
|
||||
dummy_rec = 0
|
||||
}
|
||||
/DUMMY1/ {
|
||||
# filter out dummy transactions
|
||||
dummy_rec = 1
|
||||
next
|
||||
}
|
||||
{
|
||||
if (dummy_rec) {
|
||||
next
|
||||
}
|
||||
buf_data = 0
|
||||
if (oper) { # now we can print out oper
|
||||
print oper
|
||||
oper = 0
|
||||
}
|
||||
print
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
_check_log()
|
||||
{
|
||||
_full "clean_log : xfs_logprint"
|
||||
_scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
|
||||
| head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
|
||||
}
|
||||
|
||||
_print_logstate()
|
||||
{
|
||||
_scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full >$tmp.logprint
|
||||
if grep -q "<DIRTY>" $tmp.logprint; then
|
||||
echo "dirty log"
|
||||
fi
|
||||
if grep -q "<CLEAN>" $tmp.logprint; then
|
||||
echo "clean log"
|
||||
fi
|
||||
}
|
||||
|
||||
_print_operation()
|
||||
{
|
||||
mkdir $fulldir >/dev/null 2>&1
|
||||
mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
|
||||
mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
|
||||
raw=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
|
||||
filtered=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
|
||||
|
||||
echo "### xfs_logprint output ###" | tee $raw >$filtered
|
||||
_scratch_xfs_logprint -c 2>&1 \
|
||||
| tee -a $raw \
|
||||
| _filter_logprint \
|
||||
| _filter_opnum \
|
||||
>>$filtered
|
||||
}
|
||||
|
||||
# start at rec#2 "-s 2" so we skip over UMOUNT record which will always
|
||||
# be a 512b single header at mkfs time
|
||||
# and may not match with the FS mounted at a different LR size
|
||||
# => xlog_do_recovery_pass() can not handle the different hdr sizes
|
||||
# it assumes them all to be the same between the start..finish
|
||||
# NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
|
||||
|
||||
_print_transaction_inode()
|
||||
{
|
||||
_start=$1
|
||||
mkdir $fulldir >/dev/null 2>&1
|
||||
mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
|
||||
mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
|
||||
raw=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
|
||||
filtered=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
|
||||
|
||||
echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
|
||||
_scratch_xfs_logprint -t -i -s $_start 2>&1 \
|
||||
| tee -a $raw \
|
||||
| _filter_logprint \
|
||||
>>$filtered
|
||||
}
|
||||
|
||||
_print_transaction_buf()
|
||||
{
|
||||
_start=$1
|
||||
mkdir $fulldir >/dev/null 2>&1
|
||||
mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
|
||||
mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
|
||||
raw=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
|
||||
filtered=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
|
||||
|
||||
echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
|
||||
_scratch_xfs_logprint -t -b -s $_start 2>&1 \
|
||||
| tee -a $raw \
|
||||
| _filter_logprint \
|
||||
>>$filtered
|
||||
}
|
||||
|
||||
_mkfs_log()
|
||||
{
|
||||
# create the FS
|
||||
# mkfs options to append to log size otion can be specified ($*)
|
||||
export MKFS_OPTIONS="-l size=2000b -l lazy-count=1 $*"
|
||||
_full "mkfs"
|
||||
_scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# mount fs and create some log traffic
|
||||
#
|
||||
_create_log()
|
||||
{
|
||||
# mount the FS
|
||||
_full "mount"
|
||||
_scratch_mount >>$RESULT_DIR/$seq.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "mount failed: $MOUNT_OPTIONS"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# generate some log traffic - but not too much - life gets a little
|
||||
# more complicated if the log wraps around. This traffic is
|
||||
# pretty much arbitary, but could probably be made better than this.
|
||||
touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
|
||||
|
||||
# unmount the FS
|
||||
_full "umount"
|
||||
umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "umount failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# mount fs and create some log traffic with sync'ing
|
||||
#
|
||||
_create_log_sync()
|
||||
{
|
||||
# mount the FS
|
||||
_full " mount"
|
||||
_scratch_mount >>$RESULT_DIR/$seq.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "mount failed: $MOUNT_OPTIONS"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# generate some log traffic - but not too much
|
||||
# add some syncs to get the log flushed to disk
|
||||
for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
|
||||
touch $file
|
||||
sync
|
||||
done
|
||||
|
||||
# unmount the FS
|
||||
_full "umount"
|
||||
umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "umount failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
_cmp_output()
|
||||
{
|
||||
echo "*** compare logprint: $1 with $2"
|
||||
if ! diff $1 $2 >/dev/null; then
|
||||
_fail "logprint output $1 differs to $2"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Op data of different Log Record sizes will mean that data is
|
||||
# split at different points and in op printing it will not
|
||||
# try and decode the data which has been split up.
|
||||
# So we do a special diff processing to complain of differences
|
||||
# if no split is involved.
|
||||
#
|
||||
# Example diff with forms of:
|
||||
# "Left over region from split log item"
|
||||
# "Not printing rest of data"
|
||||
#
|
||||
# 2149c2149
|
||||
# < Left over region from split log item
|
||||
# ---
|
||||
# > BUF DATA
|
||||
# 2888c2888,2889
|
||||
# < INODE: #regs: 3 Not printing rest of data
|
||||
# ---
|
||||
# > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
|
||||
# > blkno: <BLKNO> len:<LEN> boff: <BOFF>
|
||||
#
|
||||
_process_op_diff()
|
||||
{
|
||||
$AWK_PROG <$1 '
|
||||
BEGIN { num_splits = 1; max_splits = 50 }
|
||||
/^[0-9]/ {
|
||||
|
||||
# ensure a split happened in previous difference
|
||||
if (num_splits < 1 || num_splits > max_splits) {
|
||||
print num_splits, " split(s) found prior to diff cmd: ", $0
|
||||
num_splits = 1 # shut-up end condition
|
||||
exit 1
|
||||
}
|
||||
num_splits = 0
|
||||
|
||||
next
|
||||
}
|
||||
/Left over region/ || /Not printing rest/ {
|
||||
num_splits++
|
||||
next
|
||||
}
|
||||
{ next }
|
||||
END {
|
||||
if (num_splits < 1 || num_splits > max_splits) {
|
||||
print num_splits, " split(s) found prior to diff end"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
'
|
||||
return $?
|
||||
}
|
||||
|
||||
_cmp_op_output()
|
||||
{
|
||||
echo "*** compare logprint: $1 with $2"
|
||||
|
||||
diff $1 $2 >$filtered.diff
|
||||
if ! _process_op_diff $filtered.diff
|
||||
then
|
||||
_fail "logprint output $1 differs to $2 considering splits"
|
||||
fi
|
||||
}
|
||||
|
||||
# return xfs log version of device
|
||||
# e.g.
|
||||
# _log_version /dev/dsk/dks0d1s4
|
||||
#
|
||||
_log_version()
|
||||
{
|
||||
_dev=$1
|
||||
vers=`xfs_db -c 'sb 0' -c 'p versionnum' -r $_dev | $AWK_PROG '{print $3}'`
|
||||
logver=`echo $vers | sed -e 's/0x[0-9a-f]\([0-9a-f]\)[0-9a-f][0-9a-f]/\1/'`
|
||||
if [ $logver = 4 -o $logver = 5 -o $logver = 6 -o $logver = 7 -o \
|
||||
$logver = c -o $logver = d -o $logver = e -o $logver = f ]; then
|
||||
echo 2
|
||||
else
|
||||
echo 1
|
||||
fi
|
||||
}
|
||||
|
||||
_require_v2log()
|
||||
{
|
||||
# test out mkfs to see if it supports "-l version=2"
|
||||
export MKFS_OPTIONS="-l version=2"
|
||||
if ! _scratch_mkfs_xfs >>$RESULT_DIR/$seq.full 2>&1; then
|
||||
_notrun "mkfs does not support v2 logs"
|
||||
fi
|
||||
|
||||
# test out mount to see if it mounts a v2 log fs
|
||||
export MOUNT_OPTIONS="-o logbsize=32k"
|
||||
if ! _scratch_mount >>$RESULT_DIR/$seq.full 2>&1; then
|
||||
_notrun "mount/kernel does not support v2 logs"
|
||||
fi
|
||||
|
||||
# check after unmount to see if it is clean
|
||||
# i.e. it is not a 6.5.25 buggy version checking kernel
|
||||
touch $SCRATCH_MNT/file
|
||||
umount $SCRATCH_DEV >>$RESULT_DIR/$seq.full 2>&1
|
||||
if _scratch_xfs_logprint -t | tee -a $RESULT_DIR/$seq.full \
|
||||
| head | grep -q "<DIRTY>"; then
|
||||
_notrun "kernel does not support v2 logs"
|
||||
fi
|
||||
|
||||
# otherwise presume it does support v2 logs...:)
|
||||
}
|
||||
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
+525
File diff suppressed because it is too large
Load Diff
+282
@@ -0,0 +1,282 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Functions useful for quota tests
|
||||
#
|
||||
|
||||
#
|
||||
# checks that the generic quota support in the kernel is enabled
|
||||
# and that we have valid quota user tools installed.
|
||||
#
|
||||
_require_quota()
|
||||
{
|
||||
[ -n $QUOTA_PROG ] || _notrun "Quota user tools not installed"
|
||||
|
||||
case $FSTYP in
|
||||
ext2|ext3|ext4|ext4dev|reiserfs)
|
||||
if [ ! -d /proc/sys/fs/quota ]; then
|
||||
_notrun "Installed kernel does not support quotas"
|
||||
fi
|
||||
;;
|
||||
gfs2)
|
||||
;;
|
||||
xfs)
|
||||
if [ ! -f /proc/fs/xfs/xqmstat ]; then
|
||||
_notrun "Installed kernel does not support XFS quotas"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
_notrun "disk quotas not supported by this filesystem type: $FSTYP"
|
||||
;;
|
||||
esac
|
||||
|
||||
# SELinux adds extra xattrs which can mess up our expected output.
|
||||
# So, mount with a context, and they won't be created
|
||||
# nfs_t is a "liberal" context so we can use it.
|
||||
if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
|
||||
export SELINUX_MOUNT_OPTIONS="-o context=system_u:object_r:nfs_t:s0"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# checks that the XFS quota support in the kernel is enabled
|
||||
# and that we have valid quota user tools installed.
|
||||
#
|
||||
_require_xfs_quota()
|
||||
{
|
||||
src/feature -q $TEST_DEV
|
||||
[ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
|
||||
[ -n $XFS_QUOTA_PROG ] || _notrun "XFS quota user tools not installed"
|
||||
}
|
||||
|
||||
#
|
||||
# checks that the XFS project quota support in the kernel is enabled.
|
||||
#
|
||||
_require_prjquota()
|
||||
{
|
||||
[ -n "$1" ] && _dev="$1" || _dev="$TEST_DEV"
|
||||
src/feature -p $_dev
|
||||
[ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
|
||||
}
|
||||
|
||||
#
|
||||
# checks for user nobody in /etc/passwd and /etc/group.
|
||||
#
|
||||
_require_nobody()
|
||||
{
|
||||
_cat_passwd | grep -q '^nobody'
|
||||
[ $? -ne 0 ] && _notrun "password file does not contain user nobody."
|
||||
|
||||
_cat_group | egrep -q '^no(body|group)'
|
||||
[ $? -ne 0 ] && _notrun "group file does not contain nobody/nogroup."
|
||||
}
|
||||
|
||||
# create a file as a specific user (uid)
|
||||
# takes filename, id, type (u/g/p), blocksize, blockcount
|
||||
#
|
||||
_file_as_id()
|
||||
{
|
||||
[ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
|
||||
|
||||
parent=`dirname $1`
|
||||
if [ $3 = p ]; then
|
||||
echo PARENT: xfs_io -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full
|
||||
$XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$RESULT_DIR/$seq.full 2>&1
|
||||
magik='$>' # (irrelevent, above set projid-inherit-on-parent)
|
||||
elif [ $3 = u ]; then
|
||||
magik='$>' # perlspeak for effective uid
|
||||
elif [ $3 = g ]; then
|
||||
magik='$)' # perlspeak for effective gid
|
||||
else
|
||||
_notrun "broken type in call to _file_as_id in test $seq"
|
||||
fi
|
||||
|
||||
perl <<EOF >>$RESULT_DIR/$seq.full 2>&1
|
||||
\$| = 1;
|
||||
$magik = $2;
|
||||
if ($5 == 0) {
|
||||
print "touch $1";
|
||||
exec "touch $1";
|
||||
} else {
|
||||
print "dd if=/dev/zero of=$1 bs=$4 count=$5";
|
||||
exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
|
||||
}
|
||||
EOF
|
||||
# for debugging the above euid change, try... [need write in cwd]
|
||||
# exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$RESULT_DIR/$seq.full 2>&1";
|
||||
|
||||
if [ $3 = p ]; then
|
||||
echo PARENT: xfs_io -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full
|
||||
$XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$RESULT_DIR/$seq.full 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
_choose_uid()
|
||||
{
|
||||
_cat_passwd | grep '^nobody' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
|
||||
}
|
||||
|
||||
_choose_gid()
|
||||
{
|
||||
_cat_group | egrep '^no(body|group)' | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
|
||||
}
|
||||
|
||||
_choose_prid()
|
||||
{
|
||||
if [ "X$projid_file" == "X" ]; then
|
||||
projid_file=/etc/projid
|
||||
fi
|
||||
if [ ! -f $projid_file ]; then
|
||||
echo 0
|
||||
return
|
||||
fi
|
||||
perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
|
||||
$projid_file
|
||||
}
|
||||
|
||||
_qmount()
|
||||
{
|
||||
umount $SCRATCH_DEV >/dev/null 2>&1
|
||||
_scratch_mount || _fail "qmount failed"
|
||||
chmod ugo+rwx $SCRATCH_MNT
|
||||
}
|
||||
|
||||
_qsetup()
|
||||
{
|
||||
# setup exactly what it is we'll be testing
|
||||
enforce=1
|
||||
if src/feature -u $SCRATCH_DEV
|
||||
then
|
||||
type=u ;
|
||||
eval `_choose_uid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.usrquota $seq.out
|
||||
elif src/feature -g $SCRATCH_DEV
|
||||
then
|
||||
type=g
|
||||
eval `_choose_gid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.grpquota $seq.out
|
||||
elif src/feature -p $SCRATCH_DEV
|
||||
then
|
||||
type=p
|
||||
eval `_choose_prid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.prjquota $seq.out
|
||||
elif src/feature -U $SCRATCH_DEV
|
||||
then
|
||||
type=u
|
||||
eval `_choose_uid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.uqnoenforce $seq.out
|
||||
enforce=0
|
||||
elif src/feature -G $SCRATCH_DEV
|
||||
then
|
||||
type=g
|
||||
eval `_choose_gid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.gqnoenforce $seq.out
|
||||
enforce=0
|
||||
elif src/feature -P $SCRATCH_DEV
|
||||
then
|
||||
type=p
|
||||
eval `_choose_prid`
|
||||
[ ! -f $seq.out ] && ln -s $seq.pqnoenforce $seq.out
|
||||
enforce=0
|
||||
else
|
||||
_notrun "No quota support at mount time"
|
||||
fi
|
||||
|
||||
echo "Using output from '" `ls -l $seq.out` "'" >>$RESULT_DIR/$seq.full
|
||||
echo "and using type=$type id=$id" >>$RESULT_DIR/$seq.full
|
||||
}
|
||||
|
||||
#
|
||||
# Ensures only the given quota mount option is used
|
||||
#
|
||||
_qmount_option()
|
||||
{
|
||||
# Replace any user defined quota options
|
||||
# with the quota option that we want.
|
||||
# Simplest to do this rather than delete existing ones first because
|
||||
# of the variety of commas and spaces and multiple -o's
|
||||
# that we'd have to cater for. Doesn't matter if we have duplicates.
|
||||
# Use "QUOTA" string so that we don't have any substring confusion
|
||||
# thanks to "quota" which will match with "uquota" and "gquota" etc.
|
||||
export MOUNT_OPTIONS=`echo $MOUNT_OPTIONS \
|
||||
| sed -e 's/uquota/QUOTA/g' \
|
||||
-e 's/usrquota/QUOTA/g' \
|
||||
-e 's/gquota/QUOTA/g' \
|
||||
-e 's/grpquota/QUOTA/g' \
|
||||
-e 's/pquota/QUOTA/g' \
|
||||
-e 's/quota/QUOTA/g' \
|
||||
-e 's/uqnoenforce/QUOTA/g' \
|
||||
-e 's/gqnoenforce/QUOTA/g' \
|
||||
-e 's/pqnoenforce/QUOTA/g' \
|
||||
-e 's/qnoenforce/QUOTA/g' \
|
||||
-e "s/QUOTA/$1/g"`
|
||||
|
||||
# Ensure we have the given quota option - duplicates are fine
|
||||
export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
|
||||
echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$RESULT_DIR/$seq.full
|
||||
}
|
||||
|
||||
_check_quota_usage()
|
||||
{
|
||||
# Sync to get delalloc to disk
|
||||
sync
|
||||
|
||||
# kill caches to guarantee removal speculative delalloc
|
||||
# XXX: really need an ioctl instead of this big hammer
|
||||
echo 3 > /proc/sys/vm/drop_caches
|
||||
|
||||
VFS_QUOTA=0
|
||||
case $FSTYP in
|
||||
ext2|ext3|ext4|ext4dev|reiserfs)
|
||||
VFS_QUOTA=1
|
||||
quotaon -f -u -g $SCRATCH_MNT 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
|
||||
sort >$tmp.user.orig
|
||||
repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
|
||||
sort >$tmp.group.orig
|
||||
if [ $VFS_QUOTA -eq 1 ]; then
|
||||
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
|
||||
else
|
||||
# use XFS method to force quotacheck
|
||||
xfs_quota -x -c "off -ug" $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
_scratch_mount "-o usrquota,grpquota"
|
||||
fi
|
||||
repquota -u -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
|
||||
sort >$tmp.user.checked
|
||||
repquota -g -n $SCRATCH_MNT | grep -v "^#0" | _filter_scratch |
|
||||
sort >$tmp.group.checked
|
||||
if [ $VFS_QUOTA -eq 1 ]; then
|
||||
quotaon -u -g $SCRATCH_MNT 2>/dev/null
|
||||
fi
|
||||
{
|
||||
echo "Comparing user usage"
|
||||
diff $tmp.user.orig $tmp.user.checked
|
||||
} && {
|
||||
echo "Comparing group usage"
|
||||
diff $tmp.group.orig $tmp.group.checked
|
||||
}
|
||||
}
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2000-2002 Silicon Graphics, Inc. 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
|
||||
#
|
||||
#
|
||||
# Functions useful for xfs_repair tests
|
||||
#
|
||||
|
||||
_zero_position()
|
||||
{
|
||||
value=$1
|
||||
struct="$2"
|
||||
|
||||
# set values for off/len variables provided by db
|
||||
eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
|
||||
if (/byte offset (\d+), length (\d+)/) {
|
||||
print "offset=$1\nlength=$2\n"; exit
|
||||
}'`
|
||||
if [ -z "$offset" -o -z "$length" ]; then
|
||||
echo "cannot calculate offset ($offset) or length ($length)"
|
||||
exit
|
||||
fi
|
||||
length=`expr $length / 512`
|
||||
src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
|
||||
| perl -npe 's/\d\.\d\dKb/X.XXKb/g'
|
||||
}
|
||||
|
||||
_filter_repair()
|
||||
{
|
||||
perl -ne '
|
||||
# for sb
|
||||
/- agno = / && next; # remove each AG line (variable number)
|
||||
s/(pointer to) (\d+)/\1 INO/;
|
||||
s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
|
||||
s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
|
||||
s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
|
||||
s/(inconsistent with calculated value) (\d+)/\1 INO/;
|
||||
s/\.+(found)/\1/g; # remove "searching" output
|
||||
# for agf + agi
|
||||
s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
|
||||
s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
|
||||
s/(bad agbno) (\d+)/\1 AGBNO/g;
|
||||
s/(max =) (\d+)/\1 MAX/g;
|
||||
# for root inos
|
||||
s/(on inode) (\d+)/\1 INO/g;
|
||||
s/(imap claims a free inode) (\d+)/\1 INO/;
|
||||
s/(imap claims in-use inode) (\d+)/\1 INO/;
|
||||
s/(cleared root inode) (\d+)/\1 INO/;
|
||||
s/(resetting inode) (\d+)/\1 INO/;
|
||||
s/(disconnected dir inode) (\d+)/\1 INO/;
|
||||
# for log
|
||||
s/internal log/<TYPEOF> log/g;
|
||||
s/external log on \S+/<TYPEOF> log/g;
|
||||
# realtime subvol - remove this whole line if it appears
|
||||
s/ - generate realtime summary info and bitmap...\n//g;
|
||||
#
|
||||
# new xfs repair output filters
|
||||
#
|
||||
s/\s+- creating \d+ worker thread\(s\)\n//g;
|
||||
s/\s+- reporting progress in intervals of \d+ minutes\n//g;
|
||||
s/\s+- \d+:\d\d:\d\d:.*\n//g;
|
||||
# 3.1.0 extra accounting output
|
||||
/^agf_/ && next; # remove agf counts
|
||||
/^agi_/ && next; # remove agi counts
|
||||
/^sb_/ && next; # remove sb counts
|
||||
/^agi unlinked/ && next; # remove agi unlinked bucket warning
|
||||
# crc enabled filesystem output
|
||||
/XFS_CORRUPTION_ERROR/ && next;
|
||||
/^bad uuid/ && next;
|
||||
print;'
|
||||
}
|
||||
|
||||
_filter_dd()
|
||||
{
|
||||
fgrep -v records # lose records in/out lines
|
||||
}
|
||||
|
||||
# do some controlled corrupting & ensure repair recovers us
|
||||
#
|
||||
_check_repair()
|
||||
{
|
||||
value=$1
|
||||
structure="$2"
|
||||
|
||||
#ensure the filesystem has been dirtied since last repair
|
||||
_scratch_mount
|
||||
POSIXLY_CORRECT=yes \
|
||||
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
|
||||
sync
|
||||
rm -f $SCRATCH_MNT/sh
|
||||
umount $SCRATCH_MNT
|
||||
|
||||
_zero_position $value "$structure"
|
||||
_scratch_xfs_repair 2>&1 | _filter_repair
|
||||
|
||||
# some basic sanity checks...
|
||||
_check_scratch_fs
|
||||
_scratch_mount #mount
|
||||
POSIXLY_CORRECT=yes \
|
||||
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
|
||||
POSIXLY_CORRECT=yes \
|
||||
dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
|
||||
rm -f $SCRATCH_MNT/sh #unlink
|
||||
umount $SCRATCH_MNT #umount
|
||||
}
|
||||
|
||||
# make sure this script returns success
|
||||
/bin/true
|
||||
@@ -0,0 +1,63 @@
|
||||
##/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012 Red Hat, Inc
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Written by Eric Sandeen <sandeen@redhat.com>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Functions useful for tests on unique block devices
|
||||
#
|
||||
|
||||
_require_scsi_debug()
|
||||
{
|
||||
# make sure we have the module and it's not already used
|
||||
modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
|
||||
lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use")
|
||||
# make sure it has the features we need
|
||||
# logical/physical sectors plus unmap support all went in together
|
||||
modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
|
||||
}
|
||||
|
||||
# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]]
|
||||
_get_scsi_debug_dev()
|
||||
{
|
||||
# Defaults to phys 512, logical 512, aligned
|
||||
physical=${1-512}
|
||||
logical=${2-512}
|
||||
unaligned=${3-0}
|
||||
size=${4-128}
|
||||
|
||||
phys_exp=0
|
||||
while [ $logical -lt $physical ]; do
|
||||
let physical=physical/2
|
||||
let phys_exp=phys_exp+1
|
||||
done
|
||||
opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size"
|
||||
echo "scsi_debug options $opts" >> $RESULT_DIR/$seq.full
|
||||
modprobe scsi_debug $opts
|
||||
[ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
|
||||
sleep 1
|
||||
device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
|
||||
echo "/dev/$device"
|
||||
}
|
||||
|
||||
_put_scsi_debug_dev()
|
||||
{
|
||||
sleep 1
|
||||
lsmod | grep -wq scsi_debug || return
|
||||
rmmod scsi_debug || _fail "Could not remove scsi_debug module"
|
||||
}
|
||||
Reference in New Issue
Block a user