Skip to content

Use the FSID as the device identifier where possible

Tomáš Trnka requested to merge work/ttrnka/fsid_as_devid into master

The device number returned by stat() in st_dev is not persistent in many cases. Btrfs subvolumes or partitions on NVMe devices are assigned device numbers dynamically, so the resulting device ID is typically different after every reboot, forcing Baloo to repeatedly reindex all files.

Fortunately, filesystems like Btrfs or ext4 return a persistent unique filesystem ID as f_fsid from statvfs(), so we can use that when available. Other filesystems like XFS derive the FSID from the device number of the underlying block device, so switching to the FSID does not change anything.

Draft pending discussion of the following points:

  • This change will cause all IDs to change one last time, so everything will be reindexed once again. It would be best if we could somehow purge the old entries, perhaps trigger a "balooctl purge" once when the framework is updated?
  • Perhaps the include needs to be guarded by HAVE_SYS_STATVFS_H and checked by CMake, but it looks like other frameworks don't do that either, so this might be fine as is.

BUG: 402154 CCBUG: 471289

Edited by Nate Graham

Merge request reports