marsadm: fix primary detection

The actual-*/is-primary symlink may race with the appearance
of the device. Use both conditions to be sure.
This commit is contained in:
Thomas Schoebel-Theuer 2013-05-11 01:41:53 +02:00 committed by Thomas Schoebel-Theuer
parent 2dd3033ff4
commit 0953801a6e
1 changed files with 5 additions and 0 deletions

View File

@ -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;