[DRBD-cvs] drbd by phil; Looks a lot like if all handling of loca...

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Mon, 15 Mar 2004 18:32:24 +0100 (CET)


DRBD CVS committal

Author  : phil
Module  : drbd

Dir     : drbd/drbd


Modified Files:
      Tag: rel-0_7-branch
	drbd_compat_wrappers.h drbd_dsender.c drbd_int.h 
	drbd_req-2.4.c 


Log Message:
Looks a lot like if all handling of local-io-errors, does
now what it should do.

===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/drbd_compat_wrappers.h,v
retrieving revision 1.1.2.35
retrieving revision 1.1.2.36
diff -u -3 -r1.1.2.35 -r1.1.2.36
--- drbd_compat_wrappers.h	15 Mar 2004 14:10:36 -0000	1.1.2.35
+++ drbd_compat_wrappers.h	15 Mar 2004 17:32:19 -0000	1.1.2.36
@@ -199,7 +199,7 @@
 		     |(1 << BH_Req)
 		     |(1 << BH_Mapped) ;
 
-	req->rq_status = RQ_DRBD_NOTHING | RQ_DRBD_WRITE;
+	req->rq_status = RQ_DRBD_NOTHING;
 }
 
 static inline void
@@ -225,7 +225,7 @@
 		     |(1 << BH_Req)
 		     |(1 << BH_Mapped) ;
 
-	req->rq_status = RQ_DRBD_NOTHING | RQ_DRBD_READ;
+	req->rq_status = RQ_DRBD_NOTHING;
 }
 
 static inline struct page* drbd_bio_get_page(struct buffer_head *bh)
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/drbd_dsender.c,v
retrieving revision 1.1.2.85
retrieving revision 1.1.2.86
diff -u -3 -r1.1.2.85 -r1.1.2.86
--- drbd_dsender.c	14 Mar 2004 19:32:47 -0000	1.1.2.85
+++ drbd_dsender.c	15 Mar 2004 17:32:19 -0000	1.1.2.86
@@ -247,19 +247,6 @@
 	mdev=bio->bi_private;
 	PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev));
 
-
-#if 0
-	{
-		static int ccc=1;
-
-		if(ccc++ % 100 == 0) {
-			ERR("Injecting IO error.\n");
-			error=-5;
-			clear_bit(BIO_UPTODATE,&bio->bi_flags);
-		}
-	}
-#endif
-
 	e = container_of(bio,struct Tl_epoch_entry,private_bio);
 	PARANOIA_BUG_ON(!VALID_POINTER(e));
 	D_ASSERT(e->block_id != ID_VACANT);
@@ -285,7 +272,7 @@
  */
 int drbd_dio_end(struct bio *bio, unsigned int bytes_done, int error)
 {
-	struct Drbd_Conf* mdev;
+	struct Drbd_Conf* mdev=bio->bi_private;
 	drbd_request_t *req;
 	sector_t rsector;
 
@@ -293,7 +280,18 @@
 	if (bio->bi_size)
 		return 1;
 
-	mdev = bio->bi_private;
+#if 0
+	{
+		static int ccc=1;
+
+		if(ccc++ % 100 == 0) {
+			ERR("Injecting IO error.\n");
+			error=-5;
+			clear_bit(BIO_UPTODATE,&bio->bi_flags);
+		}
+	}
+#endif
+
 	PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev));
 
 	req = container_of(bio,struct drbd_request,private_bio);
@@ -312,14 +310,25 @@
  */
 int drbd_read_bi_end_io(struct bio *bio, unsigned int bytes_done, int error)
 {
-	struct Drbd_Conf* mdev;
+	struct Drbd_Conf* mdev = bio->bi_private;
 	drbd_request_t *req;
 
 	// see above
 	if (bio->bi_size)
 		return 1;
 
-	mdev = bio->bi_private;
+#if 0
+	{
+		static int ccc=1;
+
+		if(ccc++ % 100 == 0) {
+			ERR("Injecting IO error.\n");
+			error=-5;
+			clear_bit(BIO_UPTODATE,&bio->bi_flags);
+		}
+	}
+#endif
+
 	PARANOIA_BUG_ON(!IS_VALID_MDEV(mdev));
 
 	req = container_of(bio,struct drbd_request,private_bio);
@@ -346,13 +355,25 @@
 }
 #endif
 
