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
33command -v fio > /dev/null || log_unsupported "fio missing"
34
35function cleanup
36{
37	destroy_pool $TESTPOOL
38	log_must rm -f $all_vdevs
39}
40
41log_onexit cleanup
42
43log_assert "Files can be removed from full file system."
44
45all_vdevs=$(echo $TEST_BASE_DIR/file.{01..12})
46
47log_must truncate -s $MINVDEVSIZE $all_vdevs
48
49log_must zpool create -f $TESTPOOL draid2:8d:2s $all_vdevs
50log_must zfs create $TESTPOOL/$TESTFS
51log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
52log_must zfs set compression=off $TESTPOOL/$TESTFS
53
54log_note "Writing files until ENOSPC."
55log_mustnot_expect "No space left on device" fio --name=test \
56    --fallocate=none --rw=write --bs=1M --size=1G --numjobs=4 \
57    --sync=1 --directory=$TESTDIR/ --group_reporting
58
59log_must rm $TESTDIR/test.*
60log_must test -z "$(ls -A $TESTDIR)"
61
62log_pass "All files removed without error"
63