[DRBD-cvs] svn commit by phil - r2933 - in branches/drbd-8.0: drbd drbd/linux user - * "drbdadm invalidate r0" caused a kernel crash on an u

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Mon Jun 25 17:15:16 CEST 2007


Author: phil
Date: 2007-06-25 17:15:12 +0200 (Mon, 25 Jun 2007)
New Revision: 2933

Modified:
   branches/drbd-8.0/drbd/drbd_main.c
   branches/drbd-8.0/drbd/drbd_nl.c
   branches/drbd-8.0/drbd/drbd_strings.c
   branches/drbd-8.0/drbd/linux/drbd.h
   branches/drbd-8.0/user/drbdadm_main.c
   branches/drbd-8.0/user/drbdmeta.c
Log:
* "drbdadm invalidate r0" caused a kernel crash on an unconfigured 
  device! -- Fixed that.

* Made the "drbdadm invalidate r0" on unconfigured devices possible
  by usring drbdmeta.    


Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-06-25 15:15:12 UTC (rev 2933)
@@ -584,8 +584,8 @@
 	if( ns.conn == Disconnecting && os.conn == StandAlone)
 		rv=SS_AlreadyStandAlone;
 
-	if( ns.disk == Outdated && os.disk == Diskless)
-		rv=SS_CanNotOutdateDL;
+	if( ns.disk > Attaching && os.disk == Diskless)
+		rv=SS_IsDiskLess;
 
 	return rv;
 }

Modified: branches/drbd-8.0/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_nl.c	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/drbd/drbd_nl.c	2007-06-25 15:15:12 UTC (rev 2933)
@@ -1226,7 +1226,7 @@
 		// The peer probabely wants to see us outdated.
 		retcode = _drbd_request_state(mdev,NS2(conn,Disconnecting,
 						       disk,Outdated),0);
-		if( retcode == SS_CanNotOutdateDL ) {
+		if( retcode == SS_IsDiskLess ) {
 			// We are diskless and our peer wants to outdate us.
 			// So, simply go away, and let the peer try to
 			// outdate us with its 'outdate-peer' handler later.

Modified: branches/drbd-8.0/drbd/drbd_strings.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_strings.c	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/drbd/drbd_strings.c	2007-06-25 15:15:12 UTC (rev 2933)
@@ -78,7 +78,8 @@
 	[-SS_ResyncRunning] = "Can not start resync since it is already active",
 	[-SS_AlreadyStandAlone] = "Can not disconnect a StandAlone device",
 	[-SS_CW_FailedByPeer] = "State changed was refused by peer node",
-	[-SS_CanNotOutdateDL] = "Can not outdate a diskless device",
+	[-SS_IsDiskLess] = 
+		"Device is diskless, the requesed operation requires a disk",
 	[-SS_DeviceInUse] = "Device is held open by someone"
 };
 

Modified: branches/drbd-8.0/drbd/linux/drbd.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd.h	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/drbd/linux/drbd.h	2007-06-25 15:15:12 UTC (rev 2933)
@@ -206,7 +206,7 @@
 	SS_ResyncRunning=-8,
 	SS_AlreadyStandAlone=-9,
 	SS_CW_FailedByPeer=-10,
-	SS_CanNotOutdateDL=-11,
+	SS_IsDiskLess=-11,
 	SS_DeviceInUse=-12
 } set_st_err_t;
 

Modified: branches/drbd-8.0/user/drbdadm_main.c
===================================================================
--- branches/drbd-8.0/user/drbdadm_main.c	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/user/drbdadm_main.c	2007-06-25 15:15:12 UTC (rev 2933)
@@ -202,7 +202,7 @@
   { "down",              adm_generic_s, 1,1,0 },
   { "primary",           adm_generic_s, 1,1,0 },
   { "secondary",         adm_generic_s, 1,1,0 },
-  { "invalidate",        adm_generic_l, 1,1,0 },
+  { "invalidate",        adm_generic_b, 1,1,0 },
   { "invalidate-remote", adm_generic_l, 1,1,1 },
   { "outdate",           adm_generic_b, 1,1,0 },
   { "resize",            adm_resize,    1,1,1 },

