[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH mirror 13/13] Allow disk logs for temporary resync mirror



With the previous patch ("12/13"), we can use multiple disk logs
in the LV.
So unlock the use of disk log for added mirror.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Changes since rev1:
  * Modified _create_mirror_log() to retry with "_mlog%d" once
    "_mlog" suffix fails.

Index: LVM2.work/lib/metadata/mirror.c
===================================================================
--- LVM2.work.orig/lib/metadata/mirror.c
+++ LVM2.work/lib/metadata/mirror.c
@@ -1081,6 +1081,7 @@ static struct logical_volume *_create_mi
 	struct logical_volume *log_lv;
 	char *log_name;
 	size_t len;
+	int retry_count = 1; /* FIXME always "_mlog%d" */
 
 	len = strlen(lv_name) + 32;
 	if (!(log_name = alloca(len))) {
@@ -1088,15 +1089,21 @@ static struct logical_volume *_create_mi
 		return NULL;
 	}
 
-	if (dm_snprintf(log_name, len, "%s_mlog", lv->name) < 0) {
+  retry:
+	if (dm_snprintf(log_name, len, "%s_mlog%s", lv->name,
+			retry_count ? "%d" : "") < 0) {
 		log_error("log_name allocation failed.");
 		return NULL;
 	}
 
 	if (!(log_lv = lv_create_empty(log_name, NULL,
 				       VISIBLE_LV | LVM_READ | LVM_WRITE,
-				       alloc, 0, lv->vg)))
-		return_NULL;
+				       alloc, 0, lv->vg))) {
+		if (!retry_count++)
+			goto retry;
+		else
+			return_NULL;
+	}
 
 	if (!lv_add_log_segment(ah, log_lv))
 		return_NULL;
Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -387,8 +387,6 @@ static int lvconvert_mirrors(struct cmd_
 			return 1;
 		}
 	} else if (lp->mirrors > existing_mirrors) {
-		/* FIXME: can't have multiple mlogs. force corelog. */
-		corelog = 1;
 		if (!insert_layer_for_lv(cmd, lv, 0, "_resync%d")) {
 			log_error("Failed to insert resync layer");
 			return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]