+int w_io_error(drbd_dev* mdev, struct drbd_work* w,int cancel)
+{
+	drbd_request_t *req = (drbd_request_t*)w;
+
+	// TODO send a "set_out_of_sync" packet to the peer
+
+	INVALIDATE_MAGIC(req);
+	mempool_free(req,drbd_request_mempool);
+
+	return drbd_io_error(mdev);
+}
+
 int w_read_retry_remote(drbd_dev* mdev, struct drbd_work* w,int cancel)
 {
 	drbd_request_t *req = (drbd_request_t*)w;
 	int ok;
 
 	if ( cancel || 
-	     mdev->cstate <= Connected ||
+	     mdev->cstate < Connected ||
 	     test_bit(PARTNER_DISKLESS,&mdev->flags) ) {
 		ERR("WE ARE LOST. Local IO failure, no peer.\n");
 		drbd_bio_endio(req->master_bio,0);
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_int.h,v
retrieving revision 1.58.2.139
retrieving revision 1.58.2.140
diff -u -3 -r1.58.2.139 -r1.58.2.140
--- drbd_int.h	15 Mar 2004 14:10:36 -0000	1.58.2.139
+++ drbd_int.h	15 Mar 2004 17:32:19 -0000	1.58.2.140
@@ -257,8 +257,6 @@
 #define RQ_DRBD_LOCAL     0x0020
 #define RQ_DRBD_DONE      0x0030
 #define RQ_DRBD_IN_TL     0x0040
-#define RQ_DRBD_READ      0x0100
-#define RQ_DRBD_WRITE     0x0200
 
 enum MetaDataFlags {
 	MDF_Consistent   = 1,
@@ -841,7 +839,7 @@
 extern int w_e_end_rsdata_req    (drbd_dev *, struct drbd_work *, int);
 extern int w_resync_inactive     (drbd_dev *, struct drbd_work *, int);
 extern int w_resume_next_sg      (drbd_dev *, struct drbd_work *, int);
-
+extern int w_io_error            (drbd_dev *, struct drbd_work *, int);
 
 // drbd_receiver.c
 extern int drbd_release_ee(drbd_dev* mdev,struct list_head* list);
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_req-2.4.c,v
retrieving revision 1.33.2.60
retrieving revision 1.33.2.61
diff -u -3 -r1.33.2.60 -r1.33.2.61
--- drbd_req-2.4.c	15 Mar 2004 14:10:36 -0000	1.33.2.60
+++ drbd_req-2.4.c	15 Mar 2004 17:32:19 -0000	1.33.2.61
@@ -88,18 +88,20 @@
 
 	uptodate = req->rq_status & 0x0001;
 	if( !uptodate && mdev->on_io_error == Detach) {
-		if(req->rq_status & RQ_DRBD_READ) {
-			drbd_read_remote(mdev,req);
-			return;
-		} else {
-			drbd_set_out_of_sync(mdev,rsector,
-					     drbd_req_get_size(req));
-			// TODO it should also be as out of sync on 
-			// the other side! But how...
-			drbd_bio_endio(req->master_bio,1);
-			uptodate = 1; 
-                        // The assumption is that we wrote it on the peer.
-		}
+		drbd_set_out_of_sync(mdev,rsector, drbd_req_get_size(req));
+		// It should also be as out of sync on 
+		// the other side!  See w_io_error()
+
+		drbd_bio_endio(req->master_bio,uptodate);
+		// The assumption is that we wrote it on the peer.
+
+		drbd_bio_endio(req->master_bio,1);
+
+		req->w.cb = w_io_error;
+		drbd_queue_work(mdev,&mdev->data.work,&req->w);
+
+		goto out;
+
 	}
 
 	drbd_bio_endio(req->master_bio,uptodate);
@@ -107,6 +109,7 @@
 	INVALIDATE_MAGIC(req);
 	mempool_free(req,drbd_request_mempool);
 
+ out:
 	if (test_bit(ISSUE_BARRIER,&mdev->flags))
 		wake_asender(mdev);
 }
@@ -116,6 +119,7 @@
 	int rv;
 	drbd_bio_t *bio = req->master_bio;
 
+	req->w.cb = w_is_app_read;
 	spin_lock(&mdev->pr_lock);
 	list_add(&req->w.list,&mdev->new_app_reads);
 	spin_unlock(&mdev->pr_lock);