dev-mornfall-lvmcache - activation: fix lv_is_active regressions
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f12d88f840474a75a58d1f7ae8d391ec5852b850 Commit: f12d88f840474a75a58d1f7ae8d391ec5852b850 Parent: 2fbe1e6e00fc59f54ae11c19d51f2d7fc8425b16 Author: Alasdair G Kergon <[email protected]> AuthorDate: Wed May 15 02:13:31 2013 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Wed May 15 02:13:31 2013 +0100
activation: fix lv_is_active regressions
Try to fix commit bf2741376d47411994d4065863acab8e405ff5c7.
lv_is_active is not the same as lv_info(cmd, org, 0, &info, 0, 0).
Introduce and use lv_is_active_locally.
--- WHATS_NEW | 2 +- lib/activate/activate.c | 11 +++++++++++ lib/activate/activate.h | 1 + lib/metadata/lv_manip.c | 12 +++++++++++- lib/metadata/mirror.c | 5 +++-- lib/report/report.c | 2 +- 6 files changed, 28 insertions(+), 5 deletions(-)
WHATS_NEW +1 -1
@@ -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.
lib/activate/activate.c +11 -0
@@ -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;
lib/activate/activate.h +1 -0
@@ -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);
lib/metadata/lv_manip.c +11 -1
@@ -4394,6 +4394,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct lstruct 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 llog_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);
lib/metadata/mirror.c +3 -2
@@ -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." );
lib/report/report.c +1 -1
@@ -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 ;