[DRBD-cvs] svn commit by phil - r2477 - trunk/drbd - Working on the "sync-after" code. There are still some

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Sep 29 11:15:52 CEST 2006


Author: phil
Date: 2006-09-29 11:15:51 +0200 (Fri, 29 Sep 2006)
New Revision: 2477

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_worker.c
Log:
Working on the "sync-after" code. There are still some issues with
it, but the patch gets too big for me. I will continue to work
on this in the afternoon.


Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-09-28 12:29:29 UTC (rev 2476)
+++ trunk/drbd/drbd_int.h	2006-09-29 09:15:51 UTC (rev 2477)
@@ -1313,6 +1313,7 @@
 extern int drbd_resync_pause(drbd_dev *mdev, enum RSPauseReason);
 extern int drbd_resync_resume(drbd_dev *mdev, enum RSPauseReason);
 extern void drbd_start_resync(drbd_dev *mdev, drbd_conns_t side);
+extern void resume_next_sg(drbd_dev* mdev);
 extern int drbd_resync_finished(drbd_dev *mdev);
 // maybe rather drbd_main.c ?
 extern int drbd_md_sync_page_io(drbd_dev *mdev, struct drbd_backing_dev *bdev,

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-09-28 12:29:29 UTC (rev 2476)
+++ trunk/drbd/drbd_main.c	2006-09-29 09:15:51 UTC (rev 2477)
@@ -621,6 +621,12 @@
 
 	os = mdev->state;
 
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->dc.fencing;
+		dec_local(mdev);
+	}
+
 	/* Early state sanitising. Dissalow the invalidate ioctl to connect  */
 	if( (ns.conn == StartingSyncS || ns.conn == StartingSyncT) &&
 		os.conn < Connected ) {
@@ -640,15 +646,6 @@
 		ns.conn = os.conn;
 	}
 
-	if( ns.i == os.i ) return SS_NothingToDo;
-
-	fp = DontCare;
-	if(inc_local(mdev)) {
-		fp = mdev->bc->dc.fencing;
-		dec_local(mdev);
-	}
-
-	/*  State sanitising  */
 	if( ns.conn < Connected ) {
 		ns.peer = Unknown;
 		if ( ns.pdsk > DUnknown || 
@@ -723,6 +720,16 @@
 			ns.susp = 1;
 		}
 	}
+
+	if( ns.aftr_isp || ns.peer_isp || ns.user_isp ) {
+		if(ns.conn == SyncSource) ns.conn=PausedSyncS;
+		if(ns.conn == SyncTarget) ns.conn=PausedSyncT;
+	} else {
+		if(ns.conn == PausedSyncS) ns.conn=SyncSource;
+		if(ns.conn == PausedSyncT) ns.conn=SyncTarget;
+	}
+
+	if( ns.i == os.i ) return SS_NothingToDo;
 	
 	if( !(flags & ChgStateHard) ) {
 		/*  pre-state-change checks ; only look at ns  */
@@ -781,6 +788,25 @@
 		mod_timer(&mdev->resync_timer,jiffies);
 	}
 
+	if( (os.conn == PausedSyncT || os.conn == PausedSyncS) &&
+	    (ns.conn == SyncTarget  || ns.conn == SyncSource) ) {
+		INFO("Syncer continues.\n");
+		mdev->rs_paused += (long)jiffies-(long)mdev->rs_mark_time;
+		if( ns.conn == SyncTarget ) {
+			D_ASSERT(!test_bit(STOP_SYNC_TIMER,&mdev->flags));
+			mod_timer(&mdev->resync_timer,jiffies);
+		}
+	}
+
+	if( (os.conn == SyncTarget  || os.conn == SyncSource) &&
+	    (ns.conn == PausedSyncT || ns.conn == PausedSyncS) ) {
+		INFO("Resync suspended\n");
+		mdev->rs_mark_time = jiffies;
+		if( ns.conn == PausedSyncT ) {
+			set_bit(STOP_SYNC_TIMER,&mdev->flags);
+		}
+	}
+
 	if ( os.disk == Diskless && os.conn == StandAlone &&
 	     (ns.disk > Diskless || ns.conn >= Unconnected) ) {
 		int i;
@@ -1002,6 +1028,11 @@
 		lc_free(mdev->act_log); mdev->act_log = NULL;
 	}
 
+	// A resync finished or aborted, wake paused devices...
+	if ( os.conn > Connected && ns.conn <= Connected) {
+		resume_next_sg(mdev);
+	}
+
 	if ( os.conn != Disconnecting && ns.conn <= Disconnecting ) {
 		drbd_thread_stop_nowait(&mdev->receiver);
 	}

Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c	2006-09-28 12:29:29 UTC (rev 2476)
+++ trunk/drbd/drbd_worker.c	2006-09-29 09:15:51 UTC (rev 2477)
@@ -231,21 +231,24 @@
 {
 	unsigned long flags;
 	drbd_dev* mdev = (drbd_dev*) data;
+	int queue;
 
 	spin_lock_irqsave(&mdev->req_lock,flags);
 
 	if(likely(!test_and_clear_bit(STOP_SYNC_TIMER,&mdev->flags))) {
+		queue=1;
 		mdev->resync_work.cb = w_make_resync_request;
 	} else {
-		mdev->resync_work.cb = w_resume_next_sg;
+		queue=0;
+		mdev->resync_work.cb = w_resync_inactive;
 	}
 
 	spin_unlock_irqrestore(&mdev->req_lock,flags);
 
 	/* harmless race: list_empty outside data.work.q_lock */
-	if(list_empty(&mdev->resync_work.list)) {
+	if(list_empty(&mdev->resync_work.list) && queue) {
 		drbd_queue_work(&mdev->data.work,&mdev->resync_work);
-	} else INFO("Avoided requeue of resync_work\n");
+	}
 }
 
 #define SLEEP_TIME (HZ/10)
