1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 16# 17 18. $STF_SUITE/include/libtest.shlib 19. $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg 20 21# 22# DESCRIPTION: 23# 'zpool split' should work with whole-disk devices. 24# 25# STRATEGY: 26# 1. Create a mirror with a whole-disk device 27# 2. Verify 'zpool split' works and successfully split the mirror 28# 3. Cleanup and create the same mirror 29# 4. Verify 'zpool split' using the other device 30# 31 32verify_runnable "both" 33 34if is_linux; then 35 # Add one 512b spare device (4Kn would generate IO errors on replace) 36 # NOTE: must be larger than other "file" vdevs and minimum SPA devsize: 37 # add 32m of fudge 38 load_scsi_debug $(($SPA_MINDEVSIZE/1024/1024+32)) 1 1 1 '512b' 39else 40 log_unsupported "scsi debug module unsupported" 41fi 42 43function cleanup 44{ 45 destroy_pool $TESTPOOL 46 destroy_pool $TESTPOOL2 47 unload_scsi_debug 48 rm -fd "$FILE_DEVICE" "$ALTROOT" 49} 50 51function setup_mirror 52{ 53 # NOTE: "-f" is required to create a mixed (file and disk device) mirror 54 log_must truncate -s $SPA_MINDEVSIZE $FILE_DEVICE 55 log_must zpool create -f $TESTPOOL mirror $FILE_DEVICE $DISK_DEVICE 56 # NOTE: verify disk is actually a "whole-disk" device 57 log_must test "$(zdb -PC $TESTPOOL | grep -c 'whole_disk: 1')" == 1 58} 59 60log_assert "'zpool split' should work with whole-disk devices" 61log_onexit cleanup 62 63FILE_DEVICE="$TEST_BASE_DIR/file-device" 64DISK_DEVICE="$(get_debug_device)" 65ALTROOT="$TEST_BASE_DIR/altroot-$TESTPOOL2" 66 67# 1. Create a mirror with a whole-disk device 68setup_mirror 69 70# 2. Verify 'zpool split' works and successfully split the mirror 71log_must zpool split -R "$ALTROOT" $TESTPOOL $TESTPOOL2 $DISK_DEVICE 72log_must check_vdev_state $TESTPOOL $FILE_DEVICE "ONLINE" 73log_must check_vdev_state $TESTPOOL2 $DISK_DEVICE "ONLINE" 74 75# 3. Cleanup and create the same mirror 76destroy_pool $TESTPOOL 77destroy_pool $TESTPOOL2 78setup_mirror 79 80# 4. Verify 'zpool split' using the other device 81log_must zpool split -R "$ALTROOT" $TESTPOOL $TESTPOOL2 $FILE_DEVICE 82log_must check_vdev_state $TESTPOOL $DISK_DEVICE "ONLINE" 83log_must check_vdev_state $TESTPOOL2 $FILE_DEVICE "ONLINE" 84 85log_pass "'zpool split' works with whole-disk devices" 86