[DRBD-cvs] svn commit by phil - r2549 - branches/drbd-0.7/drbd - * Changed the way we freeze IO. Our make_request() func

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Thu Oct 19 15:27:16 CEST 2006


Author: phil
Date: 2006-10-19 15:27:16 +0200 (Thu, 19 Oct 2006)
New Revision: 2549

Modified:
   branches/drbd-0.7/drbd/drbd_compat_types.h
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/drbd_receiver.c
   branches/drbd-0.7/drbd/drbd_req.c
Log:
* Changed the way we freeze IO. Our make_request() function
  simply queues IO requests for execution later.

* Upon connect of a freezed device, do not go into resync states.


Modified: branches/drbd-0.7/drbd/drbd_compat_types.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_compat_types.h	2006-10-19 13:22:52 UTC (rev 2548)
+++ branches/drbd-0.7/drbd/drbd_compat_types.h	2006-10-19 13:27:16 UTC (rev 2549)
@@ -8,6 +8,8 @@
 typedef struct buffer_head drbd_bio_t;
 typedef unsigned long sector_t;
 
+#define REQ_NEXT b_reqnext
+
 #define NOT_IN_26(x...)		x
 #define ONLY_IN_26(x...)
 
@@ -316,6 +318,8 @@
 
 typedef struct bio drbd_bio_t;
 
+#define REQ_NEXT bi_next
+
 #define SIGHAND_HACK
 
 #define NOT_IN_26(x...)

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2006-10-19 13:22:52 UTC (rev 2548)
+++ branches/drbd-0.7/drbd/drbd_int.h	2006-10-19 13:27:16 UTC (rev 2549)
@@ -802,6 +802,8 @@
 	struct list_head done_ee;   // send ack
 	struct list_head read_ee;   // IO in progress
 	struct list_head net_ee;    // zero-copy network send in progress
+	drbd_bio_t *first_frozen_bio;
+	drbd_bio_t *last_frozen_bio;
 	spinlock_t pr_lock;
 	struct list_head app_reads;
 	struct list_head resync_reads;
@@ -1040,6 +1042,7 @@
 #endif
 extern int drbd_read_remote(drbd_dev *mdev, drbd_request_t *req);
 
+extern void drbd_thaw_frozen_reqs(drbd_dev *mdev);
 // drbd_fs.c
 extern char* ppsize(char* buf, size_t size);
 extern int drbd_determin_dev_size(drbd_dev*);

Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-10-19 13:22:52 UTC (rev 2548)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-10-19 13:27:16 UTC (rev 2549)
@@ -810,7 +810,7 @@
 
 	drbd_thread_start(&mdev->asender);
 
-	drbd_send_param(mdev,0);
+	drbd_send_param(mdev,test_bit(IO_FROZEN, &mdev->flags) ? 4 : 0);
 	clear_bit(USE_DEGR_WFC_T,&mdev->flags);
 
 	return 1;
@@ -1528,6 +1528,8 @@
 	}
 	if(be32_to_cpu(p->flags)&2) consider_sync=1;
 
+	if(be32_to_cpu(p->flags)&4) consider_sync=0;
+
 	// XXX harmless race with ioctl ...
 	mdev->sync_conf.rate  =
 		max_t(int,mdev->sync_conf.rate, be32_to_cpu(p->sync_rate));
@@ -1585,13 +1587,12 @@
 		INFO("Connection established.\n");
 
 		if(test_bit(IO_FROZEN, &mdev->flags)) {
-			WARN("Going to thaw IO, resuming %d requests.\n",
+			WARN("Going to thaw IO, resending %d requests.\n",
 			     atomic_read(&mdev->ap_pending_cnt));
 			tl_resend(mdev);
 			set_bit(ISSUE_BARRIER,&mdev->flags);
 			if (mdev->cstate == WFReportParams) {
-				clear_bit(IO_FROZEN, &mdev->flags);
-				consider_sync = 0; 
+				consider_sync = 0;
 			} else return FALSE;
 		}
 	}
