Skip to content

C4-5: Implement extended attribute operations #167

Closed

Description

@scttfrdmn

Summary

Implement the four extended-attribute operations — GetXattr, SetXattr, ListXattr,
RemoveXattr — on the capability layer built for Setattr (#165).

Background

All four are declared in internal/filesystem/interface.go and implemented only by a test
mock. Neither FUSE build wires them up.

This matters more than it might appear on a research-computing filesystem: macOS stores
Finder metadata in xattrs, Linux tooling uses user.* attributes, and rsync -X, tar --xattrs, and SELinux labeling all depend on them. Without xattrs those tools either fail or
silently drop metadata.

Storage follows #165: object annotations where available (mutable in place, up to 1000 per
object, 1 MiB each — a good fit for xattrs), x-amz-meta- keys otherwise. The metadata
fallback is considerably more constrained, which shapes the acceptance criteria below.

Implementation

Reuse the #165 capability layer rather than re-detecting. Namespace stored keys so xattrs
cannot collide with the POSIX attribute keys (objectfs-mode, objectfs-uid, …) or with
objectfs-sha256.

Constraints that must be handled explicitly rather than discovered in production:

  • Total metadata size limit. All S3 user metadata for an object must fit within 2 KB.
    Exceeding it fails the PUT. Return ENOSPC (or E2BIG) rather than a generic error.
  • Header-safe encoding. xattr values are arbitrary bytes; metadata values are HTTP header
    values. Base64-encode on the metadata path.
  • Case insensitivity. S3 metadata keys are case-insensitive and normalized to lowercase,
    so user.Foo and user.foo collide on the fallback path but not on annotations. Encode the
    original case in the stored key.
  • Rewrite cost. On the metadata path, every SetXattr is a CopyObject onto itself. This
    is why annotations are the preferred path.

Return ENOATTR for a missing attribute — not ENOENT, which callers interpret as a missing
file.

Acceptance Criteria

  • setfattr -n user.test -v hello f then getfattr -n user.test f returns hello
  • getfattr -d f lists all attributes
  • setfattr -x user.test f removes one
  • Attributes survive an unmount/remount cycle
  • A missing attribute returns ENOATTR, not ENOENT
  • Binary values round-trip byte-for-byte
  • user.Foo and user.foo remain distinct on both storage paths
  • Exceeding the metadata size limit returns a size error, not a generic failure
  • xattr keys cannot collide with objectfs-* internal metadata keys
  • Verified on both paths: real AWS (annotations) and a non-AWS S3-compatible endpoint (metadata)
  • go test -race ./internal/fuse/... ./internal/storage/s3/... passes
  • AWS_PROFILE=aws AWS_REGION=us-west-2 go test -race -tags=integration ./internal/fuse/... passes

Dependencies

Blocked on #165 — builds directly on its annotation-vs-metadata capability layer.

