[DRBD-cvs] user by phil; Added the user space side of ko-count. (...

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Wed, 9 Jun 2004 22:06:41 +0200 (CEST)


DRBD CVS committal

Author  : phil
Project : drbd
Module  : user

Dir     : drbd/user


Modified Files:
      Tag: rel-0_7-branch
	drbdadm_adjust.c drbdadm_parser.y drbdadm_scanner.fl 
	drbdsetup.c 


Log Message:
Added the user space side of ko-count. (as in drbd-0.6.x)
Added the user space side of on-disconnect. Kernel part not yet done.
[I am still not sure about the freeze_io thing, maybe I will remove...]

===================================================================
RCS file: /var/lib/cvs/drbd/drbd/user/Attic/drbdadm_adjust.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -u -3 -r1.1.2.15 -r1.1.2.16
--- drbdadm_adjust.c	9 Jun 2004 14:17:59 -0000	1.1.2.15
+++ drbdadm_adjust.c	9 Jun 2004 20:06:36 -0000	1.1.2.16
@@ -292,6 +292,8 @@
     do_connect |= check_opt_d(in,"max-epoch-size",1,"",res->net_options);
     do_connect |= check_opt_d(in,"max-buffers",1,"",res->net_options);
     do_connect |= check_opt_d(in,"sndbuf-size",1,"",res->net_options);
+    do_connect |= check_opt_d(in,"ko-count",1,"",res->net_options);
+    do_connect |= check_opt_s(in,"on-disconnect",res->net_options);
     do_connect |= complete(res->net_options);
   }
 
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/user/Attic/drbdadm_parser.y,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -3 -r1.1.2.22 -r1.1.2.23
--- drbdadm_parser.y	26 Apr 2004 08:36:29 -0000	1.1.2.22
+++ drbdadm_parser.y	9 Jun 2004 20:06:36 -0000	1.1.2.23
@@ -125,7 +125,7 @@
 %token <txt> TK_MAX_EPOCH_SIZE TK_SNDBUF_SIZE
 %token <txt> TK_SKIP_SYNC TK_USE_CSUMS TK_RATE TK_SYNC_GROUP TK_AL_EXTENTS
 %token <txt> TK_WFC_TIMEOUT TK_DEGR_WFC_TIMEOUT
-
+%token <txt> TK_KO_COUNT TK_ON_DISCONNECT
 
 %type <txt> hostname resource_name
 %type <d_option> disk_stmts disk_stmt
@@ -228,6 +228,8 @@
 		| TK_MAX_BUFFERS    TK_INTEGER { $$=new_opt($1,$2); }
 		| TK_MAX_EPOCH_SIZE TK_INTEGER { $$=new_opt($1,$2); }
 		| TK_SNDBUF_SIZE    TK_INTEGER { $$=new_opt($1,$2); }
+		| TK_KO_COUNT       TK_INTEGER { $$=new_opt($1,$2); }
+		| TK_ON_DISCONNECT  TK_STRING  { $$=new_opt($1,$2); }
 		;
 
 sync_stmts:	  /* empty */	           { $$ = 0; }
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/user/Attic/drbdadm_scanner.fl,v
retrieving revision 1.1.2.21
retrieving revision 1.1.2.22
diff -u -3 -r1.1.2.21 -r1.1.2.22
--- drbdadm_scanner.fl	26 Apr 2004 08:36:29 -0000	1.1.2.21
+++ drbdadm_scanner.fl	9 Jun 2004 20:06:36 -0000	1.1.2.22
@@ -48,7 +48,7 @@
 
 %x RESOURCE GLOBAL
 %x STARTUP DISK NET SYNCER HOST
-%x SEMICOLON ASSIGN NUM NUM_U NAME STRING PROTO IO_ERROR
+%x SEMICOLON ASSIGN NUM NUM_U NAME STRING PROTO IO_ERROR ON_DISCONNECT
 %x IP_AND_PORT PORT META_DISK META_IDX
 %x LS LBRACE IGNORE_SECTION
 
@@ -228,6 +228,12 @@
   {NDELIM}		expect_error("one of 'pass_on|panic|detach'");
 }
 
