[DRBD-cvs] svn commit by phil - r2539 - trunk/drbd - * Implemented the drbd_drain_block() in order to keep t

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Oct 17 12:55:38 CEST 2006


Author: phil
Date: 2006-10-17 12:55:37 +0200 (Tue, 17 Oct 2006)
New Revision: 2539

Modified:
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
Log:
* Implemented the drbd_drain_block() in order to keep the connection
  open in case we have an IO error during resync.

* Fixed the drbd_io_error() function to use inc_local_if_state(mdev,Failed)
  instead of inc_local(mdev). Since we expect the state to be failed
  already!



Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-10-17 10:00:04 UTC (rev 2538)
+++ trunk/drbd/drbd_main.c	2006-10-17 10:55:37 UTC (rev 2539)
@@ -353,7 +353,7 @@
 	int send,ok=1;
 
 	eh = PassOn;
-	if(inc_local(mdev)) {
+	if(inc_local_if_state(mdev,Failed)) {
 		eh = mdev->bc->dc.on_io_error;
 		dec_local(mdev);
 	}

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2006-10-17 10:00:04 UTC (rev 2538)
+++ trunk/drbd/drbd_receiver.c	2006-10-17 10:55:37 UTC (rev 2539)
@@ -947,6 +947,36 @@
 	return e;
 }
 
+/* drbd_drain_block() just takes a data block out of the socket input
+ * buffer and discards ist.
+ */
+STATIC int 
+drbd_drain_block(drbd_dev *mdev, int data_size)
+{
+	struct page *page;
+	int rr, rv=1;
+	void* data;
+
+	page = drbd_pp_alloc(mdev, GFP_KERNEL);
+
+	data=kmap(page);
+	while(data_size) {
+		rr = drbd_recv(mdev,data,min_t(int,data_size,PAGE_SIZE));
+		if( rr != min_t(int,data_size,PAGE_SIZE) ) {
+			rv = 0;
+			WARN("short read receiving data: read %d expected %d\n",
+			     rr, min_t(int,data_size,PAGE_SIZE));
+			goto out;
+		}
+
+		data_size -= rr;
+	}
+	kunmap(page);
+ out:
+	drbd_pp_free(mdev,page);
+	return rv;
+}
+
 /* kick lower level device, if we have more than (arbitrary number)
  * reference counts on it, which typically are locally submitted io
  * requests.  don't use unacked_cnt, so we speed up proto A and B, too. */
@@ -1142,14 +1172,10 @@
 	} else {
 		if (DRBD_ratelimit(5*HZ,5))
 			ERR("Can not write resync data to local disk.\n");
+
+		ok = drbd_drain_block(mdev,data_size);
+
 		drbd_send_ack_dp(mdev,NegAck,p);
-		/* FIXME:
-		 * we need to drain the data.  only then can we keep the
-		 * connection open.
-		 * without draining, we'd see an invalid packet header next,
-		 * and drop the connection there. */
-		/* ok = 1; not yet: keep connection open */
-		ok = 0;
 	}
 
 	return ok;



More information about the drbd-cvs mailing list