master - pvremove: Avoid metadata re-reads & related error messages.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e97023804a8aa94d723025506fa23cf4a5c323e9 Commit: e97023804a8aa94d723025506fa23cf4a5c323e9 Parent: 0987f290a7b53840c2811392868f050d9a632ea3 Author: Petr Rockai <[email protected]> AuthorDate: Tue Jan 6 14:17:53 2015 +0100 Committer: Petr Rockai <[email protected]> CommitterDate: Tue Jan 6 14:27:30 2015 +0100
pvremove: Avoid metadata re-reads & related error messages.
--- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 4 ++- lib/metadata/pv_manip.c | 61 +++++++++++++++++++++++++++---------- liblvm/lvm_pv.c | 9 +++++- test/shell/pvremove-warnings.sh | 5 +++ tools/pvremove.c | 15 +++++---- 6 files changed, 69 insertions(+), 26 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.115 - ===================================== + Avoid excessive re-reading of metadata and related error messages in pvremove. Check for cmirror availability during cluster mirror creation and activation. Add cache_policy and cache_settings reporting fields. Add missing recognition for --binary option with {pv,vg,lv}display -C.
lib/metadata/metadata-exported.h +3 -1
@@ -635,7 +635,9 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,int pvremove_single (struct cmd_context *cmd,const char *pv_name,void *handle __attribute__((unused)),unsigned force_count, -unsigned prompt); +unsigned prompt,struct dm_list *pvslist); +int pvremove_many (struct cmd_context *cmd,struct dm_list *pv_names, +unsigned force_count,unsigned prompt); int pv_resize_single(struct cmd_context *cmd, struct volume_group *vg,
lib/metadata/pv_manip.c +44 -17
107 lines not on this page · raw message
liblvm/lvm_pv.c +8 -1
@@ -16,6 +16,7 @@#include "lib.h" #include "metadata.h" #include "lvm-string.h" +#include "str_list.h" #include "lvm_misc.h" #include "lvm2app.h" #include "locking.h"
@@ -118,8 +119,14 @@ int lvm_pv_remove(lvm_t libh, const char *pv_name)int rc =0 ;struct cmd_context *cmd = (struct cmd_context *)libh;struct saved_env e =store_user_env (cmd); +struct dm_list pv_names; -if (!pvremove_single (cmd, pv_name,NULL ,0 ,0 )) +dm_list_init (&pv_names); + +if (!str_list_add (cmd->mem, &pv_names, pv_name)) + rc =-1 ; + +if (rc >=0 && !pvremove_many (cmd, &pv_names,0 ,0 )) rc =-1 ;restore_user_env (&e);
test/shell/pvremove-warnings.sh +5 -0
@@ -14,3 +14,8 @@ aux prepare_devs 2 pvcreate "$dev1" "$dev2" pvremove "$dev1" "$dev2" 2>&1 | tee pvremove.txt not grep "No physical" pvremove.txt + +pvcreate "$dev1" "$dev2" +vgcreate bla $dev1 $dev2 +pvremove -ff -y $dev1 $dev2 2>&1 | tee pvremove.txt +not grep "device missing" pvremove.txt
tools/pvremove.c +8 -7
@@ -18,9 +18,9 @@int pvremove (struct cmd_context *cmd,int argc,char **argv) {int i; -int ret =ECMD_PROCESSED ;unsigned force_count;unsigned prompt; +struct dm_list pv_names;if (!argc) {log_error ("Please enter a physical volume path" );
@@ -30,15 +30,16 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv) force_count =arg_count (cmd, force_ARG); prompt =arg_count (cmd, yes_ARG); +dm_list_init (&pv_names); +for (i =0 ; i < argc; i++) {dm_unescape_colons_and_at_signs (argv[i],NULL ,NULL ); -if (!pvremove_single (cmd, argv[i],NULL , force_count, prompt)) { - stack; - ret =ECMD_FAILED ; - } -if (sigint_caught ()) +if (!str_list_add (cmd->mem, &pv_names, argv[i])) return_ECMD_FAILED; } -return ret; +if (!pvremove_many (cmd, &pv_names, force_count, prompt)) + return_ECMD_FAILED; + +return ECMD_PROCESSED ; }