[DRBD-cvs] svn commit by phil - r2086 - in trunk: . user - Implemented the 'dstate' command to ease the heartbeat-

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Feb 28 19:14:51 CET 2006


Author: phil
Date: 2006-02-28 19:14:50 +0100 (Tue, 28 Feb 2006)
New Revision: 2086

Modified:
   trunk/ROADMAP
   trunk/user/drbdadm_main.c
   trunk/user/drbdmeta.c
   trunk/user/drbdsetup.c
Log:
Implemented the 'dstate' command to ease the heartbeat-2 
glue code.



Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2006-02-28 14:15:19 UTC (rev 2085)
+++ trunk/ROADMAP	2006-02-28 18:14:50 UTC (rev 2086)
@@ -655,6 +655,8 @@
 26 Implement a kind of "dstate" command to make integration with 
    Heartbeat-2.0's master/slave-support possible.
 
+   99% DONE
+
 27 Remove all explicit drbd_md_write() calls, and create a mechanism,
    that always keeps the on disk-metadata up-to-date implicit. 
    Calling drbd_md_write() explicit is too errorprone.
@@ -667,8 +669,7 @@
    set gets generated, the 'call home' is initiated. The user might
    of course opt out of this.
 
-   50% DONE [ Counting of resources is missing, counting of DRBD releases
-              is alrady implemented. ]
+   99% DONE
 
 29 Make drbdadm to have 'hidden-commands' command to also show
    the hidden sub-commands in the ussage.

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2006-02-28 14:15:19 UTC (rev 2085)
+++ trunk/user/drbdadm_main.c	2006-02-28 18:14:50 UTC (rev 2086)
@@ -197,6 +197,7 @@
   { "wait_connect",      adm_wait_c,    1,1,1 },
   { "state",             adm_generic_s, 1,1,0 },
   { "cstate",            adm_generic_s, 1,1,1 },
+  { "dstate",            adm_generic_b, 1,1,1 },
   { "dump",              adm_dump,      1,1,1 },
   { "create-md",         adm_create_md, 1,1,0 },
   { "show-gi",           adm_generic_b, 1,1,0 },

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-02-28 14:15:19 UTC (rev 2085)
+++ trunk/user/drbdmeta.c	2006-02-28 18:14:50 UTC (rev 2086)
@@ -753,8 +753,8 @@
 int meta_set_gi(struct format *cfg, char **argv, int argc);
 int meta_read_dev_uuid(struct format *cfg, char **argv, int argc);
 int meta_write_dev_uuid(struct format *cfg, char **argv, int argc);
+int meta_dstate(struct format *cfg, char **argv, int argc);
 
-
 struct meta_cmd cmds[] = {
 	{"get-gi", 0, meta_get_gi, 1},
 	{"show-gi", 0, meta_show_gi, 1},
@@ -765,6 +765,7 @@
 	 * implicit convert from v07 to v08 by create-md
 	 * see comments there */
 	{"outdate", 0, meta_outdate, 1},
+	{"dstate", 0, meta_dstate, 1},
 	{"read-dev-uuid", "VAL",  meta_read_dev_uuid,  0},
 	{"write-dev-uuid", "VAL", meta_write_dev_uuid, 0},
 	{"set-gi", ":::VAL:VAL:...", meta_set_gi, 0},
@@ -893,9 +894,9 @@
 	cfg->bm_offset = cfg->md_offset + cfg->md.bm_offset * 512;
 	cfg->bm_mmaped_length = (u64)(cfg->md.md_size_sect - MD_BM_OFFSET_07)*512;
 
-	fprintf(stderr,"al_offset: "U64" (%d)\n", cfg->al_offset, cfg->md.al_offset);
-	fprintf(stderr,"bm_offset: "U64" (%d)\n", cfg->bm_offset, cfg->md.bm_offset);
-	fprintf(stderr,"bm_mmaped_length: %lu\n",(unsigned long)cfg->bm_mmaped_length);
+	//fprintf(stderr,"al_offset: "U64" (%d)\n", cfg->al_offset, cfg->md.al_offset);
+	//fprintf(stderr,"bm_offset: "U64" (%d)\n", cfg->bm_offset, cfg->md.bm_offset);
+	//fprintf(stderr,"bm_mmaped_length: %lu\n",(unsigned long)cfg->bm_mmaped_length);
 
 	cfg->al_mmaped_length = MD_AL_MAX_SECT_07 * 512;
 	cfg->on_disk.al =
@@ -1538,6 +1539,28 @@
 	return cfg->ops->close(cfg);
 }
 
