]> git.proxmox.com Git - mirror_zfs.git/commit
Fix ENOSPC when unlinking multiple files from full pool
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 8 Mar 2022 17:16:35 +0000 (09:16 -0800)
committerGitHub <noreply@github.com>
Tue, 8 Mar 2022 17:16:35 +0000 (09:16 -0800)
commit6df43169b30985ce7d9df11d25093dec26829d2c
tree54b6fa3bc3bea7b231ba32b8d02d53089d917f74
parent39a4daf742a4bd34b34f85e004895385e4c46c1a
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
include/sys/dsl_pool.h
module/zfs/dsl_dir.c
module/zfs/dsl_pool.c
tests/runfiles/common.run
tests/zfs-tests/tests/functional/no_space/Makefile.am
tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh [new file with mode: 0755]