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

activation: fix lv_is_active regressions

Try to fix commit bf2741376d.

lv_is_active is not the same as lv_info(cmd, org, 0, &info, 0, 0).

Introduce and use lv_is_active_locally.
This commit is contained in:
Alasdair G Kergon 2013-05-15 02:13:31 +01:00
parent 2fbe1e6e00
commit f12d88f840
6 changed files with 28 additions and 5 deletions

View File

@ -115,7 +115,7 @@ Version 2.02.99 -
Support use of option --yes for lvchange --persistent.
Fix memory leak on error path for pvcreate with invalid uuid.
Implement ref-counting for parents in python lib.
Use lv_is_active() instead of lv_info() call.
Add lv_is_active_locally and use instead of most local lv_info calls.
Reduce some log_error messages to log_warn where we don't fail.
Remove python liblvm object. systemdir can only be changed using env var now.

View File

@ -274,6 +274,10 @@ int lv_is_active(const struct logical_volume *lv)
{
return 0;
}
int lv_is_active_locally(const struct logical_volume *lv)
{
return 0;
}
int lv_is_active_but_not_locally(const struct logical_volume *lv)
{
return 0;
@ -1252,6 +1256,13 @@ int lv_is_active(const struct logical_volume *lv)
return _lv_is_active(lv, NULL, NULL);
}
int lv_is_active_locally(const struct logical_volume *lv)
{
int l;
return _lv_is_active(lv, &l, NULL) && l;
}
int lv_is_active_but_not_locally(const struct logical_volume *lv)
{
int l;

View File

@ -134,6 +134,7 @@ int lvs_in_vg_activated(const struct volume_group *vg);
int lvs_in_vg_opened(const struct volume_group *vg);
int lv_is_active(const struct logical_volume *lv);
int lv_is_active_locally(const struct logical_volume *lv);
int lv_is_active_but_not_locally(const struct logical_volume *lv);
int lv_is_active_exclusive(const struct logical_volume *lv);
int lv_is_active_exclusive_locally(const struct logical_volume *lv);

View File

@ -4394,6 +4394,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
struct logical_volume *pool_lv;
struct lv_list *lvl;
const char *thin_name = NULL;
int origin_active = 0;
struct lvinfo info;
if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) {
log_error("Logical volume \"%s\" already exists in "
@ -4523,7 +4525,15 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
log_warn("WARNING: See global/mirror_segtype_default in lvm.conf.");
}
if (vg_is_clustered(vg) && lv_is_active(org) &&
if (!lv_info(cmd, org, 0, &info, 0, 0)) {
log_error("Check for existence of active snapshot "
"origin '%s' failed.", org->name);
return NULL;
}
origin_active = info.exists;
if (vg_is_clustered(vg) &&
!lv_is_active_exclusive_locally(org)) {
log_error("%s must be active exclusively to"
" create snapshot", org->name);

View File

@ -298,12 +298,13 @@ static int _init_mirror_log(struct cmd_context *cmd,
/* If the LV is active, deactivate it first. */
if (lv_is_active(log_lv)) {
(void) deactivate_lv(cmd, log_lv);
/*
* FIXME: workaround to fail early
* Ensure that log is really deactivated because deactivate_lv
* on cluster do not fail if there is log_lv with different UUID.
*/
if (!deactivate_lv(cmd, log_lv)) {
if (lv_is_active(log_lv)) {
log_error("Aborting. Unable to deactivate mirror log.");
goto revert_new_lv;
}
@ -1707,7 +1708,7 @@ int remove_mirror_log(struct cmd_context *cmd,
}
/* Had disk log, switch to core. */
if (lv_is_active(lv)) {
if (lv_is_active_locally(lv)) {
if (!lv_mirror_percent(cmd, lv, 0, &sync_percent,
NULL)) {
log_error("Unable to determine mirror sync status.");

View File

@ -866,7 +866,7 @@ static int _snpercent_disp(struct dm_report *rh __attribute__((unused)), struct
}
if ((!lv_is_cow(lv) && !lv_is_merging_origin(lv)) ||
!lv_is_active(lv)) {
!lv_is_active_locally(lv)) {
*sortval = UINT64_C(0);
dm_report_field_set_value(field, "", sortval);
return 1;