feat(fs): measure APFS and ReFS extent sharing instead of Unknown (0.1.22) - #354
Merged
Merged
Conversation
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
platform::fs::extent_sharing(0.1.21, #353) returnedUnknownfor every file on APFS and ReFS. A caller that needs proof that deleting a file frees its space treatsUnknownas 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
fgetattrlistwithATTR_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, otherwiseExclusive. A volume that does not return the attribute (checked viaATTR_CMN_RETURNED_ATTRS) or rejects the request keeps the existing file-system-type fallback.FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNTreturns each extent's reference count; any allocated extent (Lcn != -1) with a count > 1 →Shared, otherwiseExclusive; paged withERROR_MORE_DATA,ERROR_HANDLE_EOF= nothing allocated. NTFS/FAT stayExclusive; any other volume, or an unsupported ioctl, staysUnknown.windows-2025test job formats a 2 GB ReFS VHDX with diskpart and exportsKERNAL_REFS_TEST_DIR, so the Windows tests require a ReFS block clone to reportSharedand a fresh fileExclusiveinstead of skipping on NTFS. The macOS tests likewise require a private-size measurement and a successfulclonefilewhenever the temp dir is APFS.Verification
-D warnings(lib, libcfg(test),fstests,--features fs) clean for x86_64/aarch64 Windows MSVC, x86_64/aarch64 Apple Darwin, x86_64 Linux.fstests 76/76, extent unit tests 3/3. CI guard unittests (85), release tooling, compilation-boundary and Python package checks pass.PrivateSizeReply4/24/32, refcount header extents at 16, extent 24 bytes).🤖 Generated with Claude Code