+<ON_DISCONNECT>{
+  reconnect		|
+  stand_alone		|
+  freeze_io		yy_pop_state(); CP; return TK_STRING;
+  {NDELIM}		expect_error("one of 'reconnect|stand_alone|freeze_io'");
+}
 
 <NET>{
   sndbuf-size		do_assign(NUM_U); CP; return TK_SNDBUF_SIZE;
@@ -236,7 +242,9 @@
   connect-int		do_assign(NUM);   CP; return TK_CONNECT_INT;
   max-buffers		do_assign(NUM);   CP; return TK_MAX_BUFFERS;
   max-epoch-size	do_assign(NUM);   CP; return TK_MAX_EPOCH_SIZE;
-  {NDELIM}		expect_error("one of 'sndbuf-size|timeout|ping-int|connect-int|max-buffers|max-epoch-size'");
+  ko-count		do_assign(NUM);   CP; return TK_KO_COUNT;
+  on-disconnect 	do_assign(ON_DISCONNECT); CP; return TK_ON_DISCONNECT;
+  {NDELIM}		expect_error("one of 'sndbuf-size|timeout|ping-int|connect-int|max-buffers|max-epoch-size|ko-count|on-disconnect'");
 }
 
 <SYNCER>{
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/user/drbdsetup.c,v
retrieving revision 1.54.2.39
retrieving revision 1.54.2.40
diff -u -3 -r1.54.2.39 -r1.54.2.40
--- drbdsetup.c	9 Jun 2004 14:17:59 -0000	1.54.2.39
+++ drbdsetup.c	9 Jun 2004 20:06:36 -0000	1.54.2.40
@@ -66,6 +66,8 @@
 #define DEF_SNDBUF_SIZE           (2*65535) // ~128KB
 #define DEF_DISK_SIZE                0
 #define DEF_ON_IO_ERROR         PassOn
+#define DEF_KO_COUNT                 0
+#define DEF_ON_DISCONNECT       Reconnect
 
 #if 0
 # define ioctl(X...) (fprintf(stderr,"ioctl(%s)\n",#X),0);
@@ -148,6 +150,8 @@
      { "connect-int",required_argument, 0, 'c' },
      { "ping-int",   required_argument, 0, 'i' },
      { "sndbuf-size",required_argument, 0, 'S' },
+     { "ko-count",   required_argument, 0, 'k' },
+     { "on-disconnect",required_argument, 0, 'd' },
      { 0,            0,                 0, 0 } } },
   {"disk", cmd_disk_conf,(char *[]){"lower_dev","meta_data_dev",
 				    "meta_data_index",0},
@@ -170,6 +174,12 @@
   [Detach] = "detach" 
 };
 
+const char *dh_names[] = {
+  [Reconnect]   = "reconnect",
+  [DropNetConf] = "stand_alone",
+  [FreezeIO]    = "freeze_io" 
+};
+
 unsigned long resolv(const char* name)
 {
   unsigned long retval;
@@ -355,6 +365,12 @@
     if(i < ARRY_SIZE(eh_names)-1) printf(",");
   }
 
+  printf("\nAvailable on-disconnect handlers:");
+  for(i=0;i<ARRY_SIZE(dh_names);i++) {
+    printf(" %s",dh_names[i]);
+    if(i < ARRY_SIZE(dh_names)-1) printf(",");
+  }
+
   printf("\n\nVersion: "REL_VERSION" (api:%d)\n",API_VERSION);
   if (addinfo)
       printf("\n%s\n",addinfo);
@@ -456,15 +472,17 @@
   cn->config.max_epoch_size = DEF_MAX_EPOCH_SIZE;
   cn->config.max_buffers = DEF_MAX_BUFFERS;
   cn->config.sndbuf_size = DEF_SNDBUF_SIZE ;
-
+  cn->config.on_disconnect = DEF_ON_DISCONNECT;
+  cn->config.ko_count = DEF_KO_COUNT;
 
   if(argc==0) return 0;
 
   while(1)
     {
-      int c;
+      int c,i;
 
       PRINT_ARGV;
+      next_option:
       c = getopt_long(argc,argv,make_optstring(options),options,0);
       if(c == -1) break;
       switch(c)
@@ -487,6 +505,19 @@
 	case 'S':
 	  cn->config.sndbuf_size = m_strtol(optarg,1);
 	  break;
+       case 'k':
+          cn->config.ko_count = m_strtol(optarg,1);
+          break;
+	case 'd':
+	  for(i=0;i<ARRY_SIZE(dh_names);i++) {
+	    if (strcmp(optarg,dh_names[i])==0) {
+	      cn->config.on_disconnect=i;
+	      goto next_option;
+	    }
+	  }
+	  fprintf(stderr,"%s: '%s' is an invalid on-disconnect handler.\n",
+		  basename,optarg);
+	  return 20;
 	case 1:	// non option argument. see getopt_long(3)
 	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",basename,optarg);
 	case '?':
@@ -1132,6 +1163,10 @@
   SHOW_I("max-epoch-size","", cn.nconf.max_epoch_size, DEF_MAX_EPOCH_SIZE);
   SHOW_I("max-buffers","", cn.nconf.max_buffers, DEF_MAX_BUFFERS);
   SHOW_I("sndbuf-size","", cn.nconf.sndbuf_size, DEF_SNDBUF_SIZE);
+  SHOW_I("ko-count","", cn.nconf.ko_count, DEF_KO_COUNT);
+  if( cn.nconf.on_disconnect != DEF_ON_DISCONNECT) {
+    printf(" on-disconnect = %s\n",dh_names[cn.nconf.on_disconnect]);
+  }
 
 
   printf("Syncer options:\n");