[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
 Osstest/Debian.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.