1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2014, 2016 by Delphix. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22. $STF_SUITE/tests/functional/no_space/enospc.cfg 23 24# 25# DESCRIPTION: 26# After filling a filesystem, certain zfs commands are allowed. 27# 28 29verify_runnable "both" 30 31function cleanup 32{ 33 log_must_busy zpool destroy -f $TESTPOOL 34} 35 36log_onexit cleanup 37 38log_assert "ENOSPC is returned when file system is full." 39 40default_setup_noexit $DISK_SMALL 41log_must zfs set compression=off $TESTPOOL/$TESTFS 42log_must zfs snapshot $TESTPOOL/$TESTFS@snap 43 44# 45# Completely fill the pool in order to ensure the commands below will more 46# reliably succeed or fail as a result of lack of space. Care is taken to 47# force multiple transaction groups to ensure as many recently freed blocks 48# as possible are reallocated. 49# 50log_note "Writing files until ENOSPC." 51 52for i in $(seq 30); do 53 file_write -o create -f $TESTDIR/file.$i -b $BLOCKSZ \ 54 -c $NUM_WRITES -d $DATA 55 ret=$? 56 (( $ret != $ENOSPC )) && \ 57 log_fail "file.$i returned: $ret rather than ENOSPC." 58 59 log_must zpool sync -f 60done 61 62log_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs 63log_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone 64log_mustnot_expect space zfs snapshot $TESTPOOL/$TESTFS@snap2 65log_mustnot_expect space zfs bookmark \ 66 $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS#bookmark 67 68log_must zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$ 69log_mustnot_expect space zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$ 70log_must rm $TEST_BASE_DIR/stream.$$ 71 72log_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname 73log_must zfs rename $TESTPOOL/$TESTFS@snap_newname $TESTPOOL/$TESTFS@snap 74log_must zfs rename $TESTPOOL/$TESTFS $TESTPOOL/${TESTFS}_newname 75log_must zfs rename $TESTPOOL/${TESTFS}_newname $TESTPOOL/$TESTFS 76log_must zfs allow staff snapshot $TESTPOOL/$TESTFS 77log_must zfs unallow staff snapshot $TESTPOOL/$TESTFS 78log_must zfs set user:prop=value $TESTPOOL/$TESTFS 79log_must zfs set quota=1EB $TESTPOOL/$TESTFS 80log_must zfs set quota=none $TESTPOOL/$TESTFS 81log_must zfs set reservation=1KB $TESTPOOL/$TESTFS 82log_must zfs set reservation=none $TESTPOOL/$TESTFS 83log_must zpool scrub $TESTPOOL 84zpool scrub -s $TESTPOOL 85log_must zpool set comment="Use the force, Luke." $TESTPOOL 86log_must zpool set comment="" $TESTPOOL 87 88# destructive tests must come last 89log_must zfs rollback $TESTPOOL/$TESTFS@snap 90log_must zfs destroy $TESTPOOL/$TESTFS@snap 91 92log_pass "ENOSPC returned as expected." 93