mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
702421f528
I'm working on a set of kernel patches to change how writeback errors are handled and reported in the kernel. Instead of reporting a writeback error to only the first fsync caller on the file, it has the the kernel report them once on every file description that was open at the time of the error. This patch adds a test for this new behavior. Basically, open many fds to the same file, turn on dm_error, write to each of the fds, and then fsync them all to ensure that they all get an error back. To do that, I'm adding a new tools/dmerror script that the C program can use to load the error table from the script. It's also suitable for setting up, frobbing and tearing down a dmerror device for by-hand testing. For now, only ext2/3/4 and xfs are whitelisted on this test, since those filesystems are included in the initial patchset. We can add to that as we convert filesystems, and eventually make it a more general test. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
107 lines
2.6 KiB
Plaintext
107 lines
2.6 KiB
Plaintext
##/bin/bash
|
|
#
|
|
# Copyright (c) 2015 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
|
|
#
|
|
#
|
|
# common functions for setting up and tearing down a dmerror device
|
|
|
|
echo $MOUNT_OPTIONS | grep -q dax
|
|
if [ $? -eq 0 ]; then
|
|
_notrun "Cannot run tests with DAX on dmerror devices"
|
|
fi
|
|
|
|
_dmerror_setup()
|
|
{
|
|
local dm_backing_dev=$SCRATCH_DEV
|
|
|
|
local blk_dev_size=`blockdev --getsz $dm_backing_dev`
|
|
|
|
DMERROR_DEV='/dev/mapper/error-test'
|
|
|
|
DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0"
|
|
|
|
DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
|
|
}
|
|
|
|
_dmerror_init()
|
|
{
|
|
_dmerror_setup
|
|
$DMSETUP_PROG remove error-test > /dev/null 2>&1
|
|
$DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
|
|
_fatal "failed to create dm linear device"
|
|
}
|
|
|
|
_dmerror_mount()
|
|
{
|
|
_scratch_options mount
|
|
$MOUNT_PROG -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
|
|
$DMERROR_DEV $SCRATCH_MNT
|
|
}
|
|
|
|
_dmerror_unmount()
|
|
{
|
|
umount $SCRATCH_MNT
|
|
}
|
|
|
|
_dmerror_cleanup()
|
|
{
|
|
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
|
|
# wait for device to be fully settled so that 'dmsetup remove' doesn't
|
|
# fail due to EBUSY
|
|
$UDEV_SETTLE_PROG >/dev/null 2>&1
|
|
$DMSETUP_PROG remove error-test > /dev/null 2>&1
|
|
}
|
|
|
|
_dmerror_load_error_table()
|
|
{
|
|
suspend_opt="--nolockfs"
|
|
|
|
if [ "$1" = "lockfs" ]; then
|
|
suspend_opt=""
|
|
elif [ -n "$*" ]; then
|
|
suspend_opt="$*"
|
|
fi
|
|
|
|
$DMSETUP_PROG suspend $suspend_opt error-test
|
|
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
|
|
|
|
$DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
|
|
[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
|
|
|
|
$DMSETUP_PROG resume error-test
|
|
[ $? -ne 0 ] && _fail "dmsetup resume failed"
|
|
}
|
|
|
|
_dmerror_load_working_table()
|
|
{
|
|
suspend_opt="--nolockfs"
|
|
|
|
if [ "$1" = "lockfs" ]; then
|
|
suspend_opt=""
|
|
elif [ -n "$*" ]; then
|
|
suspend_opt="$*"
|
|
fi
|
|
|
|
$DMSETUP_PROG suspend $suspend_opt error-test
|
|
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
|
|
|
|
$DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
|
|
[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
|
|
|
|
$DMSETUP_PROG resume error-test
|
|
[ $? -ne 0 ] && _fail "dmsetup resume failed"
|
|
}
|