1#!/bin/ksh 2 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 (c) 2019, Datto Inc. All rights reserved. 16# Copyright (c) 2020 by Lawrence Livermore National Security, LLC. 17# 18 19. $STF_SUITE/include/libtest.shlib 20. $STF_SUITE/tests/functional/replacement/replacement.cfg 21 22# 23# Description: 24# Verify device_rebuild feature flags. 25# 26# Strategy: 27# 1. Create a pool with all features disabled. 28# 2. Verify 'zpool replace -s' fails and the feature is disabled. 29# 3. Enable the device_rebuild feature. 30# 4. Verify 'zpool replace -s' works and the feature is active. 31# 5. Wait for the feature to return to enabled. 32# 33 34function cleanup 35{ 36 log_must set_tunable32 SCAN_SUSPEND_PROGRESS \ 37 $ORIG_SCAN_SUSPEND_PROGRESS 38 destroy_pool $TESTPOOL1 39 rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE 40} 41 42function check_feature_flag 43{ 44 feature=$1 45 pool=$2 46 expected_value=$3 47 48 value="$(zpool get -H -o property,value all $pool | \ 49 egrep "$feature" | awk '{print $2}')" 50 if [ "$value" = "$expected_value" ]; then 51 log_note "$feature verified to be $value" 52 else 53 log_fail "$feature should be $expected_value but is $value" 54 fi 55} 56 57log_assert "Verify device_rebuild feature flags." 58 59ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS) 60 61log_onexit cleanup 62 63log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]} $SPARE_VDEV_FILE 64log_must zpool create -d $TESTPOOL1 ${VDEV_FILES[@]} 65 66log_mustnot zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE 67check_feature_flag "feature@device_rebuild" "$TESTPOOL1" "disabled" 68 69log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1 70log_must zpool set feature@device_rebuild=enabled $TESTPOOL1 71log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE 72check_feature_flag "feature@device_rebuild" "$TESTPOOL1" "active" 73 74log_must set_tunable32 SCAN_SUSPEND_PROGRESS $ORIG_SCAN_SUSPEND_PROGRESS 75log_must zpool wait -t resilver $TESTPOOL1 76check_feature_flag "feature@device_rebuild" "$TESTPOOL1" "enabled" 77 78log_pass "Verify device_rebuild feature flags." 79