@@ -1600,7 +1601,14 @@
 		if (!drbd_sync_handshake(mdev,p)) return FALSE;
 	}
 
-	if (mdev->cstate == WFReportParams) set_cstate(mdev,Connected);
+	if (mdev->cstate == WFReportParams) {
+		set_cstate(mdev,Connected);
+		if(test_bit(IO_FROZEN, &mdev->flags)) {
+			clear_bit(IO_FROZEN, &mdev->flags);
+			drbd_thaw_frozen_reqs(mdev);
+			consider_sync = 0;
+		}
+	}
 
 	oo_state = mdev->o_state;
 	mdev->o_state = be32_to_cpu(p->state);

Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c	2006-10-19 13:22:52 UTC (rev 2548)
+++ branches/drbd-0.7/drbd/drbd_req.c	2006-10-19 13:27:16 UTC (rev 2549)
@@ -167,19 +167,34 @@
 {
 	drbd_request_t *req;
 	int local, remote;
+	unsigned long flags;
 
-ONLY_IN_26(
+	ONLY_IN_26(
 	/* Currently our BARRIER code is disabled. */
 	if(unlikely(bio_barrier(bio))) {
 		bio_endio(bio, bio->bi_size, -EOPNOTSUPP);
 		return 0;
 	}
-)
+	)
 	if (unlikely(drbd_did_panic == DRBD_MAGIC)) {
 		drbd_bio_IO_error(bio);
 		return 0;
 	}
 
+	if( rw == WRITE && test_bit(IO_FROZEN, &mdev->flags)) {
+		bio->REQ_NEXT = NULL;
+
+		spin_lock_irqsave(&mdev->req_lock,flags);
+		if(mdev->last_frozen_bio == NULL) {
+			mdev->first_frozen_bio = bio;
+			mdev->last_frozen_bio = bio;
+		} else {
+			mdev->last_frozen_bio->REQ_NEXT = bio;
+			mdev->last_frozen_bio = bio;
+		}
+		spin_unlock_irqrestore(&mdev->req_lock,flags);
+		return 0;
+	}
 	/*
 	 * If someone tries to mount on Secondary, and this is a 2.4 kernel,
 	 * it would lead to a readonly mounted, but not cache-coherent,
@@ -250,9 +265,8 @@
 	// down_read(mdev->device_lock);
 
 	wait_event( mdev->cstate_wait,
-		    ((volatile int)mdev->cstate < WFBitMapS || 
-		     (volatile int) mdev->cstate > WFBitMapT) &&
-		    !(rw == WRITE && test_bit(IO_FROZEN, &mdev->flags)));
+		    (volatile int)mdev->cstate < WFBitMapS ||
+		    (volatile int) mdev->cstate > WFBitMapT);
 
 	local = inc_local(mdev);
 	NOT_IN_26( if (rw == READA) rw=READ );
@@ -419,3 +433,27 @@
 					bio->bi_sector,bio);
 }
 #endif
+
+void drbd_thaw_frozen_reqs(drbd_dev *mdev)
+{
+	drbd_bio_t *bio;
+	int reqs=0;
+
+	spin_lock_irq(&mdev->req_lock);
+	bio = mdev->first_frozen_bio;
+	mdev->first_frozen_bio = NULL;
+	mdev->last_frozen_bio = NULL;
+	spin_unlock_irq(&mdev->req_lock);
+	
+	while(bio) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+		drbd_make_request_common(mdev,WRITE,bio->b_size,bio->b_rsector,bio);
+#else
+		drbd_make_request_common(mdev,WRITE,bio->bi_size,bio->bi_sector,bio);
+#endif
+		bio = bio->REQ_NEXT;
+		reqs++;
+	}
+	WARN("Continued %d requests (which where issued after IO-freeze).\n",
+	     reqs);
+}



More information about the drbd-cvs mailing list