diff mbox series

[OSSTEST,17/82] Debian: osstest-erase-other-disks: Slightly guard against races

Message ID 20201007180024.7932-18-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series Reuse test hosts | expand

Commit Message

Ian Jackson Oct. 7, 2020, 5:59 p.m. UTC
From: Ian Jackson <ian.jackson@eu.citrix.com>

Apparently it can happen that something decides to rescan a partition
table, removing a partition block device, while it is being zeroed:

 osstest-erase-other-disks-6081: hd devices present after: /dev/hd*
 osstest-erase-other-disks-6081: Erasing /dev/sda
 osstest-erase-other-disks-6081: Erasing /dev/sda1
 osstest-erase-other-disks-6081: /dev/sda1 is no longer a block device!

To try to narrow the window during which this race occurs, do not care
if the thing we just zeroed no longer exists after we zeroed it.

We still bomb out if it exists but is not a block device - that would
probably mean we had written it out as a file.

This is all quite unfortunate.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 85fd16da..3fa26e45 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -1211,8 +1211,8 @@  zero () {
     if test -b \$dev; then
         log "Erasing \$dev"
         dd if=/dev/zero of=\$dev count=64 ||:
-        if ! test -b \$dev; then
-            log "\$dev is no longer a block device!"
+        if test -e \$dev && ! test -b \$dev; then
+            log "\$dev still exists but is no longer a block device!"
             exit 1
         fi
     else