Internals
title: Internals
Internals
Engineering notes for contributors. These pages explain why the on-disk format work looks the way it does — pointers into the relevant kernel / OpenZFS source, lists of the bugs the lib had to fix to read real-world output, and the algorithms ported into Go.
:material-bug:{ .lg .middle } On-disk format fixes
The full list of 14 format mismatches the
go-filesystems/*libraries had to fix to read realmkfs.btrfs/zpool createoutput. Each entry cites the kernel / OpenZFS reference.:material-shape:{ .lg .middle } btrfs multi-device routing
How
chunk.goandmultidev.goroute per-IO reads across the six btrfs RAID profiles, modelled onfs/btrfs/volumes.c:btrfs_map_block.:material-database-cog:{ .lg .middle } ZFS multi-vdev + RAID-Z
OpenFromDevices,multiVdevPool,raidzMapAlloc— the healthy-path RAID-Z geometry ported frommodule/zfs/vdev_raidz.c.:material-file-tree-outline:{ .lg .middle } vdev label NVList
XDR layout, encoding/decoding, and how
ProbeLabelwalksvdev_tree.childrento surface the leaf-id ordering cloud-boot-init needs.
House rules for this section
- Cite kernel / OpenZFS source by file + function. Bonus points for git tag / version.
- Quote on-disk byte layouts directly when the bug was an offset or a size mismatch — future readers need to see the numbers.
- Link the test fixture that surfaced each bug. Every fixture in
testdata/raid/*.tar.zstwas generated by realmkfs.btrfs/zpool createin a Lima Debian 12 VM. The generation recipe is an operator-side note, kept unpublished on purpose — so it is named here rather than linked. The link that used to sit in this sentence pointed into a working directory that exists on one machine and returned 404 to every reader of this page. - Keep cross-references hot. If a chunk-mapping change touched
superblock.goANDchunk.goAND every chunk-using read site, spell out all three.
Why pure-Go FS drivers?
Three reasons that compound:
- Kernel slimming. With the userland-FS pivot the
disk-<arch>.configkernel dropsCONFIG_EXT4_FS,CONFIG_XFS_FS,CONFIG_BTRFS_FSentirely. The bootstrap Image shrinks by ~5 MiB. - ZFS without DKMS. Pre-pivot, ZFS support required either
the out-of-tree OpenZFS DKMS module (multi-MB binary blob,
per-kernel-version compile) or the
zfsutils-linuxuserspace stack. Post-pivot, neither: the pure-Go driver reads OpenZFS pools end-to-end. Worth roughly 30 MB of build artifact and several minutes of CI per architecture. - Same code on every path. The loader (Path B), the init
binary (Paths A + C), and any host-side tool that wants to
inspect a chained-distro disk all share the SAME
go-filesystems/*libraries. No drift between userspace-mounted reads and embedded-init reads.