Skip to content

fix(fuse): clean up partial read setup - #425

Open
OllieinCanada wants to merge 2 commits into
deepseek-ai:mainfrom
OllieinCanada:fix/read-file-partial-init-cleanup
Open

fix(fuse): clean up partial read setup#425
OllieinCanada wants to merge 2 commits into
deepseek-ai:mainfrom
OllieinCanada:fix/read-file-partial-init-cleanup

Conversation

@OllieinCanada

@OllieinCanada OllieinCanada commented Aug 24, 2026

Copy link
Copy Markdown

Fixes #424

Summary

Preserve setup failures from hf3fs_fuse.io.read_file() and clean up only the
resources that were successfully acquired.

Root cause

The cleanup block unconditionally referenced fd, ior, iov, and shm.
When file opening, native registration, shared-memory creation, iovec creation,
or ioring creation failed, an UnboundLocalError could replace the useful
original exception. Failures after shared-memory creation could also skip its
close() and unlink() calls.

Fix

  • initialize each resource before entering the setup path
  • track whether native file-descriptor registration completed
  • deregister and close the descriptor only when applicable
  • release iovec, ioring, and shared memory only after they exist

Successful read behavior and cleanup order remain unchanged. This also lets an
underlying make_iovec() error such as #291 surface correctly; it does not
attempt to solve #291's separate symlink failure.

Tests

A host-only test with a stubbed native binding covers:

  • preserving an os.open() failure
  • not deregistering a descriptor whose registration failed
  • releasing the descriptor after shared-memory creation fails
  • releasing the descriptor, registration, and shared memory after iovec setup fails
  • releasing the descriptor, registration, and shared memory after ioring setup fails
  • unchanged successful reads and cleanup

Validation:

python -m pytest tests/fuse/test_hf3fs_fuse_io.py -q
6 passed in 0.81s

python -m compileall -q hf3fs_fuse tests/fuse/test_hf3fs_fuse_io.py
git diff --check

No 3FS mount, RDMA device, external service, or new dependency is required for
the regression test. The full deployment-dependent 3FS suite was not run in
this environment.

Oliver Slapinski added 2 commits August 24, 2026 01:51
Signed-off-by: Oliver Slapinski <olliefromcanada@gmail.com>
Signed-off-by: Oliver Slapinski <olliefromcanada@gmail.com>
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.

read_file masks setup failures and leaks partial resources

1 participant