Linux Developers Discuss A Global Counter For Block/Disk Changes
This monotonically increasing number is system-wide and would be used so systemd and other user-space software could better correlate events for devices that end up re-using the same device, such as /dev/sda and especially /dev/loop0 and other devices often end up getting re-used when one device is detached and another added. Particularly around loop devices isn't a better means of finding out if it's the same loop device as before since not having a serial number or other means of uniquely identifying it.
While user-space can use event listeners for add/remove events for trying to track disk changes, due to events possibly arriving late to user-space or out-of-order, among other concerns, this global counter for tracking is deemed one of the best approaches. Separately there is work ongoing around block namespaces and other improvements but at least the systemd folks feel that this method is immediately worthwhile and beneficial to have with the Linux kernel.
This global number is put in the uevent so user-space can use it for correlating when a driver re-uses a device, a new ioctl would also be added of BLKGETDISKSEQ to get the disk sequence number, and the sequence number would also be exposed via sysfs with diskseq. This sequence number would increment whenever the underlying media has changed or similarly for the loop device whenever setting or changing the backing file.
Those interested in the proposed patches sent out by Microsoft's Matteo Croce can see this patch series and the resulting discussion over the merits of this feature.