Linux 6.7 Adding New Feature To Btrfs For The Steam Deck
This functionality has been worked on by Igalia as part of their work with Valve on enhancing Linux for the Steam Deck / SteamOS. As explained by Igalia's Guilherme Piccoli in the prior patch series:
"Currently, we cannot reliably mount same fsid filesystems even one at a time in btrfs, but if users want to mount them at the same time, it's pretty much impossible. Other filesystems like ext4 are capable of that.
The goal is to allow systems with A/B partitioning scheme (like the Steam Deck console or various mobile devices) to be able to hold the same filesystem image in both partitions; it also allows to have block device level check for filesystem integrity - this is used in the Steam Deck image installation, to check if the current read-only image is pristine."
The code commit adding the Btrfs temp-fsid feature goes on to add:
"Supporting the same-fsid mounts has the advantage of allowing btrfs to be used in A/B partitioned devices, like mobile phones or the Steam Deck for example. Without this support, it's not safe for users to keep the same "image version" in both A and B partitions, a setup that is quite common for development, for example. Also, as a big bonus, it allows fs integrity check based on block devices for RO devices (whereas currently it is required that both have different fsid, breaking the block device hash comparison).
Such same-fsid mounting is hereby added through the usage of the filesystem feature "temp-fsid" - when such feature is used, btrfs generates a random fsid for the filesystem and leverages the long-term present metadata_uuid infrastructure to enable the usage of this secondary "virtual" fsid, effectively requiring few non-invasive changes to the code and no new potential corner cases.
In order to prevent more code complexity and corner cases, the temp-fsid feature is not allowed when the metadata_uuid flag is present on the fs, or if the device is on fsid-change state. Device removal/replace is also disabled for filesystems presenting the feature."
This functionality has been queued into kdave/linux.git's for-next branch where Btrfs material is staged ahead of the next Linux kernel cycle. Thus this new Btrfs feature will be found in Linux 6.7 barring any issues from appearing between now and the merge window opening around early November.
This Btrfs feature was also mentioned last week at OSS EU 2023 as part of Valve's upstream contributions to Linux.