FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 02-26-2010, 10:36 PM
Jonathan Brassow
 
Default LVM: subdivide mirror creation function

Patch name: lvm-subdivide-mirror-creation-function.patch

Here we carve out a portion of the 'add_mirror_images'
function that will be useful in more than one place
later.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: LVM2/lib/metadata/mirror.c
================================================== =================
--- LVM2.orig/lib/metadata/mirror.c
+++ LVM2/lib/metadata/mirror.c
@@ -1547,6 +1547,46 @@ static struct logical_volume *_create_mi
return log_lv;
}

+/*
+ * Returns: 1 on success, 0 on error
+ */
+static int _form_mirror(struct cmd_context *cmd, struct alloc_handle *ah,
+ struct logical_volume *lv,
+ uint32_t mirrors, uint32_t region_size)
+{
+ struct logical_volume **img_lvs;
+
+ /*
+ * insert a mirror layer
+ */
+ if (dm_list_size(&lv->segments) != 1 ||
+ seg_type(first_seg(lv), 0) != AREA_LV)
+ if (!insert_layer_for_lv(cmd, lv, 0, "_mimage_%d"))
+ return 0;
+
+ /*
+ * create mirror image LVs
+ */
+ if (!(img_lvs = alloca(sizeof(*img_lvs) * mirrors))) {
+ log_error("img_lvs allocation failed. "
+ "Remove new LV and retry.");
+ return 0;
+ }
+
+ if (!_create_mimage_lvs(ah, mirrors, lv, img_lvs))
+ return 0;
+
+ if (!lv_add_mirror_lvs(lv, img_lvs, mirrors,
+ MIRROR_IMAGE | (lv->status & LOCKED),
+ region_size)) {
+ log_error("Aborting. Failed to add mirror segment. "
+ "Remove new LV and retry.");
+ return 0;
+ }
+
+ return 1;
+}
+
static struct logical_volume *_set_up_mirror_log(struct cmd_context *cmd,
struct alloc_handle *ah,
struct logical_volume *lv,
@@ -1696,7 +1736,6 @@ int add_mirror_images(struct cmd_context
struct alloc_handle *ah;
const struct segment_type *segtype;
struct dm_list *parallel_areas;
- struct logical_volume **img_lvs;
struct logical_volume *log_lv = NULL;

if (stripes > 1) {
@@ -1736,34 +1775,9 @@ int add_mirror_images(struct cmd_context
So from here on, if failure occurs, the log must be explicitly
removed and the updated vg metadata should be committed. */

- /*
- * insert a mirror layer
- */
- if (dm_list_size(&lv->segments) != 1 ||
- seg_type(first_seg(lv), 0) != AREA_LV)
- if (!insert_layer_for_lv(cmd, lv, 0, "_mimage_%d"))
- goto out_remove_log;
-
- /*
- * create mirror image LVs
- */
- if (!(img_lvs = alloca(sizeof(*img_lvs) * mirrors))) {
- log_error("img_lvs allocation failed. "
- "Remove new LV and retry.");
- goto out_remove_log;
- }
-
- if (!_create_mimage_lvs(ah, mirrors, lv, img_lvs))
+ if (!_form_mirror(cmd, ah, lv, mirrors, region_size))
goto out_remove_log;

- if (!lv_add_mirror_lvs(lv, img_lvs, mirrors,
- MIRROR_IMAGE | (lv->status & LOCKED),
- region_size)) {
- log_error("Aborting. Failed to add mirror segment. "
- "Remove new LV and retry.");
- goto out_remove_images;
- }
-
if (log_count && !attach_mirror_log(first_seg(lv), log_lv))
stack;


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 09:22 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org