diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-06-17 09:39:52 -0700 |
---|---|---|
committer | Eryu Guan <eguan@redhat.com> | 2016-07-07 12:24:13 +0800 |
commit | 872ccc54ca2c5ca32b1255d32e3eac012d42e98c (patch) | |
tree | 993389257f6a8cb0c1f81b7dd2488be4e1d285a2 /common/inject | |
parent | 219d4cdcb6eab785fb92175795d2b655e7b656ad (diff) |
xfs: inject errors at various parts of the deferred op completion
Use the error injection mechanism to test log recovery of deferred
work.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Diffstat (limited to 'common/inject')
-rw-r--r-- | common/inject | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/common/inject b/common/inject new file mode 100644 index 00000000..8ecc2901 --- /dev/null +++ b/common/inject @@ -0,0 +1,93 @@ +##/bin/bash +# Routines for injecting errors into filesystems +#----------------------------------------------------------------------- +# Copyright (c) 2016 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; 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: Oracle Corporation, 500 Oracle Parkway, +# Redwood Shores, CA 94065, USA, or: http://www.oracle.com/ +#----------------------------------------------------------------------- +. ./common/log + +# Tests whether $FSTYP is one of the filesystems that supports error injection +_require_error_injection() +{ + case "$FSTYP" in + "xfs") + grep -q 'debug 1' /proc/fs/xfs/stat || \ + _notrun "XFS error injection requires CONFIG_XFS_DEBUG" + ;; + *) + _notrun "Error injection not supported on filesystem type: $FSTYP" + esac +} + +# Requires that xfs_io inject command knows about this error type +_require_xfs_io_error_injection() +{ + type="$1" + _require_error_injection + + # NOTE: We can't actually test error injection here because xfs + # hasn't always range checked the argument to xfs_errortag_add. + # We also don't want to trip an error before we're ready to deal + # with it. + + $XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \ + _notrun "XFS error injection $type unknown." +} + +# Inject an error into the test fs +_test_inject_error() +{ + type="$1" + + $XFS_IO_PROG -x -c "inject $type" $TEST_DIR +} + +# Inject an error into the scratch fs +_scratch_inject_error() +{ + type="$1" + + $XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT +} + +# Unmount and remount the scratch device, dumping the log +_scratch_inject_logprint() +{ + local opts="$1" + + if test -n "$opts"; then + opts="-o $opts" + fi + _scratch_unmount + _scratch_dump_log + _scratch_mount "$opts" +} + +# Unmount and remount the test device, dumping the log +_test_inject_logprint() +{ + local opts="$1" + + if test -n "$opts"; then + opts="-o $opts" + fi + _test_unmount + _test_dump_log + _test_mount "$opts" +} |