marsadm: allow switchback to primary when I am actually primary

For example, when /dev/mars/something is mounted or in another use,
switching to secondary will only succeed after the device has
been closed. During this intermediate state, we allow to switch
back to primary without checking all the big checks.
This commit is contained in:
Thomas Schoebel-Theuer 2013-04-03 09:17:26 +02:00
parent 6de8dc9639
commit 5fc1844eba
1 changed files with 4 additions and 0 deletions

View File

@ -807,6 +807,10 @@ sub primary_res {
exit(0);
} elsif($force) {
lprint "FORCING myself ($host) to primary...\n";
} elsif (! -d "/proc/sys/mars") {
ldie "cannot switch to primary: mars kernel module is not loaded\n";
} elsif (readlink("$mars/resource-$res/actual-$host/is-primary")) {
lwarn "I am actually primary: skipping check to set me back.\n";
} else { # try to switch myself to primary
lprint "trying to switch $host to primary...\n";
check_sync_finished($res, $host);