[DRBD-cvs] svn commit by phil - r2837 - trunk/drbd - Added some paranoia to that asserts that the bm_set num

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Apr 6 21:08:18 CEST 2007


Author: phil
Date: 2007-04-06 21:08:17 +0200 (Fri, 06 Apr 2007)
New Revision: 2837

Modified:
   trunk/drbd/drbd_bitmap.c
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_worker.c
Log:
Added some paranoia to that asserts that the bm_set number is right...


Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2007-04-06 14:22:15 UTC (rev 2836)
+++ trunk/drbd/drbd_bitmap.c	2007-04-06 19:08:17 UTC (rev 2837)
@@ -331,6 +331,23 @@
 	return bits;
 }
 
+void _drbd_bm_recount_bits(drbd_dev *mdev, char* file, int line)
+{
+	struct drbd_bitmap *b = mdev->bitmap;
+	unsigned long flags, bits;
+
+	ERR_IF(!b) return;
+
+	spin_lock_irqsave(&b->bm_lock,flags);
+	bits = bm_count_bits(b,0);
+	if(bits != b->bm_set) {
+		ERR("bm_set was %lu, corrected to %lu. %s:%d\n",
+		    b->bm_set,bits,file,line);
+		b->bm_set = bits;
+	}
+	spin_unlock_irqrestore(&b->bm_lock,flags);
+}
+
 #define BM_SECTORS_PER_BIT (BM_BLOCK_SIZE/512)
 
 /*

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2007-04-06 14:22:15 UTC (rev 2836)
+++ trunk/drbd/drbd_int.h	2007-04-06 19:08:17 UTC (rev 2837)
@@ -1157,6 +1157,8 @@
 extern void drbd_bm_unlock    (drbd_dev *mdev);
 #define drbd_bm_lock(mdev)    __drbd_bm_lock(mdev, __FILE__, __LINE__ )
 
+extern void _drbd_bm_recount_bits(drbd_dev *mdev, char* file, int line);
+#define drbd_bm_recount_bits(mdev) _drbd_bm_recount_bits(mdev,  __FILE__, __LINE__ )
 // drbd_main.c
 
 /* needs to be included here,

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2007-04-06 14:22:15 UTC (rev 2836)
+++ trunk/drbd/drbd_receiver.c	2007-04-06 19:08:17 UTC (rev 2837)
@@ -2061,6 +2061,8 @@
 		}
 	}
 
+	drbd_bm_recount_bits(mdev);
+
 	return rv;
 }
 
@@ -2509,6 +2511,8 @@
 		D_ASSERT(h->command == ReportBitMap);
 	}
 
+	drbd_bm_recount_bits(mdev);
+
 	if (mdev->state.conn == WFBitMapS) {
 		drbd_start_resync(mdev,SyncSource);
 	} else if (mdev->state.conn == WFBitMapT) {
@@ -2521,12 +2525,6 @@
 		    conns_to_name(mdev->state.conn));
 	}
 
-	// We just started resync. Now we can be sure that local disk IO is okay.
-
-	/* no, actually we can't. failures happen asynchronously, anytime.
-	 * we can never be sure. disk may have failed while we where busy shaking hands...
-	 */
-
 	ok=TRUE;
  out:
 	drbd_bm_unlock(mdev); // }

Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c	2007-04-06 14:22:15 UTC (rev 2836)
+++ trunk/drbd/drbd_worker.c	2007-04-06 19:08:17 UTC (rev 2837)
@@ -496,6 +496,8 @@
 		drbd_bm_write(mdev);
 	}
 
+	drbd_bm_recount_bits(mdev);
+
 	drbd_request_state(mdev,NS3(conn,Connected,
 				    disk,dstate,
 				    pdsk,pdstate));
@@ -831,6 +833,8 @@
 		    side==SyncTarget?"SyncTarget":"SyncSource");
 	    );
 
+	drbd_bm_recount_bits(mdev);
+
 	/* In case a previous resync run was aborted by an IO error... */
 	drbd_rs_cancel_all(mdev);
 



More information about the drbd-cvs mailing list