@@ -648,33 +651,20 @@
  */ 
 STATIC int _drbd_rs_resume(drbd_dev *mdev, enum RSPauseReason reason)
 {
-	drbd_state_t os,ns;
-	int r,doing=0;
+	drbd_state_t ns;
+	int r;
 
-	ns = os = mdev->state;
+	ns = mdev->state;
 
 	switch(reason) {
 	case AfterDependency:	ns.aftr_isp = 0;	break;
 	case PeerImposed:	ns.peer_isp = 0;	break;
 	case UserImposed:	ns.user_isp = 0;	break;
 	}
-	if(ns.aftr_isp == 0 && ns.peer_isp == 0 && ns.user_isp == 0) {
-		if(os.conn == PausedSyncS) ns.conn=SyncSource, doing=1;
-		if(os.conn == PausedSyncT) ns.conn=SyncTarget, doing=1;
-	}
 
 	// Call _drbd_set_state() in any way to set the _isp bits.
 	r = _drbd_set_state(mdev,ns,ChgStateHard|ScheduleAfter);
 
-	if(doing) {
-		INFO("Syncer continues.\n");
-		mdev->rs_paused += (long)jiffies-(long)mdev->rs_mark_time;
-
-		if(ns.conn == SyncTarget) {
-			D_ASSERT(!test_bit(STOP_SYNC_TIMER,&mdev->flags));
-			mod_timer(&mdev->resync_timer,jiffies);
-		}
-	}
 	return r != SS_NothingToDo;
 }
 
@@ -688,19 +678,11 @@
  */ 
 STATIC int _drbd_rs_pause(drbd_dev *mdev, enum RSPauseReason reason)
 {
-	drbd_state_t os,ns;
-	int r,doing=0;
+	drbd_state_t ns;
+	int r;
 
-	static const char *reason_txt[] = {
-		[AfterDependency] = "dependency",
-		[PeerImposed]     = "peer",
-		[UserImposed]     = "user",
-	};
+	ns = mdev->state;
 
-	ns = os = mdev->state;
-
-	if(os.conn == SyncSource) ns.conn=PausedSyncS, doing=1;
-	if(os.conn == SyncTarget) ns.conn=PausedSyncT, doing=1;
 	switch(reason) {
 	case AfterDependency:	ns.aftr_isp = 1;	break;
 	case PeerImposed:	ns.peer_isp = 1;	break;
@@ -710,14 +692,6 @@
 	// Call _drbd_set_state() in any way to set the _isp bits.
 	r = _drbd_set_state(mdev,ns,ChgStateHard|ScheduleAfter);
 
-	if(doing) {
-		if( ns.conn == PausedSyncT ) 
-			set_bit(STOP_SYNC_TIMER,&mdev->flags);
-
-		mdev->rs_mark_time = jiffies;
-		INFO("Resync suspended by %s.\n",reason_txt[reason]);
-	}
-
 	return r != SS_NothingToDo;
 }
 
@@ -778,16 +752,11 @@
 	return rv;
 }
 
-int w_resume_next_sg(drbd_dev* mdev, struct drbd_work* w, int unused)
+void resume_next_sg(drbd_dev* mdev)
 {
-	PARANOIA_BUG_ON(w != &mdev->resync_work);
-
 	drbd_global_lock();
 	_drbd_resume_next(mdev);
-	w->cb = w_resync_inactive;
 	drbd_global_unlock();
-
-	return 1;
 }
 
 void drbd_alter_sa(drbd_dev *mdev, int na)
@@ -835,7 +804,7 @@
 void drbd_start_resync(drbd_dev *mdev, drbd_conns_t side)
 {
 	drbd_state_t os,ns;
-	int r=0,p=0;
+	int r=0;
 
 	if(side == SyncTarget) {
 		drbd_bm_reset_find(mdev);
@@ -852,13 +821,9 @@
 	drbd_global_lock();
 	ns = os = mdev->state;
 
-	if(!_drbd_may_sync_now(mdev)) {
-		ns.aftr_isp = 1;
-		p = (PausedSyncS - SyncSource);
-	}
-	if( ns.peer_isp || ns.user_isp ) p = (PausedSyncS - SyncSource);
+	ns.aftr_isp = !_drbd_may_sync_now(mdev);
 
-	ns.conn = side + p;
+	ns.conn = side;
 
 	if(side == SyncTarget) {
 		ns.disk = Inconsistent;
@@ -867,6 +832,7 @@
 	}
 
 	r = _drbd_set_state(mdev,ns,ChgStateVerbose);
+	ns = mdev->state;
 
 	if ( r == SS_Success ) {
 		mdev->rs_total     =
@@ -880,7 +846,7 @@
 
 	if ( r == SS_Success ) {
 		after_state_ch(mdev,os,ns,ChgStateVerbose);
-
+ 
 		INFO("Began resync as %s (will sync %lu KB [%lu bits set]).\n",
 		     conns_to_name(ns.conn),
 		     (unsigned long) mdev->rs_total << (BM_BLOCK_SIZE_B-10),



More information about the drbd-cvs mailing list