Skip to content

tests: count descriptors in a process of their own - #28

Merged
brauner merged 1 commit into
mainfrom
ebusyfix
Nov 21, 2026
Merged

brauner merged 1 commit into
mainfrom
ebusyfix

Conversation

@brauner

@brauner brauner commented Nov 20, 2026

Copy link
Copy Markdown
Member

host::tests::a_large_directory_costs_no_descriptors lists /proc/self/fd
and reads every link in it 1502 times while the other unit tests of the
fat crate run in other threads of the same process. procfs takes a
reference on every file it lists and on every file whose link it reads.
If another test closes its image right then, the lister puts the last
reference. __fput() then only runs once the lister returns to user
space, and that's where locks_remove_file() drops the BSD lock. The
other test reopens the image right away, flock(LOCK_EX|LOCK_NB) fails
and the test dies with EBUSY.

So move the test into a test binary of its own. walk_tree() is private
to the crate, so the test now copies the directory into a volume with
copy_tree_with_progress() and counts in the progress callback. The
callback runs while the file being copied is open, so the limit goes up
from four descriptors to five.

Nothing else that shares a process with tests reopening images lists
/proc/self/fd. The integration tests that spawn programs already run
one at a time through common::serial(), since a child holds the files
of its parent until it execs.

On a 512 CPU machine, pinned to 384 CPUs, with RUST_TEST_THREADS=8 and
main and this branch running side by side:

  • fat's unit tests, 12 copies per tree, 3000 runs each: 8 EBUSY
    failures on main, none with this branch.
  • fat's unit tests and every ufat test binary, 10 copies per tree, 300
    runs each: 1 EBUSY failure on main, in fat's unit tests, none with
    this branch.
  • the same main binary with and without the lister, 12 copies each,
    3000 runs each: 3 EBUSY failures with it, none without.

host::tests::a_large_directory_costs_no_descriptors lists /proc/self/fd
1502 times while the other unit tests of the fat crate run in other
threads of the same process. procfs takes a reference on every file it
lists and on every file whose link it reads. When another test closes
its image in that moment, the scanner puts the last reference and the
BSD lock is only dropped when the scanner returns to user space. The
other test reopens the image right away and fails with EBUSY.

Move the test into a test binary of its own, so no other test runs in
the process that lists /proc/self/fd. walk_tree() is private to the fat
crate, so the test now copies the directory into a volume with
copy_tree_with_progress() and counts in the progress callback. That
callback runs while the walk holds its pins and the file it copies, so
the limit goes up from four descriptors to five.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
@brauner
brauner added this pull request to stack #29 November 20, 2026 22:22
@brauner
brauner merged commit 186671f into main Nov 21, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant