[DRBD-cvs] svn commit by phil - r3089 - in branches/drbd-8.2: scripts user - Changed drbdadm to accept device, disk and meta-disk in

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed Oct 3 15:45:54 CEST 2007


Author: phil
Date: 2007-10-03 15:45:44 +0200 (Wed, 03 Oct 2007)
New Revision: 3089

Modified:
   branches/drbd-8.2/scripts/drbd.conf
   branches/drbd-8.2/user/drbdadm.h
   branches/drbd-8.2/user/drbdadm_main.c
   branches/drbd-8.2/user/drbdadm_parser.c
Log:
Changed drbdadm to accept device, disk and meta-disk in the
resource section as well.


Modified: branches/drbd-8.2/scripts/drbd.conf
===================================================================
--- branches/drbd-8.2/scripts/drbd.conf	2007-10-03 12:45:04 UTC (rev 3088)
+++ branches/drbd-8.2/scripts/drbd.conf	2007-10-03 13:45:44 UTC (rev 3089)
@@ -428,18 +428,18 @@
   syncer {
   }
 
+  # It is valid to move device, disk and meta-disk to the
+  # resource level.
+  device	/dev/drbd1;
+  disk		/dev/hde6;
+  meta-disk	/dev/somewhere [7];
+
   on amd {
-    device	/dev/drbd1;
-    disk	/dev/hde6;
     address	192.168.22.11:7789;
-    meta-disk	/dev/somewhere [7];
   }
 
   on alf {
-    device     /dev/drbd1;
-    disk       /dev/hdc6;
     address    192.168.22.12:7789;
-    meta-disk  /dev/somewhere [7];
   }
 }
 

