Fix race condition with blockdev/BLKRRPART due to lack of fsync
authorMichael Prokop <mika@grml.org>
Tue, 17 Nov 2020 22:45:23 +0000 (23:45 +0100)
committerMichael Prokop <mika@grml.org>
Tue, 17 Nov 2020 22:46:46 +0000 (23:46 +0100)
commit272b66ed0ec6a5faa3d36d75843b34d8d6c01d12
treeb214c279b4c66d70b85e75276cfde155a3e14934
parent073fee44304aa4279c7192b33557a5e139f11b16
Fix race condition with blockdev/BLKRRPART due to lack of fsync

Quoting dann frazier from Debian's #975015:

| grml2usb autopkgtest frequently fail in Ubuntu's CI.
| [...]
| 2020-11-17 14:14:49,433 Probing device via 'blockdev --rereadpt /dev/loop0'
| blockdev: ioctl error on BLKRRPART: Device or resource busy
| 2020-11-17 14:14:49,452 Execution failed: ("Couldn't execute blockdev on '%s' (install util-linux?)", '/dev/loop0')
|
| I am able to reproduce this on an OpenStack instance with a failure rate of
| 33% (36 failures, 110 passes). My theory is that the sync is not sufficient,
| and that we really need to do a targeted fsync of the file. With the
| attached patch, I've yet to see a failure in 42 iterations.

Thanks: dann frazier <dannf@dannf.org> for bug report and patch
Closes: #975015
grml2usb