+int meta_dstate(struct format *cfg, char **argv __attribute((unused)), int argc)
+{
+	if (argc > 0) {
+		fprintf(stderr, "Ignoring additional arguments\n");
+	}
+
+	if (cfg->ops->open(cfg))
+		return -1;
+
+	if(cfg->md.flags & MDF_Consistent) {
+		if(cfg->md.flags & MDF_WasUpToDate) {
+			printf("Consistent/DUnknown\n");
+		} else {
+			printf("Outdated/DUnknown\n");
+		}
+	} else {
+		printf("Inconsistent/DUnknown\n");
+	}
+
+	return cfg->ops->close(cfg);
+}
+
 int meta_set_gi(struct format *cfg, char **argv, int argc)
 {
 	struct md_cpu tmp;

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-02-28 14:15:19 UTC (rev 2085)
+++ trunk/user/drbdsetup.c	2006-02-28 18:14:50 UTC (rev 2086)
@@ -122,6 +122,7 @@
 int cmd_detach(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_state(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_cstate(int drbd_fd,char** argv,int argc,struct option *options);
+int cmd_dstate(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_show_gi(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_get_gi(int drbd_fd,char** argv,int argc,struct option *options);
 
@@ -188,6 +189,7 @@
   {"disconnect", cmd_disconnect,     0, 0, },
   {"state", cmd_state,               0, 0, },
   {"cstate", cmd_cstate,             0, 0, },
+  {"dstate", cmd_dstate,             0, 0, },
   {"show-gi", cmd_show_gi,           0, 0, },
   {"get-gi", cmd_get_gi,             0, 0, },
   {"show", cmd_show,                 0, 0, },
@@ -1390,8 +1392,8 @@
 
   if( cn.state.conn == StandAlone && cn.state.disk == Diskless)
     {
-      printf("Not configured\n");
-      return 0;
+      fprintf(stderr,"Not configured\n");
+      return 10;
     }
 
   printf("%s/%s\n",roles_to_name(cn.state.role),
@@ -1414,8 +1416,8 @@
 
   if( cn.state.conn == StandAlone && cn.state.disk == Diskless)
     {
-      printf("Not configured\n");
-      return 0;
+      fprintf(stderr,"Not configured\n");
+      return 10;
     }
 
   printf("%s\n",conns_to_name(cn.state.conn));
@@ -1423,6 +1425,29 @@
   return 0;
 }
 
+int cmd_dstate(int drbd_fd,char** argv __attribute((unused)),int argc __attribute((unused)),struct option *options __attribute((unused)))
+{
+  struct ioctl_get_config cn;
+  int err;
+
+  err=ioctl(drbd_fd,DRBD_IOCTL_GET_CONFIG,&cn);
+  if(err)
+    {
+      PERROR("ioctl(,GET_CONFIG,) failed");
+      return 20;
+    }
+
+  if( cn.state.conn == StandAlone && cn.state.disk == Diskless)
+    {
+      fprintf(stderr,"Not configured\n");
+      return 10;
+    }
+
+  printf("%s/%s\n",disks_to_name(cn.state.disk),disks_to_name(cn.state.pdsk));
+
+  return 0;
+}
+
 int cmd_get_gi(int drbd_fd,char** argv __attribute((unused)),int argc __attribute((unused)),struct option *options __attribute((unused)))
 {
   struct ioctl_get_uuids cn;



More information about the drbd-cvs mailing list