1#! /usr/local/bin/ksh93 -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# $FreeBSD$ 24 25# 26# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zvol_misc_009_pos.ksh 1.3 08/05/14 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33. $STF_SUITE/tests/zvol/zvol_common.kshlib 34 35############################################################################### 36# 37# __stc_assertion_start 38# 39# ID: zvol_misc_009_pos 40# 41# DESCRIPTION: 42# Verify that device nodes are modified appropriately during zfs command 43# operations on volumes. 44# 45# STRATEGY: 46# For a certain number of iterations, with root setup for each test set: 47# - Recursively snapshot the root. 48# - Send|Receive the root to another root. 49# - Destroy the original and received roots. 50# 51# At each stage, the device nodes are checked to match the expectations. 52# 53# TESTABILITY: explicit 54# 55# TEST_AUTOMATION_LEVEL: automated 56# 57# CODING_STATUS: COMPLETED (2008-03-04) 58# 59# __stc_assertion_end 60# 61################################################################################ 62 63verify_runnable "global" 64 65log_assert "Verify that ZFS volume device nodes are handled properly (part 3)." 66 67ROOTPREFIX=$TESTPOOL/009 68DIRS="dir0 dir1" 69VOLS="vol0 dir0/dvol0 dir1/dvol1" 70 71typeset -i NUM_ITERATIONS=5 72 73function onexit_callback 74{ 75 log_must $ZFS list -t all 76 log_note "Char devices in /dev/zvol:" 77 find /dev/zvol -type c 78} 79log_onexit onexit_callback 80 81function root_setup 82{ 83 rootds=$1 84 85 log_must $ZFS create $rootds 86 for dir in $DIRS; do 87 log_must $ZFS create $rootds/$dir 88 done 89 for vol in $VOLS; do 90 log_must $ZFS create -V 100M $rootds/$vol 91 log_must test -c /dev/zvol/$rootds/$vol 92 done 93} 94 95typeset -i i=0 96while (( i != NUM_ITERATIONS )); do 97 root=${ROOTPREFIX}_iter${i} 98 # Test set 3: send|receive & receive with forced rollback 99 root_setup $root 100 log_must $ZFS snapshot -r $root@snap 101 received=${root}_recv 102 log_must eval "$ZFS send -R $root@snap | $ZFS receive -F ${received}" 103 for vol in $VOLS; do 104 log_must test -c /dev/zvol/${received}/${vol} 105 log_must test -c /dev/zvol/${received}/${vol}@snap 106 done 107 # Re-send with -F, to ensure that actual receive rollback also works. 108 # For good measure, pre-destroy one of the volumes. Also, destroy 109 # the snapshot we received earlier for this to work. 110 log_must $ZFS destroy -r $received/vol0 111 log_must $ZFS destroy -r $received@snap 112 log_must eval "$ZFS send -R $root@snap | $ZFS receive -F ${received}" 113 for vol in $VOLS; do 114 log_must test -c /dev/zvol/${received}/${vol} 115 log_must test -c /dev/zvol/${received}/${vol}@snap 116 done 117 log_must $ZFS destroy -r ${root} 118 log_mustnot test -e /dev/zvol/${root}/vol0 119 log_mustnot test -e /dev/zvol/${root}/vol0@snap 120 log_must $ZFS destroy -r ${received} 121 log_mustnot test -e /dev/zvol/${received}/vol0 122 log_mustnot test -e /dev/zvol/${received}/vol0@snap 123 124 (( i += 1 )) 125done 126log_pass "ZFS volume device nodes are handled properly (part 3)." 127