koverstreet / bcachefs-tools

http://bcachefs.org
GNU General Public License v2.0
123 stars 90 forks source link

bcachefs is not device mapper multi-path aware #260

Open tasleson opened 6 months ago

tasleson commented 6 months ago

If you try to mount bcachefs using a UUID or a single block device today which causes a mount by FS UUID, the mount will fail with

Fatal error: Device or resource busy

This is caused by multiple paths which correspond to the same block device which all have the same FS UUID when every block device is examined and the super block is read up.

An example output of failure (abbreviated):

# BCACHEFS_BLOCK_SCAN=1 bcachefs mount -v UUID=a7a20e78-f7b9-419d-845f-a0d4c21bf6cd /mnt
DEBUG - bcachefs::commands::cmd_mount: Checking all block devices for bcachefs super block!
DEBUG - bcachefs::commands::cmd_mount: enumerating devices with UUID a7a20e78-f7b9-419d-845f-a0d4c21bf6cd
bcachefs (/dev/sdah): error reading default superblock: Not a bcachefs superblock (got magic 00000000-0000-0000-0000-000000000000)
bcachefs (/dev/sdah): error reading superblock: Not a bcachefs superblock layout
bcachefs (/dev/sdai): error reading default superblock: Not a bcachefs superblock (got magic 00000000-0000-0000-0000-000000000000)
...
bcachefs (/dev/dm-9): error reading default superblock: Not a bcachefs superblock (got magic 00000000-0000-0000-0000-000000000000)
bcachefs (/dev/dm-9): error reading superblock: Not a bcachefs superblock layout
INFO - bcachefs::commands::cmd_mount: mounting with params: device: /dev/sdo:/dev/sdi:/dev/sdae:/dev/sdy:/dev/dm-14:/dev/dm-18, target: /mnt, options: 
DEBUG - bcachefs::commands::cmd_mount: parsing mount options: 
INFO - bcachefs::commands::cmd_mount: mounting bcachefs filesystem, /mnt
INFO - bcachefs::commands::cmd_mount: mounting filesystem
ERROR - bcachefs::commands::cmd_mount: Fatal error: Device or resource busy

When using the change in https://github.com/koverstreet/bcachefs-tools/pull/254 we work as the udev db only has the FS UUID for the correct /dev/dm-N devices to use.

eg.

#  bcachefs mount -v UUID=a7a20e78-f7b9-419d-845f-a0d4c21bf6cd /mnt
DEBUG - bcachefs::commands::cmd_mount: Walking udev db!
DEBUG - bcachefs::commands::cmd_mount: enumerating devices with UUID a7a20e78-f7b9-419d-845f-a0d4c21bf6cd
INFO - bcachefs::commands::cmd_mount: mounting with params: device: /dev/dm-14:/dev/dm-18, target: /mnt, options: 
DEBUG - bcachefs::commands::cmd_mount: parsing mount options: 
INFO - bcachefs::commands::cmd_mount: mounting bcachefs filesystem, /mnt
INFO - bcachefs::commands::cmd_mount: mounting filesystem
INFO - bcachefs::commands::cmd_mount: Successfully mounted