diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 02b9b3449..c9a0efd9a 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -136,33 +136,19 @@ static int _lv_deactivate(struct logical_volume *lv) static int _lv_suspend(struct logical_volume *lv) { -#if 0 - char buffer[128]; + int r; + struct dev_manager *dm; - log_very_verbose("Suspending %s", lv->name); - if (test_mode()) { - _skip("Suspending '%s'.", lv->name); - return 0; - } - - if (!build_dm_name(buffer, sizeof(buffer), "", - lv->vg->name, lv->name)) { + if (!(dm = dev_manager_create(lv->vg->name))) { stack; return 0; } - if (!device_suspend(buffer)) { + if (!(r = dev_manager_suspend(dm, lv))) stack; - return 0; - } - fs_del_lv(lv); - - return 1; -#else - log_err("lv_suspend not implemented."); - return 1; -#endif + dev_manager_destroy(dm); + return r; } static int _lv_rename(const char *old_name, struct logical_volume *lv) @@ -278,6 +264,7 @@ static struct logical_volume *_lv_from_lvid(struct cmd_context *cmd, return lvl->lv; } +/* These return success if the device is not active */ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) { struct logical_volume *lv; @@ -286,6 +273,11 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) if (!(lv = _lv_from_lvid(cmd, lvid_s))) return 0; + if (test_mode()) { + _skip("Suspending '%s'.", lv->name); + return 0; + } + if (!lv_info(lv, &info)) { stack; return 0; @@ -306,6 +298,11 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s) if (!(lv = _lv_from_lvid(cmd, lvid_s))) return 0; + if (test_mode()) { + _skip("Resuming '%s'.", lv->name); + return 0; + } + if (!lv_info(lv, &info)) { stack; return 0; @@ -325,6 +322,11 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) if (!(lv = _lv_from_lvid(cmd, lvid_s))) return 0; + if (test_mode()) { + _skip("Deactivating '%s'.", lv->name); + return 0; + } + if (!lv_info(lv, &info)) { stack; return 0; @@ -344,6 +346,11 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s) if (!(lv = _lv_from_lvid(cmd, lvid_s))) return 0; + if (test_mode()) { + _skip("Activating '%s'.", lv->name); + return 0; + } + if (!lv_info(lv, &info)) { stack; return 0; diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index a9b478ef8..416bffb2d 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -587,7 +587,6 @@ int dev_manager_info(struct dev_manager *dm, struct logical_volume *lv, int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv) { char *name; - struct dm_info info; /* * Build a name for the top layer. @@ -597,20 +596,7 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv) return 0; } - /* - * Try and get some info on this device. - */ - if (!_info(name, &info)) { - stack; - return 0; - } - - if (!info.exists) { - log_warn("No such device '%s'.", lv->name); - return 0; - } - - if (!info.suspended && !_suspend_or_resume(name, 1)) { + if (!_suspend_or_resume(name, 1)) { stack; return 0; }