[DRBD-cvs] svn commit by phil - r2009 - in trunk: . user - Implemented a simple run lengh encoding in the dump-md

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Sat Nov 19 10:15:20 CET 2005


Author: phil
Date: 2005-11-19 10:15:19 +0100 (Sat, 19 Nov 2005)
New Revision: 2009

Modified:
   trunk/ROADMAP
   trunk/user/drbdmeta.c
   trunk/user/drbdmeta_parser.h
   trunk/user/drbdmeta_scanner.fl
Log:
Implemented a simple run lengh encoding in the dump-md and restore-md
commands. This make it much more feasible to dump-md, edit wit favourite
editore, restore-md for debugging purposis.


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-11-18 22:36:10 UTC (rev 2008)
+++ trunk/ROADMAP	2005-11-19 09:15:19 UTC (rev 2009)
@@ -394,9 +394,11 @@
   0% DONE
 
 15 Accept BIOs bigger than one page, probabely up to 32k (8 pages) 
-  currently. When this is done make the bits in the bitmap to account 
-  for more then 4k e.g. 64k
-  50% DONE we handle big BIOs now, a bitmap bit is still 4k.
+  currently.
+  * Normal Requsts. -> DONE
+  * Make the syncer to commulate adjacent bits into bigger requests. -> DONE
+  * Make the bitmap more coarse grained. -> TODO
+  66% DONE
 
 16 Displace the current generation-counters with a data-generation-UUID 
    concept.

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2005-11-18 22:36:10 UTC (rev 2008)
+++ trunk/user/drbdmeta.c	2005-11-19 09:15:19 UTC (rev 2009)
@@ -849,18 +849,38 @@
 	return words;
 }
 
+static void printf_bm_eol(unsigned int i)
+{
+	if ((i & 31) == 0)
+		printf("\n   # at %llukB\n   ", (256LLU * i));
+	else
+		printf("\n   ");
+}
+
 /* le_u64, because we want to be able to hexdump it reliably
  * regardless of sizeof(long) */
 void printf_bm(const le_u64 * bm, const unsigned int n)
 {
 	unsigned int i;
+	unsigned int j;
+
 	printf("bm {");
 	for (i = 0; i < n; i++) {
 		if ((i & 3) == 0) {
-			if ((i & 31) == 0)
-				printf("\n   # %llukB\n   ", (256LLU * i));
-			else
-				printf("\n   ");
+			printf_bm_eol(i);
+
+			// RLL encoding 
+			for (j = i+1; j < n; j++) {
+				if(bm[i].le != bm[j].le) break;
+			}
+			j &= ~3; // round down to a multiple of 4
+			if (j-i > 4 && i > 1) {
+				printf(" %d times 0x"X64(016)";",
+				       j-i, le64_to_cpu(bm[i].le));
+				i = j;
+
+				printf_bm_eol(i);
+			}
 		}
 		printf(" 0x"X64(016)";", le64_to_cpu(bm[i].le));
 	}
@@ -1661,9 +1681,9 @@
 
 int meta_restore_md(struct format *cfg, char **argv, int argc)
 {
-	int i;
+	int i,times;
 	int err;
-	le_u64 *bm;
+	le_u64 *bm, value;
 
 	if (argc > 0) {
 		yyin = fopen(argv[0],"r");
@@ -1705,11 +1725,29 @@
 	EXP(TK_BM); EXP('{');
 	bm = (le_u64 *)cfg->on_disk.bm;
 	i = 0;
-	while(yylex() == TK_U64) {
-		bm[i].le = cpu_to_le64(yylval.u64);
-		i++;
-		EXP(';');
+	while(1) {
+		switch(yylex()) {
+		case TK_U64:
+			bm[i].le = cpu_to_le64(yylval.u64);
+			i++;
+			EXP(';');
+			break;
+		case TK_NUM:
+			EXP(TK_TIMES);
+			times = yylval.u64;
+			EXP(TK_U64);
+			value.le = cpu_to_le64(yylval.u64);
+			EXP(';');
+			while(times--) bm[i++] = value;
+			break;
+		case '}': 
+			goto break_loop;
+		default:
+			md_parse_error("TK_U64, TK_NUM or }");
+			goto break_loop;
+		}
 	}
+	break_loop:
 
 	err = cfg->ops->md_cpu_to_disk(cfg);
 	err = cfg->ops->close(cfg) || err;

Modified: trunk/user/drbdmeta_parser.h
===================================================================
--- trunk/user/drbdmeta_parser.h	2005-11-18 22:36:10 UTC (rev 2008)
+++ trunk/user/drbdmeta_parser.h	2005-11-19 09:15:19 UTC (rev 2009)
@@ -17,7 +17,8 @@
 	TK_BM,
 	TK_UUID,
 	TK_VERSION,
-	TK_LA_SIZE
+	TK_LA_SIZE,
+	TK_TIMES
 };
 
 /* avoid compiler warnings about implicit declaration */

Modified: trunk/user/drbdmeta_scanner.fl
===================================================================
--- trunk/user/drbdmeta_scanner.fl	2005-11-18 22:36:10 UTC (rev 2008)
+++ trunk/user/drbdmeta_scanner.fl	2005-11-19 09:15:19 UTC (rev 2009)
@@ -34,6 +34,7 @@
 uuid		DP; return TK_UUID;
 version		DP; return TK_VERSION;
 la-size-sect	DP; return TK_LA_SIZE;
+times		DP; return TK_TIMES;
 
 %%
 



More information about the drbd-cvs mailing list