]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
libxfs: partition memfd files to avoid using too many fds
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:10 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:40 +0000 (11:37 -0700)
commitd9bbcebf2456e1f302ca9b637c76e9201ddad4b4
treecd226e9bb0cdb044efb913c3c94584547707939f
parent1cb2e387792d724a9ea983edfcacd370ff764c81
libxfs: partition memfd files to avoid using too many fds

In a few patchsets from now, we'll transition xfs_repair to use
memfd-backed rmap and rcbag btrees for storing repair data instead of
heap allocations.  This allows repair to use libxfs code shared from the
online repair code, which reduces the size of the codebase.  It also
reduces heap fragmentation, which might be critical on 32-bit systems.

However, there's one hitch -- userspace xfiles naively allocate one
memfd per data structure, but there's only so many file descriptors that
a process can open.  If a filesystem has a lot of allocation groups, we
can run out of fds and fail.  xfs_repair already tries to increase
RLIMIT_NOFILE to the maximum (~1M) but this can fail due to system or
memory constraints.

Fortunately, it is possible to compute the upper bound of a memfd btree,
which implies that we can store multiple btrees per memfd.  Make it so
that we can partition a memfd file to avoid running out of file
descriptors.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/xfile.c
libxfs/xfile.h