From ed09d7e394af869e308fe20ef4654c3f6f122677 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 27 Jan 2006 18:38:14 +0000 Subject: [PATCH] Rename register_dev; fix missing initialisation; reduce number of ifdefs. --- lib/activate/activate.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 57a6c7848..b5b8da997 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -574,11 +574,10 @@ int lvs_in_vg_opened(struct volume_group *vg) return count; } -#ifdef DMEVENTD -static int _register_dev(struct cmd_context *cmd, struct logical_volume *lv, - int do_reg) +static int _register_dev_for_events(struct cmd_context *cmd, + struct logical_volume *lv, int do_reg) { - +#ifdef DMEVENTD struct list *tmp; struct lv_segment *seg; int (*reg) (struct dm_pool *mem, struct lv_segment *, @@ -587,6 +586,8 @@ static int _register_dev(struct cmd_context *cmd, struct logical_volume *lv, list_iterate(tmp, &lv->segments) { seg = list_item(tmp, struct lv_segment); + reg = NULL; + if (do_reg) { if (seg->segtype->ops->target_register_events) reg = seg->segtype->ops->target_register_events; @@ -601,9 +602,9 @@ static int _register_dev(struct cmd_context *cmd, struct logical_volume *lv, } } +#endif return 1; } -#endif static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, int error_if_not_suspended) @@ -637,9 +638,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, } } -#ifdef DMEVENTD - _register_dev(cmd, lv, 0); -#endif + if (!_register_dev_for_events(cmd, lv, 0)) + stack; + memlock_inc(); if (!_lv_suspend_lv(lv)) { memlock_dec(); @@ -690,9 +691,8 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s, memlock_dec(); fs_unlock(); -#ifdef DMEVENTD - _register_dev(cmd, lv, 1); -#endif + if (!_register_dev_for_events(cmd, lv, 1)) + stack; return 1; } @@ -737,9 +737,8 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) return 0; } -#ifdef DMEVENTD - _register_dev(cmd, lv, 0); -#endif + if (!_register_dev_for_events(cmd, lv, 0)) + stack; memlock_inc(); r = _lv_deactivate(lv); @@ -811,9 +810,8 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, memlock_dec(); fs_unlock(); -#ifdef DMEVENTD - _register_dev(cmd, lv, 1); -#endif + if (!_register_dev_for_events(cmd, lv, 1)) + stack; return r; }