1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30# Copyright 2019 Joyent, Inc. 31# 32 33. $STF_SUITE/tests/functional/cache/cache.cfg 34. $STF_SUITE/tests/functional/cache/cache.kshlib 35 36# 37# DESCRIPTION: 38# Verify cache device must be a block device or plain file. 39# 40# STRATEGY: 41# 1. Create a pool 42# 2. Verify that raw disks, loopback files, and zvols can't be used to 43# back cache vdevs 44# 45 46verify_runnable "global" 47 48function cleanup_testenv 49{ 50 cleanup 51 if [[ -n $lofidev ]]; then 52 log_must lofiadm -d $lofidev 53 fi 54} 55 56log_assert "Cache device can only be block devices or plain files." 57log_onexit cleanup_testenv 58 59TESTVOL=testvol1$$ 60dsk1=${DISKS%% *} 61 62log_must zpool create $TESTPOOL ${DISKS#$dsk1} 63 64# Add normal /dev/rdsk device 65log_mustnot zpool add $TESTPOOL cache /dev/rdsk/${dsk1}s0 66#log_must verify_cache_device $TESTPOOL $dsk1 'ONLINE' 67 68# Add /dev/rlofi device 69lofidev=${VDEV2%% *} 70log_must lofiadm -a $lofidev 71lofidev=$(lofiadm $lofidev) 72log_mustnot zpool add $TESTPOOL cache "/dev/rlofi/${lofidev#/dev/lofi/}" 73if [[ -n $lofidev ]]; then 74 log_must lofiadm -d $lofidev 75 lofidev="" 76fi 77 78# Add normal files 79log_must zpool add $TESTPOOL cache $FILEDEV 80 81# Add /dev/zvol/rdsk device 82log_must zpool create $TESTPOOL2 $VDEV2 83log_must zfs create -V $SIZE $TESTPOOL2/$TESTVOL 84log_mustnot zpool add $TESTPOOL cache /dev/zvol/rdsk/$TESTPOOL2/$TESTVOL 85 86log_pass "Cache device can only be block devices or plain files." 87