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

Change LV locking macros to take lv instead of lvid.

This commit is contained in:
Alasdair Kergon 2005-08-15 12:00:04 +00:00
parent 07d318310b
commit 0fb173aa3a
12 changed files with 68 additions and 67 deletions

View File

@ -1,5 +1,6 @@
Version 2.01.15 -
=================================
Change LV locking macros to take lv instead of lvid.
Prepend 'cluster' activation parameter to mirror log when appropriate.
Pass exclusive flag to lv_activate and on to target activation code.
Prevent snapshot creation in a clustered VG for now.

View File

@ -268,7 +268,7 @@ int resume_lvs(struct cmd_context *cmd, struct list *lvs)
struct lv_list *lvl;
list_iterate_items(lvl, lvs)
resume_lv(cmd, lvl->lv->lvid.s);
resume_lv(cmd, lvl->lv);
return 1;
}
@ -280,11 +280,11 @@ int suspend_lvs(struct cmd_context *cmd, struct list *lvs)
struct lv_list *lvl;
list_iterate_items(lvl, lvs) {
if (!suspend_lv(cmd, lvl->lv->lvid.s)) {
if (!suspend_lv(cmd, lvl->lv)) {
log_error("Failed to suspend %s", lvl->lv->name);
list_uniterate(lvh, lvs, &lvl->list) {
lvl = list_item(lvh, struct lv_list);
resume_lv(cmd, lvl->lv->lvid.s);
resume_lv(cmd, lvl->lv);
}
return 0;
@ -301,11 +301,11 @@ int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs)
struct lv_list *lvl;
list_iterate_items(lvl, lvs) {
if (!activate_lv_excl(cmd, lvl->lv->lvid.s)) {
if (!activate_lv_excl(cmd, lvl->lv)) {
log_error("Failed to activate %s", lvl->lv->name);
list_uniterate(lvh, lvs, &lvl->list) {
lvl = list_item(lvh, struct lv_list);
activate_lv(cmd, lvl->lv->lvid.s);
activate_lv(cmd, lvl->lv);
}
return 0;

View File

@ -81,16 +81,16 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define unlock_vg(cmd, vol) lock_vol(cmd, vol, LCK_VG_UNLOCK)
#define resume_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_RESUME)
#define suspend_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_SUSPEND | LCK_HOLD)
#define deactivate_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_DEACTIVATE)
#define activate_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD)
#define activate_lv_excl(cmd, vol) \
lock_vol(cmd, vol, LCK_LV_EXCLUSIVE | LCK_HOLD)
#define activate_lv_local(cmd, vol) \
lock_vol(cmd, vol, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL)
#define deactivate_lv_local(cmd, vol) \
lock_vol(cmd, vol, LCK_LV_DEACTIVATE | LCK_LOCAL)
#define resume_lv(cmd, lv) lock_vol(cmd, (lv)->lvid.s, LCK_LV_RESUME)
#define suspend_lv(cmd, lv) lock_vol(cmd, (lv)->lvid.s, LCK_LV_SUSPEND | LCK_HOLD)
#define deactivate_lv(cmd, lv) lock_vol(cmd, (lv)->lvid.s, LCK_LV_DEACTIVATE)
#define activate_lv(cmd, lv) lock_vol(cmd, (lv)->lvid.s, LCK_LV_ACTIVATE | LCK_HOLD)
#define activate_lv_excl(cmd, lv) \
lock_vol(cmd, (lv)->lvid.s, LCK_LV_EXCLUSIVE | LCK_HOLD)
#define activate_lv_local(cmd, lv) \
lock_vol(cmd, (lv)->lvid.s, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL)
#define deactivate_lv_local(cmd, lv) \
lock_vol(cmd, (lv)->lvid.s, LCK_LV_DEACTIVATE | LCK_LOCAL)
/* Process list of LVs */
int suspend_lvs(struct cmd_context *cmd, struct list *lvs);

View File

@ -52,19 +52,19 @@ static int lvchange_permission(struct cmd_context *cmd,
backup(lv->vg);
if (!suspend_lv(cmd, lv->lvid.s)) {
if (!suspend_lv(cmd, lv)) {
log_error("Failed to lock %s", lv->name);
vg_revert(lv->vg);
return 0;
}
if (!vg_commit(lv->vg)) {
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
return 0;
}
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
if (!resume_lv(cmd, lv->lvid.s)) {
if (!resume_lv(cmd, lv)) {
log_error("Problem reactivating %s", lv->name);
return 0;
}
@ -83,13 +83,13 @@ static int lvchange_availability(struct cmd_context *cmd,
if (activate == CHANGE_ALN) {
log_verbose("Deactivating logical volume \"%s\" locally",
lv->name);
if (!deactivate_lv_local(cmd, lv->lvid.s)) {
if (!deactivate_lv_local(cmd, lv)) {
stack;
return 0;
}
} else if (activate == CHANGE_AN) {
log_verbose("Deactivating logical volume \"%s\"", lv->name);
if (!deactivate_lv(cmd, lv->lvid.s)) {
if (!deactivate_lv(cmd, lv)) {
stack;
return 0;
}
@ -103,21 +103,21 @@ static int lvchange_availability(struct cmd_context *cmd,
if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
log_verbose("Activating logical volume \"%s\" "
"exclusively", lv->name);
if (!activate_lv_excl(cmd, lv->lvid.s)) {
if (!activate_lv_excl(cmd, lv)) {
stack;
return 0;
}
} else if (activate == CHANGE_ALY) {
log_verbose("Activating logical volume \"%s\" locally",
lv->name);
if (!activate_lv_local(cmd, lv->lvid.s)) {
if (!activate_lv_local(cmd, lv)) {
stack;
return 0;
}
} else {
log_verbose("Activating logical volume \"%s\"",
lv->name);
if (!activate_lv(cmd, lv->lvid.s)) {
if (!activate_lv(cmd, lv)) {
stack;
return 0;
}
@ -137,7 +137,7 @@ static int lvchange_availability(struct cmd_context *cmd,
static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
{
log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name);
if (!suspend_lv(cmd, lv->lvid.s) || !resume_lv(cmd, lv->lvid.s))
if (!suspend_lv(cmd, lv) || !resume_lv(cmd, lv))
return 0;
return 1;
@ -216,19 +216,19 @@ static int lvchange_readahead(struct cmd_context *cmd,
backup(lv->vg);
if (!suspend_lv(cmd, lv->lvid.s)) {
if (!suspend_lv(cmd, lv)) {
log_error("Failed to lock %s", lv->name);
vg_revert(lv->vg);
return 0;
}
if (!vg_commit(lv->vg)) {
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
return 0;
}
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
if (!resume_lv(cmd, lv->lvid.s)) {
if (!resume_lv(cmd, lv)) {
log_error("Problem reactivating %s", lv->name);
return 0;
}
@ -274,7 +274,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
active = 1;
}
log_verbose("Ensuring %s is inactive.", lv->name);
if (!deactivate_lv(cmd, lv->lvid.s)) {
if (!deactivate_lv(cmd, lv)) {
log_error("%s: deactivation failed", lv->name);
return 0;
}
@ -286,7 +286,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
if (active) {
log_verbose("Re-activating logical volume \"%s\"",
lv->name);
if (!activate_lv(cmd, lv->lvid.s)) {
if (!activate_lv(cmd, lv)) {
log_error("%s: reactivation failed", lv->name);
return 0;
}
@ -301,19 +301,19 @@ static int lvchange_persistent(struct cmd_context *cmd,
backup(lv->vg);
if (!suspend_lv(cmd, lv->lvid.s)) {
if (!suspend_lv(cmd, lv)) {
log_error("Failed to lock %s", lv->name);
vg_revert(lv->vg);
return 0;
}
if (!vg_commit(lv->vg)) {
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
return 0;
}
log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name);
if (!resume_lv(cmd, lv->lvid.s)) {
if (!resume_lv(cmd, lv)) {
log_error("Problem reactivating %s", lv->name);
return 0;
}

View File

@ -93,20 +93,20 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l
backup(lv->vg);
if (!suspend_lv(cmd, lv->lvid.s)) {
if (!suspend_lv(cmd, lv)) {
log_error("Failed to lock %s", lv->name);
vg_revert(lv->vg);
return 0;
}
if (!vg_commit(lv->vg)) {
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
return 0;
}
log_very_verbose("Updating \"%s\" in kernel", lv->name);
if (!resume_lv(cmd, lv->lvid.s)) {
if (!resume_lv(cmd, lv)) {
log_error("Problem reactivating %s", lv->name);
return 0;
}

View File

@ -623,7 +623,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
goto error;
}
if (!activate_lv(cmd, log_lv->lvid.s)) {
if (!activate_lv(cmd, log_lv)) {
log_error("Aborting. Failed to activate mirror log. "
"Remove new LVs and retry.");
goto error;
@ -635,7 +635,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
goto error;
}
if (!deactivate_lv(cmd, log_lv->lvid.s)) {
if (!deactivate_lv(cmd, log_lv)) {
log_error("Aborting. Failed to deactivate mirror log. "
"Remove new LV and retry.");
goto error;
@ -711,7 +711,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
return 0;
}
if (!activate_lv(cmd, lv->lvid.s)) {
if (!activate_lv(cmd, lv)) {
if (lp->snapshot)
/* FIXME Remove the failed lv we just added */
log_error("Aborting. Failed to activate snapshot "
@ -737,13 +737,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
/* Reset permission after zeroing */
if (!(lp->permission & LVM_WRITE))
lv->status &= ~LVM_WRITE;
if (!deactivate_lv(cmd, lv->lvid.s)) {
if (!deactivate_lv(cmd, lv)) {
log_err("Couldn't deactivate new snapshot.");
return 0;
}
/* FIXME write/commit/backup sequence issue */
if (!suspend_lv(cmd, org->lvid.s)) {
if (!suspend_lv(cmd, org)) {
log_error("Failed to suspend origin %s", org->name);
return 0;
}
@ -758,7 +758,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
if (!vg_write(vg) || !vg_commit(vg))
return 0;
if (!resume_lv(cmd, org->lvid.s)) {
if (!resume_lv(cmd, org)) {
log_error("Problem reactivating origin %s", org->name);
return 0;
}

View File

@ -74,7 +74,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!archive(vg))
return ECMD_FAILED;
if (!deactivate_lv(cmd, lv->lvid.s)) {
if (!deactivate_lv(cmd, lv)) {
log_error("Unable to deactivate logical volume \"%s\"",
lv->name);
return ECMD_FAILED;

View File

@ -158,18 +158,18 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
backup(lv->vg);
if (!suspend_lv(cmd, lv->lvid.s)) {
if (!suspend_lv(cmd, lv)) {
stack;
goto error;
}
if (!vg_commit(vg)) {
stack;
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
goto error;
}
resume_lv(cmd, lv->lvid.s);
resume_lv(cmd, lv);
unlock_vg(cmd, vg_name);

View File

@ -124,7 +124,7 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
uint32_t extents_used = 0;
uint32_t size_rest;
alloc_policy_t alloc;
char *lock_lvid;
struct logical_volume *lock_lv;
struct lv_list *lvl;
int consistent = 1;
struct lv_segment *seg;
@ -518,11 +518,11 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
/* If snapshot, must suspend all associated devices */
if ((snap_seg = find_cow(lv)))
lock_lvid = snap_seg->origin->lvid.s;
lock_lv = snap_seg->origin;
else
lock_lvid = lv->lvid.s;
lock_lv = lv;
if (!suspend_lv(cmd, lock_lvid)) {
if (!suspend_lv(cmd, lock_lv)) {
log_error("Failed to suspend %s", lp->lv_name);
vg_revert(vg);
return ECMD_FAILED;
@ -530,11 +530,11 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
if (!vg_commit(vg)) {
stack;
resume_lv(cmd, lock_lvid);
resume_lv(cmd, lock_lv);
return ECMD_FAILED;
}
if (!resume_lv(cmd, lock_lvid)) {
if (!resume_lv(cmd, lock_lv)) {
log_error("Problem reactivating %s", lp->lv_name);
return ECMD_FAILED;
}

View File

@ -219,7 +219,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
/* Suspend mirrors on subsequent calls */
if (!first_time) {
if (!suspend_lv(cmd, lv_mirr->lvid.s)) {
if (!suspend_lv(cmd, lv_mirr)) {
stack;
resume_lvs(cmd, lvs_changed);
vg_revert(vg);
@ -231,7 +231,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
if (!vg_commit(vg)) {
log_error("ABORTING: Volume group metadata update failed.");
if (!first_time)
resume_lv(cmd, lv_mirr->lvid.s);
resume_lv(cmd, lv_mirr);
resume_lvs(cmd, lvs_changed);
return 0;
}
@ -240,7 +240,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
/* Only the first mirror segment gets activated as a mirror */
/* FIXME: Add option to use a log */
if (first_time) {
if (!activate_lv_excl(cmd, lv_mirr->lvid.s)) {
if (!activate_lv_excl(cmd, lv_mirr)) {
if (!test_mode())
log_error("ABORTING: Temporary mirror "
"activation failed. "
@ -249,7 +249,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
resume_lvs(cmd, lvs_changed);
return 0;
}
} else if (!resume_lv(cmd, lv_mirr->lvid.s)) {
} else if (!resume_lv(cmd, lv_mirr)) {
log_error("Unable to reactivate logical volume \"%s\"",
lv_mirr->name);
resume_lvs(cmd, lvs_changed);
@ -318,7 +318,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
}
/* Ensure mirror LV is active */
if (!activate_lv_excl(cmd, lv_mirr->lvid.s)) {
if (!activate_lv_excl(cmd, lv_mirr)) {
log_error
("ABORTING: Temporary mirror activation failed.");
unlock_vg(cmd, pv->vg_name);
@ -415,7 +415,7 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
}
/* Suspend mirror LV to flush pending I/O */
if (!suspend_lv(cmd, lv_mirr->lvid.s)) {
if (!suspend_lv(cmd, lv_mirr)) {
log_error("Suspension of temporary mirror LV failed");
r = 0;
}
@ -425,13 +425,13 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
log_error("ABORTING: Failed to write new data locations "
"to disk.");
vg_revert(vg);
resume_lv(cmd, lv_mirr->lvid.s);
resume_lv(cmd, lv_mirr);
resume_lvs(cmd, lvs_changed);
return 0;
}
/* Release mirror LV. (No pending I/O because it's been suspended.) */
if (!resume_lv(cmd, lv_mirr->lvid.s)) {
if (!resume_lv(cmd, lv_mirr)) {
log_error("Unable to reactivate logical volume \"%s\"",
lv_mirr->name);
r = 0;
@ -441,7 +441,7 @@ static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
resume_lvs(cmd, lvs_changed);
/* Deactivate mirror LV */
if (!deactivate_lv(cmd, lv_mirr->lvid.s)) {
if (!deactivate_lv(cmd, lv_mirr)) {
log_error("ABORTING: Unable to deactivate temporary logical "
"volume \"%s\"", lv_mirr->name);
r = 0;

View File

@ -37,18 +37,18 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
continue;
if (activate == CHANGE_AN) {
if (!deactivate_lv(cmd, lv->lvid.s))
if (!deactivate_lv(cmd, lv))
continue;
} else if (activate == CHANGE_ALN) {
if (!deactivate_lv_local(cmd, lv->lvid.s))
if (!deactivate_lv_local(cmd, lv))
continue;
} else if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
if (!activate_lv_excl(cmd, lv->lvid.s))
if (!activate_lv_excl(cmd, lv))
continue;
} else if (activate == CHANGE_ALY) {
if (!activate_lv_local(cmd, lv->lvid.s))
if (!activate_lv_local(cmd, lv))
continue;
} else if (!activate_lv(cmd, lv->lvid.s))
} else if (!activate_lv(cmd, lv))
continue;
if ((lv->status & PVMOVE) &&

View File

@ -61,7 +61,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
log_verbose("Deactivating (if active) logical volume %s",
lv->name);
if (!deactivate_lv(cmd, lv->lvid.s)) {
if (!deactivate_lv(cmd, lv)) {
log_error("Failed to deactivate LV %s", lv->name);
return 0;
}
@ -69,7 +69,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
log_verbose("Deactivating (if active) logical volume %s "
"(origin of %s)", snap_seg->origin->name, lv->name);
if (!deactivate_lv(cmd, snap_seg->origin->lvid.s)) {
if (!deactivate_lv(cmd, snap_seg->origin)) {
log_error("Failed to deactivate LV %s",
snap_seg->origin->name);
return 0;