Skip to contentSkip to conversation

master - toollib: initialize handles (including reporting for selection) for _select_match_* used in process_each_* fns

PATCH Peter Rajnoha 1 participant 1 message Feb 10, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56011918e66adf1f639436fd6781a89ad61eb8f4
Commit:        56011918e66adf1f639436fd6781a89ad61eb8f4
Parent:        a91bc7a19b8f439fa1d21101ad5c11d72413d4c0
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Fri Nov 28 15:04:25 2014 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Tue Feb 10 16:05:29 2015 +0100

toollib: initialize handles (including reporting for selection) for _select_match_* used in process_each_* fns

Call _init_processing_handle, _init_selection_handle and _destroy_processing_handle in process_each_* and related functions to set up and destroy handles used while processing items.

---
 tools/lvconvert.c   |   16 ++++--
 tools/polldaemon.c  |    2 +
 tools/pvresize.c    |   11 +++--
 tools/toollib.c     |  135 +++++++++++++++++++++++++++++++++++----------------
 tools/vgcfgbackup.c |    1 +
 5 files changed, 113 insertions(+), 52 deletions(-)
tools/lvconvert.c +10 -6
index f9f666d..2df2483 100644
@@ -3538,6 +3538,7 @@ static int _lvconvert_merge_single(struct cmd_context *cmd, struct logical_volum
 
 int lvconvert(struct cmd_context * cmd, int argc, char **argv)
 {
+	int ret = ECMD_PROCESSED;
 	struct lvconvert_params lp = {
 		.target_attr = ~0,
 	};
@@ -3547,13 +3548,16 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
 					    .custom_handle = &lp };
 
 	if (!_read_params(cmd, argc, argv, &lp)) {
-		stack;
-		return EINVALID_CMD_LINE;
+		ret = EINVALID_CMD_LINE;
+		goto_out;
 	}
 
 	if (lp.merge)
-		return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, &handle,
-				       &_lvconvert_merge_single);
-
-	return lvconvert_single(cmd, &lp);
+		ret = process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, &handle,
+				    &_lvconvert_merge_single);
+	else
+		ret = lvconvert_single(cmd, &lp);
+out:
+	destroy_processing_handle(cmd, &handle, 0);
+	return ret;
 }
tools/polldaemon.c +2 -0
index 3eb9b17..204c495 100644
@@ -240,6 +240,8 @@ static void _poll_for_all_vgs(struct cmd_context *cmd,
 			break;
 		sleep(parms->interval);
 	}
+
+	destroy_processing_handle(cmd, &handle, 0);
 }
 
 /*
tools/pvresize.c +7 -4
index a2f6b8b..f6253d9 100644
@@ -50,16 +50,18 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
 	struct processing_handle handle = { .internal_report_for_select = 1,
 					    .selection_handle = NULL,
 					    .custom_handle = &params };
-	int ret;
+	int ret = ECMD_PROCESSED;
 
 	if (!argc) {
 		log_error("Please supply physical volume(s)");
-		return EINVALID_CMD_LINE;
+		ret = EINVALID_CMD_LINE;
+		goto out;
 	}
 
 	if (arg_sign_value(cmd, physicalvolumesize_ARG, SIGN_NONE) == SIGN_MINUS) {
 		log_error("Physical volume size may not be negative");
-		return EINVALID_CMD_LINE;
+		ret = EINVALID_CMD_LINE;
+		goto out;
 	}
 
 	params.new_size = arg_uint64_value(cmd, physicalvolumesize_ARG,
@@ -73,6 +75,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
 
 	log_print_unless_silent("%d physical volume(s) resized / %d physical volume(s) "
 				"not resized", params.done, params.total - params.done);
-
+out:
+	destroy_processing_handle(cmd, &handle, 0);
 	return ret;
 }
tools/toollib.c +93 -42

254 lines not on this page · raw message

tools/vgcfgbackup.c +1 -0
index ee65f18..0a6c5f2 100644
@@ -96,5 +96,6 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
 
 	init_pvmove(0);
 
+	destroy_processing_handle(cmd, &handle, 0);
 	return ret;
 }