Use taskq for dump_bytes()
[zfs.git] / scripts / zpool-config / scsi_debug-noraid.sh
1 #!/bin/bash
2 #
3 # 1 scsi_debug devices on top of which is layered no raid.
4 #
5
6 SDSIZE=${SDSIZE:-128}
7 SDHOSTS=${SDHOSTS:-1}
8 SDTGTS=${SDTGTS:-1}
9 SDLUNS=${SDLUNS:-1}
10 LDMOD=/sbin/modprobe
11
12 zpool_create() {
13         check_sd_utils
14
15         test `${LSMOD} | grep -c scsi_debug` -gt 0 && \
16                 (echo 0 >/sys/module/scsi_debug/parameters/every_nth &&      \
17                 ${RMMOD} scsi_debug || exit 1)
18         udev_trigger
19
20         msg "${LDMOD} scsi_debug dev_size_mb=${SDSIZE} "                     \
21                 "add_host=${SDHOSTS} num_tgts=${SDTGTS} "                    \
22                 "max_luns=${SDLUNS}"
23         ${LDMOD} scsi_debug                                                  \
24                 dev_size_mb=${SDSIZE}                                        \
25                 add_host=${SDHOSTS}                                          \
26                 num_tgts=${SDTGTS}                                           \
27                 max_luns=${SDLUNS} ||                                        \
28                 die "Error $? creating scsi_debug devices"
29         udev_trigger
30         SDDEVICE=`${LSSCSI}|${AWK} '/scsi_debug/ { print $6; exit }'`
31
32         msg "${PARTED} -s ${SDDEVICE} mklabel gpt"
33         ${PARTED} -s ${SDDEVICE} mklabel gpt ||                              \
34                 (${RMMOD} scsi_debug && die "Error $? creating gpt label")
35
36         msg "${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${SDDEVICE}"
37         ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${SDDEVICE} ||           \
38                 (${RMMOD} scsi_debug && exit 1)
39 }
40
41 zpool_destroy() {
42         msg ${ZPOOL} destroy ${ZPOOL_NAME}
43         ${ZPOOL} destroy ${ZPOOL_NAME}
44         msg "${RMMOD} scsi_debug"
45         ${RMMOD} scsi_debug || die "Error $? removing scsi_debug devices"
46 }