}
/* store vg on disk(s) */
- if (!vg_write(vg))
- goto_out;
-
- if (!suspend_lv(cmd, lock_lv)) {
- log_error("Failed to suspend %s", lock_lv->name);
- vg_revert(vg);
- goto bad;
- }
-
- if (!vg_commit(vg)) {
- stack;
- if (!resume_lv(cmd, lock_lv))
- stack;
- goto bad;
- }
-
- if (!resume_lv(cmd, lock_lv)) {
- log_error("Problem reactivating %s", lock_lv->name);
- goto bad;
- }
+ if (!lv_update_and_reload(lock_lv))
+ goto_bad;
if (lv_is_cow_covering_origin(lv))
if (!monitor_dev_for_events(cmd, lv, 0, 0))
if (!update_pool_lv(lock_lv, 0))
goto_bad;
+ backup(vg);
+
if (inactive && !deactivate_lv(cmd, lock_lv)) {
log_error("Problem deactivating %s.", lock_lv->name);
- backup(vg);
return 0;
}
}
- backup(vg);
-
log_print_unless_silent("Logical volume %s successfully resized", lp->lv_name);
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
return_0;
return 1;
-
bad:
- backup(vg);
-out:
if (inactive && !deactivate_lv(cmd, lock_lv))
log_error("Problem deactivating %s.", lock_lv->name);
* I say that would be cleaner, but I'm not sure
* about the effects on thinpool yet...
*/
- if (!vg_write(vg) || !suspend_lv(cmd, lv) ||
- !vg_commit(vg) || !resume_lv(cmd, lv))
+ if (!lv_update_and_reload(lv)) {
+ stack;
goto deactivate_and_revert_new_lv;
+ }
if (!(lvl = find_lv_in_vg(vg, lp->origin)))
goto deactivate_and_revert_new_lv;
uint32_t old_count = lv_raid_image_count(lv);
uint32_t count = new_count - old_count;
uint64_t status_mask = -1;
- struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *seg = first_seg(lv);
struct dm_list meta_lvs, data_lvs;
struct lv_list *lvl;
dm_list_iterate_items(lvl, &data_lvs)
lv_set_hidden(lvl->lv);
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv_origin(cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!resume_lv_origin(cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
+ if (!lv_update_and_reload_origin(lv))
+ return_0;
/*
* Now that the 'REBUILD' has made its way to the kernel, we must
return 0;
}
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv(lv->vg->cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
+ if (!lv_update_and_reload(lv))
+ return_0;
log_print_unless_silent("%s split from %s for read-only purposes.",
seg_lv(seg, s)->name, lv->name);
- /* Resume original LV */
- if (!resume_lv(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
/* Activate the split (and tracking) LV */
if (!_activate_sublv_preserving_excl(lv, seg_lv(seg, s)))
return 0;
image_lv->status |= (lv->status & LVM_WRITE);
image_lv->status |= RAID_IMAGE;
- if (!vg_write(vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, vg->name);
- return 0;
- }
-
- if (!suspend_lv(vg->cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, vg->name);
- return 0;
- }
-
- if (!resume_lv(vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- vg->name, lv->name);
- return 0;
- }
+ if (!lv_update_and_reload(lv))
+ return_0;
log_print_unless_silent("%s/%s successfully merged back into %s/%s",
vg->name, image_lv->name, vg->name, lv->name);
lv->status |= RAID;
seg->status |= RAID;
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv(lv->vg->cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!resume_lv(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
+ if (!lv_update_and_reload(lv))
+ return_0;
return 1;
}
}
}
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv_origin(lv->vg->cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!resume_lv_origin(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
+ if (!lv_update_and_reload_origin(lv))
+ return_0;
dm_list_iterate_items(lvl, &old_lvs) {
if (!deactivate_lv(lv->vg->cmd, lvl->lv))
}
}
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv_origin(lv->vg->cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!resume_lv_origin(lv->vg->cmd, lv)) {
- log_error("Failed to resume %s/%s after committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
+ if (!lv_update_and_reload_origin(lv))
+ return_0;
return 1;
}
{
uint32_t s;
struct lv_segment *seg = first_seg(lv);
- struct cmd_context *cmd = lv->vg->cmd;
if (!(lv->status & PARTIAL_LV)) {
log_error(INTERNAL_ERROR "%s/%s is not a partial LV",
}
}
- if (!vg_write(lv->vg)) {
- log_error("Failed to write changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!suspend_lv(cmd, lv)) {
- log_error("Failed to suspend %s/%s before committing changes",
- lv->vg->name, lv->name);
- return 0;
- }
-
- if (!vg_commit(lv->vg)) {
- log_error("Failed to commit changes to %s in %s",
- lv->name, lv->vg->name);
- return 0;
- }
-
- if (!resume_lv(cmd, lv))
+ if (!lv_update_and_reload(lv))
return_0;
return 1;
{
uint32_t lv_access;
struct lvinfo info;
- int r = 0;
lv_access = arg_uint_value(cmd, permission_ARG, 0);
lv->name);
}
- log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
- if (!vg_write(lv->vg))
+ if (!lv_update_and_reload(lv))
return_0;
- if (!suspend_lv(cmd, lv)) {
- log_error("Failed to lock %s", lv->name);
- vg_revert(lv->vg);
- goto out;
- }
-
- if (!vg_commit(lv->vg)) {
- if (!resume_lv(cmd, lv))
- stack;
- goto_out;
- }
-
- log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
- if (!resume_lv(cmd, lv)) {
- log_error("Problem reactivating %s", lv->name);
- goto out;
- }
-
- r = 1;
-out:
- backup(lv->vg);
- return r;
+ return 1;
}
static int lvchange_pool_update(struct cmd_context *cmd,
struct logical_volume *lv)
{
- int r = 0;
int update = 0;
unsigned val;
thin_discards_t discards;
if (!update)
return 0;
- log_very_verbose("Updating logical volume \"%s\" on disk(s).", lv->name);
- if (!vg_write(lv->vg))
+ if (!lv_update_and_reload_origin(lv))
return_0;
- if (!suspend_lv_origin(cmd, lv)) {
- log_error("Failed to update active %s/%s (deactivation is needed).",
- lv->vg->name, lv->name);
- vg_revert(lv->vg);
- goto out;
- }
-
- if (!vg_commit(lv->vg)) {
- if (!resume_lv_origin(cmd, lv))
- stack;
- goto_out;
- }
-
- if (!resume_lv_origin(cmd, lv)) {
- log_error("Problem reactivating %s.", lv->name);
- goto out;
- }
-
- r = 1;
-out:
- backup(lv->vg);
- return r;
+ return 1;
}
static int lvchange_monitoring(struct cmd_context *cmd,
{
unsigned read_ahead = 0;
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
- int r = 0;
read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
log_verbose("Setting read ahead to %u for \"%s\"", read_ahead,
lv->name);
- log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
- if (!vg_write(lv->vg))
+ if (!lv_update_and_reload(lv))
return_0;
- if (!suspend_lv(cmd, lv)) {
- log_error("Failed to lock %s", lv->name);
- vg_revert(lv->vg);
- goto out;
- }
-
- if (!vg_commit(lv->vg)) {
- if (!resume_lv(cmd, lv))
- stack;
- goto_out;
- }
-
- log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
- if (!resume_lv(cmd, lv)) {
- log_error("Problem reactivating %s", lv->name);
- goto out;
- }
-
- r = 1;
-out:
- backup(lv->vg);
- return r;
+ return 1;
}
static int lvchange_persistent(struct cmd_context *cmd,
}
}
- if (!vg_write(lv->vg))
- return_0;
-
- if (!suspend_lv(cmd, lv)) {
- vg_revert(lv->vg);
- return_0;
- }
-
- if (!vg_commit(lv->vg)) {
- if (!resume_lv(cmd, lv))
- stack;
+ if (!lv_update_and_reload(lv))
return_0;
- }
-
- log_very_verbose("Updating writemostly for \"%s\" in kernel", lv->name);
- if (!resume_lv(cmd, lv)) {
- log_error("Problem reactivating %s", lv->name);
- return 0;
- }
return 1;
}
return 0;
}
- if (!vg_write(lv->vg))
- return_0;
-
- if (!suspend_lv(cmd, lv)) {
- vg_revert(lv->vg);
+ if (!lv_update_and_reload(lv))
return_0;
- }
-
- if (!vg_commit(lv->vg)) {
- if (!resume_lv(cmd, lv))
- stack;
- return_0;
- }
-
- log_very_verbose("Updating recovery rate for \"%s\" in kernel",
- lv->name);
- if (!resume_lv(cmd, lv)) {
- log_error("Problem reactivating %s", lv->name);
- return 0;
- }
return 1;
}