[DRBD-cvs] svn commit by lars - r2488 - branches/drbd-0.7/drbd - rebalance ap_pending/rs_pending. sometimes, if it is hi

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Mon Oct 2 23:13:21 CEST 2006


Author: lars
Date: 2006-10-02 23:13:19 +0200 (Mon, 02 Oct 2006)
New Revision: 2488

Modified:
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/drbd/drbd_receiver.c
   branches/drbd-0.7/drbd/drbd_req.c
Log:
rebalance ap_pending/rs_pending. sometimes, if it is hidden in broken macros, it is impossible to find :(

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2006-10-02 15:54:16 UTC (rev 2487)
+++ branches/drbd-0.7/drbd/drbd_int.h	2006-10-02 21:13:19 UTC (rev 2488)
@@ -219,11 +219,11 @@
 
 #ifdef DBG_ASSERTS
 extern void drbd_assert_breakpoint(drbd_dev*, char *, char *, int );
-# define D_ASSERT(exp)  if (!(exp)) \
-	 drbd_assert_breakpoint(mdev,#exp,__FILE__,__LINE__)
+# define D_ASSERT(exp)  do { if (!(exp)) \
+	 drbd_assert_breakpoint(mdev,#exp,__FILE__,__LINE__); } while (0)
 #else
-# define D_ASSERT(exp)  if (!(exp)) \
-	 ERR("ASSERT( " #exp " ) in %s:%d\n", __FILE__,__LINE__)
+# define D_ASSERT(exp)  do { if (!(exp)) \
+	 ERR("ASSERT( " #exp " ) in %s:%d\n", __FILE__,__LINE__); } while (0) 
 #endif
 #define ERR_IF(exp) if (({ \
 	int _b = (exp)!=0; \
@@ -1334,21 +1334,21 @@
 		    __func__ , __LINE__ ,			\
 		    atomic_read(&mdev->which))
 
-#define dec_ap_pending(mdev)					\
+#define dec_ap_pending(mdev) do {				\
 	typecheck(drbd_dev*,mdev);				\
 	if(atomic_dec_and_test(&mdev->ap_pending_cnt))		\
 		wake_up(&mdev->cstate_wait);			\
-	ERR_IF_CNT_IS_NEGATIVE(ap_pending_cnt)
+	ERR_IF_CNT_IS_NEGATIVE(ap_pending_cnt); } while (0)
 
 static inline void inc_rs_pending(drbd_dev* mdev)
 {
 	atomic_inc(&mdev->rs_pending_cnt);
 }
 
-#define dec_rs_pending(mdev)					\
+#define dec_rs_pending(mdev) do {				\
 	typecheck(drbd_dev*,mdev);				\
 	atomic_dec(&mdev->rs_pending_cnt);			\
-	ERR_IF_CNT_IS_NEGATIVE(rs_pending_cnt)
+	ERR_IF_CNT_IS_NEGATIVE(rs_pending_cnt); } while (0)
 
 static inline void inc_unacked(drbd_dev* mdev)
 {
@@ -1394,15 +1394,15 @@
 		drbd_push_msock(mdev);				\
 	ERR_IF_CNT_IS_NEGATIVE(unacked_cnt);
 #else
-#define dec_unacked(mdev)					\
+#define dec_unacked(mdev) do {					\
 	typecheck(drbd_dev*,mdev);				\
 	atomic_dec(&mdev->unacked_cnt);				\
-	ERR_IF_CNT_IS_NEGATIVE(unacked_cnt)
+	ERR_IF_CNT_IS_NEGATIVE(unacked_cnt); } while (0)
 
-#define sub_unacked(mdev, n)					\
+#define sub_unacked(mdev, n) do {				\
 	typecheck(drbd_dev*,mdev);				\
 	atomic_sub(n, &mdev->unacked_cnt);			\
-	ERR_IF_CNT_IS_NEGATIVE(unacked_cnt)
+	ERR_IF_CNT_IS_NEGATIVE(unacked_cnt); } while (0)
 #endif
 
 

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-10-02 15:54:16 UTC (rev 2487)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-10-02 21:13:19 UTC (rev 2488)
@@ -325,9 +325,6 @@
 			list_del(&r->w.list);
 
 			if( !(r->rq_status & RQ_DRBD_SENT) ) {
-				if(mdev->conf.wire_protocol != DRBD_PROT_A )
-					dec_ap_pending(mdev);
-
 				_drbd_end_req(r,RQ_DRBD_SENT,1, sector);
 			} else if ((r->rq_status & RQ_DRBD_DONE) == RQ_DRBD_DONE) {
 				D_ASSERT(r->master_bio == NULL);
@@ -343,7 +340,6 @@
 		dec_ap_pending(mdev); // for the barrier
 	}
 	spin_unlock_irq(&mdev->req_lock);
-
 }
 
 /**
@@ -793,14 +789,12 @@
 	int ok;
 	Drbd_Barrier_Packet p;
 
-	/* printk(KERN_DEBUG DEVICE_NAME": issuing a barrier\n"); */
 	/* tl_add_barrier() must be called with the sock_mutex aquired */
 	p.barrier=tl_add_barrier(mdev);
 
 	inc_ap_pending(mdev);
 	ok = _drbd_send_cmd(mdev,mdev->data.socket,Barrier,(Drbd_Header*)&p,sizeof(p),0);
 
-//	if (!ok) dec_ap_pending(mdev); // is done in tl_clear()
 	return ok;
 }
 
@@ -1054,8 +1048,9 @@
 
 	if(test_and_clear_bit(ISSUE_BARRIER,&mdev->flags))
 		ok = _drbd_send_barrier(mdev);
+
+	tl_add(mdev,req);
 	if(ok) {
-		tl_add(mdev,req);
 		dump_packet(mdev,mdev->data.socket,0,(void*)&p, __FILE__, __LINE__);
 		set_bit(UNPLUG_REMOTE,&mdev->flags);
 		ok = sizeof(p) == drbd_send(mdev,mdev->data.socket,&p,sizeof(p),MSG_MORE);

Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-10-02 15:54:16 UTC (rev 2487)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-10-02 21:13:19 UTC (rev 2488)
@@ -2170,7 +2170,6 @@
 		dec_rs_pending(mdev);
 	} else {
 		D_ASSERT(mdev->conf.wire_protocol != DRBD_PROT_A);
-		dec_ap_pending(mdev);
 	}
 	return TRUE;
 }

Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c	2006-10-02 15:54:16 UTC (rev 2487)
+++ branches/drbd-0.7/drbd/drbd_req.c	2006-10-02 21:13:19 UTC (rev 2488)
@@ -42,6 +42,8 @@
 		ERR("request state error(%d)\n", req->rq_status);
 	}
 
+	if (nextstate == RQ_DRBD_SENT) dec_ap_pending(mdev);
+
 	req->rq_status |= nextstate;
 	req->rq_status &= er_flags | ~0x0001;
 	if( (req->rq_status & RQ_DRBD_DONE) != RQ_DRBD_DONE )
@@ -62,6 +64,7 @@
 		// the other side!  See w_io_error()
 
 		drbd_bio_endio(req->master_bio,1);
+		req->master_bio = NULL;
 		dec_ap_bio(mdev);
 		// The assumption is that we wrote it on the peer.
 
@@ -326,10 +329,8 @@
 			if (!drbd_send_dblock(mdev,req)) {
 				if (mdev->cstate >= Connected)
 					set_cstate(mdev,NetworkFailure);
-				dec_ap_pending(mdev);
 				drbd_thread_restart_nowait(&mdev->receiver);
 			} else if(mdev->conf.wire_protocol == DRBD_PROT_A) {
-				dec_ap_pending(mdev);
 				drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
 			}
 		} else {



More information about the drbd-cvs mailing list