1#! /usr/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 2016 Nexenta Systems, Inc. 31# 32 33. $STF_SUITE/include/libtest.shlib 34 35# 36# DESCRIPTION: 37# Verify that ZFS volume snapshot could be fscked 38# 39# STRATEGY: 40# 1. Create a ZFS volume 41# 2. Copy some files and create snapshot 42# 3. Verify fsck on the snapshot is OK 43# 44 45verify_runnable "global" 46 47volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL) 48 49function cleanup 50{ 51 snapexists $TESTPOOL/$TESTVOL@snap && \ 52 zfs destroy $TESTPOOL/$TESTVOL@snap 53 54 ismounted $TESTDIR ufs 55 (( $? == 0 )) && log_must umount $TESTDIR 56 57 [[ -e $TESTDIR ]] && rm -rf $TESTDIR 58 zfs set volsize=$volsize $TESTPOOL/$TESTVOL 59} 60 61log_assert "Verify that ZFS volume snapshot could be fscked" 62log_onexit cleanup 63 64TESTVOL='testvol' 65BLOCKSZ=$(( 1024 * 1024 )) 66NUM_WRITES=40 67 68log_must zfs set volsize=128m $TESTPOOL/$TESTVOL 69 70echo "y" | newfs -v /dev/zvol/rdsk/$TESTPOOL/$TESTVOL >/dev/null 2>&1 71(( $? != 0 )) && log_fail "Unable to newfs(1M) $TESTPOOL/$TESTVOL" 72 73log_must mkdir $TESTDIR 74log_must mount /dev/zvol/dsk/$TESTPOOL/$TESTVOL $TESTDIR 75 76typeset -i fn=0 77typeset -i retval=0 78 79while (( 1 )); do 80 file_write -o create -f $TESTDIR/testfile$$.$fn \ 81 -b $BLOCKSZ -c $NUM_WRITES 82 retval=$? 83 if (( $retval != 0 )); then 84 break 85 fi 86 (( fn = fn + 1 )) 87done 88 89log_must lockfs -f $TESTDIR 90log_must zfs snapshot $TESTPOOL/$TESTVOL@snap 91 92fsck -n /dev/zvol/rdsk/$TESTPOOL/$TESTVOL@snap >/dev/null 2>&1 93retval=$? 94(( $retval == 39 )) || log_fail "fsck exited with wrong value $retval " 95 96log_pass "Verify that ZFS volume snapshot could be fscked" 97