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# Copyright (c) 2022 by Lawrence Livermore National Security, LLC.
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, verify the contents can be removed
28# without encountering an ENOSPC error.
29#
30
31verify_runnable "both"
32
33function cleanup
34{
35	destroy_pool $TESTPOOL
36	log_must rm -f $all_vdevs
37}
38
39log_onexit cleanup
40
41log_assert "Files can be removed from full file system."
42
43all_vdevs=$(echo $TEST_BASE_DIR/file.{01..12})
44
45log_must truncate -s $MINVDEVSIZE $all_vdevs
46
47log_must zpool create -f $TESTPOOL draid2:8d:2s $all_vdevs
48log_must zfs create $TESTPOOL/$TESTFS
49log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
50log_must zfs set compression=off $TESTPOOL/$TESTFS
51
52log_note "Writing files until ENOSPC."
53log_mustnot_expect "No space left on device" fio --name=test \
54    --fallocate=none --rw=write --bs=1M --size=1G --numjobs=4 \
55    --sync=1 --directory=$TESTDIR/ --group_reporting
56
57log_must rm $TESTDIR/test.*
58log_must test -z "$(ls -A $TESTDIR)"
59
60log_pass "All files removed without error"
61