1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Integrate suspend.

This commit is contained in:
Alasdair Kergon 2002-03-14 15:36:07 +00:00
parent c22c93f0b6
commit 20c5fcf764
2 changed files with 28 additions and 35 deletions

View File

@ -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;

View File

@ -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;
}