diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2011-03-11 14:56:56 +0000 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2011-03-11 14:56:56 +0000 |
commit | 84f48499a3213f425f3d96e45cf7a80071f3022c (patch) | |
tree | 1a806f2b77d921cf7509fb032cb9b99cd9a3213f /tools/pvremove.c | |
parent | 1307ddf4cfefd68b2fea4a3b6551777f1d2b9b25 (diff) | |
download | lvm2-84f48499a3213f425f3d96e45cf7a80071f3022c.tar.gz lvm2-84f48499a3213f425f3d96e45cf7a80071f3022c.tar.xz lvm2-84f48499a3213f425f3d96e45cf7a80071f3022c.zip |
Add new free_pv_fid fn and use it throughout to free all attached fids.
Since format instances will use own memory pool, it's necessary to properly
deallocate it. For now, only fid is deallocated. The PV structure itself
still uses cmd mempool mostly, but anytime we'd like to add a mempool
in the struct physical_volume, we can just rename this fn to free_pv and
add the code (like we have free_vg fn for VGs).
Diffstat (limited to 'tools/pvremove.c')
-rw-r--r-- | tools/pvremove.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/pvremove.c b/tools/pvremove.c index 36da62da..060303ee 100644 --- a/tools/pvremove.c +++ b/tools/pvremove.c @@ -49,31 +49,34 @@ static int pvremove_check(struct cmd_context *cmd, const char *name) if (!scan_vgs_for_pvs(cmd, 0)) { log_error("Rescan for PVs without metadata areas " "failed."); - return 0; + goto bad; } + free_pv_fid(pv); if (!(pv = pv_read(cmd, name, NULL, 1, 0))) { log_error("Failed to read physical volume %s", name); - return 0; + goto bad; } } /* orphan ? */ - if (is_orphan(pv)) + if (is_orphan(pv)) { + free_pv_fid(pv); return 1; + } /* Allow partial & exported VGs to be destroyed. */ /* we must have -ff to overwrite a non orphan */ if (arg_count(cmd, force_ARG) < 2) { log_error("PV %s belongs to Volume Group %s so please use vgreduce first.", name, pv_vg_name(pv)); log_error("(If you are certain you need pvremove, then confirm by using --force twice.)"); - return 0; + goto bad; } /* prompt */ if (!arg_count(cmd, yes_ARG) && yes_no_prompt(_really_wipe, name, pv_vg_name(pv)) == 'n') { log_error("%s: physical volume label not removed", name); - return 0; + goto bad; } if (arg_count(cmd, force_ARG)) { @@ -84,7 +87,12 @@ static int pvremove_check(struct cmd_context *cmd, const char *name) !is_orphan(pv) ? "\"" : ""); } + free_pv_fid(pv); return 1; + +bad: + free_pv_fid(pv); + return 0; } static int pvremove_single(struct cmd_context *cmd, const char *pv_name, |