[DRBD-cvs] svn commit by phil - r2538 - trunk/drbd - * The BIO_RW_SYNC flag needs to get replicated as well.

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Oct 17 12:00:06 CEST 2006


Author: phil
Date: 2006-10-17 12:00:04 +0200 (Tue, 17 Oct 2006)
New Revision: 2538

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
Log:
* The BIO_RW_SYNC flag needs to get replicated as well. This is an 
  alternative to unplug events.

* Lars and Stefan perfer to have EMEDIUMTYPE as returncode of open
  in case the device is not primary.

* Fixed a bug when negotiating a new disk state...



Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-10-16 20:07:02 UTC (rev 2537)
+++ trunk/drbd/drbd_int.h	2006-10-17 10:00:04 UTC (rev 2538)
@@ -392,7 +392,7 @@
  */
 
 #define DP_HARDBARRIER 1
-/* FIXME map BIO_RW_SYNC, too ... */
+#define DP_RW_SYNC     2
 
 typedef struct {
 	Drbd_Header head;

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-10-16 20:07:02 UTC (rev 2537)
+++ trunk/drbd/drbd_main.c	2006-10-17 10:00:04 UTC (rev 2538)
@@ -1697,10 +1697,13 @@
 	p.block_id = (unsigned long)req;
 	p.seq_num  = cpu_to_be32( req->seq_num =
 				  atomic_add_return(1,&mdev->packet_seq) );
+	dp_flags = 0;
 	if(req->master_bio->bi_rw & BIO_RW_BARRIER) {
 		dp_flags = DP_HARDBARRIER;
 	}
-	/* FIXME BIO_RW_SYNC */
+	if(req->master_bio->bi_rw & BIO_RW_SYNC) {
+		dp_flags = DP_RW_SYNC;
+	}
 
 	p.dp_flags = cpu_to_be32(dp_flags);
 	dump_packet(mdev,mdev->data.socket,0,(void*)&p, __FILE__, __LINE__);
@@ -1871,7 +1874,7 @@
 	if(!mdev) return -ENODEV;
 
 	if( mdev->state.role == Secondary && !disable_bd_claim) {
-		return -ETXTBSY;
+		return -EMEDIUMTYPE;
 	}
 	if (file->f_mode & FMODE_WRITE) {
 		if( mdev->state.role == Secondary) {

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2006-10-16 20:07:02 UTC (rev 2537)
+++ trunk/drbd/drbd_receiver.c	2006-10-17 10:00:04 UTC (rev 2538)
@@ -1249,6 +1249,7 @@
 	int header_size, data_size, packet_seq, discard, rv;
 	unsigned int barrier_nr = 0;
 	unsigned int epoch_size = 0;
+	u32 dp_flags;
 
 	// FIXME merge this code dups into some helper function
 	header_size = sizeof(*p) - sizeof(*h);
@@ -1365,9 +1366,13 @@
 	}
 #endif
 
-	if ( be32_to_cpu(p->dp_flags) & DP_HARDBARRIER ) {
+	dp_flags = be32_to_cpu(p->dp_flags);
+	if ( dp_flags & DP_HARDBARRIER ) {
 		e->private_bio->bi_rw |= BIO_RW_BARRIER;
 	}
+	if ( dp_flags & DP_RW_SYNC ) {
+		e->private_bio->bi_rw |= BIO_RW_SYNC;
+	}
 
 	/* when using TCQ:
 	 * note that, when using tagged command queuing, we may
@@ -1776,7 +1781,11 @@
 {
 	int hg;
 	drbd_conns_t rv = conn_mask;
+	drbd_disks_t mydisk;
 
+	mydisk = mdev->state.disk;
+	if( mydisk == Negotiating ) mydisk = mdev->new_state_tmp.disk;
+
 	hg = drbd_uuid_compare(mdev);
 
 	MTRACE(TraceTypeUuid,TraceLvlSummary,
@@ -1823,8 +1832,8 @@
 	if (hg == 0) {
 		// This is needed in case someone does an invalidate on an
 		// disconnected node.
-		if(mdev->state.disk==Inconsistent && peer_disk>Inconsistent) hg=-1;
-		if(mdev->state.disk>Inconsistent && peer_disk==Inconsistent) hg= 1;
+		if(mydisk==Inconsistent && peer_disk>Inconsistent) hg=-1;
+		if(mydisk>Inconsistent && peer_disk==Inconsistent) hg= 1;
 	}
 
 	if (hg == -1000) {
@@ -1841,13 +1850,13 @@
 		return conn_mask;
 	}
 
-	if (hg > 0 && mdev->state.disk <= Inconsistent ) {
+	if (hg > 0 && mydisk <= Inconsistent ) {
 		ERR("I shall become SyncSource, but I am inconsistent!\n");
 		drbd_force_state(mdev,NS(conn,Disconnecting));
 		return conn_mask;
 	}
 	if (hg < 0 && 
-	    mdev->state.role == Primary && mdev->state.disk >= Consistent ) {
+	    mdev->state.role == Primary && mydisk >= Consistent ) {
 		ERR("I shall become SyncTarget, but I am primary!\n");
 		drbd_force_state(mdev,NS(conn,Disconnecting));
 		return conn_mask;



More information about the drbd-cvs mailing list