Modified: branches/drbd-8.2/user/drbdadm.h
===================================================================
--- branches/drbd-8.2/user/drbdadm.h	2007-10-03 12:45:04 UTC (rev 3088)
+++ branches/drbd-8.2/user/drbdadm.h	2007-10-03 13:45:44 UTC (rev 3089)
@@ -100,6 +100,10 @@
 {
   char* name;
   char* protocol;
+  char* device;     // gets propagated to host_info sections later.
+  char* disk;       // gets propagated to host_info sections later.
+  char* meta_disk;  // gets propagated to host_info sections later.
+  char* meta_index; // gets propagated to host_info sections later.
   struct d_host_info* me;
   struct d_host_info* peer;
   struct d_host_info* all_hosts;

Modified: branches/drbd-8.2/user/drbdadm_main.c
===================================================================
--- branches/drbd-8.2/user/drbdadm_main.c	2007-10-03 12:45:04 UTC (rev 3088)
+++ branches/drbd-8.2/user/drbdadm_main.c	2007-10-03 13:45:44 UTC (rev 3089)
@@ -621,6 +621,10 @@
   for_each_resource(f,t,res) {
     free(f->name);
     free(f->protocol);
+    free(f->device);
+    free(f->disk);
+    free(f->meta_disk);
+    free(f->meta_index);
     free_host_info(f->me);
     free_host_info(f->peer);
     free_options(f->net_options);

Modified: branches/drbd-8.2/user/drbdadm_parser.c
===================================================================
--- branches/drbd-8.2/user/drbdadm_parser.c	2007-10-03 12:45:04 UTC (rev 3088)
+++ branches/drbd-8.2/user/drbdadm_parser.c	2007-10-03 13:45:44 UTC (rev 3089)
@@ -295,7 +295,6 @@
 	struct d_option *options = NULL, *ro = NULL;
 	fline = line;
 
-	EXP('{');
 	while (1) {
 		token = yylex();
 		if (token == token_switch) {
@@ -367,6 +366,20 @@
 	return;
 }
 
+static void parse_meta_disk(char **disk, char** index)
+{
+	EXP(TK_STRING);
+	*disk = yylval.txt;
+	if (strcmp("internal", yylval.txt)) {
+		EXP('[');
+		EXP(TK_INTEGER);
+		*index = yylval.txt;
+		EXP(']');
+		EXP(';');
+	} else {
+		EXP(';');
+	}
+}
 
 static void parse_host_section(struct d_resource *res, 
 			       char *host_name, int require_all)
@@ -417,17 +430,7 @@
 		case TK_META_DISK:
 			check_uniq("meta-disk statement", "%s:%s:meta-disk",
 				   res->name, host->name);
-			EXP(TK_STRING);
-			host->meta_disk = yylval.txt;
-			if (strcmp("internal", yylval.txt)) {
-				EXP('[');
-				EXP(TK_INTEGER);
-				host->meta_index = yylval.txt;
-				EXP(']');
-				EXP(';');
-			} else {
-				EXP(';');
-			}
+			parse_meta_disk(&host->meta_disk, &host->meta_index);
 			check_meta_disk(host);
 			break;
 		case TK_FLEX_META_DISK:
@@ -462,6 +465,26 @@
 		}
 	}
       break_loop:
+
+	/* Inerit device, disk, meta_disk and meta_index from the resource. */
+	if(!host->disk && res->disk) {
+		host->disk = strdup(res->disk);
+		check_uniq("disk", "%s:%s:%s", "disk",
+			   host->name, host->disk);
+	}
+
+	if(!host->device && res->device) {
+		host->device = strdup(res->device);
+		check_uniq("device", "%s:%s:%s", "device",
+			   host->name, host->device);
+	}
+
+	if(!host->meta_disk && res->meta_disk) {
+		host->meta_disk = strdup(res->meta_disk);
+		if(res->meta_index) host->meta_index = strdup(res->meta_index);
+		check_meta_disk(host);
+	}
+
 	if (!require_all)
 		return;
 	if (!host->device)
@@ -541,34 +564,65 @@
 			parse_host_section(res, strdup("_remote_host"), 0);
 			break;
 		case TK_DISK:
-			check_uniq("disk section", "%s:disk", res->name);
-			res->disk_options = parse_options(TK_DISK_SWITCH,
-							  TK_DISK_OPTION);
+			switch (token=yylex()) {
+			case TK_STRING:
+				res->disk = yylval.txt;
+				EXP(';');
+				break;
+			case '{':
+				check_uniq("disk section", "%s:disk", res->name);
+				res->disk_options = parse_options(TK_DISK_SWITCH,
+								  TK_DISK_OPTION);
+				break;
+			default: 
+				pe_expected_got( "TK_STRING | {", token);
+			}
 			break;
 		case TK_NET:
 			check_uniq("net section", "%s:net", res->name);
+			EXP('{');
 			res->net_options = parse_options(TK_NET_SWITCH,
 							 TK_NET_OPTION);
 			break;
 		case TK_SYNCER:
 			check_uniq("syncer section", "%s:syncer", res->name);
+			EXP('{');
 			res->sync_options = parse_options(TK_SYNCER_SWITCH,
 							  TK_SYNCER_OPTION);
 			break;
 		case TK_STARTUP:
 			check_uniq("startup section", "%s:startup", res->name);
+			EXP('{');
 			res->startup_options=parse_options(TK_STARTUP_SWITCH,
 							   TK_STARTUP_OPTION);
 			break;
 		case TK_HANDLER:
 			check_uniq("handlers section", "%s:handlers", res->name);
+			EXP('{');
 			res->handlers =  parse_options(0, TK_HANDLER_OPTION);
 			break;
 		case TK_PROXY:
 			check_uniq("proxy section", "%s:proxy", res->name);
+			EXP('{');
 			res->proxy_options =  parse_options(TK_PROXY_SWITCH,
 							    TK_PROXY_OPTION);
 			break;
+		case TK_DEVICE:
+			EXP(TK_STRING);
+			res->device = yylval.txt;
+			EXP(';');
+			break;
+		case TK_META_DISK:
+			parse_meta_disk(&res->meta_disk, &res->meta_index);
+			break;
+		case TK_FLEX_META_DISK:
+			EXP(TK_STRING);
+			res->meta_disk = yylval.txt;
+			if (strcmp("internal", yylval.txt)) {
+				res->meta_index = strdup("flexible");
+			}
+			EXP(';');
+			break;
 		case '}':
 		case 0:
 			goto exit_loop;



More information about the drbd-cvs mailing list