mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Fix ENOSPC when unlinking multiple files from full pool
When unlinking multiple files from a pool at 100% capacity, it was
possible for ENOSPC to be returned after the first unlink. e.g.
rm -f /mnt/fs/test1.0.0 /mnt/fs/test1.1.0 /mnt/fs/test1.2.0
rm: cannot remove '/mnt/fs/test1.1.0': No space left on device
rm: cannot remove '/mnt/fs/test1.2.0': No space left on device
After waiting for the pending deferred frees from the first unlink to
be processed the remaining files can then be unlinked. This is caused
by the quota limit in dsl_dir_tempreserve_impl() being temporarily
decreased to the allocatable pool capacity less any deferred free
space.
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.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13172
This commit is contained in:
+14
-6
@@ -1334,13 +1334,21 @@ top_of_function:
|
||||
/*
|
||||
* If they are requesting more space, and our current estimate
|
||||
* is over quota, they get to try again unless the actual
|
||||
* on-disk is over quota and there are no pending changes (which
|
||||
* may free up space for us).
|
||||
* on-disk is over quota and there are no pending changes
|
||||
* or deferred frees (which may free up space for us).
|
||||
*/
|
||||
if (used_on_disk + est_inflight >= quota) {
|
||||
if (est_inflight > 0 || used_on_disk < quota ||
|
||||
(retval == ENOSPC && used_on_disk < quota))
|
||||
retval = ERESTART;
|
||||
if (est_inflight > 0 || used_on_disk < quota) {
|
||||
retval = SET_ERROR(ERESTART);
|
||||
} else {
|
||||
ASSERT3U(used_on_disk, >=, quota);
|
||||
|
||||
if (retval == ENOSPC && (used_on_disk - quota) <
|
||||
dsl_pool_deferred_space(dd->dd_pool)) {
|
||||
retval = SET_ERROR(ERESTART);
|
||||
}
|
||||
}
|
||||
|
||||
dprintf_dd(dd, "failing: used=%lluK inflight = %lluK "
|
||||
"quota=%lluK tr=%lluK err=%d\n",
|
||||
(u_longlong_t)used_on_disk>>10,
|
||||
@@ -1348,7 +1356,7 @@ top_of_function:
|
||||
(u_longlong_t)quota>>10, (u_longlong_t)asize>>10, retval);
|
||||
mutex_exit(&dd->dd_lock);
|
||||
DMU_TX_STAT_BUMP(dmu_tx_quota);
|
||||
return (SET_ERROR(retval));
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/* We need to up our estimated delta before dropping dd_lock */
|
||||
|
||||
@@ -950,6 +950,12 @@ dsl_pool_unreserved_space(dsl_pool_t *dp, zfs_space_check_t slop_policy)
|
||||
return (quota);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
dsl_pool_deferred_space(dsl_pool_t *dp)
|
||||
{
|
||||
return (metaslab_class_get_deferred(spa_normal_class(dp->dp_spa)));
|
||||
}
|
||||
|
||||
boolean_t
|
||||
dsl_pool_need_dirty_delay(dsl_pool_t *dp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user