mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
zpool: allow split with whole-disk devices
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
This commit is contained in:
parent
bd9c195805
commit
0cd5c941d0
@ -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));
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -15,6 +15,7 @@
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
|
@ -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))
|
||||
|
@ -15,6 +15,7 @@
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
|
@ -15,6 +15,7 @@
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
|
@ -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"
|
Loading…
Reference in New Issue
Block a user