Skip to content

perf(virtiofs): reuse create handles for atomic open#2120

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/optimize-virtiofs-p2
Jul 14, 2026
Merged

perf(virtiofs): reuse create handles for atomic open#2120
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/optimize-virtiofs-p2

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

  • reuse the file handle returned by FUSE_CREATE instead of issuing FUSE_RELEASE followed by FUSE_OPEN
  • add a VFS preopened-file guard that safely transfers ownership through mount wrapping and closes handles on failure
  • cache FUSE_CREATE ENOSYS and preserve the Linux-compatible MKNOD + OPEN fallback
  • add FUSE regression coverage for handle reuse, flag filtering, fallback caching, and error cleanup

Root cause

DragonOS discarded the handle returned by FUSE_CREATE and then opened the new inode again. This added two FUSE requests per created file and amplified metadata-heavy virtiofs workloads.

Validation

  • make kernel
  • make all
  • Rust formatting check
  • FuseCore: 5/5 passed
  • FuseExtended: 63/63 passed
  • 64-file metadata workload: 8 to 6 FUSE requests per file; redundant FUSE_OPEN count reduced from 64 to 0
  • CubeSandbox 64-file create workload: median 2.79s to 2.06s (about 26% faster)
  • CubeSandbox command and file-read workloads improved materially; large-file write throughput remains a separate bottleneck

Fixes #2019

FUSE_CREATE already returns an opened file handle, but the VFS create path discarded it with FUSE_RELEASE and constructed the file through a second FUSE_OPEN. This added two protocol requests for every created file and amplified metadata-heavy container workloads.

Add an optional VFS create-and-open operation backed by an RAII preopened-file guard. Carry the returned FUSE handle through MountFS wrapping and File construction, skip the redundant open request, and close the handle on every intermediate failure path.

Cache FUSE_CREATE ENOSYS at the connection level and preserve the Linux-compatible MKNOD plus OPEN fallback. Forward Linux-compatible create flags while keeping close, cache-state, writeback, and file-mode initialization consistent with normal FUSE opens.

Extend FuseExtended coverage for handle reuse, CREATE flag filtering, ENOSYS fallback caching, and RELEASE/FORGET cleanup of invalid replies.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@fslongjin
fslongjin merged commit d544044 into DragonOS-Community:master Jul 14, 2026
15 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.

virtiofs: plan and implement DAX support using the virtiofs shared-memory cache

1 participant