Activity

  1. added
    type: enhancement
    priority: medium
    area: fuse
    on Jul 30, 2026
  2. scttfrdmn commented on Jul 30, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: annotations require an SDK bump this repo has not taken

    The annotations-as-accelerator design depends on API operations that do not exist in the pinned SDK. This is a hard prerequisite, not a detail.

    Version gate. go.mod:10 pins github.com/aws/aws-sdk-go-v2/service/s3 v1.88.4. Listing that module directory for annotation operations returns nothing. The operations first appear in v1.104.0:

    api_op_PutObjectAnnotation.go
    api_op_GetObjectAnnotation.go
    api_op_ListObjectAnnotations.go
    api_op_DeleteObjectAnnotation.go
    api_op_UpdateBucketMetadataAnnotationTableConfiguration.go
    

    So the annotations path cannot be written at all until service/s3 moves from v1.88.4 to >= v1.104.0, which pulls the core aws-sdk-go-v2 and smithy-go forward with it.

    MVS compatibility risk. CargoShip v0.13.0 pins service/s3 v1.82.0 and aws-sdk-go-v2 v1.41.0 ([email protected]/go.mod). Minimal version selection will resolve to our higher version, so it should build — but CargoShip is compiled against the older s3.Client surface, and this needs an actual go build ./... plus the CargoShip-path tests to confirm, not an assumption. Verify before committing to the annotations design.

    Semantic defect in the conditional-write plan. The issue proposes x-amz-object-if-match for safe concurrent attribute updates. Per the SDK:

    // If specified, the operation only succeeds if the object's ETag matches the
    // provided value.
    ObjectIfMatch *string

    It matches the parent object's ETag, not the annotation's. Two concurrent chmods against an unmodified object therefore both present the same valid ETag and both succeed — last writer wins, silently. Annotations give no compare-and-swap on the annotation value itself. If atomic attribute updates are a requirement, annotations alone cannot provide them; that needs a separate mechanism and should be designed explicitly rather than assumed.

    Payload constraint. Annotation values must be valid UTF-8; non-UTF-8 bytes are rejected with HTTP 415. This matters for #167 (xattrs) in particular, where setfattr values are arbitrary binary. Base64-encode xattr values on the annotations path, or the metadata fallback will be the only correct path for binary xattrs.

    Suggested adjustment

    1. File a prerequisite issue for the SDK bump (service/s3 -> >= v1.104.0, core -> v1.42.x, smithy-go -> v1.27.x) with a CargoShip build/test check as its acceptance criterion, and make this issue depend on it.
    2. Build the metadata fallback first and ship it standalone. It needs no SDK bump, works on MinIO/Ceph/Wasabi, and is the default path per the design decision already taken. Annotations then become a genuinely optional optimization layered on later.
    3. Drop the atomicity claim from the acceptance criteria, or replace it with an explicit last-writer-wins statement.
  3. added
    effort: medium
    on Aug 3, 2026
  4. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    Scoping notes before implementation — two premises in this issue do not match the tree.

    1. The storage design says annotations; the code already decided against them. This issue says "object annotations where available ... x-amz-meta- keys otherwise", and #165's closing comment lists the annotation capability layer as "Not started". But internal/vfs/attr.go:170 records the opposite decision, deliberately:

    Object metadata, not S3 object annotations: metadata works on every S3-compatible implementation (MinIO, Ceph, Wasabi) and on directory buckets, and it survives the copy a tier transition performs.

    Nothing in the repo implements annotations — grep for "annotation" outside internal/awsrates returns only that comment. So xattrs are being implemented over object metadata, consistent with how objectfs-mode/objectfs-uid/objectfs-gid/objectfs-mtime are already persisted, and no annotation path or probe for one is being built.

    2. The cited declaration site is a dead design sketch. This issue says the four methods are "declared in internal/filesystem/interface.go and implemented only by a test mock". That is accurate but misleading as a place to implement: the package's own doc comment says it has no importers anywhere in the tree, that its only implementation is its own test mock, and — verbatim — "Do not infer support from this file." It also records that this interface advertising Symlink and Link with nothing behind them "is precisely what went wrong in v0.10.0." The live path is internal/fuse → internal/vfs → pkg/types.Backend, so that is where the work goes.

    3. An existing test asserts these operations fail, and it has to change with them. internal/fuse/unimplemented_test.go drives go-fuse's raw bridge directly and pins setxattr/removexattr at ENOATTR. Its header explains why that matters: the README errno table documented a dependency's defaults and a guess about one of them (rename → ENOSYS vs the actual ENOTSUP) was wrong in a way no build or lint could catch. That file, the README operations table, and the implementation move together — "a row asserting an operation fails is as wrong as a row asserting the wrong errno once the operation works."

    Also being handled explicitly rather than discovered later: the 2 KB total user-metadata budget is shared with the POSIX attribute keys already stored, so the xattr budget is 2 KB minus those; S3 lower-cases metadata keys in transit, so user.Foo/user.foo collide unless the original case is encoded; and a user setting user.objectfs-mode must not be able to reach the file's real POSIX mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fuseeffort: mediumpriority: mediumtype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions