Skip to content

feat(fs): measure APFS and ReFS extent sharing instead of Unknown (0.1.22) - #354

Merged
zackees merged 1 commit into
mainfrom
feat/macos-apfs-extent-sharing
Sep 26, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/macos-apfs-extent-sharing

Conversation

@zackees

@zackees zackees commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Problem

platform::fs::extent_sharing (0.1.21, #353) returned Unknown for every file on APFS and ReFS. A caller that needs proof that deleting a file frees its space treats Unknown as possibly shared, so zccache (zackees/zccache#1673, PR zackees/zccache#1676) could never credit a reclaimed byte on a Mac or a Windows Dev Drive. Its macOS CI fails on exactly that.

Changes

  • macOS / APFS: fgetattrlist with ATTR_CMNEXT_PRIVATESIZE (FSOPT_ATTR_CMN_EXTENDED, macOS 10.15+) returns the bytes the file shares with no clone or snapshot. Private size < allocated (st_blocks * 512) → Shared, otherwise Exclusive. A volume that does not return the attribute (checked via ATTR_CMN_RETURNED_ATTRS) or rejects the request keeps the existing file-system-type fallback.
  • Windows / ReFS: FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT returns each extent's reference count; any allocated extent (Lcn != -1) with a count > 1 → Shared, otherwise Exclusive; paged with ERROR_MORE_DATA, ERROR_HANDLE_EOF = nothing allocated. NTFS/FAT stay Exclusive; any other volume, or an unsupported ioctl, stays Unknown.
  • CI: the windows-2025 test job formats a 2 GB ReFS VHDX with diskpart and exports KERNAL_REFS_TEST_DIR, so the Windows tests require a ReFS block clone to report Shared and a fresh file Exclusive instead of skipping on NTFS. The macOS tests likewise require a private-size measurement and a successful clonefile whenever the temp dir is APFS.
  • Version 0.1.21 → 0.1.22.

Verification

  • Clippy -D warnings (lib, lib cfg(test), fs tests, --features fs) clean for x86_64/aarch64 Windows MSVC, x86_64/aarch64 Apple Darwin, x86_64 Linux.
  • Linux: fs tests 76/76, extent unit tests 3/3. CI guard unittests (85), release tooling, compilation-boundary and Python package checks pass.
  • Layout tests pin the reply structs (PrivateSizeReply 4/24/32, refcount header extents at 16, extent 24 bytes).

🤖 Generated with Claude Code

…nknown (0.1.22)

extent_sharing reported Unknown for every file on APFS and ReFS, so a
caller that needs proof (zccache#1673) could never credit a freed byte on
a Mac or a Dev Drive.

- macOS: fgetattrlist ATTR_CMNEXT_PRIVATESIZE gives the bytes a file
  shares with no clone; a private size below the allocation is Shared,
  otherwise Exclusive. Volumes that do not report it keep the file
  system type fallback.
- Windows: on ReFS, FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT reports
  each extent's reference count; any allocated extent above one is
  Shared. NTFS/FAT stay Exclusive.
- CI formats a ReFS volume on windows-2025 (KERNAL_REFS_TEST_DIR) so the
  block-clone path is proven, and the macOS tests require a measurement
  and a clone on APFS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zackees zackees added the ci-full Run the complete release-equivalent CI matrix on this PR SHA label Sep 26, 2026
@zackees
zackees merged commit 5b142e0 into main Sep 26, 2026
14 of 19 checks passed
zackees added a commit to zackees/zccache that referenced this pull request Sep 26, 2026
…sharing (#1673)

kernal-api 0.1.22 (zackees/kernal-api#354) answers extent_sharing on
APFS (ATTR_CMNEXT_PRIVATESIZE) and ReFS (per-extent reference counts)
instead of Unknown, so retired-store bytes are credited on macOS and Dev
Drives again. Comments that said APFS/ReFS always report unknown sharing
now describe unqueryable volumes instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
zackees added a commit to zackees/zccache that referenced this pull request Sep 26, 2026
…sharing (#1673) (#1679)

kernal-api 0.1.22 (zackees/kernal-api#354) answers extent_sharing on
APFS (ATTR_CMNEXT_PRIVATESIZE) and ReFS (per-extent reference counts)
instead of Unknown, so retired-store bytes are credited on macOS and Dev
Drives again. Comments that said APFS/ReFS always report unknown sharing
now describe unqueryable volumes instead.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zackees
zackees deleted the feat/macos-apfs-extent-sharing branch September 26, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run the complete release-equivalent CI matrix on this PR SHA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant