[lvm-devel] [PATCH 6/9] Refactor vgsplit - create _vgsplit_from function to open source vg.
Dave Wysochanski
dwysocha at redhat.com
Thu Aug 13 21:27:00 UTC 2009
Should be no functional change and allows future reorder of source and dest
vgs.
Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
---
tools/vgsplit.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 508d547..bfcd7f5 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -244,6 +244,27 @@ static struct volume_group *_vgsplit_to(struct cmd_context *cmd,
}
/*
+ * Open the source of the vgsplit operation.
+ * Returns
+ * - non-NULL: VG handle w/VG lock held
+ * - NULL: no VG lock held
+ */
+static struct volume_group *_vgsplit_from(struct cmd_context *cmd,
+ const char *vg_name_from)
+{
+ struct volume_group *vg_from;
+
+ log_verbose("Checking for volume group \"%s\"", vg_name_from);
+
+ vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
+ if (vg_read_error(vg_from)) {
+ vg_release(vg_from);
+ return NULL;
+ }
+ return vg_from;
+}
+
+/*
* Has the user given an option related to a new vg as the split destination?
*/
static int new_vg_option_specified(struct cmd_context *cmd)
@@ -293,13 +314,9 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- log_verbose("Checking for volume group \"%s\"", vg_name_from);
-
- vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
- if (vg_read_error(vg_from)) {
- vg_release(vg_from);
+ vg_from = _vgsplit_from(cmd, vg_name_from);
+ if (!vg_from)
return ECMD_FAILED;
- }
/*
* Set metadata format of original VG.
--
1.6.0.6
More information about the lvm-devel
mailing list