From 0953801a6e30e5cd38a271f1dd1a0507878ea7f8 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Sat, 11 May 2013 01:41:53 +0200 Subject: [PATCH] marsadm: fix primary detection The actual-*/is-primary symlink may race with the appearance of the device. Use both conditions to be sure. --- userspace/marsadm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/userspace/marsadm b/userspace/marsadm index 4fcae451..c9854cce 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -245,6 +245,11 @@ sub check_primary { my ($cmd, $res) = @_; my $lnk = "$mars/resource-$res/actual-$host/is-primary"; my $is_primary = get_link($lnk); + if (!$is_primary) { # give it a second chance + my $name = get_link("$mars/resource-$res/device-$host"); + my $dev = "/dev/mars/$name"; + $is_primary = 1 if -b $dev; + } ldie "for operation '$cmd' I need to be primary\n" unless $is_primary; my $primary = _get_designated_primary($res); ldie "for operation '$cmd', I also must be the designated primary\n" unless $primary eq $host;