Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [Drbd-dev] drbdsetup  events patch to announce Split-brain
@ 2007-10-01 21:24 Montrose, Ernest
  2007-10-25 10:15 ` Philipp Reisner
  2007-10-25 12:24 ` Montrose, Ernest
  0 siblings, 2 replies; 5+ messages in thread
From: Montrose, Ernest @ 2007-10-01 21:24 UTC (permalink / raw)
  To: drbd-dev


[-- Attachment #1.1: Type: text/plain, Size: 382 bytes --]

Hi,
 
Included here is a small patch that I find useful when monitoring with
drbdsetup().  It adds the ability to generate an netlink event to user
space when drbd Split-brain and disconnect.  Based on that event we can
then take action. I could not find a more
convenient way to know that a split-brain occurred other then looking in
/var/log/messages.
 
Thanks
 
EM--

[-- Attachment #1.2: Type: text/html, Size: 4866 bytes --]

[-- Attachment #2: sb_event.patch --]
[-- Type: application/octet-stream, Size: 3208 bytes --]

Index: drbd/drbd_receiver.c
===================================================================
--- drbd/drbd_receiver.c	(revision 19016)
+++ drbd/drbd_receiver.c	(working copy)
@@ -2011,6 +2011,7 @@
 		drbd_uuid_dump(mdev,"self",mdev->bc->md.uuid);
 		drbd_uuid_dump(mdev,"peer",mdev->p_uuid);
 		drbd_force_state(mdev,NS(conn,Disconnecting));
+              drbd_bcast_split_brain(mdev,1);//Tell user we split brained 
 		return conn_mask;
 	}
 
Index: drbd/drbd_nl.c
===================================================================
--- drbd/drbd_nl.c	(revision 19016)
+++ drbd/drbd_nl.c	(working copy)
@@ -1759,6 +1759,41 @@
 	cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
 }
 
+void drbd_bcast_split_brain(drbd_dev *mdev,int flag)
+{
+	char buffer[sizeof(struct cn_msg)+
+		    sizeof(struct drbd_nl_cfg_reply)+
+		    sizeof(struct split_brain_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 val = flag;
+       
+	*tl++ = T_split_brain;
+	*tl++ = sizeof(int);
+       memcpy(tl, &val, 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_split_brain;
+	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);
+}
+
 void drbd_bcast_sync_progress(drbd_dev *mdev)
 {
 	char buffer[sizeof(struct cn_msg)+
Index: drbd/linux/drbd_nl.h
===================================================================
--- drbd/linux/drbd_nl.h	(revision 19016)
+++ drbd/linux/drbd_nl.h	(working copy)
@@ -97,6 +97,10 @@
 	INTEGER(	43,	T_MAY_IGNORE,	sync_progress)
 )
 
+PACKET(split_brain, 24,
+	INTEGER(	44,	T_MAY_IGNORE,	split_brain)
+)
+
 #undef PACKET
 #undef INTEGER
 #undef INT64
Index: drbd/drbd_int.h
===================================================================
--- drbd/drbd_int.h	(revision 19016)
+++ drbd/drbd_int.h	(working copy)
@@ -1417,6 +1417,7 @@
 int __init drbd_nl_init(void);
 void drbd_bcast_state(drbd_dev *mdev);
 void drbd_bcast_sync_progress(drbd_dev *mdev);
+void drbd_bcast_split_brain(drbd_dev *mdev,int flag);
 
 /*
  * inline helper functions
Index: user/drbdsetup.c
===================================================================
--- user/drbdsetup.c	(revision 19016)
+++ user/drbdsetup.c	(working copy)
@@ -1231,6 +1231,14 @@
 				synced % 10);
 		} else fprintf(stderr,"Missing tag !?\n");
 		break;
+	case P_split_brain:
+		if (consume_tag_int(T_split_brain, reply->tag_list, &synced)) {
+			printf("%u SB %d %d\n", 
+				seq,
+				reply->minor,
+				synced);
+		} else fprintf(stderr,"Missing tag !?\n");
+		break;
 	default:
 		printf("%u ?? %d <other message>\n",seq, reply->minor);
 		break;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-29 13:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-01 21:24 [Drbd-dev] drbdsetup events patch to announce Split-brain Montrose, Ernest
2007-10-25 10:15 ` Philipp Reisner
2007-10-25 12:24 ` Montrose, Ernest
2007-10-29 10:19   ` Philipp Reisner
2007-10-29 13:36   ` Montrose, Ernest

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox