[DRBD-cvs] svn commit by phil - r2924 - in branches/drbd-8.0: drbd drbd/linux user - Now the sync progress is also visible via the "drbdsetu

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed Jun 20 11:43:08 CEST 2007


Author: phil
Date: 2007-06-20 11:43:06 +0200 (Wed, 20 Jun 2007)
New Revision: 2924

Modified:
   branches/drbd-8.0/drbd/drbd_actlog.c
   branches/drbd-8.0/drbd/drbd_int.h
   branches/drbd-8.0/drbd/drbd_nl.c
   branches/drbd-8.0/drbd/linux/drbd_nl.h
   branches/drbd-8.0/user/drbdsetup.c
Log:
Now the sync progress is also visible via the "drbdsetup events" interface.


Modified: branches/drbd-8.0/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_actlog.c	2007-06-19 15:40:39 UTC (rev 2923)
+++ branches/drbd-8.0/drbd/drbd_actlog.c	2007-06-20 09:43:06 UTC (rev 2924)
@@ -802,6 +802,7 @@
 		drbd_resync_finished(mdev);
 		drbd_bm_unlock(mdev);
 	}
+	drbd_bcast_sync_progress(mdev);
 
 	return 1;
 }

Modified: branches/drbd-8.0/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_int.h	2007-06-19 15:40:39 UTC (rev 2923)
+++ branches/drbd-8.0/drbd/drbd_int.h	2007-06-20 09:43:06 UTC (rev 2924)
@@ -1414,6 +1414,7 @@
 void drbd_nl_cleanup(void);
 int __init drbd_nl_init(void);
 void drbd_bcast_state(drbd_dev *mdev);
+void drbd_bcast_sync_progress(drbd_dev *mdev);
 
 /*
  * inline helper functions

Modified: branches/drbd-8.0/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_nl.c	2007-06-19 15:40:39 UTC (rev 2923)
+++ branches/drbd-8.0/drbd/drbd_nl.c	2007-06-20 09:43:06 UTC (rev 2924)
@@ -1731,6 +1731,56 @@
 	cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
 }
 
+void drbd_bcast_sync_progress(drbd_dev *mdev)
+{
+	char buffer[sizeof(struct cn_msg)+
+		    sizeof(struct drbd_nl_cfg_reply)+
+		    sizeof(struct sync_progress_tag_len_struct)+
+		    sizeof(short int)];
+	struct cn_msg *cn_reply = (struct cn_msg *) buffer;
+	struct drbd_nl_cfg_reply* reply = (struct drbd_nl_cfg_reply*)cn_reply->data;
+	unsigned short *tl = reply->tag_list;
+	int res;
+	unsigned long rs_left;
+
+	if (inc_local(mdev)) {
+		typecheck(unsigned long, mdev->rs_total);
+
+		rs_left = drbd_bm_total_weight(mdev) - mdev->rs_failed;
+		if (rs_left > mdev->rs_total) {
+			ERR("logic bug? rs_left=%lu > rs_total=%lu (rs_failed %lu)\n",
+					rs_left, mdev->rs_total, mdev->rs_failed);
+			res = 1000;
+		} else {
+			res = (rs_left >> 10)*1000/((mdev->rs_total >> 10) + 1);
+		}
+		dec_local(mdev);
+		res = 1000L - res;
+		*tl++ = T_sync_progress;
+		*tl++ = sizeof(int);
+		memcpy(tl, &res, sizeof(int));
+		tl=(unsigned short*)((char*)tl + sizeof(int));
+	}
+	*tl++ = TT_END; /* Close the tag list */
+
+	cn_reply->id.idx = CN_IDX_DRBD;
+	cn_reply->id.val = CN_VAL_DRBD;
+
+	cn_reply->seq = atomic_add_return(1,&drbd_nl_seq);
+	cn_reply->ack = 0; // not used here.
+	cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
+		(int)((char*)tl - (char*)reply->tag_list);
+	cn_reply->flags = 0;
+
+	reply->packet_type = P_sync_progress;
+	reply->minor = mdev_to_minor(mdev);
+	reply->ret_code = NoError;
+
+	TRACE(TraceTypeNl, TraceLvlSummary, nl_trace_reply(cn_reply););
+
+	cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
+}
+
 #ifdef NETLINK_ROUTE6
 int __init cn_init(void);
 void __exit cn_fini(void);

Modified: branches/drbd-8.0/drbd/linux/drbd_nl.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd_nl.h	2007-06-19 15:40:39 UTC (rev 2923)
+++ branches/drbd-8.0/drbd/linux/drbd_nl.h	2007-06-20 09:43:06 UTC (rev 2924)
@@ -90,6 +90,13 @@
 	STRING(		38,	T_MAY_IGNORE,	helper,		32)
 )
 
+// Tag nr 42 already allocated in drbd-8.1 development.
+// Packet numbers 21 and 22 already in drbd-8.1 development.
+
+PACKET(sync_progress, 23,
+	INTEGER(	43,	T_MAY_IGNORE,	sync_progress)
+)
+
 #undef PACKET
 #undef INTEGER
 #undef INT64

Modified: branches/drbd-8.0/user/drbdsetup.c
===================================================================
--- branches/drbd-8.0/user/drbdsetup.c	2007-06-19 15:40:39 UTC (rev 2923)
+++ branches/drbd-8.0/user/drbdsetup.c	2007-06-20 09:43:06 UTC (rev 2924)
@@ -1182,6 +1182,7 @@
 {
 	drbd_state_t state;
 	char* str;
+	int synced = 0;
 
 	switch (reply->packet_type) {
 	case P_get_state:
@@ -1205,6 +1206,15 @@
 			printf("%u UH %d %s\n", seq, reply->minor, str);
 		} else fprintf(stderr,"Missing tag !?\n");
 		break;
+	case P_sync_progress:
+		if (consume_tag_int(T_sync_progress, reply->tag_list, &synced)) {
+			printf("%u SP %d %i.%i\n", 
+				seq,
+				reply->minor,
+				synced / 10,
+				synced % 10);
+		} else fprintf(stderr,"Missing tag !?\n");
+		break;
 	default:
 		printf("%u ?? %d <other message>\n",seq, reply->minor);
 		break;



More information about the drbd-cvs mailing list