fix: stale read issue when probing

An utility used to format the partition (e.g. cryptsetup) might open the
block device with `O_DIRECT`, so the next read done by the probing code
might be hitting the buffer cache, and it doesn't see the writes done by
`cryptsetup` (the cache is not coherent).

We can't use `O_DIRECT` for I/O, as it has tight requirements for
aligning the reads and writes, so instead ask Linux to invalidate the
cache before probing.

We only probe on blockdevice changes, so it shouldn't cause performance
issues.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 file changed