Skip to content

mount -a doesn't correctly detect already mounted btrfs raid1 filesystems leading to duplicated mounts #3778

@adippl

Description

@adippl

I have multiple gentoo servers with root filesystem on raid1 btrfs.
This bug affects all my raid1 btrfs installations but is not present systems with non-raid1 btrfs rootfs.

Example of my fstab

LABEL=rootfs	/						btrfs	compress=zstd,subvol=root 0 0
LABEL=rootfs	/mnt/a					btrfs	compress=zstd,subvolid=0 0 0
LABEL=rootfs	/var/lib/containers		btrfs	compress=zstd,subvol=containers 0 0
LABEL=rootfs	/var/lib/libvirt		btrfs	compress=zstd,subvol=vm 0 0
LABEL=rootfs	/var/tmp				btrfs	defaults,nodev,nosuid,noatime,compress=zstd,subvol=var_tmp		0 0
LABEL=rootfs	/var/cache				btrfs	defaults,nodev,nosuid,noatime,compress=zstd,subvol=var_cache		0 0

When I run mount -a -v on system with non raid1 btrfs I get this output:
(mount correctly detects that filesystem/subvolumes are already mounted)

/                        : ignored
/mnt/a                   : already mounted
/var/lib/containers      : already mounted
/var/tmp                 : already mounted
/var/cache               : already mounted

When I run mount -a -v on system with raid1 btrfs I get this output:

/                        : ignored
/mnt/a                   : successfully mounted
/var/lib/containers      : successfully mounted
/var/lib/libvirt         : successfully mounted
/var/tmp                 : successfully mounted
/var/cache               : successfully mounted

mount doesn't detect that filesystems/subvolumes are already mounted and mounts them again.

This leads to ever increasing duplications of mounted fs. Which is really annoying in lsblk output

example lsblk from one of the systems

lsblk /dev/nvme1n1
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme1n1     259:0    0 476.9G  0 disk 
├─nvme1n1p1 259:1    0    64M  0 part /boot/efi
├─nvme1n1p2 259:2    0     4G  0 part /boot
│                                     /boot
│                                     /boot
│                                     /boot
│                                     /boot
└─nvme1n1p3 259:3    0 472.9G  0 part /mnt/meta_snapshots
                                      /mnt/meta
                                      /var/cache
                                      /var/tmp
                                      /var/lib/libvirt
                                      /var/lib/containers
                                      /mnt/a
                                      /mnt/meta_snapshots
                                      /mnt/meta
                                      /var/cache
                                      /var/tmp
                                      /var/lib/libvirt
                                      /var/lib/containers
                                      /mnt/a
                                      /mnt/meta_snapshots
                                      /mnt/meta
                                      /var/cache
                                      /var/tmp
                                      /var/lib/libvirt
                                      /var/lib/containers
                                      /mnt/a
                                      /mnt/a
                                      /mnt/a
                                      /mnt/meta
                                      /mnt/meta
                                      /var/cache
                                      /mnt/a
                                      /mnt/meta
                                      /var/cache
                                      /mnt/a
                                      /mnt/meta_snapshots
                                      /mnt/meta
                                      /var/cache
                                      /var/tmp
                                      /var/lib/libvirt
                                      /var/lib/containers
                                      /mnt/a
                                      /

in /proc/mounts

cat /proc/mounts | grep  containers
/dev/nvme1n1p3 /var/lib/containers btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/containers 0 0
/dev/nvme1n1p3 /var/lib/containers btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/containers 0 0
/dev/nvme1n1p3 /var/lib/containers btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/containers 0 0
/dev/nvme1n1p3 /var/lib/containers btrfs rw,relatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=262,subvol=/containers 0 0

I've retested this today on util-linux-2.41.2 version available in gentoo. I couldn't use gentoo's git version of this package to build master branch util-linux because build was failing.

I'm testing it on 6.12.47-gentoo-dist and 6.12.41-gentoo-dist kernels but I'm pretty sure it's not kernel related issue.

I don't think it's a regression, I don't remember it ever working correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BLOCKERRequired for the next release.TODOWe going to think about it ;-)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions