FUSE: require valid file/dir handle; drop open_files fallback

Several FUSE ops fell back to looking up a FileInfo via
state.open_files when the kernel-provided fh was zero, returning
-ENOENT if the lookup failed. This path papered over handle-tracking
bugs and added cost on every call. Use the handle directly and
return -EBADF when it is invalid - the kernel should always hand us
a valid fh for an open resource.

Also simplify FileInfo::from_fh / DirInfo::from_fh and their to_fh
helpers: callers now handle the null-pointer case explicitly so the
ASSERT_NOT_NULL checks are redundant.

Covers fallocate, fchmod, fchown, fgetattr, flock, ftruncate,
futimens, read, release, releasedir, write, statx, ioctl (file +
dir), readdir (sequential, concurrent-on-read,
concurrent-on-search), and the passthrough fast paths in
create/open.
This commit is contained in:
Antonio S. Musumeci 2026-04-18 00:53:11 -04:00 • committed by trapexit
parent 0dcca0f1a3
commit 98648ae44b
21 changed files with 74 additions and 143 deletions

View file

@ -168,6 +168,8 @@ _write(const fuse_file_info_t *ffi_,
FileInfo *fi;
fi = FileInfo::from_fh(ffi_->fh);
if(not fi)
return -EBADF;
// Concurrent writes can only happen if:
// 1) writeback-cache is enabled and using page caching