Handle BTRFS better in GIO file attributes
Recently I've handled a fun bug with BTRFS in Tracker, relating to subvolumes, and creative reintepretation of filesystem principles from BTRFS authors: tracker-miners!449 (merged)
The gist of it is summed up in a brief note at https://btrfs.readthedocs.io/en/latest/Subvolumes.html#inode-numbers:
Inode number is not a filesystem-wide unique identifier, some applications assume that.
Please use pair subvolumeid:inodenumber for that purpose.
This subvolumeid information (and I think subvolume name too) is available without additional capabilities through ioctl()
. After the bandaid is in place for Tracker, I think there's a few improvements in GIO that would be nice to have for BTRFS filesystems:
- Some file attributes to get this information specifically (e.g.
G_FILE_ATTRIBUTE_BTRFS_SUBVOLUME_ID
and - The existing G_FILE_ATTRIBUTE_ID_FILE attribute should probably include the subvolume ID as part of the identifier, for BTRFS filesystems.
- Bonus point: I found that the additional check added at commit 0c5f0842 trips with BTRFS if a subvolume is created as a direct child of another subvolume, since the root inode of all subvolumes is the same (256). This results in
is-mountpoint
being toggled on the child subvolume even if it's not a mountpoint. AFAICS extending the check so that it ensures device and inode are the same should still catch the root mount and leave out BTRFS subvolumes.