mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
Move metadata backup call after vg_commit.
The backup() call store metadata from memory. But in cluster backup() call performs remote nodes metadata backup and it reads data from disk. For metadata backup consistency, patch moves all backup() calls after vg_commit. (Moreover, some tools already do that this way.)
This commit is contained in:
parent
c4ff133840
commit
8f3fd69ffa
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.46 -
|
Version 2.02.46 -
|
||||||
================================
|
================================
|
||||||
|
Fix metadata backup to run after vg_commit always.
|
||||||
Tidy clvmd volume lock cache functions.
|
Tidy clvmd volume lock cache functions.
|
||||||
Fix pvs report for orphan PVs when segment attributes are requested.
|
Fix pvs report for orphan PVs when segment attributes are requested.
|
||||||
Fix pvs -a output to not read volume groups from non-PV devices.
|
Fix pvs -a output to not read volume groups from non-PV devices.
|
||||||
|
@ -1736,6 +1736,7 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
{
|
{
|
||||||
struct volume_group *vg = lv->vg;
|
struct volume_group *vg = lv->vg;
|
||||||
struct lv_names lv_names;
|
struct lv_names lv_names;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
/* rename is not allowed on sub LVs */
|
/* rename is not allowed on sub LVs */
|
||||||
if (!lv_is_displayable(lv)) {
|
if (!lv_is_displayable(lv)) {
|
||||||
@ -1773,23 +1774,21 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
if (!vg_write(vg))
|
if (!vg_write(vg))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
backup(vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, lv)) {
|
if (!suspend_lv(cmd, lv)) {
|
||||||
stack;
|
|
||||||
vg_revert(vg);
|
vg_revert(vg);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(vg)) {
|
if (!vg_commit(vg)) {
|
||||||
stack;
|
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
|
r = 1;
|
||||||
return 1;
|
out:
|
||||||
|
backup(vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *generate_lv_name(struct volume_group *vg, const char *format,
|
char *generate_lv_name(struct volume_group *vg, const char *format,
|
||||||
@ -2051,14 +2050,11 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* store it on disks */
|
/* store it on disks */
|
||||||
if (!vg_write(vg))
|
if (!vg_write(vg) || !vg_commit(vg))
|
||||||
return 0;
|
return_0;
|
||||||
|
|
||||||
backup(vg);
|
backup(vg);
|
||||||
|
|
||||||
if (!vg_commit(vg))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* If no snapshots left, reload without -real. */
|
/* If no snapshots left, reload without -real. */
|
||||||
if (origin && !lv_is_origin(origin)) {
|
if (origin && !lv_is_origin(origin)) {
|
||||||
if (!suspend_lv(cmd, origin))
|
if (!suspend_lv(cmd, origin))
|
||||||
|
@ -270,14 +270,11 @@ static int _init_mirror_log(struct cmd_context *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* store mirror log on disk(s) */
|
/* store mirror log on disk(s) */
|
||||||
if (!vg_write(log_lv->vg))
|
if (!vg_write(log_lv->vg) || !vg_commit(log_lv->vg))
|
||||||
goto activate_lv;
|
goto activate_lv;
|
||||||
|
|
||||||
backup(log_lv->vg);
|
backup(log_lv->vg);
|
||||||
|
|
||||||
if (!vg_commit(log_lv->vg))
|
|
||||||
goto activate_lv;
|
|
||||||
|
|
||||||
if (!activate_lv(cmd, log_lv)) {
|
if (!activate_lv(cmd, log_lv)) {
|
||||||
log_error("Aborting. Failed to activate mirror log.");
|
log_error("Aborting. Failed to activate mirror log.");
|
||||||
goto revert_new_lv;
|
goto revert_new_lv;
|
||||||
@ -334,10 +331,12 @@ revert_new_lv:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_write(log_lv->vg) ||
|
if (!vg_write(log_lv->vg) || !vg_commit(log_lv->vg))
|
||||||
(backup(log_lv->vg), !vg_commit(log_lv->vg)))
|
|
||||||
log_error("Manual intervention may be required to "
|
log_error("Manual intervention may be required to "
|
||||||
"remove/restore abandoned log LV before retrying.");
|
"remove/restore abandoned log LV before retrying.");
|
||||||
|
else
|
||||||
|
backup(log_lv->vg);
|
||||||
|
|
||||||
activate_lv:
|
activate_lv:
|
||||||
if (was_active && !remove_on_failure && !activate_lv(cmd, log_lv))
|
if (was_active && !remove_on_failure && !activate_lv(cmd, log_lv))
|
||||||
return_0;
|
return_0;
|
||||||
@ -1504,11 +1503,15 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
out_remove_log:
|
out_remove_log:
|
||||||
if (log_lv && (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
|
if (log_lv) {
|
||||||
(backup(log_lv->vg), !vg_commit(log_lv->vg))))
|
if (!lv_remove(log_lv) ||
|
||||||
|
!vg_write(log_lv->vg) ||
|
||||||
|
!vg_commit(log_lv->vg))
|
||||||
log_error("Manual intervention may be required to remove "
|
log_error("Manual intervention may be required to remove "
|
||||||
"abandoned log LV before retrying.");
|
"abandoned log LV before retrying.");
|
||||||
|
else
|
||||||
|
backup(log_lv->vg);
|
||||||
|
}
|
||||||
out_remove_imgs:
|
out_remove_imgs:
|
||||||
alloc_destroy(ah);
|
alloc_destroy(ah);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -20,6 +20,7 @@ static int lvchange_permission(struct cmd_context *cmd,
|
|||||||
{
|
{
|
||||||
uint32_t lv_access;
|
uint32_t lv_access;
|
||||||
struct lvinfo info;
|
struct lvinfo info;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
lv_access = arg_uint_value(cmd, permission_ARG, 0);
|
lv_access = arg_uint_value(cmd, permission_ARG, 0);
|
||||||
|
|
||||||
@ -56,26 +57,27 @@ static int lvchange_permission(struct cmd_context *cmd,
|
|||||||
if (!vg_write(lv->vg))
|
if (!vg_write(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, lv)) {
|
if (!suspend_lv(cmd, lv)) {
|
||||||
log_error("Failed to lock %s", lv->name);
|
log_error("Failed to lock %s", lv->name);
|
||||||
vg_revert(lv->vg);
|
vg_revert(lv->vg);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(lv->vg)) {
|
if (!vg_commit(lv->vg)) {
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
|
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
|
||||||
if (!resume_lv(cmd, lv)) {
|
if (!resume_lv(cmd, lv)) {
|
||||||
log_error("Problem reactivating %s", lv->name);
|
log_error("Problem reactivating %s", lv->name);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
r = 1;
|
||||||
|
out:
|
||||||
|
backup(lv->vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_monitoring(struct cmd_context *cmd,
|
static int lvchange_monitoring(struct cmd_context *cmd,
|
||||||
@ -274,8 +276,6 @@ static int lvchange_resync(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup(lv->vg);
|
|
||||||
|
|
||||||
if (!vg_commit(lv->vg)) {
|
if (!vg_commit(lv->vg)) {
|
||||||
log_error("Failed to commit intermediate VG metadata.");
|
log_error("Failed to commit intermediate VG metadata.");
|
||||||
if (!attach_mirror_log(first_seg(lv), log_lv))
|
if (!attach_mirror_log(first_seg(lv), log_lv))
|
||||||
@ -285,6 +285,8 @@ static int lvchange_resync(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup(lv->vg);
|
||||||
|
|
||||||
if (!activate_lv(cmd, log_lv)) {
|
if (!activate_lv(cmd, log_lv)) {
|
||||||
log_error("Unable to activate %s for mirror log resync",
|
log_error("Unable to activate %s for mirror log resync",
|
||||||
log_lv->name);
|
log_lv->name);
|
||||||
@ -349,15 +351,12 @@ static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
|
|
||||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
|
|
||||||
if (!vg_write(lv->vg))
|
/* No need to suspend LV for this change */
|
||||||
|
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
backup(lv->vg);
|
||||||
|
|
||||||
/* No need to suspend LV for this change */
|
|
||||||
if (!vg_commit(lv->vg))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,6 +365,7 @@ static int lvchange_readahead(struct cmd_context *cmd,
|
|||||||
{
|
{
|
||||||
unsigned read_ahead = 0;
|
unsigned read_ahead = 0;
|
||||||
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
|
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
|
read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
|
||||||
|
|
||||||
@ -401,26 +401,27 @@ static int lvchange_readahead(struct cmd_context *cmd,
|
|||||||
if (!vg_write(lv->vg))
|
if (!vg_write(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, lv)) {
|
if (!suspend_lv(cmd, lv)) {
|
||||||
log_error("Failed to lock %s", lv->name);
|
log_error("Failed to lock %s", lv->name);
|
||||||
vg_revert(lv->vg);
|
vg_revert(lv->vg);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(lv->vg)) {
|
if (!vg_commit(lv->vg)) {
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
|
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
|
||||||
if (!resume_lv(cmd, lv)) {
|
if (!resume_lv(cmd, lv)) {
|
||||||
log_error("Problem reactivating %s", lv->name);
|
log_error("Problem reactivating %s", lv->name);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
r = 1;
|
||||||
|
out:
|
||||||
|
backup(lv->vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_persistent(struct cmd_context *cmd,
|
static int lvchange_persistent(struct cmd_context *cmd,
|
||||||
@ -477,14 +478,11 @@ static int lvchange_persistent(struct cmd_context *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
if (!vg_write(lv->vg))
|
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
backup(lv->vg);
|
||||||
|
|
||||||
if (!vg_commit(lv->vg))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
log_verbose("Re-activating logical volume \"%s\"", lv->name);
|
log_verbose("Re-activating logical volume \"%s\"", lv->name);
|
||||||
if (!activate_lv(cmd, lv)) {
|
if (!activate_lv(cmd, lv)) {
|
||||||
@ -527,15 +525,13 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
if (!vg_write(lv->vg))
|
|
||||||
|
/* No need to suspend LV for this change */
|
||||||
|
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
backup(lv->vg);
|
||||||
|
|
||||||
/* No need to suspend LV for this change */
|
|
||||||
if (!vg_commit(lv->vg))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,8 @@ static int _finish_lvconvert_mirror(struct cmd_context *cmd,
|
|||||||
struct logical_volume *lv,
|
struct logical_volume *lv,
|
||||||
struct dm_list *lvs_changed __attribute((unused)))
|
struct dm_list *lvs_changed __attribute((unused)))
|
||||||
{
|
{
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
if (!collapse_mirrored_lv(lv)) {
|
if (!collapse_mirrored_lv(lv)) {
|
||||||
log_error("Failed to remove temporary sync layer.");
|
log_error("Failed to remove temporary sync layer.");
|
||||||
return 0;
|
return 0;
|
||||||
@ -281,29 +283,29 @@ static int _finish_lvconvert_mirror(struct cmd_context *cmd,
|
|||||||
if (!vg_write(vg))
|
if (!vg_write(vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, lv)) {
|
if (!suspend_lv(cmd, lv)) {
|
||||||
log_error("Failed to lock %s", lv->name);
|
log_error("Failed to lock %s", lv->name);
|
||||||
vg_revert(vg);
|
vg_revert(vg);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(vg)) {
|
if (!vg_commit(vg)) {
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating \"%s\" in kernel", lv->name);
|
log_very_verbose("Updating \"%s\" in kernel", lv->name);
|
||||||
|
|
||||||
if (!resume_lv(cmd, lv)) {
|
if (!resume_lv(cmd, lv)) {
|
||||||
log_error("Problem reactivating %s", lv->name);
|
log_error("Problem reactivating %s", lv->name);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = 1;
|
||||||
log_print("Logical volume %s converted.", lv->name);
|
log_print("Logical volume %s converted.", lv->name);
|
||||||
|
out:
|
||||||
return 1;
|
backup(vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct poll_functions _lvconvert_mirror_fns = {
|
static struct poll_functions _lvconvert_mirror_fns = {
|
||||||
@ -383,6 +385,7 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
|
|||||||
const char *mirrorlog;
|
const char *mirrorlog;
|
||||||
unsigned corelog = 0;
|
unsigned corelog = 0;
|
||||||
struct logical_volume *original_lv;
|
struct logical_volume *original_lv;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
seg = first_seg(lv);
|
seg = first_seg(lv);
|
||||||
existing_mirrors = lv_mirror_count(lv);
|
existing_mirrors = lv_mirror_count(lv);
|
||||||
@ -589,30 +592,31 @@ commit_changes:
|
|||||||
if (!vg_write(lv->vg))
|
if (!vg_write(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, lv)) {
|
if (!suspend_lv(cmd, lv)) {
|
||||||
log_error("Failed to lock %s", lv->name);
|
log_error("Failed to lock %s", lv->name);
|
||||||
vg_revert(lv->vg);
|
vg_revert(lv->vg);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(lv->vg)) {
|
if (!vg_commit(lv->vg)) {
|
||||||
resume_lv(cmd, lv);
|
resume_lv(cmd, lv);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("Updating \"%s\" in kernel", lv->name);
|
log_very_verbose("Updating \"%s\" in kernel", lv->name);
|
||||||
|
|
||||||
if (!resume_lv(cmd, lv)) {
|
if (!resume_lv(cmd, lv)) {
|
||||||
log_error("Problem reactivating %s", lv->name);
|
log_error("Problem reactivating %s", lv->name);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lp->need_polling)
|
if (!lp->need_polling)
|
||||||
log_print("Logical volume %s converted.", lv->name);
|
log_print("Logical volume %s converted.", lv->name);
|
||||||
|
|
||||||
return 1;
|
r = 1;
|
||||||
|
out:
|
||||||
|
backup(lv->vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvconvert_snapshot(struct cmd_context *cmd,
|
static int lvconvert_snapshot(struct cmd_context *cmd,
|
||||||
@ -620,6 +624,7 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
|
|||||||
struct lvconvert_params *lp)
|
struct lvconvert_params *lp)
|
||||||
{
|
{
|
||||||
struct logical_volume *org;
|
struct logical_volume *org;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
if (!(org = find_lv(lv->vg, lp->origin))) {
|
if (!(org = find_lv(lv->vg, lp->origin))) {
|
||||||
log_error("Couldn't find origin volume '%s'.", lp->origin);
|
log_error("Couldn't find origin volume '%s'.", lp->origin);
|
||||||
@ -664,25 +669,25 @@ static int lvconvert_snapshot(struct cmd_context *cmd,
|
|||||||
if (!vg_write(lv->vg))
|
if (!vg_write(lv->vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(lv->vg);
|
|
||||||
|
|
||||||
if (!suspend_lv(cmd, org)) {
|
if (!suspend_lv(cmd, org)) {
|
||||||
log_error("Failed to suspend origin %s", org->name);
|
log_error("Failed to suspend origin %s", org->name);
|
||||||
vg_revert(lv->vg);
|
vg_revert(lv->vg);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(lv->vg))
|
if (!vg_commit(lv->vg))
|
||||||
return_0;
|
goto_out;
|
||||||
|
|
||||||
if (!resume_lv(cmd, org)) {
|
if (!resume_lv(cmd, org)) {
|
||||||
log_error("Problem reactivating origin %s", org->name);
|
log_error("Problem reactivating origin %s", org->name);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_print("Logical volume %s converted to snapshot.", lv->name);
|
log_print("Logical volume %s converted to snapshot.", lv->name);
|
||||||
|
r = 1;
|
||||||
return 1;
|
out:
|
||||||
|
backup(lv->vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
|
static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
|
@ -786,14 +786,11 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* store vg on disk(s) */
|
/* store vg on disk(s) */
|
||||||
if (!vg_write(vg))
|
if (!vg_write(vg) || !vg_commit(vg))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
backup(vg);
|
backup(vg);
|
||||||
|
|
||||||
if (!vg_commit(vg))
|
|
||||||
return_0;
|
|
||||||
|
|
||||||
if (lp->snapshot) {
|
if (lp->snapshot) {
|
||||||
if (!activate_lv_excl(cmd, lv)) {
|
if (!activate_lv_excl(cmd, lv)) {
|
||||||
log_error("Aborting. Failed to activate snapshot "
|
log_error("Aborting. Failed to activate snapshot "
|
||||||
@ -878,9 +875,12 @@ deactivate_and_revert_new_lv:
|
|||||||
|
|
||||||
revert_new_lv:
|
revert_new_lv:
|
||||||
/* FIXME Better to revert to backup of metadata? */
|
/* FIXME Better to revert to backup of metadata? */
|
||||||
if (!lv_remove(lv) || !vg_write(vg) || (backup(vg), !vg_commit(vg)))
|
if (!lv_remove(lv) || !vg_write(vg) || !vg_commit(vg))
|
||||||
log_error("Manual intervention may be required to remove "
|
log_error("Manual intervention may be required to remove "
|
||||||
"abandoned LV(s) before retrying.");
|
"abandoned LV(s) before retrying.");
|
||||||
|
else
|
||||||
|
backup(vg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,8 +626,6 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup(vg);
|
|
||||||
|
|
||||||
/* If snapshot, must suspend all associated devices */
|
/* If snapshot, must suspend all associated devices */
|
||||||
if (lv_is_cow(lv))
|
if (lv_is_cow(lv))
|
||||||
lock_lv = origin_from_cow(lv);
|
lock_lv = origin_from_cow(lv);
|
||||||
@ -637,20 +635,25 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
if (!suspend_lv(cmd, lock_lv)) {
|
if (!suspend_lv(cmd, lock_lv)) {
|
||||||
log_error("Failed to suspend %s", lp->lv_name);
|
log_error("Failed to suspend %s", lp->lv_name);
|
||||||
vg_revert(vg);
|
vg_revert(vg);
|
||||||
|
backup(vg);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vg_commit(vg)) {
|
if (!vg_commit(vg)) {
|
||||||
stack;
|
stack;
|
||||||
resume_lv(cmd, lock_lv);
|
resume_lv(cmd, lock_lv);
|
||||||
|
backup(vg);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resume_lv(cmd, lock_lv)) {
|
if (!resume_lv(cmd, lock_lv)) {
|
||||||
log_error("Problem reactivating %s", lp->lv_name);
|
log_error("Problem reactivating %s", lp->lv_name);
|
||||||
|
backup(vg);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup(vg);
|
||||||
|
|
||||||
log_print("Logical volume %s successfully resized", lp->lv_name);
|
log_print("Logical volume %s successfully resized", lp->lv_name);
|
||||||
|
|
||||||
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
|
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
|
||||||
|
@ -280,6 +280,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
{
|
{
|
||||||
unsigned exclusive = _pvmove_is_exclusive(cmd, vg);
|
unsigned exclusive = _pvmove_is_exclusive(cmd, vg);
|
||||||
unsigned first_time = (flags & PVMOVE_FIRST_TIME) ? 1 : 0;
|
unsigned first_time = (flags & PVMOVE_FIRST_TIME) ? 1 : 0;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
log_verbose("Updating volume group metadata");
|
log_verbose("Updating volume group metadata");
|
||||||
if (!vg_write(vg)) {
|
if (!vg_write(vg)) {
|
||||||
@ -287,19 +288,16 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup(vg);
|
|
||||||
|
|
||||||
/* Suspend lvs_changed */
|
/* Suspend lvs_changed */
|
||||||
if (!suspend_lvs(cmd, lvs_changed))
|
if (!suspend_lvs(cmd, lvs_changed))
|
||||||
return_0;
|
goto_out;
|
||||||
|
|
||||||
/* Suspend mirrors on subsequent calls */
|
/* Suspend mirrors on subsequent calls */
|
||||||
if (!first_time) {
|
if (!first_time) {
|
||||||
if (!suspend_lv(cmd, lv_mirr)) {
|
if (!suspend_lv(cmd, lv_mirr)) {
|
||||||
stack;
|
|
||||||
resume_lvs(cmd, lvs_changed);
|
resume_lvs(cmd, lvs_changed);
|
||||||
vg_revert(vg);
|
vg_revert(vg);
|
||||||
return 0;
|
goto_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +307,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
if (!first_time)
|
if (!first_time)
|
||||||
resume_lv(cmd, lv_mirr);
|
resume_lv(cmd, lv_mirr);
|
||||||
resume_lvs(cmd, lvs_changed);
|
resume_lvs(cmd, lvs_changed);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Activate the temporary mirror LV */
|
/* Activate the temporary mirror LV */
|
||||||
@ -323,22 +321,25 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
"Run pvmove --abort.");
|
"Run pvmove --abort.");
|
||||||
/* FIXME Resume using *original* metadata here! */
|
/* FIXME Resume using *original* metadata here! */
|
||||||
resume_lvs(cmd, lvs_changed);
|
resume_lvs(cmd, lvs_changed);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if (!resume_lv(cmd, lv_mirr)) {
|
} else if (!resume_lv(cmd, lv_mirr)) {
|
||||||
log_error("Unable to reactivate logical volume \"%s\"",
|
log_error("Unable to reactivate logical volume \"%s\"",
|
||||||
lv_mirr->name);
|
lv_mirr->name);
|
||||||
resume_lvs(cmd, lvs_changed);
|
resume_lvs(cmd, lvs_changed);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsuspend LVs */
|
/* Unsuspend LVs */
|
||||||
if (!resume_lvs(cmd, lvs_changed)) {
|
if (!resume_lvs(cmd, lvs_changed)) {
|
||||||
log_error("Unable to resume logical volumes");
|
log_error("Unable to resume logical volumes");
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
r = 1;
|
||||||
|
out:
|
||||||
|
backup(vg);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user