diff options
Diffstat (limited to 'scripts/zpool-config')
-rw-r--r-- | scripts/zpool-config/Makefile.am | 63 | ||||
-rw-r--r-- | scripts/zpool-config/Makefile.in | 63 | ||||
-rw-r--r-- | scripts/zpool-config/lo-faulty-raid0.sh | 78 | ||||
-rw-r--r-- | scripts/zpool-config/lo-faulty-raid10.sh | 84 | ||||
-rw-r--r-- | scripts/zpool-config/lo-faulty-raidz.sh | 72 | ||||
-rw-r--r-- | scripts/zpool-config/lo-faulty-raidz2.sh | 72 | ||||
-rw-r--r-- | scripts/zpool-config/lo-faulty-raidz3.sh | 72 | ||||
-rw-r--r-- | scripts/zpool-config/lo-raid0.sh | 2 | ||||
-rw-r--r-- | scripts/zpool-config/lo-raid10.sh | 2 | ||||
-rw-r--r-- | scripts/zpool-config/lo-raidz.sh | 2 | ||||
-rw-r--r-- | scripts/zpool-config/lo-raidz2.sh | 2 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-noraid.sh | 46 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-raid0.sh | 79 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-raid10.sh | 93 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-raidz.sh | 79 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-raidz2.sh | 79 | ||||
-rw-r--r-- | scripts/zpool-config/scsi_debug-raidz3.sh | 79 |
17 files changed, 915 insertions, 52 deletions
diff --git a/scripts/zpool-config/Makefile.am b/scripts/zpool-config/Makefile.am index 0c7e0714b..5af373bec 100644 --- a/scripts/zpool-config/Makefile.am +++ b/scripts/zpool-config/Makefile.am @@ -1,31 +1,42 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@/zpool-config dist_pkglibexec_SCRIPTS = \ - $(top_srcdir)/scripts/zpool-config/dm0-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raid0-1x70.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raid10-35x2.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raidz2-7x10.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raidz-7x10.sh \ - $(top_srcdir)/scripts/zpool-config/file-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/file-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/file-raidz2.sh \ - $(top_srcdir)/scripts/zpool-config/file-raidz.sh \ - $(top_srcdir)/scripts/zpool-config/hda-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raidz2.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raidz.sh \ - $(top_srcdir)/scripts/zpool-config/md0-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/md0-raid5.sh \ - $(top_srcdir)/scripts/zpool-config/ram0-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/sda-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raid0-1x16.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raid10-8x2.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raidz2-4x4.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raidz-4x4.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raid0-1x48.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raid10-24x2.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raidz2-8x6.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raidz-8x6.sh + $(top_srcdir)/scripts/zpool-config/dm0-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raid0-1x70.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raid10-35x2.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raidz2-7x10.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raidz-7x10.sh \ + $(top_srcdir)/scripts/zpool-config/file-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/file-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/file-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/file-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/hda-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz3.sh \ + $(top_srcdir)/scripts/zpool-config/md0-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/md0-raid5.sh \ + $(top_srcdir)/scripts/zpool-config/ram0-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-noraid.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz3.sh \ + $(top_srcdir)/scripts/zpool-config/sda-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raid0-1x16.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raid10-8x2.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raidz2-4x4.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raidz-4x4.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raid0-1x48.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raid10-24x2.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raidz2-8x6.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raidz-8x6.sh all: @list='$(dist_pkglibexec_SCRIPTS)'; \ diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in index a312c948c..61f54ca0a 100644 --- a/scripts/zpool-config/Makefile.in +++ b/scripts/zpool-config/Makefile.in @@ -273,32 +273,43 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ dist_pkglibexec_SCRIPTS = \ - $(top_srcdir)/scripts/zpool-config/dm0-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raid0-1x70.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raid10-35x2.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raidz2-7x10.sh \ - $(top_srcdir)/scripts/zpool-config/dragon-raidz-7x10.sh \ - $(top_srcdir)/scripts/zpool-config/file-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/file-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/file-raidz2.sh \ - $(top_srcdir)/scripts/zpool-config/file-raidz.sh \ - $(top_srcdir)/scripts/zpool-config/hda-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raidz2.sh \ - $(top_srcdir)/scripts/zpool-config/lo-raidz.sh \ - $(top_srcdir)/scripts/zpool-config/md0-raid10.sh \ - $(top_srcdir)/scripts/zpool-config/md0-raid5.sh \ - $(top_srcdir)/scripts/zpool-config/ram0-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/sda-raid0.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raid0-1x16.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raid10-8x2.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raidz2-4x4.sh \ - $(top_srcdir)/scripts/zpool-config/supermicro-raidz-4x4.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raid0-1x48.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raid10-24x2.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raidz2-8x6.sh \ - $(top_srcdir)/scripts/zpool-config/x4550-raidz-8x6.sh + $(top_srcdir)/scripts/zpool-config/dm0-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raid0-1x70.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raid10-35x2.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raidz2-7x10.sh \ + $(top_srcdir)/scripts/zpool-config/dragon-raidz-7x10.sh \ + $(top_srcdir)/scripts/zpool-config/file-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/file-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/file-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/file-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/hda-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/lo-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/lo-faulty-raidz3.sh \ + $(top_srcdir)/scripts/zpool-config/md0-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/md0-raid5.sh \ + $(top_srcdir)/scripts/zpool-config/ram0-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-noraid.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raid10.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz2.sh \ + $(top_srcdir)/scripts/zpool-config/scsi_debug-raidz3.sh \ + $(top_srcdir)/scripts/zpool-config/sda-raid0.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raid0-1x16.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raid10-8x2.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raidz2-4x4.sh \ + $(top_srcdir)/scripts/zpool-config/supermicro-raidz-4x4.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raid0-1x48.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raid10-24x2.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raidz2-8x6.sh \ + $(top_srcdir)/scripts/zpool-config/x4550-raidz-8x6.sh all: all-am diff --git a/scripts/zpool-config/lo-faulty-raid0.sh b/scripts/zpool-config/lo-faulty-raid0.sh new file mode 100644 index 000000000..10b8f88bc --- /dev/null +++ b/scripts/zpool-config/lo-faulty-raid0.sh @@ -0,0 +1,78 @@ +#!/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 ---------------------> +# + +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3" +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 +} diff --git a/scripts/zpool-config/lo-faulty-raid10.sh b/scripts/zpool-config/lo-faulty-raid10.sh new file mode 100644 index 000000000..ef81abb9d --- /dev/null +++ b/scripts/zpool-config/lo-faulty-raid10.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# 4 loopback devices using the md faulty level for easy +# fault injection on top of which is layered raid10 (mirrored). +# +# zpool-vdev0 zpool-vdev1 zpool-vdev2 zpool-vdev3 +# loop0 loop1 loop2 loop3 +# md0 (faulty) md1 (faulty) md2 (faulty) md3 (faulty) +# <--------------------- raid10 zpool ---------------------> +# + +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3" +LODEVICES="" +MDDEVICES="" +MDDEVICES_M1="" +MDDEVICES_M2="" + +zpool_create() { + local COUNT=0 + + 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` + let COUNT=${COUNT}+1 + + 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}") + + # Create empty GPT/EFI partition table. + ${PARTED} --script ${MDDEVICE} mklabel gpt + MDDEVICES="${MDDEVICES} ${MDDEVICE}" + if [ $((COUNT % 2)) -eq 0 ]; then + MDDEVICES_M2="${MDDEVICES_M2} ${MDDEVICE}" + else + MDDEVICES_M1="${MDDEVICES_M1} ${MDDEVICE}" + fi + done + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \ + mirror ${MDDEVICES_M1} mirror ${MDDEVICES_M2} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \ + mirror ${MDDEVICES_M1} mirror ${MDDEVICES_M2} || \ + (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 +} diff --git a/scripts/zpool-config/lo-faulty-raidz.sh b/scripts/zpool-config/lo-faulty-raidz.sh new file mode 100644 index 000000000..2f1f08aa6 --- /dev/null +++ b/scripts/zpool-config/lo-faulty-raidz.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# 4 loopback devices using the md faulty level for easy +# fault injection on top of which is layered raidz. +# +# zpool-vdev0 zpool-vdev1 zpool-vdev2 zpool-vdev3 +# loop0 loop1 loop2 loop3 +# md0 (faulty) md1 (faulty) md2 (faulty) md3 (faulty) +# <--------------------- raidz zpool ---------------------> +# + +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3" +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}") + + # Create empty GPT/EFI partition table. + ${PARTED} --script ${MDDEVICE} mklabel gpt + MDDEVICES="${MDDEVICES} ${MDDEVICE}" + done + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${MDDEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${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 +} diff --git a/scripts/zpool-config/lo-faulty-raidz2.sh b/scripts/zpool-config/lo-faulty-raidz2.sh new file mode 100644 index 000000000..2522fa7e7 --- /dev/null +++ b/scripts/zpool-config/lo-faulty-raidz2.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# 4 loopback devices using the md faulty level for easy +# fault injection on top of which is layered raidz2. +# +# zpool-vdev0 zpool-vdev1 zpool-vdev2 zpool-vdev3 +# loop0 loop1 loop2 loop3 +# md0 (faulty) md1 (faulty) md2 (faulty) md3 (faulty) +# <--------------------- raidz2 zpool --------------------> +# + +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3" +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}") + + # Create empty GPT/EFI partition table. + ${PARTED} --script ${MDDEVICE} mklabel gpt + MDDEVICES="${MDDEVICES} ${MDDEVICE}" + done + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${MDDEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${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 +} diff --git a/scripts/zpool-config/lo-faulty-raidz3.sh b/scripts/zpool-config/lo-faulty-raidz3.sh new file mode 100644 index 000000000..e5adaafc4 --- /dev/null +++ b/scripts/zpool-config/lo-faulty-raidz3.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# 4 loopback devices using the md faulty level for easy +# fault injection on top of which is layered raidz3. +# +# zpool-vdev0 zpool-vdev1 zpool-vdev2 zpool-vdev3 +# loop0 loop1 loop2 loop3 +# md0 (faulty) md1 (faulty) md2 (faulty) md3 (faulty) +# <--------------------- raidz3 zpool --------------------> +# + +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2 \ + /tmp/zpool-vdev3" +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}") + + # Create empty GPT/EFI partition table. + ${PARTED} --script ${MDDEVICE} mklabel gpt + MDDEVICES="${MDDEVICES} ${MDDEVICE}" + done + + msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz3 ${MDDEVICES} + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz3 ${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 +} diff --git a/scripts/zpool-config/lo-raid0.sh b/scripts/zpool-config/lo-raid0.sh index 321d9b1f7..f7eb77d7b 100644 --- a/scripts/zpool-config/lo-raid0.sh +++ b/scripts/zpool-config/lo-raid0.sh @@ -10,6 +10,8 @@ FILES="/tmp/zpool-vdev0 \ DEVICES="" zpool_create() { + check_loop_utils + for FILE in ${FILES}; do DEVICE=`unused_loop_device` msg "Creating ${FILE} using loopback device ${DEVICE}" diff --git a/scripts/zpool-config/lo-raid10.sh b/scripts/zpool-config/lo-raid10.sh index f9c47cd1e..5350930bb 100644 --- a/scripts/zpool-config/lo-raid10.sh +++ b/scripts/zpool-config/lo-raid10.sh @@ -12,6 +12,8 @@ DEVICES_M1="" DEVICES_M2="" zpool_create() { + check_loop_utils + for FILE in ${FILES_M1}; do DEVICE=`unused_loop_device` msg "Creating ${FILE} using loopback device ${DEVICE}" diff --git a/scripts/zpool-config/lo-raidz.sh b/scripts/zpool-config/lo-raidz.sh index 509f6ee1d..e83e4a838 100644 --- a/scripts/zpool-config/lo-raidz.sh +++ b/scripts/zpool-config/lo-raidz.sh @@ -10,6 +10,8 @@ FILES="/tmp/zpool-vdev0 \ DEVICES="" zpool_create() { + check_loop_utils + for FILE in ${FILES}; do DEVICE=`unused_loop_device` msg "Creating ${FILE} using loopback device ${DEVICE}" diff --git a/scripts/zpool-config/lo-raidz2.sh b/scripts/zpool-config/lo-raidz2.sh index 6e61293c0..c6381eaff 100644 --- a/scripts/zpool-config/lo-raidz2.sh +++ b/scripts/zpool-config/lo-raidz2.sh @@ -10,6 +10,8 @@ FILES="/tmp/zpool-vdev0 \ DEVICES="" zpool_create() { + check_loop_utils + for FILE in ${FILES}; do DEVICE=`unused_loop_device` msg "Creating ${FILE} using loopback device ${DEVICE}" diff --git a/scripts/zpool-config/scsi_debug-noraid.sh b/scripts/zpool-config/scsi_debug-noraid.sh new file mode 100644 index 000000000..dfcf1586c --- /dev/null +++ b/scripts/zpool-config/scsi_debug-noraid.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# 1 scsi_debug devices on top of which is layered no raid. +# + +SDSIZE=${SDSIZE:-128} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe + +zpool_create() { + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + SDDEVICE=`${LSSCSI}|${AWK} '/scsi_debug/ { print $6; exit }'` + + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${SDDEVICE}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${SDDEVICE} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} diff --git a/scripts/zpool-config/scsi_debug-raid0.sh b/scripts/zpool-config/scsi_debug-raid0.sh new file mode 100644 index 000000000..797ea8019 --- /dev/null +++ b/scripts/zpool-config/scsi_debug-raid0.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# 1 scsi_debug device for fault injection and 3 loopback devices +# on top of which is layered raid0 (striped). +# + +SDSIZE=${SDSIZE:-256} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2" +DEVICES="" + +zpool_create() { + check_loop_utils + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + + SDDEVICE=`${LSSCSI} | ${AWK} '/scsi_debug/ { print $6; exit }'` + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + for FILE in ${FILES}; do + LODEVICE=`unused_loop_device` + + rm -f ${FILE} || exit 1 + dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \ + &>/dev/null || (${RMMOD} scsi_debug && \ + die "Error $? creating ${FILE}") + + # Setup the loopback device on the file. + msg "Creating ${LODEVICE} using ${FILE}" + ${LOSETUP} ${LODEVICE} ${FILE} || (${RMMOD} scsi_debug \ + die "Error $? creating ${LODEVICE} using ${FILE}") + + DEVICES="${DEVICES} ${LODEVICE}" + done + + DEVICES="${DEVICES} ${SDDEVICE}" + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + + for FILE in ${FILES}; do + LODEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:` + msg "Removing ${LODEVICE} using ${FILE}" + ${LOSETUP} -d ${LODEVICE} || + die "Error $? destroying ${LODEVICE} using ${FILE}" + rm -f ${FILE} || exit 1 + done + + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} diff --git a/scripts/zpool-config/scsi_debug-raid10.sh b/scripts/zpool-config/scsi_debug-raid10.sh new file mode 100644 index 000000000..4ec205b8b --- /dev/null +++ b/scripts/zpool-config/scsi_debug-raid10.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# 1 scsi_debug device for fault injection and 3 loopback devices +# on top of which is layered raid10 (mirrored). +# + +SDSIZE=${SDSIZE:-256} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2" +DEVICES_M1="" +DEVICES_M2="" + +zpool_create() { + local COUNT=0 + + check_loop_utils + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + SDDEVICE=`${LSSCSI}|${AWK} '/scsi_debug/ { print $6; exit }'` + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + for FILE in ${FILES}; do + LODEVICE=`unused_loop_device` + + rm -f ${FILE} || exit 1 + dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \ + &>/dev/null || (${RMMOD} scsi_debug && \ + die "Error $? creating ${FILE}") + + # Setup the loopback device on the file. + msg "Creating ${LODEVICE} using ${FILE}" + ${LOSETUP} ${LODEVICE} ${FILE} || (${RMMOD} scsi_debug \ + die "Error $? creating ${LODEVICE} using ${FILE}") + + DEVICES="${DEVICES} ${LODEVICE}" + done + + DEVICES="${DEVICES} ${SDDEVICE}" + + for DEVICE in ${DEVICES}; do + let COUNT=${COUNT}+1 + + if [ $((COUNT % 2)) -eq 0 ]; then + DEVICES_M2="${DEVICES_M2} ${DEVICE}" + else + DEVICES_M1="${DEVICES_M1} ${DEVICE}" + fi + done + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} " \ + "mirror ${DEVICES_M1} mirror ${DEVICES_M2}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \ + mirror ${DEVICES_M1} mirror ${DEVICES_M2} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + + for FILE in ${FILES}; do + LODEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:` + msg "Removing ${LODEVICE} using ${FILE}" + ${LOSETUP} -d ${LODEVICE} || + die "Error $? destroying ${LODEVICE} using ${FILE}" + rm -f ${FILE} || exit 1 + done + + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} diff --git a/scripts/zpool-config/scsi_debug-raidz.sh b/scripts/zpool-config/scsi_debug-raidz.sh new file mode 100644 index 000000000..c811a0182 --- /dev/null +++ b/scripts/zpool-config/scsi_debug-raidz.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# 1 scsi_debug device for fault injection and 3 loopback devices +# on top of which is layered raidz. +# + +SDSIZE=${SDSIZE:-256} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2" +DEVICES="" + +zpool_create() { + check_loop_utils + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + + SDDEVICE=`${LSSCSI} | ${AWK} '/scsi_debug/ { print $6; exit }'` + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + for FILE in ${FILES}; do + LODEVICE=`unused_loop_device` + + rm -f ${FILE} || exit 1 + dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \ + &>/dev/null || (${RMMOD} scsi_debug && \ + die "Error $? creating ${FILE}") + + # Setup the loopback device on the file. + msg "Creating ${LODEVICE} using ${FILE}" + ${LOSETUP} ${LODEVICE} ${FILE} || (${RMMOD} scsi_debug \ + die "Error $? creating ${LODEVICE} using ${FILE}") + + DEVICES="${DEVICES} ${LODEVICE}" + done + + DEVICES="${DEVICES} ${SDDEVICE}" + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${DEVICES}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz ${DEVICES} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + + for FILE in ${FILES}; do + LODEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:` + msg "Removing ${LODEVICE} using ${FILE}" + ${LOSETUP} -d ${LODEVICE} || + die "Error $? destroying ${LODEVICE} using ${FILE}" + rm -f ${FILE} || exit 1 + done + + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} diff --git a/scripts/zpool-config/scsi_debug-raidz2.sh b/scripts/zpool-config/scsi_debug-raidz2.sh new file mode 100644 index 000000000..429a84143 --- /dev/null +++ b/scripts/zpool-config/scsi_debug-raidz2.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# 1 scsi_debug device for fault injection and 3 loopback devices +# on top of which is layered raidz2. +# + +SDSIZE=${SDSIZE:-256} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2" +DEVICES="" + +zpool_create() { + check_loop_utils + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + + SDDEVICE=`${LSSCSI} | ${AWK} '/scsi_debug/ { print $6; exit }'` + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + for FILE in ${FILES}; do + LODEVICE=`unused_loop_device` + + rm -f ${FILE} || exit 1 + dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \ + &>/dev/null || (${RMMOD} scsi_debug && \ + die "Error $? creating ${FILE}") + + # Setup the loopback device on the file. + msg "Creating ${LODEVICE} using ${FILE}" + ${LOSETUP} ${LODEVICE} ${FILE} || (${RMMOD} scsi_debug \ + die "Error $? creating ${LODEVICE} using ${FILE}") + + DEVICES="${DEVICES} ${LODEVICE}" + done + + DEVICES="${DEVICES} ${SDDEVICE}" + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${DEVICES}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz2 ${DEVICES} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + + for FILE in ${FILES}; do + LODEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:` + msg "Removing ${LODEVICE} using ${FILE}" + ${LOSETUP} -d ${LODEVICE} || + die "Error $? destroying ${LODEVICE} using ${FILE}" + rm -f ${FILE} || exit 1 + done + + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} diff --git a/scripts/zpool-config/scsi_debug-raidz3.sh b/scripts/zpool-config/scsi_debug-raidz3.sh new file mode 100644 index 000000000..34654b5a8 --- /dev/null +++ b/scripts/zpool-config/scsi_debug-raidz3.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# 1 scsi_debug device for fault injection and 3 loopback devices +# on top of which is layered raidz3. +# + +SDSIZE=${SDSIZE:-256} +SDHOSTS=${SDHOSTS:-1} +SDTGTS=${SDTGTS:-1} +SDLUNS=${SDLUNS:-1} +LDMOD=/sbin/modprobe +FILES="/tmp/zpool-vdev0 \ + /tmp/zpool-vdev1 \ + /tmp/zpool-vdev2" +DEVICES="" + +zpool_create() { + check_loop_utils + check_sd_utils + + test `${LSMOD} | grep -c scsi_debug` -gt 0 && \ + (echo 0 >/sys/module/scsi_debug/parameters/every_nth && \ + ${RMMOD} scsi_debug || exit 1) + udev_trigger + + msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} " \ + "add_host=${SDHOSTS} num_tgts=${SDTGTS} " \ + "max_luns=${SDLUNS}" + ${LDMOD} scsi_debug \ + dev_size_mb=${SDSIZE} \ + add_host=${SDHOSTS} \ + num_tgts=${SDTGTS} \ + max_luns=${SDLUNS} || \ + die "Error $? creating scsi_debug devices" + udev_trigger + + SDDEVICE=`${LSSCSI} | ${AWK} '/scsi_debug/ { print $6; exit }'` + msg "${PARTED} -s ${SDDEVICE} mklabel gpt" + ${PARTED} -s ${SDDEVICE} mklabel gpt || \ + (${RMMOD} scsi_debug && die "Error $? creating gpt label") + + for FILE in ${FILES}; do + LODEVICE=`unused_loop_device` + + rm -f ${FILE} || exit 1 + dd if=/dev/zero of=${FILE} bs=1024k count=0 seek=256 \ + &>/dev/null || (${RMMOD} scsi_debug && \ + die "Error $? creating ${FILE}") + + # Setup the loopback device on the file. + msg "Creating ${LODEVICE} using ${FILE}" + ${LOSETUP} ${LODEVICE} ${FILE} || (${RMMOD} scsi_debug \ + die "Error $? creating ${LODEVICE} using ${FILE}") + + DEVICES="${DEVICES} ${LODEVICE}" + done + + DEVICES="${DEVICES} ${SDDEVICE}" + + msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz3 ${DEVICES}" + ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} raidz3 ${DEVICES} || \ + (${RMMOD} scsi_debug && exit 1) +} + +zpool_destroy() { + msg ${ZPOOL} destroy ${ZPOOL_NAME} + ${ZPOOL} destroy ${ZPOOL_NAME} + + for FILE in ${FILES}; do + LODEVICE=`${LOSETUP} -a | grep ${FILE} | head -n1|cut -f1 -d:` + msg "Removing ${LODEVICE} using ${FILE}" + ${LOSETUP} -d ${LODEVICE} || + die "Error $? destroying ${LODEVICE} using ${FILE}" + rm -f ${FILE} || exit 1 + done + + msg "${RMMOD} scsi_debug" + ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices" +} |