[PR #425] fix(fuse): clean up partial read setup #428

Open
opened 2026-10-26 09:50:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/3FS/pull/425
Author: @OllieinCanada
Created: 8/24/2026
Status: 🔄 Open

Base: main ← Head: fix/read-file-partial-init-cleanup


📝 Commits (2)

  • 645e583 fix(fuse): clean up partial read setup
  • a7063dd test(fuse): cover remaining read setup failures

📊 Changes

2 files changed (+164 additions, -4 deletions)

View changed files

📝 hf3fs_fuse/io.py (+13 -4)
➕ tests/fuse/test_hf3fs_fuse_io.py (+151 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/3FS/pull/425 **Author:** [@OllieinCanada](https://github.com/OllieinCanada) **Created:** 8/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/read-file-partial-init-cleanup` --- ### 📝 Commits (2) - [`645e583`](https://github.com/deepseek-ai/3FS/commit/645e583b7e2c634aa197cc0e1ad75ab19daa0505) fix(fuse): clean up partial read setup - [`a7063dd`](https://github.com/deepseek-ai/3FS/commit/a7063dd23f890d9f488055c26daaf0163c6623c9) test(fuse): cover remaining read setup failures ### 📊 Changes **2 files changed** (+164 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `hf3fs_fuse/io.py` (+13 -4) ➕ `tests/fuse/test_hf3fs_fuse_io.py` (+151 -0) </details> ### 📄 Description 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: ```text 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/3FS#428
No description provided.