On 5/5/23 01:07, Guilherme G. Piccoli wrote:
Hi folks, this is an attempt of supporting same fsid mounting on btrfs. 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. A bit more details are provided in the following ML thread: https://lore.kernel.org/linux-btrfs/c702fe27-8da9-505b-6e27-713edacf723a@xxxxxxxxxx/
Confused about your requirement: 2 identical filesystems mounted simultaneously or just one at a time? Latter works. Bugs were fixed.
Have you considered using the btrfs seed device feature to avoid sacrificing 50% capacity? Create read-only seed device as golden image, add writable device on top. Example:
$ btrfstune -S1 /dev/rdonly-golden-img $ mount /dev/rdonly-golden-img /btrfs $ btrfs dev add /dev/rw-dev /btrfs $ mount -o remount,rw /dev/rw-dev /btrfs To switch golden image: $ btrfs dev del /dev/rdonly-golden-img /btrfs $ umount /btrfs $ btrfstune -S1 /dev/rw-dev Thanks, Anand
The mechanism used to achieve it is based in the metadata_uuid feature, leveraging such code infrastructure for that. The patches are based on kernel 6.3 and were tested both in a virtual machine as well as in the Steam Deck. Comments, suggestions and overall feedback is greatly appreciated - thanks in advance! Cheers, Guilherme Guilherme G. Piccoli (2): btrfs: Introduce the virtual_fsid feature btrfs: Add module parameter to enable non-mount scan skipping fs/btrfs/disk-io.c | 22 +++++++-- fs/btrfs/ioctl.c | 18 ++++++++ fs/btrfs/super.c | 41 ++++++++++++----- fs/btrfs/super.h | 1 + fs/btrfs/volumes.c | 111 +++++++++++++++++++++++++++++++++++++++------ fs/btrfs/volumes.h | 11 ++++- 6 files changed, 174 insertions(+), 30 deletions(-)