Re: automatic freeing of space on ENOSPC

Theodore Ts'o
2021-06-29T16:47:20Z

On Mon, Jun 28, 2021 at 03:49:08PM -0400, J. Bruce Fields wrote:
> Is there anything analogous to a "shrinker", but for disk space? So,
> some hook that a filesystem could call to say "I'm running out of space,
> could you please free something?", before giving up and returning
> ENOSPC?

In addition to the issues raised by Neil, Amir, Dave, and others, the
other challenge with the file system calling a "please try to free
something before I return ENOSPC" is that this would almost certainly
require blocking a system call while some userspace daemon tried to
free up some space --- or were you thinking that the nfsd kernel code
would be tracking all of the silly-rename files so it could release
space really quickly on demand?

Even if this is only a kernel callback, I'd be concerned about
potential locking hierarchy problems if we are calling out from block
allocation subsystem to nfsd, only to have nfsd call back in to
request unlinking a silly-renamed file.

So the suggestion that we not wait until we're down to 0 blocks free,
but when we hit some threshold (say, free space dips below N minutes
worth of worst or average case block allocations), trigger code which
deletes silly-renamed files, is probably the best way to go. In which
case, a callback is not what is needed; and if N is large enough, this
could done via a pure user-space-only solution.

- Ted