Retire zpool_id infrastructure
[zfs.git] / scripts / zpool-config / zpool-raid10.sh
1 #!/bin/bash
2 #
3 # Zpool Raid-10 Configuration
4 #
5 # This script is used to test with the /dev/disk/by-vdev/[A-Z][1-n] devices.
6 # It assumes that you have already populated /dev/disk/by-vdev/ by creating
7 # an /etc/zfs/vdev_id.conf file based on your system design.
8 #
9 # You can then use either the zpool-create.sh or the zpios.sh test script to
10 # test various Raid-10 configurations by adjusting the following tunables.
11 # For example if you wanted to create and test a single 4-disk Raid-10
12 # configuration using disks [A-D]1 with dedicated ZIL and L2ARC devices
13 # you could run the following.
14 #
15 # ZIL="log A2" L2ARC="cache B2" RANKS=1 CHANNELS=4 \
16 # zpool-create.sh -c zpool-raid10
17 #
18 # zpool status tank
19 #   pool: tank
20 #  state: ONLINE
21 #  scan: none requested
22 # config:
23
24 #       NAME        STATE     READ WRITE CKSUM
25 #       tank        ONLINE       0     0     0
26 #         mirror-0  ONLINE       0     0     0
27 #           A1      ONLINE       0     0     0
28 #           B1      ONLINE       0     0     0
29 #         mirror-1  ONLINE       0     0     0
30 #           C1      ONLINE       0     0     0
31 #           D1      ONLINE       0     0     0
32 #       logs
33 #         A2        ONLINE       0     0     0
34 #       cache
35 #         B2        ONLINE       0     0     0
36 #
37 # errors: No known data errors
38 #
39
40 # Number of interior vdevs to create using the following rank ids.
41 RANKS=${RANKS:-1}
42 RANK_LIST=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 )
43
44 # Number of devices per vdev using the following channel ids.
45 CHANNELS=${CHANNELS:-8}
46 CHANNEL_LIST=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
47
48 # Create a ZIL vdev as follows.
49 ZIL=${ZIL:-}
50
51 # Create an L2ARC vdev as follows.
52 L2ARC=${L2ARC:-}
53
54
55 raid10_setup() {
56         local RANKS=$1
57         local CHANNELS=$2
58         local IDX=0
59
60         RAID10S=()
61         for (( i=0, l=0 ; i<${RANKS}; i++ )); do
62                 RANK=${RANK_LIST[$i]}
63
64                 for (( j=0, k=1; j<${CHANNELS}; j+=2,k+=2,l++ )); do
65                         DISK1="${CHANNEL_LIST[$j]}${RANK}"
66                         DISK2="${CHANNEL_LIST[$k]}${RANK}"
67                         RAID10S[$l]="mirror ${DISK1} ${DISK2}"
68                 done
69         done
70
71         return 0
72 }
73
74 zpool_create() {
75         raid10_setup ${RANKS} ${CHANNELS}
76
77         ZPOOL_DEVICES="${RAID10S[*]} ${ZIL} ${L2ARC}"
78         msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${ZPOOL_DEVICES}
79         ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${ZPOOL_DEVICES} || exit 1
80 }
81
82 zpool_destroy() {
83         msg ${ZPOOL} destroy ${ZPOOL_NAME}
84         ${ZPOOL} destroy ${ZPOOL_NAME}
85 }