[DRBD-cvs] svn commit by phil - r2480 - trunk/drbd - I just realized a horrible bug. My _NS() macros silentl

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Sep 29 22:56:20 CEST 2006


Author: phil
Date: 2006-09-29 22:56:19 +0200 (Fri, 29 Sep 2006)
New Revision: 2480

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_nl.c
   trunk/drbd/drbd_worker.c
Log:
I just realized a horrible bug. My _NS() macros silently 
referenced to the local variable mdev. Only that in 
_drbd_pause_after() and _drbd_resume_next() I called
_drbd_set_state(odev,_NS(... ) ) which resulted in 
deriving the new state of odev from mdev !!!

Fixed that by having the device as additional parameter
for the _NS macros 



Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-09-29 20:35:05 UTC (rev 2479)
+++ trunk/drbd/drbd_int.h	2006-09-29 20:56:19 UTC (rev 2480)
@@ -1393,12 +1393,12 @@
                 ({drbd_state_t val; val.i=0; val.T1 = (S1); \
                   val.T2 = (S2); val.T3 = (S3); val;})
 
-#define _NS(T,S) ({drbd_state_t ns; ns.i = mdev->state.i; ns.T = (S); ns;})
-#define _NS2(T1,S1,T2,S2) \
-                ({drbd_state_t ns; ns.i = mdev->state.i; ns.T1 = (S1); \
+#define _NS(D,T,S) D,({drbd_state_t ns; ns.i = D->state.i; ns.T = (S); ns;})
+#define _NS2(D,T1,S1,T2,S2) \
+                D,({drbd_state_t ns; ns.i = D->state.i; ns.T1 = (S1); \
                 ns.T2 = (S2); ns;})
-#define _NS3(T1,S1,T2,S2,T3,S3) \
-                ({drbd_state_t ns; ns.i = mdev->state.i; ns.T1 = (S1); \
+#define _NS3(D,T1,S1,T2,S2,T3,S3) \
+                D,({drbd_state_t ns; ns.i = D->state.i; ns.T1 = (S1); \
                 ns.T2 = (S2); ns.T3 = (S3); ns;})
 
 static inline void drbd_state_lock(drbd_dev *mdev)
@@ -1434,13 +1434,13 @@
 	    }
 	    /* NOTE fall through to detach case if forcedetach set */
 	case Detach:
-		if (_drbd_set_state(mdev,_NS(disk,Failed),ChgStateHard) 
+		if (_drbd_set_state(_NS(mdev,disk,Failed),ChgStateHard) 
 		    == SS_Success) {
 			ERR("Local IO failed. Detaching...\n");
 		}
 		break;
 	case Panic:
-		_drbd_set_state(mdev,_NS(disk,Failed),ChgStateHard);
+		_drbd_set_state(_NS(mdev,disk,Failed),ChgStateHard);
 		/* FIXME this is very ugly anyways.
 		 * but in case we panic, we should at least not panic
 		 * while holding the req_lock hand with irq disabled. */

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-09-29 20:35:05 UTC (rev 2479)
+++ trunk/drbd/drbd_main.c	2006-09-29 20:56:19 UTC (rev 2480)
@@ -358,7 +358,7 @@
 
 	spin_lock_irqsave(&mdev->req_lock,flags);
 	if( (send = (mdev->state.disk == Failed)) ) {
-		_drbd_set_state(mdev,_NS(disk,Diskless),
+		_drbd_set_state(_NS(mdev,disk,Diskless),
 				ChgStateHard|ScheduleAfter);
 	}
 	spin_unlock_irqrestore(&mdev->req_lock,flags);
@@ -892,7 +892,7 @@
 		     (os.conn < Connected && ns.conn >= Connected) ) {
 			tl_clear(mdev);
 			spin_lock_irq(&mdev->req_lock);
-			_drbd_set_state(mdev,_NS(susp,0), 
+			_drbd_set_state(_NS(mdev,susp,0), 
 					ChgStateVerbose | ScheduleAfter );
 			spin_unlock_irq(&mdev->req_lock);
 		}
@@ -989,7 +989,7 @@
 
 		if (ns.conn == StartingSyncT) {
 			spin_lock_irq(&mdev->req_lock);
-			_drbd_set_state(mdev,_NS(conn,WFSyncUUID), 
+			_drbd_set_state(_NS(mdev,conn,WFSyncUUID), 
 					ChgStateVerbose | ScheduleAfter );
 			spin_unlock_irq(&mdev->req_lock);
 		} else /* StartingSyncS */ {

Modified: trunk/drbd/drbd_nl.c
===================================================================
--- trunk/drbd/drbd_nl.c	2006-09-29 20:35:05 UTC (rev 2479)
+++ trunk/drbd/drbd_nl.c	2006-09-29 20:56:19 UTC (rev 2480)
@@ -1321,7 +1321,7 @@
 	if( mdev->state.disk < Outdated ) {
 		retcode = -999;
 	} else {
-		retcode = _drbd_set_state(mdev,_NS(disk,Outdated),ChgStateVerbose);
+		retcode = _drbd_set_state(_NS(mdev,disk,Outdated),ChgStateVerbose);
 	}
 	ns = mdev->state;
 	spin_unlock_irq(&mdev->req_lock);

Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c	2006-09-29 20:35:05 UTC (rev 2479)
+++ trunk/drbd/drbd_worker.c	2006-09-29 20:56:19 UTC (rev 2480)
@@ -670,7 +670,7 @@
 	for (i=0; i < minor_count; i++) {
 		if( !(odev = minor_to_mdev(i)) ) continue;
 		if (! _drbd_may_sync_now(odev)) {
-			rv |= ( _drbd_set_state(odev,_NS(aftr_isp,1),
+			rv |= ( _drbd_set_state(_NS(odev,aftr_isp,1),
 						ChgStateHard|ScheduleAfter)
 				!= SS_NothingToDo ) ;
 		}
@@ -694,7 +694,7 @@
 		if( !(odev = minor_to_mdev(i)) ) continue;
 		if ( odev->state.aftr_isp ) {
 			if (_drbd_may_sync_now(odev)) {
-				rv |= ( _drbd_set_state(odev,_NS(aftr_isp,0),
+				rv |= ( _drbd_set_state(_NS(odev,aftr_isp,0),
 							ChgStateHard|ScheduleAfter)
 					!= SS_NothingToDo ) ;
 			}



More information about the drbd-cvs mailing list