]> granicus.if.org Git - zfs/commitdiff
zpool: allow split with whole-disk devices
authorLOLi <loli10K@users.noreply.github.com>
Tue, 20 Nov 2018 18:22:53 +0000 (19:22 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 20 Nov 2018 18:22:53 +0000 (10:22 -0800)
This change allows 'zpool split' to work with whole-disk devices and
updates the ZFS Test Suite with a new script to exercise this
functionality.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #6643
Closes #8133

cmd/zpool/zpool_vdev.c
tests/runfiles/linux.run
tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg [new file with mode: 0644]
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_cliargs.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_encryption.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_resilver.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh [new file with mode: 0755]

index 5134553a5493e5e00026cc0af60e129a30b0d241..7ea9d742006de153613bc827cf491308621082f6 100644 (file)
@@ -1286,7 +1286,7 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)
                 * symbolic link will be removed, partition table created,
                 * and then block until udev creates the new link.
                 */
-               if (!is_exclusive || !is_spare(NULL, udevpath)) {
+               if (!is_exclusive && !is_spare(NULL, udevpath)) {
                        char *devnode = strrchr(devpath, '/') + 1;
 
                        ret = strncmp(udevpath, UDISK_ROOT, strlen(UDISK_ROOT));
index 225e9bc8b53dd9e470d1241708564d9800227af1..a4c6769dbb837834150237675010aed1e045d022 100644 (file)
@@ -440,7 +440,7 @@ tags = ['functional', 'cli_root', 'zpool_set']
 [tests/functional/cli_root/zpool_split]
 tests = ['zpool_split_cliargs', 'zpool_split_devices',
     'zpool_split_encryption', 'zpool_split_props', 'zpool_split_vdevs',
-    'zpool_split_resilver']
+    'zpool_split_resilver', 'zpool_split_wholedisk']
 tags = ['functional', 'cli_root', 'zpool_split']
 
 [tests/functional/cli_root/zpool_status]
index b2a7fec10f2185dc7eb351874d367eb048ebe170..d00f39d35d77632a8a8be2d4bc27e1e1267f5f66 100644 (file)
@@ -10,4 +10,8 @@ dist_pkgdata_SCRIPTS = \
        zpool_split_encryption.ksh \
        zpool_split_props.ksh \
        zpool_split_vdevs.ksh \
-       zpool_split_resilver.ksh
+       zpool_split_resilver.ksh \
+       zpool_split_wholedisk.ksh
+
+dist_pkgdata_DATA = \
+       zpool_split.cfg
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg
new file mode 100644 (file)
index 0000000..5833a42
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
+#
+
+export DISKSARRAY=$DISKS
+export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
+set_device_dir
index 4a779a225598434cb74702f099425ffa7181033d..ae9ad1354b0ac2d39ecb329a73316434f39cfc92 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 
 #
 # DESCRIPTION:
index c9e9d807b216c8250f87b78a9ac38b58c3149b4d..d64c30d5c5617de7e6fe158fadef8e7a69dddac6 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 
 #
 # DESCRIPTION:
@@ -91,7 +92,7 @@ do
        # Verify "good" devices ended up in the new pool
        log_must poolexists $TESTPOOL2
        for filedev in ${gooddevs[$i]}; do
-               log_must check_vdev_state $TESTPOOL2 $filedev ""
+               log_must check_vdev_state $TESTPOOL2 $filedev "ONLINE"
        done
        cleanup
        ((i = i + 1))
index dc686c73feefa8be3656e033a09bbcc5bf02ac26..768466983423f6fe580f64954590d7a289767e72 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 
 #
 # DESCRIPTION:
index 6176adf8bfb9ca3530c1eaa1c984be29d42c86f2..67dbed6933a349c67afbae20cd7f6a74c7a69dc1 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
 
 #
index 4fa1d925eb441e9de44932362c388e53fe8a3160..ffc841f7662e4e570f4244163f908ebb7dcb0a49 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 
 #
 # DESCRIPTION:
index a9a407f8e30f399afe33b9cd45b06c6402db92ac..b7ebe55cb8dc956c35555c77e52da82e5d770f4c 100755 (executable)
@@ -15,6 +15,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
 . $STF_SUITE/include/math.shlib
 
 #
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh
new file mode 100755 (executable)
index 0000000..085856c
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/ksh -p
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
+
+#
+# DESCRIPTION:
+# 'zpool split' should work with whole-disk devices.
+#
+# STRATEGY:
+# 1. Create a mirror with a whole-disk device
+# 2. Verify 'zpool split' works and successfully split the mirror
+# 3. Cleanup and create the same mirror
+# 4. Verify 'zpool split' using the other device
+#
+
+verify_runnable "both"
+
+if is_linux; then
+       # Add one 512b spare device (4Kn would generate IO errors on replace)
+       # NOTE: must be larger than other "file" vdevs and minimum SPA devsize:
+       # add 32m of fudge
+       load_scsi_debug $(($SPA_MINDEVSIZE/1024/1024+32)) 1 1 1 '512b'
+else
+       log_unsupported "scsi debug module unsupported"
+fi
+
+function cleanup
+{
+       destroy_pool $TESTPOOL
+       destroy_pool $TESTPOOL2
+       unload_scsi_debug
+       rm -f "$FILE_DEVICE"
+}
+
+function setup_mirror
+{
+       # NOTE: "-f" is required to create a mixed (file and disk device) mirror
+       log_must truncate -s $SPA_MINDEVSIZE $FILE_DEVICE
+       log_must zpool create -f $TESTPOOL mirror $FILE_DEVICE $DISK_DEVICE
+       # NOTE: verify disk is actually a "whole-disk" device
+       log_must test  "$(zdb -PC $TESTPOOL | grep -c 'whole_disk: 1')" == 1
+}
+
+log_assert "'zpool split' should work with whole-disk devices"
+log_onexit cleanup
+
+FILE_DEVICE="$TEST_BASE_DIR/file-device"
+DISK_DEVICE="$(get_debug_device)"
+ALTROOT="$TEST_BASE_DIR/altroot-$TESTPOOL2"
+
+# 1. Create a mirror with a whole-disk device
+setup_mirror
+
+# 2. Verify 'zpool split' works and successfully split the mirror
+log_must zpool split -R "$ALTROOT" $TESTPOOL $TESTPOOL2 $DISK_DEVICE
+log_must check_vdev_state $TESTPOOL $FILE_DEVICE "ONLINE"
+log_must check_vdev_state $TESTPOOL2 $DISK_DEVICE "ONLINE"
+
+# 3. Cleanup and create the same mirror
+destroy_pool $TESTPOOL
+destroy_pool $TESTPOOL2
+setup_mirror
+
+# 4. Verify 'zpool split' using the other device
+log_must zpool split -R "$ALTROOT" $TESTPOOL $TESTPOOL2 $FILE_DEVICE
+log_must check_vdev_state $TESTPOOL $DISK_DEVICE "ONLINE"
+log_must check_vdev_state $TESTPOOL2 $FILE_DEVICE "ONLINE"
+
+log_pass "'zpool split' works with whole-disk devices"