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 100); 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 sync_all_pools true 60done 61 62log_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs 63log_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone 64 65log_must eval "zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$" 66log_mustnot_expect space eval "zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$" 67log_must rm $TEST_BASE_DIR/stream.$$ 68 69log_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname 70log_must zfs rename $TESTPOOL/$TESTFS@snap_newname $TESTPOOL/$TESTFS@snap 71log_must zfs rename $TESTPOOL/$TESTFS $TESTPOOL/${TESTFS}_newname 72log_must zfs rename $TESTPOOL/${TESTFS}_newname $TESTPOOL/$TESTFS 73log_must zfs allow staff snapshot $TESTPOOL/$TESTFS 74log_must zfs unallow staff snapshot $TESTPOOL/$TESTFS 75log_must zfs set user:prop=value $TESTPOOL/$TESTFS 76log_must zfs set quota=1EB $TESTPOOL/$TESTFS 77log_must zfs set quota=none $TESTPOOL/$TESTFS 78log_must zfs set reservation=1KB $TESTPOOL/$TESTFS 79log_must zfs set reservation=none $TESTPOOL/$TESTFS 80log_must zpool scrub $TESTPOOL 81zpool scrub -s $TESTPOOL 82log_must zpool set comment="Use the force, Luke." $TESTPOOL 83log_must zpool set comment="" $TESTPOOL 84 85# destructive tests must come last 86log_must zfs rollback $TESTPOOL/$TESTFS@snap 87log_must zfs destroy $TESTPOOL/$TESTFS@snap 88 89log_pass "ENOSPC returned as expected." 90