From b975532433dcbcc01e3cc0ebe8c6165e2d6470f8 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Tue, 23 Aug 2016 12:16:39 +0100 Subject: dmeventd: Simplify replacement unmonitor code. --- lib/activate/activate.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/lib/activate/activate.c b/lib/activate/activate.c index de5deae66..22e3afaf8 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -1831,52 +1831,43 @@ int monitor_dev_for_events(struct cmd_context *cmd, const struct logical_volume if (monitor) { if (monitored) log_verbose("%s already monitored.", display_lvname(lv)); - else if (seg->segtype->ops->target_monitor_events) + else if (seg->segtype->ops->target_monitor_events) { + log_verbose("Monitoring %s%s", display_lvname(lv), test_mode() ? " [Test mode: skipping this]" : ""); monitor_fn = seg->segtype->ops->target_monitor_events; + } } else { if (!monitored) log_verbose("%s already not monitored.", display_lvname(lv)); - else if (*dso) + else if (*dso) { /* * Divert unmonitor away from code that depends on the new segment * type instead of the existing one if it's changing. */ + log_verbose("Not monitoring %s with %s%s", display_lvname(lv), dso, test_mode() ? " [Test mode: skipping this]" : ""); new_unmonitor = 1; - else if (seg->segtype->ops->target_unmonitor_events) - monitor_fn = seg->segtype->ops->target_unmonitor_events; + } } - if (new_unmonitor) { - log_verbose("Not monitoring %s with %s%s", display_lvname(lv), dso, test_mode() ? " [Test mode: skipping this]" : ""); - - /* FIXME Test mode should really continue a bit further. */ - if (test_mode()) - return 1; + /* FIXME Test mode should really continue a bit further. */ + if (test_mode()) + continue; + if (new_unmonitor) { if (!target_register_events(cmd, dso, lv, 0, 0, 0)) { log_error("%s: segment unmonitoring failed.", display_lvname(lv)); return 0; } - - } else if (!monitor_fn) - continue; - else if (monitor_fn) { - log_verbose("%sonitoring %s%s", monitor ? "M" : "Not m", display_lvname(lv), - test_mode() ? " [Test mode: skipping this]" : ""); - - /* FIXME Test mode should really continue a bit further. */ - if (test_mode()) - continue; - + } else if (monitor_fn) { /* FIXME specify events */ if (!monitor_fn(seg, 0)) { log_error("%s: %s segment monitoring function failed.", display_lvname(lv), seg->segtype->name); return 0; } - } + } else + continue; /* Check [un]monitor results */ /* Try a couple times if pending, but not forever... */ -- cgit v1.2.1