]> git.proxmox.com Git - mirror_zfs.git/commit
Channel program may spuriously fail with "memory limit exhausted"
authorMatthew Ahrens <matthew.ahrens@delphix.com>
Thu, 12 Nov 2020 01:16:15 +0000 (17:16 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Nov 2020 17:02:00 +0000 (09:02 -0800)
commit4a87c280dc9a58e35ca0dc52ff6ab6bcd0cededc
tree4e472ce8330c4ebff540795ed361a46939d00c2a
parentd237d9a918860b2ec3f442919dbe974532d49251
Channel program may spuriously fail with "memory limit exhausted"

ZFS channel programs (invoked by `zfs program`) are executed in a LUA
sandbox with a limit on the amount of memory they can consume.  The
limit is 10MB by default, and can be raised to 100MB with the `-m` flag.
If the memory limit is exceeded, the LUA program exits and the command
fails with a message like `Channel program execution failed: Memory
limit exhausted.`

The LUA sandbox allocates memory with `vmem_alloc(KM_NOSLEEP)`, which
will fail if the requested memory is not immediately available.  In this
case, the program fails with the same message, `Memory limit exhausted`.
However, in this case the specified memory limit has not been reached,
and the memory may only be temporarily unavailable.

This commit changes the LUA memory allocator `zcp_lua_alloc()` to use
`vmem_alloc(KM_SLEEP)`, so that we won't spuriously fail when memory is
temporarily low.  Instead, we rely on the system to be able to free up
memory (e.g. by evicting from the ARC), and we assume that even at the
highest memory limit of 100MB, the channel program will not truly
exhaust the system's memory.

External-issue: DLPX-71924
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11190
module/zfs/zcp.c