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