[DRBD-cvs] svn commit by phil - r2426 - trunk/drbd - Worked on clusters in this state: primary/diskless O ==

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Sep 15 13:45:28 CEST 2006


Author: phil
Date: 2006-09-15 13:45:26 +0200 (Fri, 15 Sep 2006)
New Revision: 2426

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_worker.c
Log:
Worked on clusters in this state:

  primary/diskless  O ==== connected ==== O  secodnary/UpToDate
  
* The side with disk has to use it's activitiy log and it's
  bitmap to mark written blocks as out of sync.

* Make recovery from such a state possible by attaching a 
  disk on the primary node, as well start the right resync 
  at that stage.

* In such a cluster we have to set the primary-Indicator on the
  secondary node. (Since we hold the data, the primary node 
  modifies.)

* Get every thing right when the diskless peer changes its
  role from secondary to primary and back.
  


Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-09-15 09:43:51 UTC (rev 2425)
+++ trunk/drbd/drbd_int.h	2006-09-15 11:45:26 UTC (rev 2426)
@@ -658,11 +658,19 @@
 	   In case the barrier after this write has been coalesced
 	   as well, we set it's barrier_nr into barrier_nr2 */
 
+	unsigned int flags;
 	u64    block_id;
 };
 
-/* flag bits */
+/* ee flag bits */
 enum {
+	__CALL_AL_COMPLETE_IO,
+};
+#define CALL_AL_COMPLETE_IO (1<<__CALL_AL_COMPLETE_IO)
+
+
+/* global flag bits */
+enum {
 	ISSUE_BARRIER,		// next Data is preceeded by a Barrier
 	SIGNAL_ASENDER,		// whether asender wants to be interrupted
 	SEND_PING,		// whether asender should send a ping asap

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-09-15 09:43:51 UTC (rev 2425)
+++ trunk/drbd/drbd_main.c	2006-09-15 11:45:26 UTC (rev 2426)
@@ -814,7 +814,9 @@
 					     MDF_ConnectedInd|MDF_WasUpToDate|
 					     MDF_PeerOutDated );
 		if (test_bit(CRASHED_PRIMARY,&mdev->flags) ||
-		    mdev->state.role == Primary)       mdf |= MDF_PrimaryInd;
+		    mdev->state.role == Primary ||
+		    ( mdev->state.pdsk < Inconsistent && 
+		      mdev->state.peer == Primary ) )  mdf |= MDF_PrimaryInd;
 		if (mdev->state.conn > WFReportParams) mdf |= MDF_ConnectedInd;
 		if (mdev->state.disk > Inconsistent)   mdf |= MDF_Consistent;
 		if (mdev->state.disk > Outdated)       mdf |= MDF_WasUpToDate;
@@ -878,6 +880,18 @@
 		}
 	}
 
+	if( ns.pdsk < Inconsistent ) {
+		/* Diskless Peer becomes primary */
+		if (os.peer == Secondary && ns.peer == Primary ) {
+			INFO("Creating new current UUID\n");
+			drbd_uuid_new_current(mdev);
+		}
+		/* Diskless Peer becomes secondary */
+		if (os.peer == Primary && ns.peer == Secondary ) {
+			drbd_al_to_on_disk_bm(mdev);
+		}
+	}
+
 	/* Last part of the attaching process ... */
 	if ( os.disk == Attaching && ns.disk == Negotiating ) {
 		drbd_send_sizes(mdev);  // to start sync...

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2006-09-15 09:43:51 UTC (rev 2425)
+++ trunk/drbd/drbd_receiver.c	2006-09-15 11:45:26 UTC (rev 2426)
@@ -279,6 +279,7 @@
 	INIT_HLIST_NODE(&e->colision);
 	e->barrier_nr = 0;
 	e->barrier_nr2 = 0;
+	e->flags = 0;
 
 	return e;
 
@@ -1427,6 +1428,13 @@
 		break;
 	}
 
+	if(mdev->state.pdsk <= Inconsistent) {
+		// In case we have the only disk of the cluster, 
+		drbd_set_out_of_sync(mdev,e->sector,e->size);
+		e->flags >= CALL_AL_COMPLETE_IO;
+		drbd_al_begin_io(mdev, e->sector);
+	}
+
 	/* FIXME drbd_al_begin_io in case we have two primaries... */
 	drbd_generic_make_request(WRITE,e->private_bio);
 	/* accounting done in endio */
@@ -1798,7 +1806,7 @@
 		return conn_mask;
 	}
 	if (hg < 0 && 
-	    mdev->state.role == Primary && mdev->state.disk != Attaching ) {
+	    mdev->state.role == Primary && mdev->state.disk != Negotiating ) {
 		ERR("I shall become SyncTarget, but I am primary!\n");
 		drbd_force_state(mdev,NS(conn,StandAlone));
 		drbd_thread_stop_nowait(&mdev->receiver);
@@ -2146,14 +2154,6 @@
 		}
 	}
 
-	/*
-        if ( peer_state.disk == Negotiating && nconn == Connected ) {
-		// Peer should promote from Negotiating to UpToDate.
-		drbd_send_state(mdev);
-		peer_state.disk = UpToDate;
-	}
-	*/
-
 	spin_lock_irq(&mdev->req_lock);
 	os = mdev->state;
 	ns.i = mdev->state.i;

Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c	2006-09-15 09:43:51 UTC (rev 2425)
+++ trunk/drbd/drbd_worker.c	2006-09-15 11:45:26 UTC (rev 2426)
@@ -134,6 +134,8 @@
 
 	if (do_wake) wake_up(&mdev->ee_wait);
 
+	if(e->flags & CALL_AL_COMPLETE_IO) drbd_al_complete_io(mdev,e->sector);
+
 	wake_asender(mdev);
 	dec_local(mdev);
 	return 0;



More information about the drbd-cvs mailing list