From 33e889b502a75c6b4e5aa27ad7f507352e61278e Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Sat, 2 Feb 2019 22:49:31 +0100 Subject: [PATCH] marsadm: handover wait for systemd stopping --- userspace/marsadm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/userspace/marsadm b/userspace/marsadm index 55ddcabf..5d793682 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -3373,6 +3373,20 @@ sub primary_phase0 { lprint "all preconditions OK for resource '$res'\n"; } +# only for systemd: wait that primary device is no longer open +sub primary_phase0b { + my ($cmd, $res) = @_; + return unless systemd_present(@_); + # only relevant for true handover + my $old = _get_designated_primary($res); + return if ($old eq $host || $old eq "(none)"); + # ignore primary --force + my $connect_path = "$mars/resource-$res/todo-$host/connect"; + my $connect = get_link($connect_path, 1); + return if (!defined($connect) || !$connect); + check_status($cmd, $res, "open-count", 0, 1, undef, undef, $old); +} + # when necessary, switch to secondary (intermediately) sub primary_phase1 { my ($cmd, $res) = @_; @@ -6032,6 +6046,8 @@ my %cmd_table = "For more details, please refer to the PDF manual.", \&primary_phase0, "check preconditions", + \&primary_phase0b, + "wait for systemd", \&primary_phase1, "leave primary state", \&primary_phase2,