All of lore.kernel.org
 help / color / mirror / Atom feed
* [Drbd-dev] Problems at boot time with drbd-8
@ 2006-06-27 20:13 Graham, Simon
  2006-07-03 15:41 ` Philipp Reisner
  0 siblings, 1 reply; 2+ messages in thread
From: Graham, Simon @ 2006-06-27 20:13 UTC (permalink / raw)
  To: drbd-dev

[-- Attachment #1: Type: text/plain, Size: 3605 bytes --]

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
   }



[-- Attachment #2: Type: text/html, Size: 10710 bytes --]

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

* Re: [Drbd-dev] Problems at boot time with drbd-8
  2006-06-27 20:13 [Drbd-dev] Problems at boot time with drbd-8 Graham, Simon
@ 2006-07-03 15:41 ` Philipp Reisner
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Reisner @ 2006-07-03 15:41 UTC (permalink / raw)
  To: drbd-dev

Am Dienstag, 27. Juni 2006 22:13 schrieb Graham, Simon:
> 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.

Thanks, for that detailed description. I took an other route to fixe
the issue, by calling the convert_ functions from one central
place, once. Thanks!

> 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.
>

Right.

Thanks again!

Applied it to SVN...

-Philipp
-- 
: Dipl-Ing Philipp Reisner                      Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH          Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austria    http://www.linbit.com :

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

end of thread, other threads:[~2006-07-03 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-27 20:13 [Drbd-dev] Problems at boot time with drbd-8 Graham, Simon
2006-07-03 15:41 ` Philipp Reisner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.