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# Copyright (c) 2023 Hewlett Packard Enterprise Development LP.
21#
22
23. $STF_SUITE/include/libtest.shlib
24. $STF_SUITE/tests/functional/no_space/enospc.cfg
25
26#
27# DESCRIPTION:
28# After filling a filesystem, verify the contents can be removed
29# without encountering an ENOSPC error.
30#
31
32verify_runnable "both"
33
34command -v fio > /dev/null || log_unsupported "fio missing"
35
36function cleanup
37{
38	destroy_pool $TESTPOOL
39	log_must rm -f $all_vdevs
40}
41
42log_onexit cleanup
43
44log_assert "Files can be removed from full file system."
45
46all_vdevs=$(echo $TEST_BASE_DIR/file.{01..12})
47
48log_must truncate -s $MINVDEVSIZE $all_vdevs
49
50log_must zpool create -f $TESTPOOL draid2:8d:2s $all_vdevs
51log_must zfs create $TESTPOOL/$TESTFS
52log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
53log_must zfs set compression=off $TESTPOOL/$TESTFS
54
55log_note "Writing Big(1G) files until ENOSPC."
56log_mustnot_expect "No space left on device" fio --name=test \
57    --fallocate=none --rw=write --bs=1M --size=1G --numjobs=4 \
58    --sync=1 --directory=$TESTDIR/ --group_reporting
59
60log_must rm $TESTDIR/test.*
61log_must test -z "$(ls -A $TESTDIR)"
62sync_pool $TESTPOOL true
63
64log_note "Writing small(10M) files until ENOSPC."
65log_mustnot_expect "No space left on device" fio --name=test \
66    --fallocate=none --rw=write --bs=1M --size=10M --numjobs=200 \
67    --sync=1 --directory=$TESTDIR/ --group_reporting
68
69log_must rm $TESTDIR/test.*
70log_must test -z "$(ls -A $TESTDIR)"
71
72log_pass "All files removed without error"
73