On 04/05/2023 19.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.
Hi Guilherme, did you tried to run "btrfs dev scan --forget /dev/sd.." before mount the filesystem ? Assuming that you have two devices /dev/sdA and /dev/sdB with two btrfs filesystem with the same uuid, you should mount /dev/sdA btrfs dev scan --forget /dev/sdB # you can use event /dev/sdA mount /dev/sdA /mnt/target and to mount /dev/sdB btrfs dev scan --forget /dev/sdA # you can use event /dev/sdB mount /dev/sdB /mnt/target I made a quick test using two loop devices and it seems that it works reliably. Another option should be make a kernel change that "forget" the device before mounting *if* the filesystem is composed by only one device ( and another few exceptions like the filesystem is already mounted). This would avoid all the problem related to make a "temporary" uuid.
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/ 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(-)
-- gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5