Skip to content

Commit

Permalink
Fix ENOSPC for extended quota
Browse files Browse the repository at this point in the history
When unlinking multiple files from a pool at 100% capacity, it
was possible for ENOSPC to be returned after the first few unlinks.
This issue was fixed previously by PR #13172 but then this was
again introduced by PR #13839.

This is resolved using the existing mechanism of returning ERESTART
when over quota as long as we know enough space will shortly be
available after processing the pending deferred frees.

Also, updated the existing testcase which reliably reproduced the
issue without this patch.

Reviewed-by: Dipak Ghosh <[email protected]>
Signed-off-by: Akash B <[email protected]>
  • Loading branch information
akashb-22 committed Sep 25, 2023
1 parent 2e2a46e commit 901832a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions module/zfs/dsl_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright (c) 2016 Actifio, Inc. All rights reserved.
* Copyright (c) 2018, loli10K <[email protected]>. All rights reserved.
* Copyright (c) 2023 Hewlett Packard Enterprise Development LP.
*/

#include <sys/dmu.h>
Expand Down Expand Up @@ -1358,6 +1359,10 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
ext_quota = 0;

if (used_on_disk >= quota) {
if (retval == ENOSPC && (used_on_disk - quota) <
dsl_pool_deferred_space(dd->dd_pool)) {
retval = SET_ERROR(ERESTART);
}
/* Quota exceeded */
mutex_exit(&dd->dd_lock);
DMU_TX_STAT_BUMP(dmu_tx_quota);
Expand Down
11 changes: 10 additions & 1 deletion tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#
# Copyright (c) 2014, 2016 by Delphix. All rights reserved.
# Copyright (c) 2022 by Lawrence Livermore National Security, LLC.
# Copyright (c) 2023 Hewlett Packard Enterprise Development LP.
#

. $STF_SUITE/include/libtest.shlib
Expand Down Expand Up @@ -51,12 +52,20 @@ log_must zfs create $TESTPOOL/$TESTFS
log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
log_must zfs set compression=off $TESTPOOL/$TESTFS

log_note "Writing files until ENOSPC."
log_note "Writing Big(1G) files until ENOSPC."
log_mustnot_expect "No space left on device" fio --name=test \
--fallocate=none --rw=write --bs=1M --size=1G --numjobs=4 \
--sync=1 --directory=$TESTDIR/ --group_reporting

log_must rm $TESTDIR/test.*
log_must test -z "$(ls -A $TESTDIR)"

log_note "Writing small(10M) files until ENOSPC."
log_mustnot_expect "No space left on device" fio --name=test \
--fallocate=none --rw=write --bs=1M --size=10M --numjobs=200 \
--sync=1 --directory=$TESTDIR/ --group_reporting

log_must rm $TESTDIR/test.*
log_must test -z "$(ls -A $TESTDIR)"

log_pass "All files removed without error"

0 comments on commit 901832a

Please sign in to comment.