From 2b82bd79f59ffb49cc864cf0d2e9268c652443d3 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 8 Dec 2010 20:50:48 +0000 Subject: [PATCH] Rename vg_release to free_vg. --- WHATS_NEW | 2 +- daemons/clvmd/lvm-functions.c | 2 +- lib/activate/activate.c | 14 +++---- lib/cache/lvmcache.c | 2 +- lib/format_text/archive.c | 2 +- lib/format_text/archiver.c | 6 +-- lib/format_text/format-text.c | 4 +- lib/locking/locking.h | 4 +- lib/metadata/metadata-exported.h | 6 +-- lib/metadata/metadata.c | 72 ++++++++++++++++---------------- lib/metadata/replicator_manip.c | 8 ++-- liblvm/lvm_vg.c | 8 ++-- tools/lvconvert.c | 10 ++--- tools/lvcreate.c | 4 +- tools/lvrename.c | 4 +- tools/lvresize.c | 4 +- tools/polldaemon.c | 8 ++-- tools/pvchange.c | 8 ++-- tools/pvcreate.c | 2 +- tools/pvdisplay.c | 4 +- tools/pvmove.c | 4 +- tools/pvresize.c | 4 +- tools/reporter.c | 8 ++-- tools/toollib.c | 22 +++++----- tools/vgcreate.c | 6 +-- tools/vgextend.c | 6 +-- tools/vgmerge.c | 14 +++---- tools/vgreduce.c | 6 +-- tools/vgrename.c | 10 ++--- tools/vgsplit.c | 22 +++++----- 30 files changed, 139 insertions(+), 137 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 86b0a865c..b20094fa0 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,7 +1,7 @@ Version 2.02.79 - =================================== Cope better with an undefined target_percent operation in _percent_run. - Fix write to released memory in vg_release(). (2.02.78) + Fix write to released memory in vg_release and rename to free_vg. (2.02.78) Version 2.02.78 - 6th December 2010 =================================== diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 0520ae9a7..214f22955 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -863,7 +863,7 @@ void lvm_do_backup(const char *vgname) else log_error("Error backing up metadata, can't find VG for group %s", vgname); - vg_release(vg); + free_vg(vg); dm_pool_empty(cmd->mem); pthread_mutex_unlock(&lvm_lock); diff --git a/lib/activate/activate.c b/lib/activate/activate.c index a19d55671..88cb184a8 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -491,7 +491,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, origin_only = 0; r = lv_info(cmd, lv, origin_only, info, with_open_count, with_read_ahead); - vg_release(lv->vg); + free_vg(lv->vg); return r; } @@ -1052,10 +1052,10 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, r = 1; out: if (lv_pre) - vg_release(lv_pre->vg); + free_vg(lv_pre->vg); if (lv) { lv_release_replicator_vgs(lv); - vg_release(lv->vg); + free_vg(lv->vg); } return r; @@ -1120,7 +1120,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s, r = 1; out: if (lv) - vg_release(lv->vg); + free_vg(lv->vg); return r; } @@ -1213,7 +1213,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) out: if (lv) { lv_release_replicator_vgs(lv); - vg_release(lv->vg); + free_vg(lv->vg); } return r; @@ -1243,7 +1243,7 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s, r = 1; out: if (lv) - vg_release(lv->vg); + free_vg(lv->vg); return r; } @@ -1313,7 +1313,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, out: if (lv) { lv_release_replicator_vgs(lv); - vg_release(lv->vg); + free_vg(lv->vg); } return r; diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 35b698664..ab16536c9 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -643,7 +643,7 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted) if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid))) { _free_cached_vgmetadata(vginfo); - vg_release(vg); + free_vg(vg); return_NULL; } diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c index bf16da573..43425dc30 100644 --- a/lib/format_text/archive.c +++ b/lib/format_text/archive.c @@ -329,7 +329,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af) log_print("Description:\t%s", desc ? : ""); log_print("Backup Time:\t%s", ctime(&when)); - vg_release(vg); + free_vg(vg); tf->fmt->ops->destroy_instance(tf); } diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index 3ace6281f..ef85c6cbf 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -365,7 +365,7 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, log_error("Cannot restore Volume Group %s with %i PVs " "marked as missing.", vg->name, missing_pvs); - vg_release(vg); + free_vg(vg); return r; } @@ -446,14 +446,14 @@ void check_current_backup(struct volume_group *vg) (vg->seqno == vg_backup->seqno) && (id_equal(&vg->id, &vg_backup->id))) { log_suppress(old_suppress); - vg_release(vg_backup); + free_vg(vg_backup); return; } log_suppress(old_suppress); if (vg_backup) { archive(vg_backup); - vg_release(vg_backup); + free_vg(vg_backup); } archive(vg); backup_locally(vg); diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 1f09b7b91..13a8482d0 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -857,7 +857,7 @@ static struct volume_group *_vg_read_file_name(struct format_instance *fid, * check that it contains the correct volume group. */ if (vgname && strcmp(vgname, vg->name)) { - dm_pool_destroy(vg->vgmem); + free_vg(vg); log_error("'%s' does not contain volume group '%s'.", read_path, vgname); return NULL; @@ -1085,7 +1085,7 @@ static int _scan_file(const struct format_type *fmt) path))) { /* FIXME Store creation host in vg */ lvmcache_update_vg(vg, 0); - dm_pool_destroy(vg->vgmem); + free_vg(vg); } } diff --git a/lib/locking/locking.h b/lib/locking/locking.h index cb1a55f08..88935004f 100644 --- a/lib/locking/locking.h +++ b/lib/locking/locking.h @@ -143,10 +143,10 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname); 0) #define unlock_vg(cmd, vol) lock_vol(cmd, vol, LCK_VG_UNLOCK) -#define unlock_and_release_vg(cmd, vg, vol) \ +#define unlock_and_free_vg(cmd, vg, vol) \ do { \ unlock_vg(cmd, vol); \ - vg_release(vg); \ + free_vg(vg); \ } while (0) #define resume_lv(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_RESUME) diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index c348d8b31..6994e0c1f 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -425,10 +425,10 @@ int remove_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg, force_t force); /* - * vg_release() must be called on every struct volume_group allocated + * free_vg() must be called on every struct volume_group allocated * by vg_create() or vg_read_internal() to free it when no longer required. */ -void vg_release(struct volume_group *vg); +void free_vg(struct volume_group *vg); /* Manipulate LVs */ struct logical_volume *lv_create_empty(const char *name, @@ -682,7 +682,7 @@ struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs, struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs, const char *vg_name, const char *vgid); int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs); -void cmd_vg_release(struct dm_list *cmd_vgs); +void free_cmd_vgs(struct dm_list *cmd_vgs); int find_replicator_vgs(struct logical_volume *lv); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index d913df01c..3b7061c55 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -366,7 +366,7 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name, } } out: - vg_release(vg); + free_vg(vg); return r; } @@ -920,7 +920,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name) /* is this vg name already in use ? */ if ((vg = vg_read_internal(cmd, vg_name, NULL, 1, &consistent))) { log_error("A volume group called '%s' already exists.", vg_name); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return _vg_make_handle(cmd, NULL, FAILED_EXIST); } @@ -988,7 +988,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name) return _vg_make_handle(cmd, vg, SUCCESS); bad: - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); /* FIXME: use _vg_make_handle() w/proper error code */ return NULL; } @@ -2700,7 +2700,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, } return correct_vg; } else { - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = NULL; } @@ -2741,7 +2741,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, (!use_precommitted && !(vg = mda->ops->vg_read(fid, vgname, mda)))) { inconsistent = 1; - vg_release(vg); + free_vg(vg); continue; } if (!correct_vg) { @@ -2760,13 +2760,13 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, inconsistent_seqno = 1; } if (vg->seqno > correct_vg->seqno) { - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = vg; } } if (vg != correct_vg) - vg_release(vg); + free_vg(vg); } /* Ensure every PV in the VG was in the cache */ @@ -2841,7 +2841,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, if (memlock()) inconsistent = 1; else { - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = NULL; } } else dm_list_iterate_items(pvl, &correct_vg->pvs) { @@ -2850,14 +2850,14 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) { log_debug("Cached VG %s had incorrect PV list", vgname); - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = NULL; break; } } if (correct_vg && inconsistent_mdas) { - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = NULL; } } @@ -2896,7 +2896,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, if (!correct_vg) { correct_vg = vg; if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg)) { - vg_release(vg); + free_vg(vg); return_NULL; } continue; @@ -2920,18 +2920,18 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, inconsistent_seqno = 1; } if (!_update_pv_list(cmd->mem, &all_pvs, vg)) { - vg_release(vg); - vg_release(correct_vg); + free_vg(vg); + free_vg(correct_vg); return_NULL; } if (vg->seqno > correct_vg->seqno) { - vg_release(correct_vg); + free_vg(correct_vg); correct_vg = vg; } } if (vg != correct_vg) - vg_release(vg); + free_vg(vg); } /* Give up looking */ @@ -2961,7 +2961,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, *consistent = 0; return correct_vg; } - vg_release(correct_vg); + free_vg(correct_vg); return NULL; } @@ -2989,7 +2989,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, cmd->handles_missing_pvs = 1; if (!vg_write(correct_vg)) { log_error("Automatic metadata correction failed"); - vg_release(correct_vg); + free_vg(correct_vg); cmd->handles_missing_pvs = saved_handles_missing_pvs; return NULL; } @@ -2998,7 +2998,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, if (!vg_commit(correct_vg)) { log_error("Automatic metadata correction commit " "failed"); - vg_release(correct_vg); + free_vg(correct_vg); return NULL; } @@ -3008,13 +3008,13 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, goto next_pv; } if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) { - vg_release(correct_vg); + free_vg(correct_vg); return_NULL; } log_error("Removing PV %s (%s) that no longer belongs to VG %s", pv_dev_name(pvl->pv), uuid, correct_vg->name); if (!pv_write_orphan(cmd, pvl->pv)) { - vg_release(correct_vg); + free_vg(correct_vg); return_NULL; } @@ -3036,7 +3036,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, "volume group %s", correct_vg->name); log_error("Please restore the metadata by running " "vgcfgrestore."); - vg_release(correct_vg); + free_vg(correct_vg); return NULL; } @@ -3056,7 +3056,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam if (!check_pv_segments(vg)) { log_error(INTERNAL_ERROR "PV segments corrupted in %s.", vg->name); - vg_release(vg); + free_vg(vg); return NULL; } @@ -3064,7 +3064,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam if (!check_lv_segments(lvl->lv, 0)) { log_error(INTERNAL_ERROR "LV segments corrupted in %s.", lvl->lv->name); - vg_release(vg); + free_vg(vg); return NULL; } } @@ -3076,7 +3076,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam if (!check_lv_segments(lvl->lv, 1)) { log_error(INTERNAL_ERROR "LV segments corrupted in %s.", lvl->lv->name); - vg_release(vg); + free_vg(vg); return NULL; } } @@ -3084,14 +3084,16 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam return vg; } -void vg_release(struct volume_group *vg) +void free_vg(struct volume_group *vg) { - if (!vg || !vg->vgmem) + if (!vg) return; - if (vg->cmd && vg->vgmem == vg->cmd->mem) + if (vg->cmd && vg->vgmem == vg->cmd->mem) { log_error(INTERNAL_ERROR "global memory pool used for VG %s", vg->name); + return; + } dm_pool_destroy(vg->vgmem); } @@ -3122,7 +3124,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd, "inconsistent", vg->name); return vg; } - vg_release(vg); + free_vg(vg); } /* Mustn't scan if memory locked: ensure cache gets pre-populated! */ @@ -3151,12 +3153,12 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd, if (!consistent) { log_error("Volume group %s metadata is " "inconsistent", vgname); - vg_release(vg); + free_vg(vg); return NULL; } return vg; } - vg_release(vg); + free_vg(vg); } return NULL; @@ -3190,7 +3192,7 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s, return lvl->lv; out: - vg_release(vg); + free_vg(vg); return NULL; } @@ -3384,12 +3386,12 @@ static int _get_pvs(struct cmd_context *cmd, int warnings, struct dm_list **pvsl dm_list_iterate_items(pvl, &vg->pvs) { if (!(pvl_copy = _copy_pvl(cmd->mem, pvl))) { log_error("PV list allocation failed"); - vg_release(vg); + free_vg(vg); return 0; } dm_list_add(results, &pvl_copy->list); } - vg_release(vg); + free_vg(vg); } init_pvmove(old_pvmove); @@ -3592,7 +3594,7 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd, return_NULL; if (!consistent) { - vg_release(vg); + free_vg(vg); return_NULL; } @@ -3664,7 +3666,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha /* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */ if (!consistent && !failure) { - vg_release(vg); + free_vg(vg); if (!(vg = _recover_vg(cmd, vg_name, vgid))) { log_error("Recovery of volume group \"%s\" failed.", vg_name); diff --git a/lib/metadata/replicator_manip.c b/lib/metadata/replicator_manip.c index b3a2fff66..79abca04f 100644 --- a/lib/metadata/replicator_manip.c +++ b/lib/metadata/replicator_manip.c @@ -590,16 +590,16 @@ int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs) * * \param cmd_vgs Contains list of cmd_vg entries. */ -void cmd_vg_release(struct dm_list *cmd_vgs) +void free_cmd_vgs(struct dm_list *cmd_vgs) { struct cmd_vg *cvl; /* Backward iterate cmd_vg list */ dm_list_iterate_back_items(cvl, cmd_vgs) { if (vg_read_error(cvl->vg)) - vg_release(cvl->vg); + free_vg(cvl->vg); else - unlock_and_release_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name); + unlock_and_free_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name); cvl->vg = NULL; } } @@ -687,7 +687,7 @@ void lv_release_replicator_vgs(struct logical_volume *lv) dm_list_iterate_back_items(rsite, &first_seg(lv)->replicator->rsites) if (rsite->vg_name && rsite->vg) { - vg_release(rsite->vg); + free_vg(rsite->vg); rsite->vg = NULL; } } diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c index 66391a335..281851971 100644 --- a/liblvm/lvm_vg.c +++ b/liblvm/lvm_vg.c @@ -56,7 +56,7 @@ vg_t lvm_vg_create(lvm_t libh, const char *vg_name) vg = vg_create((struct cmd_context *)libh, vg_name); /* FIXME: error handling is still TBD */ if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); return NULL; } vg->open_mode = 'w'; @@ -159,9 +159,9 @@ int lvm_vg_write(vg_t vg) int lvm_vg_close(vg_t vg) { if (vg_read_error(vg) == FAILED_LOCKING) - vg_release(vg); + free_vg(vg); else - unlock_and_release_vg(vg->cmd, vg, vg->name); + unlock_and_free_vg(vg->cmd, vg, vg->name); return 0; } @@ -196,7 +196,7 @@ vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode, vg = vg_read((struct cmd_context *)libh, vgname, NULL, internal_flags); if (vg_read_error(vg)) { /* FIXME: use log_errno either here in inside vg_read */ - vg_release(vg); + free_vg(vg); return NULL; } /* FIXME: combine this with locking ? */ diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 95b60cc64..7c7826bbd 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -1619,7 +1619,7 @@ static struct logical_volume *get_vg_lock_and_logical_volume(struct cmd_context { /* * Returns NULL if the requested LV doesn't exist; - * otherwise the caller must vg_release(lv->vg) + * otherwise the caller must free_vg(lv->vg) * - it is also up to the caller to unlock_vg() as needed */ struct volume_group *vg; @@ -1627,13 +1627,13 @@ static struct logical_volume *get_vg_lock_and_logical_volume(struct cmd_context vg = _get_lvconvert_vg(cmd, vg_name, NULL); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); return_NULL; } if (!(lv = _get_lvconvert_lv(cmd, vg, lv_name, NULL, 0))) { log_error("Can't find LV %s in VG %s", lv_name, vg_name); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return NULL; } @@ -1686,7 +1686,7 @@ bad: ret = poll_logical_volume(cmd, lp->lv_to_poll, lp->wait_completion); - vg_release(lv->vg); + free_vg(lv->vg); out: init_ignore_suspended_devices(saved_ignore_suspended_devices); return ret; @@ -1736,7 +1736,7 @@ static int lvconvert_merge_single(struct cmd_context *cmd, struct logical_volume } } - vg_release(refreshed_lv->vg); + free_vg(refreshed_lv->vg); return ret; } diff --git a/tools/lvcreate.c b/tools/lvcreate.c index dec786b8a..13b592659 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -546,7 +546,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv) log_verbose("Finding volume group \"%s\"", lp.vg_name); vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; return ECMD_FAILED; } @@ -561,6 +561,6 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv) r = ECMD_FAILED; } out: - unlock_and_release_vg(cmd, vg, lp.vg_name); + unlock_and_free_vg(cmd, vg, lp.vg_name); return r; } diff --git a/tools/lvrename.c b/tools/lvrename.c index 2342ad0ed..db47a8bc6 100644 --- a/tools/lvrename.c +++ b/tools/lvrename.c @@ -104,7 +104,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) log_verbose("Checking for existing volume group \"%s\"", vg_name); vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; return ECMD_FAILED; } @@ -123,6 +123,6 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) r = ECMD_PROCESSED; error: - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return r; } diff --git a/tools/lvresize.c b/tools/lvresize.c index 9ce73b77c..c970f3f53 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -738,7 +738,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv) log_verbose("Finding volume group %s", lp.vg_name); vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; return ECMD_FAILED; } @@ -746,7 +746,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv) if (!(r = _lvresize(cmd, vg, &lp))) stack; - unlock_and_release_vg(cmd, vg, lp.vg_name); + unlock_and_free_vg(cmd, vg, lp.vg_name); return r; } diff --git a/tools/polldaemon.c b/tools/polldaemon.c index 8372ef257..50579baba 100644 --- a/tools/polldaemon.c +++ b/tools/polldaemon.c @@ -183,7 +183,7 @@ static int _wait_for_single_lv(struct cmd_context *cmd, const char *name, const /* Locks the (possibly renamed) VG again */ vg = parms->poll_fns->get_copy_vg(cmd, name, uuid); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); log_error("ABORTING: Can't reread VG for %s", name); /* What more could we do here? */ return 0; @@ -193,16 +193,16 @@ static int _wait_for_single_lv(struct cmd_context *cmd, const char *name, const parms->lv_type))) { log_error("ABORTING: Can't find LV in %s for %s", vg->name, name); - unlock_and_release_vg(cmd, vg, vg->name); + unlock_and_free_vg(cmd, vg, vg->name); return 0; } if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) { - unlock_and_release_vg(cmd, vg, vg->name); + unlock_and_free_vg(cmd, vg, vg->name); return 0; } - unlock_and_release_vg(cmd, vg, vg->name); + unlock_and_free_vg(cmd, vg, vg->name); /* * FIXME Sleeping after testing, while preferred, also works around diff --git a/tools/pvchange.c b/tools/pvchange.c index 02d351050..28e71b845 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -240,7 +240,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) } vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; continue; } @@ -254,7 +254,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) total++; done += _pvchange_single(cmd, vg, pvl->pv, NULL); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); } } else { log_verbose("Scanning for physical volume names"); @@ -275,7 +275,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) dm_list_iterate_items(sll, vgnames) { vg = vg_read_for_update(cmd, sll->str, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; continue; } @@ -285,7 +285,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv) pvl->pv, NULL); } - unlock_and_release_vg(cmd, vg, sll->str); + unlock_and_free_vg(cmd, vg, sll->str); } } } diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 3dc3a3bd0..a955d3737 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -74,7 +74,7 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd, pp->pe_start = pv_pe_start(existing_pvl->pv); pp->extent_size = pv_pe_size(existing_pvl->pv); pp->extent_count = pv_pe_count(existing_pvl->pv); - vg_release(vg); + free_vg(vg); } if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) { diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c index 47def172a..1ae0339ab 100644 --- a/tools/pvdisplay.c +++ b/tools/pvdisplay.c @@ -32,7 +32,7 @@ static int _pvdisplay_single(struct cmd_context *cmd, vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0); if (vg_read_error(vg)) { log_error("Skipping volume group %s", vg_name); - vg_release(vg); + free_vg(vg); /* FIXME If CLUSTERED should return ECMD_PROCESSED here */ return ECMD_FAILED; } @@ -85,7 +85,7 @@ out: if (vg_name) unlock_vg(cmd, vg_name); if (!old_vg) - vg_release(vg); + free_vg(vg); return ret; } diff --git a/tools/pvmove.c b/tools/pvmove.c index ce48c68ee..51f442fab 100644 --- a/tools/pvmove.c +++ b/tools/pvmove.c @@ -445,7 +445,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name, vg = _get_vg(cmd, pv_vg_name(pv)); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; return ECMD_FAILED; } @@ -510,7 +510,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name, /* LVs are all in status LOCKED */ r = ECMD_PROCESSED; out: - unlock_and_release_vg(cmd, vg, pv_vg_name(pv)); + unlock_and_free_vg(cmd, vg, pv_vg_name(pv)); return r; } diff --git a/tools/pvresize.c b/tools/pvresize.c index af499e5bc..8582ef429 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -58,7 +58,7 @@ static int _pv_resize_single(struct cmd_context *cmd, vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); log_error("Unable to read volume group \"%s\".", vg_name); return 0; @@ -164,7 +164,7 @@ static int _pv_resize_single(struct cmd_context *cmd, out: unlock_vg(cmd, vg_name); if (!old_vg) - vg_release(vg); + free_vg(vg); return r; } diff --git a/tools/reporter.c b/tools/reporter.c index 40d3c9aaf..fbd0c2745 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -65,7 +65,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, }; if (!(_free_vg.vgmem = dm_pool_create("_free_vg", 10240))) - return ECMD_FAILED; + return ECMD_FAILED; struct logical_volume _free_logical_volume = { .vg = vg ?: &_free_vg, @@ -110,7 +110,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd, goto_out; } out: - dm_pool_destroy(_free_vg.vgmem); + free_vg(&_free_vg); return ret; } @@ -145,7 +145,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg, vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0); if (vg_read_error(vg)) { log_error("Skipping volume group %s", vg_name); - vg_release(vg); + free_vg(vg); return ECMD_FAILED; } @@ -185,7 +185,7 @@ out: unlock_vg(cmd, vg_name); if (!old_vg) - vg_release(vg); + free_vg(vg); return ret; } diff --git a/tools/toollib.c b/tools/toollib.c index 9be993629..0a1a8d489 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -311,7 +311,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } if (!cmd_vg_read(cmd, &cmd_vgs)) { - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); if (ret_max < ECMD_FAILED) { log_error("Skipping volume group %s", vgname); ret_max = ECMD_FAILED; @@ -337,7 +337,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, dm_pool_strdup(cmd->mem, lv_name + 1))) { log_error("strlist allocation failed"); - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); return ECMD_FAILED; } } @@ -355,7 +355,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, dm_list_init(&lvnames); dm_list_splice(&lvnames, &failed_lvnames); - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); if (!cmd_vg_read(cmd, &cmd_vgs)) { ret = ECMD_FAILED; /* break */ break; @@ -364,7 +364,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, if (ret > ret_max) ret_max = ret; - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); /* FIXME: logic for breaking command is not consistent */ if (sigint_caught()) return ECMD_FAILED; @@ -392,7 +392,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd, vg = vg_read(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); log_error("Skipping volume group %s", vg_name); return ECMD_FAILED; } @@ -404,7 +404,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd, if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) { log_error("Unable to find %s in volume group %s", pv_dev_name(pv), vg_name); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return ECMD_FAILED; } @@ -427,7 +427,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd, if (vg_name) unlock_vg(cmd, vg_name); if (!old_vg) - vg_release(vg); + free_vg(vg); return ret_max; } @@ -498,10 +498,10 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name, if (!cvl_vg->vg->cmd_missing_vgs) break; - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); } - cmd_vg_release(&cmd_vgs); + free_cmd_vgs(&cmd_vgs); return (ret > ret_max) ? ret : ret_max; } @@ -774,7 +774,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, vg = vg_read(cmd, sll->str, NULL, flags); if (vg_read_error(vg)) { ret_max = ECMD_FAILED; - vg_release(vg); + free_vg(vg); stack; continue; } @@ -783,7 +783,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, handle, process_single_pv); - unlock_and_release_vg(cmd, vg, sll->str); + unlock_and_free_vg(cmd, vg, sll->str); if (ret > ret_max) ret_max = ret; diff --git a/tools/vgcreate.c b/tools/vgcreate.c index 3c4c6d2d4..49574f335 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -56,7 +56,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) log_error("A volume group called %s already exists.", vp_new.vg_name); else log_error("Can't get lock for %s.", vp_new.vg_name); - vg_release(vg); + free_vg(vg); return ECMD_FAILED; } @@ -120,13 +120,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) log_print("%s%colume group \"%s\" successfully created", clustered_message, *clustered_message ? 'v' : 'V', vg->name); - vg_release(vg); + free_vg(vg); return ECMD_PROCESSED; bad: unlock_vg(cmd, VG_ORPHANS); bad_orphan: - vg_release(vg); + free_vg(vg); unlock_vg(cmd, vp_new.vg_name); return ECMD_FAILED; } diff --git a/tools/vgextend.c b/tools/vgextend.c index f91b1d3f3..a0c166b06 100644 --- a/tools/vgextend.c +++ b/tools/vgextend.c @@ -72,7 +72,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) log_verbose("Checking for volume group \"%s\"", vg_name); vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); stack; return ECMD_FAILED; } @@ -92,7 +92,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) } else { /* no --restore, normal vgextend */ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { log_error("Can't get lock for orphan PVs"); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return ECMD_FAILED; } @@ -135,6 +135,6 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) bad: if (!arg_count(cmd, restoremissing_ARG)) unlock_vg(cmd, VG_ORPHANS); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return r; } diff --git a/tools/vgmerge.c b/tools/vgmerge.c index 403a5e040..4d55510e2 100644 --- a/tools/vgmerge.c +++ b/tools/vgmerge.c @@ -22,7 +22,7 @@ static struct volume_group *_vgmerge_vg_read(struct cmd_context *cmd, log_verbose("Checking for volume group \"%s\"", vg_name); vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); return NULL; } return vg; @@ -54,7 +54,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, vg_to = _vgmerge_vg_read(cmd, vg_name_to); if (!vg_to) { stack; - unlock_and_release_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_from, vg_name_from); return ECMD_FAILED; } } else { @@ -67,7 +67,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, vg_from = _vgmerge_vg_read(cmd, vg_name_from); if (!vg_from) { stack; - unlock_and_release_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_to, vg_name_to); return ECMD_FAILED; } } @@ -148,11 +148,11 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, r = ECMD_PROCESSED; bad: if (lock_vg_from_first) { - unlock_and_release_vg(cmd, vg_to, vg_name_to); - unlock_and_release_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_from, vg_name_from); } else { - unlock_and_release_vg(cmd, vg_from, vg_name_from); - unlock_and_release_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_to, vg_name_to); } return r; } diff --git a/tools/vgreduce.c b/tools/vgreduce.c index eceafcd5a..4aa8f01e6 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -450,7 +450,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name); r = ECMD_PROCESSED; bad: - unlock_and_release_vg(cmd, orphan_vg, VG_ORPHANS); + unlock_and_free_vg(cmd, orphan_vg, VG_ORPHANS); return r; } @@ -524,7 +524,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) goto out; } - vg_release(vg); + free_vg(vg); log_verbose("Trying to open VG %s for recovery...", vg_name); vg = vg_read_for_update(cmd, vg_name, NULL, @@ -570,7 +570,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) } out: init_ignore_suspended_devices(saved_ignore_suspended_devices); - unlock_and_release_vg(cmd, vg, vg_name); + unlock_and_free_vg(cmd, vg, vg_name); return ret; diff --git a/tools/vgrename.c b/tools/vgrename.c index 3c383fbd6..98be9a960 100644 --- a/tools/vgrename.c +++ b/tools/vgrename.c @@ -25,7 +25,7 @@ static struct volume_group *_get_old_vg_for_rename(struct cmd_context *cmd, nevertheless. */ vg = vg_read_for_update(cmd, vg_name_old, vgid, READ_ALLOW_EXPORTED); if (vg_read_error(vg)) { - vg_release(vg); + free_vg(vg); return_NULL; } @@ -117,7 +117,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, return_0; if (!_lock_new_vg_for_rename(cmd, vg_name_new)) { - unlock_and_release_vg(cmd, vg, vg_name_old); + unlock_and_free_vg(cmd, vg, vg_name_old); return_0; } } else { @@ -168,7 +168,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, backup_remove(cmd, vg_name_old); unlock_vg(cmd, vg_name_new); - unlock_and_release_vg(cmd, vg, vg_name_old); + unlock_and_free_vg(cmd, vg, vg_name_old); log_print("Volume group \"%s\" successfully renamed to \"%s\"", vg_name_old, vg_name_new); @@ -182,9 +182,9 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, error: if (lock_vg_old_first) { unlock_vg(cmd, vg_name_new); - unlock_and_release_vg(cmd, vg, vg_name_old); + unlock_and_free_vg(cmd, vg, vg_name_old); } else { - unlock_and_release_vg(cmd, vg, vg_name_old); + unlock_and_free_vg(cmd, vg, vg_name_old); unlock_vg(cmd, vg_name_new); } return 0; diff --git a/tools/vgsplit.c b/tools/vgsplit.c index e6a65111c..045c699ff 100644 --- a/tools/vgsplit.c +++ b/tools/vgsplit.c @@ -223,16 +223,16 @@ static struct volume_group *_vgsplit_to(struct cmd_context *cmd, vg_to = vg_create(cmd, vg_name_to); if (vg_read_error(vg_to) == FAILED_LOCKING) { log_error("Can't get lock for %s", vg_name_to); - vg_release(vg_to); + free_vg(vg_to); return NULL; } if (vg_read_error(vg_to) == FAILED_EXIST) { *existing_vg = 1; - vg_release(vg_to); + free_vg(vg_to); vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0); if (vg_read_error(vg_to)) { - vg_release(vg_to); + free_vg(vg_to); stack; return NULL; } @@ -258,7 +258,7 @@ static struct volume_group *_vgsplit_from(struct cmd_context *cmd, vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0); if (vg_read_error(vg_from)) { - vg_release(vg_from); + free_vg(vg_from); return NULL; } return vg_from; @@ -333,7 +333,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv) vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg); if (!vg_to) { - unlock_and_release_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_from, vg_name_from); stack; return ECMD_FAILED; } @@ -345,7 +345,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv) } vg_from = _vgsplit_from(cmd, vg_name_from); if (!vg_from) { - unlock_and_release_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_to, vg_name_to); stack; return ECMD_FAILED; } @@ -462,7 +462,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv) * Finally, remove the EXPORTED flag from the new VG and write it out. */ if (!test_mode()) { - vg_release(vg_to); + free_vg(vg_to); vg_to = vg_read_for_update(cmd, vg_name_to, NULL, READ_ALLOW_EXPORTED); if (vg_read_error(vg_to)) { @@ -487,11 +487,11 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv) bad: if (lock_vg_from_first) { - unlock_and_release_vg(cmd, vg_to, vg_name_to); - unlock_and_release_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_from, vg_name_from); } else { - unlock_and_release_vg(cmd, vg_from, vg_name_from); - unlock_and_release_vg(cmd, vg_to, vg_name_to); + unlock_and_free_vg(cmd, vg_from, vg_name_from); + unlock_and_free_vg(cmd, vg_to, vg_name_to); } return r; }