Modified: branches/drbd-8.0/user/drbdmeta.c
===================================================================
--- branches/drbd-8.0/user/drbdmeta.c	2007-06-25 14:12:55 UTC (rev 2932)
+++ branches/drbd-8.0/user/drbdmeta.c	2007-06-25 15:15:12 UTC (rev 2933)
@@ -324,6 +324,7 @@
 	void (*show_gi) (struct md_cpu *md);
 	void (*set_gi) (struct md_cpu *md, char **argv, int argc);
 	int (*outdate_gi) (struct md_cpu *md);
+	int (*invalidate_gi) (struct md_cpu *md);
 };
 
 void *my_mmap(const char* func, const unsigned int line, const char* what,
@@ -661,10 +662,12 @@
 void m_show_gc(struct md_cpu *md);
 void m_set_gc(struct md_cpu *md, char **argv, int argc);
 int m_outdate_gc(struct md_cpu *md);
+int m_invalidate_gc(struct md_cpu *md);
 void m_get_uuid(struct md_cpu *md);
 void m_show_uuid(struct md_cpu *md);
 void m_set_uuid(struct md_cpu *md, char **argv, int argc);
 int m_outdate_uuid(struct md_cpu *md);
+int m_invalidate_uuid(struct md_cpu *md);
 
 int v06_md_close(struct format *cfg);
 int v06_md_cpu_to_disk(struct format *cfg);
@@ -705,6 +708,7 @@
 		     .show_gi = m_show_gc,
 		     .set_gi = m_set_gc,
 		     .outdate_gi = m_outdate_gc,
+		     .invalidate_gi = m_invalidate_gc,
 		     },
 	[Drbd_07] = {
 		     .name = "v07",
@@ -720,6 +724,7 @@
 		     .show_gi = m_show_gc,
 		     .set_gi = m_set_gc,
 		     .outdate_gi = m_outdate_gc,
+		     .invalidate_gi = m_invalidate_gc,
 		     },
 	[Drbd_08] = {
 		     .name = "v08",
@@ -735,6 +740,7 @@
 		     .show_gi = m_show_uuid,
 		     .set_gi = m_set_uuid,
 		     .outdate_gi = m_outdate_uuid,
+		     .invalidate_gi = m_invalidate_uuid,
 		     },
 };
 
@@ -774,6 +780,7 @@
 int meta_create_md(struct format *cfg, char **argv, int argc);
 int meta_wipe_md(struct format *cfg, char **argv, int argc);
 int meta_outdate(struct format *cfg, char **argv, int argc);
+int meta_invalidate(struct format *cfg, char **argv, int argc);
 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);
@@ -787,6 +794,7 @@
 	{"create-md", 0, meta_create_md, 1},
 	{"wipe-md", 0, meta_wipe_md, 1},
 	{"outdate", 0, meta_outdate, 1},
+	{"invalidate", 0, meta_invalidate, 1},
 	{"dstate", 0, meta_dstate, 1},
 	{"read-dev-uuid", "VAL",  meta_read_dev_uuid,  0},
 	{"write-dev-uuid", "VAL", meta_write_dev_uuid, 0},
@@ -1151,7 +1159,22 @@
 }
 
 
+int m_invalidate_gc(struct md_cpu *md)
+{
+	md->gc[Flags] &= ~MDF_Consistent;
 
+	return 5;
+}
+
+int m_invalidate_uuid(struct md_cpu *md)
+{
+	md->flags &= ~MDF_Consistent;
+	md->flags &= ~MDF_WasUpToDate;
+
+	return 0;
+}
+
+
 /******************************************
  begin of v06 {{{
  ******************************************/
@@ -2205,7 +2228,26 @@
 	return err;
 }
 
+int meta_invalidate(struct format *cfg, char **argv __attribute((unused)), int argc)
+{
+	int err;
 
+	if (argc > 0) {
+		fprintf(stderr, "Ignoring additional arguments\n");
+	}
+
+	if (cfg->ops->open(cfg))
+		return -1;
+
+	cfg->ops->invalidate_gi(&cfg->md);
+	err = cfg->ops->md_cpu_to_disk(cfg);
+	err = cfg->ops->close(cfg)          || err; // <- close always
+	if (err)
+		fprintf(stderr, "update failed\n");
+
+	return err;
+}
+
 #if 0
 int meta_set_size(struct format *cfg, char **argv, int argc)
 {



More information about the drbd-cvs mailing list