bcachefs: enable in-tree module and add userspace-tools sysext#4136
Open
ananthb wants to merge 5 commits into
Open
bcachefs: enable in-tree module and add userspace-tools sysext#4136ananthb wants to merge 5 commits into
ananthb wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new optional Flatcar systemd-sysext (flatcar-bcachefs) that bundles the bcachefs userspace tools and out-of-tree kernel module, built from a vendored Gentoo sys-fs/bcachefs-tools ebuild and registered in the extra sysext build matrix.
Changes:
- Vendor
sys-fs/bcachefs-tools-1.38.6intoportage-stable(ebuild, metadata, Manifest). - Add sysext build integration: env override for kernel-binpkg installs, sysext mangle script, and registration in
extra_sysexts.sh. - Add a user-facing changelog entry describing enablement and kernel floor (≥ 6.16).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk_container/src/third_party/portage-stable/sys-fs/bcachefs-tools/metadata.xml | Adds Gentoo package metadata for the vendored bcachefs tools ebuild. |
| sdk_container/src/third_party/portage-stable/sys-fs/bcachefs-tools/Manifest | Adds distfile checksums (bcachefs tarball + Rust crates) needed for offline builds. |
| sdk_container/src/third_party/portage-stable/sys-fs/bcachefs-tools/bcachefs-tools-1.38.6.ebuild | Introduces the vendored build recipe including optional module build via linux-mod-r1. |
| sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-fs/bcachefs-tools | Ensures kernel version/env is preserved for module builds when installing from binpkgs. |
| build_library/sysext_mangle_flatcar-bcachefs | Prunes non-runtime files, relocates /usr/sbin payload, and wires module loading via shared helper. |
| build_library/extra_sysexts.sh | Registers the new sysext in the extra sysext build list (amd64, USE=modules). |
| changelog/changes/2026-07-08-bcachefs.md | Documents the new extension, enablement, and kernel version floor for users. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Introduces a `flatcar-bcachefs` sysext following the shape of the existing `flatcar-zfs` sysext. Ships both the bcachefs userspace utilities and the bcachefs.ko kernel module, built together from a single ebuild against the exact kernel Flatcar's SDK produces. Files: - sdk_container/.../portage-stable/sys-fs/bcachefs-tools/: verbatim vendor of Gentoo's sys-fs/bcachefs-tools 1.38.6 from the main tree. Gentoo's ebuild has MODULES_OPTIONAL_IUSE=+modules and inherits linux-mod-r1, so with USE="modules" (default-on) it produces both the userspace binaries and bcachefs.ko in one pass. - sdk_container/.../coreos-overlay/coreos/config/env/sys-fs/bcachefs-tools: the same SKIP_KERNEL_BINPKG_ENV_RESET / LINUX_INFO_BINARY_RESET env pattern used by sys-fs/zfs-kmod so binpkg installs pick up Flatcar's kernel headers correctly. - build_library/sysext_mangle_flatcar-bcachefs: prunes dev/debug bits and calls the shared configure_modprobe helper (from sysext_mangle_kmod) to wire bcachefs.ko through the overlay-based modprobe helper — same shape as the ZFS mangle script. - build_library/extra_sysexts.sh: registers `bcachefs|sys-fs/bcachefs-tools|modules|amd64`. amd64-only for now; arm64 keywording follows once upstream marks it stable. - changelog/changes/2026-07-08-bcachefs.md: user-facing note. Kernel requirement: bcachefs's DKMS harness has BUILD_EXCLUSIVE_KERNEL_MIN=6.16, so the sysext will only build cleanly on channels whose kernel meets that floor (currently alpha). This is enforced by the ebuild — no additional gating is added here. Stable and lts channels will start producing the sysext once their kernels reach 6.16+. Background: bcachefs was mainlined in Linux 6.7 and removed in 6.18 after Kent Overstreet moved it to a DKMS-shape out-of-tree module. See https://lwn.net/Articles/1040120/ for the removal context. bcachefs is pre-1.0 for on-disk format stability, so this sysext is opt-in (users enable it by writing 'bcachefs' to /etc/flatcar/enabled-sysext.conf) and not supported for the root partition — matching the ZFS experimental posture. Signed-off-by: Ananth Bhaskararaman <antsub@gmail.com>
Registering bcachefs in EXTRA_SYSEXTS unconditionally would let the ebuild's MODULES_KERNEL_MIN=6.16 refusal abort create_prod_sysexts() on channels whose kernel is older, since the loop runs under set -e with no per-sysext gating. Extend the EXTRA_SYSEXTS schema with an optional fifth min_kernel field and skip entries whose requirement outpaces the board's coreos-kernel version. Also fix the /usr/sbin relocation in the mangle script: mv ./usr/sbin/* misses Portage .keep* placeholders, leaving the directory non-empty and making the following rmdir fail under set -e. cp -a src/. dst/ includes dotfiles, and rm -rf tolerates emptiness. Signed-off-by: Ananth Bhaskararaman <antsub@gmail.com>
Kent Overstreet's plan for bcachefs (1.38.7+) makes out-of-tree module builds impractical: once Rust becomes a hard dependency (kernel 7.0), DKMS needs an exact rustc match, the Rust stdlib sources, bindgen and the kernel build's .rlib/.rmeta artifacts. Flatcar builds its own kernel and can sidestep the whole mess by enabling bcachefs in-tree. Enable CONFIG_BCACHEFS_FS=m (and CONFIG_BCACHEFS_POSIX_ACL=y to match btrfs's shape) in coreos-modules commonconfig-6.12 so bcachefs.ko ships with the base image and is loaded on demand via modprobe. Rework the sysext to userspace-only: - extra_sysexts.sh: drop the `modules` USE flag (explicit `-modules`) and the min_kernel gate — the ebuild refuses to build below 6.16 only when it builds the OOT module, which we no longer do. - prod_image_util.sh: revert the min_kernel schema field; it existed solely to gate this sysext. - sysext_mangle_flatcar-bcachefs: drop configure_modprobe wiring, no OOT module to install. - coreos/config/env/sys-fs/bcachefs-tools: delete; the KV env dance was needed only for module builds against the board root's kernel. Keep the dotfile-safe /usr/sbin relocation (Portage .keep* under set -e). Update the changelog to describe the new shape. Signed-off-by: Ananth Bhaskararaman <antsub@gmail.com>
- src_unpack(): the previous flow ran `unpacker ${P}.tar.zst` and then
`cargo_src_unpack`, which itself iterates ${A} and re-extracts the
tarball. With USE=verify-sig the .sign file also lands in ${A} and
cargo's per-file unpack chokes on it. Fold everything into a single
pass: verify-sig streams the tarball into tar during signature check,
and we then hand cargo_src_unpack an ${A} with the tarball / .sign
filtered out. In the non-verify-sig path cargo_src_unpack extracts
the tarball itself.
- Drop `[[ -e bcachefs ]] && die` in src_compile: the workaround is
purely defensive against upstream's mangled symlink; killing the
build once upstream stops mangling would be an unnecessary trap.
`ln -rsf` is idempotent — just force the link.
- metadata.xml: drop the `fuse` USE flag entry. The ebuild does not
declare `IUSE=fuse` and the FUSE bits are unconditionally included,
so the flag entry only produces QA warnings.
Signed-off-by: Ananth Bhaskararaman <antsub@gmail.com>
f90f0e3 to
e617fd9
Compare
Address a second round of Copilot review feedback: - `src_install`: switch `into /` → `into /usr` and retarget all six compat symlinks (fsck/mkfs/mount plus the .fuse.* variants) from /sbin to /usr/sbin. `build_sysext` prunes every non-/usr top-level before running the mangle script, so anything installed to /sbin was quietly getting dropped from the final sysext. On usrmerge systems (Flatcar, modern Gentoo) this doesn't change what users see on disk since /sbin unifies with /usr/sbin — but it lets the mangle script's existing /usr/sbin → /usr/bin relocation catch the whole payload. - `QA_FLAGS_IGNORED`: retarget /sbin/bcachefs → /usr/sbin/bcachefs so the QA ignore still matches the actual install path. - `MODULES_OPTIONAL_IUSE=+modules` → `MODULES_OPTIONAL_IUSE=modules`: make the DKMS/OOT module build opt-in. With Flatcar shipping CONFIG_BCACHEFS_FS=m in coreos-modules, the ebuild's CONFIG_CHECK refuses to build the module (`!BCACHEFS_FS`). A default `emerge sys-fs/bcachefs-tools` would fail unless users remembered to pass USE=-modules; flipping the default keeps `emerge` working out of the box for the userspace tools. `extra_sysexts.sh` still passes `USE="-modules"` explicitly as belt-and-suspenders in case a profile force-enables it. Signed-off-by: Ananth Bhaskararaman <antsub@gmail.com>
| @@ -0,0 +1 @@ | |||
| - Enabled the in-tree bcachefs kernel module (`CONFIG_BCACHEFS_FS=m` with POSIX ACLs) and provided a companion bcachefs Flatcar extension as an optional systemd-sysext image with the release. Write `bcachefs` to `/etc/flatcar/enabled-sysext.conf` through Ignition and the sysext will be installed during provisioning; it ships the userspace utilities (`mkfs.bcachefs`, `mount.bcachefs`, ...) that pair with the kernel module. bcachefs is still experimental (pre-1.0 on-disk format) and is not supported for the root partition. | |||
Comment on lines
+263
to
+276
| if use verify-sig; then | ||
| # Upstream signs the uncompressed tarball. Stream-verify the | ||
| # detached signature while extracting the tarball via tee, | ||
| # leaving the source tree in place. | ||
| einfo "Verifying and unpacking ${P}.tar.zst ..." | ||
| verify-sig_verify_detached - "${DISTDIR}"/${P}.tar.sign \ | ||
| < <(zstd -fdc "${DISTDIR}"/${P}.tar.zst | tee >(tar -xf -)) | ||
| assert "Unpack failed" | ||
| # Filter the tarball and its detached signature out of ${A} | ||
| # so cargo_src_unpack doesn't re-extract the tarball or feed | ||
| # the .sign file to unpack (which would die). | ||
| local A=${A//${P}.tar.zst/} | ||
| A=${A//${P}.tar.sign/} | ||
| fi |
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.
Summary
Ships bcachefs on Flatcar as:
bcachefs.kobuilt in-tree withcoreos-modules(CONFIG_BCACHEFS_FS=m,CONFIG_BCACHEFS_POSIX_ACL=y). The module is part of the base image and loads on demand viamodprobe.flatcar-bcachefssysext that carries the bcachefs userspace utilities (bcachefs,mkfs.bcachefs,fsck.bcachefs,mount.bcachefs, ...).Users opt into the tools by writing
bcachefsto/etc/flatcar/enabled-sysext.conf. The kernel module is available on every Flatcar image whether or not the sysext is merged.amd64-only
Keeping the sysext amd64-only until arm64 stabilizes. The kernel module itself is architecture-neutral in Kconfig, so it will also be available on arm64 images without any further config change.
Test plan
emerge sys-kernel/coreos-modulesbuilds cleanly with the new config;olddefconfigdoesn't downgradeBCACHEFS_FSton(i.e., everyselected dep is satisfied by the existing config).bcachefs.koviamodprobe bcachefsandgrep bcachefs /proc/filesystemsreports it.USE=\"-modules\" emerge sys-fs/bcachefs-toolsproduces/usr/bin/bcachefsand the compat symlinks without touching any kernel module tree.flatcar-bcachefssysext exposesmkfs.bcachefs,mount.bcachefs, etc.mkfs.bcachefson a loopback file +mount -t bcachefsround-trip.