[Drbd-dev] Problems at boot time with drbd-8

Graham, Simon Simon.Graham at stratus.com
Tue Jun 27 22:13:56 CEST 2006


I've been working on getting the pre-release version of DRBD8 up on my
system and have run into a couple of minor problems... first of all, I
found that drbdadm dies with a segfault when running 'drbdadm adjust
all' at boot time - turns out this is because the underlying 'drbdsetup
/dev/drbd0 show' command returns "# not configured" at that time - the
parsing of this into a resource structure by drbdadm leaves the
running->me field NULL and we then trip over an attempt to strcmp the
name of the device with the configured name - after some checking, I
found that this problem is actually fixed in the trunk so I moved
forward to there, BUT there are still a couple of issues with startup,
namely:

1.	The routine convert_after_option (in drbdadm_main.c) ends up
being called twice when the 'drbdadm adjust all' command is issued -
once when comparing with the current running config and then again if a
sync operation is actually kicked off - unforturnately, this routine
actually crashes if the name stored in the after option is not a valid
resource name (which of course it isn't after it's been converted the
first time). I fixed this simply by not doing the conversion if the name
does not represent a valid resource - if it truly is a bad resource name
then the later attempt to use it will fail.
2.	The new code added to check IP addresses (verify_ips in
drbdadm_main.c) is not properly initializing the sin_addr local variable
which should have the IP address of the local system - thus this routine
always fails and you get the 'OOPS: the IP address x.y.z.a isn't
configure/up on your system!' error message.
3.	The definition & use of INVALID_IP_IS_INVALID_CONF are
inconsistent; the definition defines it as zero and implies this means
the option is disabled whereas the .c file uses #ifdef to check if it is
enabled. I think this should be #if instead. 

Attached is a patch that fixes these.
Simon


Index: user/drbdadm_main.c
===================================================================
--- user/drbdadm_main.c	(revision 2739)
+++ user/drbdadm_main.c	(working copy)
@@ -794,6 +794,12 @@
 struct d_resource* res_by_name(const char *name);
 
 // Need to convert after from resourcename to minor_number.
+// NOTE: this _may_ already have been done (for example, adjust
+//       processing will call this, then may start a syncer op
+//       which will call it again for the same resource). This is
+//       detected by attempting to locate the resource structure
+//       for the resource -- if this fails, we assume the tx has
+//       already been done.
 void convert_after_option(struct d_resource* res)
 {
   struct d_option* opt;
@@ -802,9 +808,13 @@
 
   if ( (opt = find_opt(res->sync_options, "after")) ) {
     char *ptr;
-
ssprintf(ptr,"%d",dt_minor_of_dev(res_by_name(opt->value)->me->device));
-    free(opt->value);
-    opt->value=strdup(ptr);
+    struct d_resource *ares = res_by_name(opt->value);
+
+    if (ares) {
+        ssprintf(ptr,"%d",dt_minor_of_dev(ares->me->device));
+        free(opt->value);
+        opt->value=strdup(ptr);
+    }
   }
 }
 
@@ -1293,6 +1303,7 @@
   const char *my_ip;
 
   my_ip = res->me->address;
+  sin_addr.s_addr = inet_addr(my_ip);
 
   /* does DRBD support inet6? */
   family = AF_INET;
@@ -1316,7 +1327,7 @@
 
   if (valid == 0) {
     fprintf(stderr, "OOPS, the IP address %s isn't configure/up on your
system!\n", my_ip);
-#ifdef INVALID_IP_IS_INVALID_CONF
+#if INVALID_IP_IS_INVALID_CONF
     config_valid = 0;
 #endif
   }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linbit.com/pipermail/drbd-dev/attachments/20060627/ac96d19d/attachment.htm


More information about the drbd-dev mailing list