-
On some distributions having btrfs on top of LUKS encrypted partitions, adding a second device and removing the first device used to mount the file system causes GParted to no longer be able to report the file system as busy or the mount points themselves. For example, on CentOS 7, create a single btrfs file system and mount it. The provided /dev/mapper/sdb1_crypt name is reported, via /proc/mounts, as the mounting device: # cryptsetup luksFormat --force-password /dev/sdb1 # cryptsetup luksOpen /dev/sdb1 sdb1_crypt # mkfs.btrfs -L encrypted-btrfs /dev/mapper/sdb1_crypt # mount /dev/mapper/sdb1_crypt /mnt/1 # ls -l /dev/mapper total 0 lrwxrwxrwx. 1 root root 7 Jul 2 14:15 centos-root -> ../dm-1 lrwxrwxrwx. 1 root root 7 Jul 2 14:15 centos-swap -> ../dm-0 crw-------. 1 root root 10, 236 Jul 2 14:15 control lrwxrwxrwx. 1 root root 7 Jul 2 15:14 sdb1_crypt -> ../dm-2 # fgrep btrfs /proc/mounts /dev/mapper/sdb1_crypt /mnt/1 btrfs rw,seclabel,relatime,space_cache 0 0 Add a second device to the btrfs file system: # cryptsetup luksFormat --force-password /dev/sdb2 # cryptsetup luksOpen /dev/sdb2 sdb2_crypt # btrfs device add /dev/mapper/sdb2_crypt /mnt/1 # ls -l /dev/mapper ... lrwxrwxrwx. 1 root root 7 Jul 2 15:12 sdb2_crypt -> ../dm-3 # btrfs filesystem show /dev/mapper/sdb1_crypt Label: 'encrypted-btrfs' uuid: 45d7b1ef-820c-4ef8-8abd-c70d928afb49 Total devices 2 FS bytes used 32.00KiB devid 1 size 1022.00MiB used 12.00MiB path /dev/mapper/sdb1_crypt devid 2 size 1022.00MiB used 0.00B path /dev/mapper/sdb2_crypt Remove the first mounting device from the btrfs file system. Now the non-canonical name /dev/dm-3 is reported, via /proc/mounts, as the mounting device: # btrfs device delete /dev/mapper/sdb1_crypt /mnt/1 # btrfs filesystem show /dev/mapper/sdb2_crypt Label: 'encrypted-btrfs' uuid: 45d7b1ef-820c-4ef8-8abd-c70d928afb49 Total devices 1 FS bytes used 96.00KiB devid 2 size 1022.00MiB used 144.00MiB path /dev/mapper/sdb2_crypt # fgrep btrfs /proc/mounts /dev/dm-3 /mnt/1 btrfs rw,seclabel,relatime,space_cache 0 0 # ls -l /dev/dm-3 brw-rw----. 1 root disk 253, 3 Jul 2 15:12 /dev/dm-3 GParted loads the mount_info mapping from /proc/mounts and with it the /dev/dm-3 name. When GParted is determining if the encrypted btrfs file system is mounted or getting the mount points it is using the /dev/mapper/sdb2_crypt name. Therefore no information is found and the file system is incorrectly reported as unmounted. Fix by changing mount_info and fstab_info to use BlockSpecial objects instead of strings so that matching is performed by major, minor device numbers rather than by string compare. Note that as BlockSpecial objects are used as the key of std::map [1] mappings operator<() [2] needs to be provided to order the key values. [1] std::map http://www.cplusplus.com/reference/map/map/ [2] std::map::key_comp http://www.cplusplus.com/reference/map/map/key_comp/ Bug 767842 - File system usage missing when tools report alternate block device names
a800ca8b