mirror of https://github.com/schoebel/mars
marsadm: fix 'invalidate' racing against replay
This commit is contained in:
parent
22d4516d21
commit
ddf28af52d
|
@ -3077,10 +3077,13 @@ done:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_show_actual(rot->parent_path, "is-replaying", rot->trans_brick && rot->trans_brick->replay_mode && !rot->trans_brick->power.led_off);
|
||||||
if (rot->trans_brick)
|
if (rot->trans_brick)
|
||||||
_show_rate(rot, &rot->replay_limiter, rot->trans_brick->power.led_on, "replay_rate");
|
_show_rate(rot, &rot->replay_limiter, rot->trans_brick->power.led_on, "replay_rate");
|
||||||
|
_show_actual(rot->parent_path, "is-copying", rot->copy_brick && !rot->copy_brick->power.led_off);
|
||||||
if (rot->copy_brick)
|
if (rot->copy_brick)
|
||||||
_show_rate(rot, &rot->file_limiter, rot->copy_brick->power.led_on, "file_rate");
|
_show_rate(rot, &rot->file_limiter, rot->copy_brick->power.led_on, "file_rate");
|
||||||
|
_show_actual(rot->parent_path, "is-syncing", rot->sync_brick && !rot->sync_brick->power.led_off);
|
||||||
if (rot->sync_brick)
|
if (rot->sync_brick)
|
||||||
_show_rate(rot, &rot->sync_limiter, rot->sync_brick->power.led_on, "sync_rate");
|
_show_rate(rot, &rot->sync_limiter, rot->sync_brick->power.led_on, "sync_rate");
|
||||||
err:
|
err:
|
||||||
|
|
|
@ -202,6 +202,12 @@ sub wait_cond {
|
||||||
(
|
(
|
||||||
"attach" => "is-attached",
|
"attach" => "is-attached",
|
||||||
"attached" => "is-attached",
|
"attached" => "is-attached",
|
||||||
|
"replay" => "is-replaying",
|
||||||
|
"replaying"=> "is-replaying",
|
||||||
|
"copy" => "is-copying",
|
||||||
|
"copying" => "is-copying",
|
||||||
|
"sync" => "is-syncing",
|
||||||
|
"syncing" => "is-syncing",
|
||||||
"primary" => "is-primary",
|
"primary" => "is-primary",
|
||||||
);
|
);
|
||||||
my $name = $table{$specific};
|
my $name = $table{$specific};
|
||||||
|
@ -1391,13 +1397,23 @@ sub cleanup_res {
|
||||||
sub invalidate_res_phase0 {
|
sub invalidate_res_phase0 {
|
||||||
my ($cmd, $res) = @_;
|
my ($cmd, $res) = @_;
|
||||||
check_not_primary(@_);
|
check_not_primary(@_);
|
||||||
if (!$force) {
|
|
||||||
check_todo($cmd, $res, "attach", 0, 0);
|
|
||||||
check_status($cmd, $res, "is-attached", 0, 0, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub invalidate_res_phase1 {
|
sub invalidate_res_phase1 {
|
||||||
|
my ($cmd, $res) = @_;
|
||||||
|
_switch($cmd, $res, "$mars/resource-$res/todo-$host/sync", 0);
|
||||||
|
_switch($cmd, $res, "$mars/resource-$res/todo-$host/allow-replay", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub invalidate_res_phase2 {
|
||||||
|
my ($cmd, $res) = @_;
|
||||||
|
if (!$force) {
|
||||||
|
check_status($cmd, $res, "is-syncing", 0, 1);
|
||||||
|
check_status($cmd, $res, "is-replaying", 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub invalidate_res_phase3 {
|
||||||
my ($cmd, $res) = @_;
|
my ($cmd, $res) = @_;
|
||||||
my $dst = "$mars/resource-$res/syncstatus-$host";
|
my $dst = "$mars/resource-$res/syncstatus-$host";
|
||||||
my $primary = _get_designated_primary($res);
|
my $primary = _get_designated_primary($res);
|
||||||
|
@ -1406,8 +1422,10 @@ sub invalidate_res_phase1 {
|
||||||
my $replay_nr = $1;
|
my $replay_nr = $1;
|
||||||
set_link("0", $dst);
|
set_link("0", $dst);
|
||||||
finish_links(); # opportunity for errors => don't continue
|
finish_links(); # opportunity for errors => don't continue
|
||||||
_set_replaylink("$mars/resource-$res", $replay_nr, $primary);
|
set_link($replay, "$mars/resource-$res/replay-$host");
|
||||||
cleanup_res($cmd, $res, $replay_nr);
|
cleanup_res($cmd, $res, $replay_nr);
|
||||||
|
_switch($cmd, $res, "$mars/resource-$res/todo-$host/allow-replay", 1);
|
||||||
|
_switch($cmd, $res, "$mars/resource-$res/todo-$host/sync", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub resize_res {
|
sub resize_res {
|
||||||
|
@ -1670,7 +1688,9 @@ my %cmd_table =
|
||||||
],
|
],
|
||||||
"invalidate" => [
|
"invalidate" => [
|
||||||
"check preconditions", \&invalidate_res_phase0,
|
"check preconditions", \&invalidate_res_phase0,
|
||||||
"force symlinks", \&invalidate_res_phase1,
|
"stop old replay", \&invalidate_res_phase1,
|
||||||
|
"wait for replay off", \&invalidate_res_phase2,
|
||||||
|
"force symlinks", \&invalidate_res_phase3,
|
||||||
],
|
],
|
||||||
"invalidate-remote" => \&forbidden_cmd,
|
"invalidate-remote" => \&forbidden_cmd,
|
||||||
"resize" => \&resize_res,
|
"resize" => \&resize_res,
|
||||||
|
|
Loading…
Reference in New Issue