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

Clean-up: Replace 'lv_is_active' with more correct/specific variants

There are places where 'lv_is_active' was being used where it was
more correct to use 'lv_is_active_locally'.  For example, when checking
for the existance of a kernel instance before asking for its status.
Most of the time these would work correctly.  (RAID is only allowed on
non-clustered VGs at the moment, which means that 'lv_is_active' and
'lv_is_active_locally' would give the same result.)  However, it is
more correct to use the proper variant and it helps with future
scenarios where targets might be allowed exclusively (or clustered) in
a cluster VG.
This commit is contained in:
Jonathan Brassow 2013-05-16 10:36:56 -05:00
parent b3b551a93e
commit 06ac797f42
7 changed files with 31 additions and 18 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 - Version 2.02.99 -
=================================== ===================================
Replace 'lv_is_active' with more correct/specific variants (e.g. *_locally).
Refuse to init a snapshot merge in lvconvert if there's no kernel support. Refuse to init a snapshot merge in lvconvert if there's no kernel support.
Fix exported symbols regex for non-GNU busybox sed. Fix exported symbols regex for non-GNU busybox sed.
Accept --yes in all commands so test scripts can be simpler. Accept --yes in all commands so test scripts can be simpler.

View File

@ -818,7 +818,7 @@ int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health)
log_debug_activation("Checking raid device health for LV %s/%s", log_debug_activation("Checking raid device health for LV %s/%s",
lv->vg->name, lv->name); lv->vg->name, lv->name);
if (!lv_is_active(lv)) if (!lv_is_active_locally(lv))
return 0; return 0;
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
@ -850,7 +850,7 @@ int lv_raid_mismatch_count(const struct logical_volume *lv, uint64_t *cnt)
log_debug_activation("Checking raid mismatch count for LV %s/%s", log_debug_activation("Checking raid mismatch count for LV %s/%s",
lv->vg->name, lv->name); lv->vg->name, lv->name);
if (!lv_is_active(lv)) if (!lv_is_active_locally(lv))
return_0; return_0;
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
@ -881,7 +881,7 @@ int lv_raid_sync_action(const struct logical_volume *lv, char **sync_action)
log_debug_activation("Checking raid sync_action for LV %s/%s", log_debug_activation("Checking raid sync_action for LV %s/%s",
lv->vg->name, lv->name); lv->vg->name, lv->name);
if (!lv_is_active(lv)) if (!lv_is_active_locally(lv))
return_0; return_0;
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
@ -907,7 +907,7 @@ int lv_raid_message(const struct logical_volume *lv, const char *msg)
struct dev_manager *dm; struct dev_manager *dm;
struct dm_status_raid *status; struct dm_status_raid *status;
if (!lv_is_active(lv)) { if (!lv_is_active_locally(lv)) {
log_error("Unable to send message to an inactive logical volume."); log_error("Unable to send message to an inactive logical volume.");
return 0; return 0;
} }

View File

@ -393,8 +393,11 @@ static int _lv_raid_image_in_sync(const struct logical_volume *lv)
char *raid_health; char *raid_health;
struct lv_segment *raid_seg; struct lv_segment *raid_seg;
/* If the LV is not active, it doesn't make sense to check status */ /*
if (!lv_is_active(lv)) * If the LV is not active locally,
* it doesn't make sense to check status
*/
if (!lv_is_active_locally(lv))
return 0; /* Assume not in-sync */ return 0; /* Assume not in-sync */
if (!(lv->status & RAID_IMAGE)) { if (!(lv->status & RAID_IMAGE)) {
@ -452,8 +455,11 @@ static int _lv_raid_healthy(const struct logical_volume *lv)
char *raid_health; char *raid_health;
struct lv_segment *raid_seg; struct lv_segment *raid_seg;
/* If the LV is not active, it doesn't make sense to check status */ /*
if (!lv_is_active(lv)) * If the LV is not active locally,
* it doesn't make sense to check status
*/
if (!lv_is_active_locally(lv))
return 1; /* assume healthy */ return 1; /* assume healthy */
if (!lv_is_raid_type(lv)) { if (!lv_is_raid_type(lv)) {

View File

@ -2906,8 +2906,8 @@ int lv_extend(struct logical_volume *lv,
(lv->status & LV_NOTSYNCED)) { (lv->status & LV_NOTSYNCED)) {
percent_t sync_percent = PERCENT_INVALID; percent_t sync_percent = PERCENT_INVALID;
if (!lv_is_active(lv)) { if (!lv_is_active_locally(lv)) {
log_error("%s/%s is not active." log_error("%s/%s is not active locally."
" Unable to get sync percent.", " Unable to get sync percent.",
lv->vg->name, lv->name); lv->vg->name, lv->name);
/* FIXME Support --force */ /* FIXME Support --force */

View File

@ -1714,6 +1714,10 @@ int remove_mirror_log(struct cmd_context *cmd,
log_error("Unable to determine mirror sync status."); log_error("Unable to determine mirror sync status.");
return 0; return 0;
} }
} else if (lv_is_active(lv)) {
log_error("Unable to determine sync status of"
" remotely active mirror, %s", lv->name);
return 0;
} else if (vg_is_clustered(vg)) { } else if (vg_is_clustered(vg)) {
log_error("Unable to convert the log of an inactive " log_error("Unable to convert the log of an inactive "
"cluster mirror, %s", lv->name); "cluster mirror, %s", lv->name);

View File

@ -84,7 +84,7 @@ static int _activate_sublv_preserving_excl(struct logical_volume *top_lv,
/* If top RAID was EX, use EX */ /* If top RAID was EX, use EX */
if (lv_is_active_exclusive_locally(top_lv)) { if (lv_is_active_exclusive_locally(top_lv)) {
if (!activate_lv_excl(cmd, sub_lv)) if (!activate_lv_excl_local(cmd, sub_lv))
return_0; return_0;
} else { } else {
if (!activate_lv(cmd, sub_lv)) if (!activate_lv(cmd, sub_lv))
@ -226,7 +226,7 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
*/ */
static int _clear_lv(struct logical_volume *lv) static int _clear_lv(struct logical_volume *lv)
{ {
int was_active = lv_is_active(lv); int was_active = lv_is_active_locally(lv);
if (test_mode()) if (test_mode())
return 1; return 1;
@ -1579,9 +1579,10 @@ int lv_raid_replace(struct logical_volume *lv,
dm_list_init(&new_meta_lvs); dm_list_init(&new_meta_lvs);
dm_list_init(&new_data_lvs); dm_list_init(&new_data_lvs);
if (!lv_is_active(lv)) { if (!lv_is_active_locally(lv)) {
log_error("%s/%s must be active to perform this operation.", log_error("%s/%s must be active %sto perform this operation.",
lv->vg->name, lv->name); lv->vg->name, lv->name,
vg_is_clustered(lv->vg) ? "locally " : "");
return 0; return 0;
} }

View File

@ -1681,9 +1681,10 @@ static int lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp
return lv_raid_replace(lv, lp->replace_pvh, lp->pvh); return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
if (arg_count(cmd, repair_ARG)) { if (arg_count(cmd, repair_ARG)) {
if (!lv_is_active(lv)) { if (!lv_is_active_locally(lv)) {
log_error("%s/%s must be active to perform" log_error("%s/%s must be active %sto perform"
"this operation.", lv->vg->name, lv->name); "this operation.", lv->vg->name, lv->name,
vg_is_clustered(lv->vg) ? "locally " : "");
return 0; return 0;
} }