Skip to content

Expose immutable NFSv4.2 objects for filesystem adapters - #615

Open
kogeler wants to merge 3 commits into
sahlberg:masterfrom
kogeler:pr/nfs4-object-api
Open

kogeler wants to merge 3 commits into
sahlberg:masterfrom
kogeler:pr/nfs4-object-api

Conversation

@kogeler

@kogeler kogeler commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an opaque, context-scoped NFSv4.2 object API for lookup, open, metadata, directory and namespace operations. It keeps the server filehandle identity without exposing private nfsfh internals, and reuses the existing async callbacks, operation builders and OPEN/session machinery.
  • This comes from work on fuse-nfs. An atomic save from another client changes what a pathname refers to; an already open fd or mmap must still refer to the old object while it exists. Path operations cannot provide that identity, and an OPEN handle alone does not cover FUSE lookup lifetimes or retained directory parents. The API lets the adapter key its inode table by filehandle and operate on the retained object instead of resolving its former name again.
  • Existing path APIs remain available. Objects are not OPEN state or a promise of persistence: removing the last server link can still make one stale. Error propagation is tested independently of the separate ESTALE mapping change.

This is a proposal driven by my Linux/FUSE and NFSv4.2 use case, not an attempt to define a universal object API. I'm open to a smaller interface or different naming and ownership conventions if they fit libnfs better.

Test plan

  • Allocation-failure injection, all 256 SETATTR masks, malformed replies and callback ownership.
  • Ordinary and extended stat results with numeric owner/named group attributes, including truncated replies after string decoding.
  • Autotools build/check and a Linux build with -DENABLE_NFS4_2=OFF to check compatibility with disabled support.
  • PS2 EE cross-build with the same toolchain image digest as CI: reproduced the original compiler failure, then built the fixed and merged revisions successfully.
  • Previous combined fork tested in fuse-nfs with lookup caching off/on: old fd/fstat/read/mmap, external replacement, directory lifetime and concurrent access. That integration run predates this upstream port; it is not a test of this exact PR revision.

Add public filehandle-based lookup, open, metadata, directory and namespace
operations without exposing private nfsfh internals or retaining mutable
paths. Reuse existing callback data, operation fillers, OPEN/CLOSE and RPC
session machinery with explicit input/result ownership.

Use CLAIM_FH to open an existing object, authorize object OPEN on the server,
support directory LOOKUP access and atomic SETATTR masks.

Port the downstream change to the current attribute parser and internal
stat helpers, preserving ordinary nfs_stat_64 object results. The upstream
base already fixes the malformed-stat callback's missing return.

Add a deterministic local RPC fixture covering operations, all 256 SETATTR
masks, malformed replies, cancellation, copied inputs and optional
allocation-failure injection. Check ordinary and extended stat results
with numeric owner and named group attributes, including truncated replies.
Check STALE propagation through the existing errno mapper so this change
does not depend on the separate STALE-to-ESTALE fix.

Downstream-case: NFS-008
(cherry picked from commit ce6ed07)
The PS2 EE build does not define the public NFS_V4_2 dialect constant.
Referencing it unconditionally in object_supported() broke that build.
A Linux build with ENABLE_NFS4_2=OFF still exposes the constant, so the
disabled-support build alone did not catch the regression.

Use the existing HAVE_NFS4_2 build guard and report that support was not
built in, following the other optional NFSv4.2 operations. Leave supported
object operations and the platform feature definitions unchanged.

Reproduce the compiler error on the original revision, then build the fixed
PS2 static library with the same toolchain image digest as the CI job.
Repeat the Linux Debug, sanitizer, allocation, Autotools and disabled-support
checks. The existing PS2 CI job remains the upstream regression coverage.

Fixes: 75896cb
Downstream-case: NFS-008
Include upstream 96cc605, which accepted
the independent STALE-to-ESTALE change in PR sahlberg#614.

Resolve the CMake test-list conflict by keeping the delay, errno and object
fixtures. Keep the object fixture's skip code and both Autotools test entries.
No object API behavior or build defaults change in the conflict resolution;
the PS2 feature guard remains in its separate preceding commit.

Validate the merged tree inside agents-a: all five selected tests pass in
Debug and ASan/UBSan, allocation-failure injection passes, and Autotools
build/check runs all three RPC/errno fixtures plus the ZDR bytes check.
The Linux NFSv4.2-disabled build and the real PS2 cross-build also pass.
No library installation or NFS mount is involved.

Related-change: 75896cb
Related-change: 0610624
Downstream-case: NFS-008
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