zfs/scripts/zpool-config/lo-faulty-raid0.sh

78 lines
2.6 KiB
Bash
Raw Normal View History

Add zfault zpool configurations and tests Eleven new zpool configurations were added to allow testing of various failure cases. The first 5 zpool configurations leverage the 'faulty' md device type which allow us to simuluate IO errors at the block layer. The last 6 zpool configurations leverage the scsi_debug module provided by modern kernels. This device allows you to create virtual scsi devices which are backed by a ram disk. With this setup we can verify the full IO stack by injecting faults at the lowest layer. Both methods of fault injection are important to verifying the IO stack. The zfs code itself also provides a mechanism for error injection via the zinject command line tool. While we should also take advantage of this appraoch to validate the code it does not address any of the Linux integration issues which are the most concerning. For the moment we're trusting that the upstream Solaris guys are running zinject and would have caught internal zfs logic errors. Currently, there are 6 r/w test cases layered on top of the 'faulty' md devices. They include 3 writes tests for soft/transient errors, hard/permenant errors, and all writes error to the device. There are 3 matching read tests for soft/transient errors, hard/permenant errors, and fixable read error with a write. Although for this last case zfs doesn't do anything special. The seventh test case verifies zfs detects and corrects checksum errors. In this case one of the drives is extensively damaged and by dd'ing over large sections of it. We then ensure zfs logs the issue and correctly rebuilds the damage. The next test cases use the scsi_debug configuration to injects error at the bottom of the scsi stack. This ensures we find any flaws in the scsi midlayer or our usage of it. Plus it stresses the device specific retry, timeout, and error handling outside of zfs's control. The eighth test case is to verify that the system correctly handles an intermittent device timeout. Here the scsi_debug device drops 1 in N requests resulting in a retry either at the block level. The ZFS code does specify the FAILFAST option but it turns out that for this case the Linux IO stack with still retry the command. The FAILFAST logic located in scsi_noretry_cmd() does no seem to apply to the simply timeout case. It appears to be more targeted to specific device or transport errors from the lower layers. The ninth test case handles a persistent failure in which the device is removed from the system by Linux. The test verifies that the failure is detected, the device is made unavailable, and then can be successfully re-add when brought back online. Additionally, it ensures that errors and events are logged to the correct places and the no data corruption has occured due to the failure.
2010-09-28 23:32:12 +00:00
#!/bin/bash
#
# 4 loopback devices using the md faulty level for easy
# fault injection on top of which is layered raid0 (striped).
#
# zpool-vdev0 zpool-vdev1 zpool-vdev2 zpool-vdev3
# loop0 loop1 loop2 loop3
# md0 (faulty) md1 (faulty) md2 (faulty) md3 (faulty)
# <--------------------- raid0 zpool --------------------->
#
FILEDIR=${FILEDIR:-/var/tmp}
FILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 \
$FILEDIR/file-vdev2 $FILEDIR/file-vdev3"}
Add zfault zpool configurations and tests Eleven new zpool configurations were added to allow testing of various failure cases. The first 5 zpool configurations leverage the 'faulty' md device type which allow us to simuluate IO errors at the block layer. The last 6 zpool configurations leverage the scsi_debug module provided by modern kernels. This device allows you to create virtual scsi devices which are backed by a ram disk. With this setup we can verify the full IO stack by injecting faults at the lowest layer. Both methods of fault injection are important to verifying the IO stack. The zfs code itself also provides a mechanism for error injection via the zinject command line tool. While we should also take advantage of this appraoch to validate the code it does not address any of the Linux integration issues which are the most concerning. For the moment we're trusting that the upstream Solaris guys are running zinject and would have caught internal zfs logic errors. Currently, there are 6 r/w test cases layered on top of the 'faulty' md devices. They include 3 writes tests for soft/transient errors, hard/permenant errors, and all writes error to the device. There are 3 matching read tests for soft/transient errors, hard/permenant errors, and fixable read error with a write. Although for this last case zfs doesn't do anything special. The seventh test case verifies zfs detects and corrects checksum errors. In this case one of the drives is extensively damaged and by dd'ing over large sections of it. We then ensure zfs logs the issue and correctly rebuilds the damage. The next test cases use the scsi_debug configuration to injects error at the bottom of the scsi stack. This ensures we find any flaws in the scsi midlayer or our usage of it. Plus it stresses the device specific retry, timeout, and error handling outside of zfs's control. The eighth test case is to verify that the system correctly handles an intermittent device timeout. Here the scsi_debug device drops 1 in N requests resulting in a retry either at the block level. The ZFS code does specify the FAILFAST option but it turns out that for this case the Linux IO stack with still retry the command. The FAILFAST logic located in scsi_noretry_cmd() does no seem to apply to the simply timeout case. It appears to be more targeted to specific device or transport errors from the lower layers. The ninth test case handles a persistent failure in which the device is removed from the system by Linux. The test verifies that the failure is detected, the device is made unavailable, and then can be successfully re-add when brought back online. Additionally, it ensures that errors and events are logged to the correct places and the no data corruption has occured due to the failure.
2010-09-28 23:32:12 +00:00
LODEVICES=""
MDDEVICES=""
zpool_create() {
check_loop_utils
check_md_utils
check_md_partitionable || die "Error non-partitionable md devices"
for FILE in ${FILES}; do
LODEVICE=`unused_loop_device`
MDDEVICE=`unused_md_device`
rm -f ${FILE} || exit 1
dd if=/dev/zero of=${FILE} bs=1M count=0 seek=256 \
&>/dev/null || die "Error $? creating ${FILE}"
# Setup the loopback device on the file.
msg "Creating ${LODEVICE} using ${FILE}"
${LOSETUP} ${LODEVICE} ${FILE} || \
die "Error $? creating ${LODEVICE} using ${FILE}"
LODEVICES="${LODEVICES} ${LODEVICE}"
# Setup the md device on the loopback device.
msg "Creating ${MDDEVICE} using ${LODEVICE}"
${MDADM} --build ${MDDEVICE} --level=faulty \
--raid-devices=1 ${LODEVICE} &>/dev/null || \
(destroy_md_devices "${MDDEVICES}" && \
destroy_loop_devices "${LODEVICES}" && \
die "Error $? creating ${MDDEVICE} using ${LODEVICE}")
wait_udev ${MDDEVICE} 30 || \
(destroy_md_devices "${MDDEVICES}" && \
destroy_loop_devices "${LODEVICES}" && \
die "Error udev never created ${MDDEVICE}")
# Check if the md device support partitions
${BLOCKDEV} --rereadpt ${MDDEVICE} 2>/dev/null || \
(destroy_md_devices "${MDDEVICES}" && \
destroy_loop_devices "${LODEVICES}" && \
die "Error ${MDDEVICE} does not support partitions")
# Create a GPT/EFI partition table for ZFS to use.
${PARTED} --script ${MDDEVICE} mklabel gpt
MDDEVICES="${MDDEVICES} ${MDDEVICE}"
done
msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${MDDEVICES}
${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${MDDEVICES} || \
(destroy_md_devices "${MDDEVICES}" && \
destroy_loop_devices "${LODEVICES}" && exit 1)
echo "$LODEVICES" >/tmp/zpool-lo.txt
echo "$MDDEVICES" >/tmp/zpool-md.txt
}
zpool_destroy() {
msg ${ZPOOL} destroy ${ZPOOL_NAME}
${ZPOOL} destroy ${ZPOOL_NAME}
destroy_md_devices "`cat /tmp/zpool-md.txt`"
destroy_loop_devices "`cat /tmp/zpool-lo.txt`"
rm -f /tmp/zpool-md.txt /tmp/zpool-lo.txt
}