* [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d
@ 2012-08-24 9:57 Miquel van Smoorenburg
2012-08-24 11:12 ` Dmitrijs Ledkovs
0 siblings, 1 reply; 5+ messages in thread
From: Miquel van Smoorenburg @ 2012-08-24 9:57 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
Some daemons should not be killed when the system is shutting down. In
debian this is achieved by putting a file with the pid of the daemon in
it in /run/sendsigs.omit.d (or a symlink to its pidfile).
This patch lets mdmon automatically create a symlink in
/run/sendsigs.omit.d to its pidfile.
See also debian bug 684708 at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684708 ,
where I submitted a previous version of this patch.
Comments welcome.
Thanks,
Mike.
[-- Attachment #2: debian-sendsigs-omit.patch --]
[-- Type: text/plain, Size: 1639 bytes --]
Index: mdadm-3.2.5/mdmon.c
===================================================================
--- mdadm-3.2.5.orig/mdmon.c 2012-08-13 09:46:43.205209547 +0000
+++ mdadm-3.2.5/mdmon.c 2012-08-24 09:44:45.472421616 +0000
@@ -142,6 +142,9 @@
static int make_pidfile(char *devname)
{
+#ifdef SENDSIGS_OMIT_DIR
+ char sendsigs_omit_path[100];
+#endif
char path[100];
char pid[10];
int fd;
@@ -160,6 +163,13 @@
close(fd);
if (n < 0)
return -errno;
+
+#ifdef SENDSIGS_OMIT_DIR
+ /* automatically symlink pidfile to sendsigs.omit.d/. ignore result. */
+ sprintf(sendsigs_omit_path, "%s/%s.pid", SENDSIGS_OMIT_DIR, devname);
+ symlink(path, sendsigs_omit_path);
+#endif
+
return 0;
}
@@ -211,6 +221,11 @@
unlink(buf);
sprintf(buf, "%s/%s.sock", MDMON_DIR, devname);
unlink(buf);
+#ifdef SENDSIGS_OMIT_DIR
+ sprintf(buf, "%s/%s.pid", SENDSIGS_OMIT_DIR, devname);
+ unlink(buf);
+#endif
+
}
static int make_control_sock(char *devname)
Index: mdadm-3.2.5/mdadm.h
===================================================================
--- mdadm-3.2.5.orig/mdadm.h 2012-05-18 07:10:03.000000000 +0000
+++ mdadm-3.2.5/mdadm.h 2012-08-24 09:41:53.205479556 +0000
@@ -102,6 +102,16 @@
#define FAILED_SLOTS_DIR "/run/mdadm/failed-slots"
#endif /* FAILED_SLOTS */
+/* Debian has a sendsigs.omit.d directory where pidfiles are located
+ * of daemons that should not be killed when shutting down. We symlink
+ * the mdmon pidfiles into this directory.
+ */
+#ifdef DEBIAN
+#ifndef SENDSIGS_OMIT_DIR
+#define SENDSIGS_OMIT_DIR "/run/sendsigs.omit.d"
+#endif
+#endif
+
#include "md_u.h"
#include "md_p.h"
#include "bitmap.h"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d
2012-08-24 9:57 [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d Miquel van Smoorenburg
@ 2012-08-24 11:12 ` Dmitrijs Ledkovs
2012-08-24 11:49 ` Miquel van Smoorenburg
0 siblings, 1 reply; 5+ messages in thread
From: Dmitrijs Ledkovs @ 2012-08-24 11:12 UTC (permalink / raw)
To: Miquel van Smoorenburg; +Cc: NeilBrown, linux-raid
On 24 August 2012 10:57, Miquel van Smoorenburg <mikevs@xs4all.net> wrote:
> Some daemons should not be killed when the system is shutting down. In
> debian this is achieved by putting a file with the pid of the daemon in it
> in /run/sendsigs.omit.d (or a symlink to its pidfile).
>
> This patch lets mdmon automatically create a symlink in /run/sendsigs.omit.d
> to its pidfile.
>
> See also debian bug 684708 at
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684708 ,
> where I submitted a previous version of this patch.
>
> Comments welcome.
>
For upstream, it might be more appropriate to have a configurable
MDMON_PIDDIR, which defaults to $MDMON_DIR. As far as I know,
sendssigs.omit.d is very specific to Debian and it's derivatives, and
it's not used in the brave new systemd world.
Regards,
Dmitrijs.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d
2012-08-24 11:12 ` Dmitrijs Ledkovs
@ 2012-08-24 11:49 ` Miquel van Smoorenburg
2012-08-24 12:31 ` NeilBrown
0 siblings, 1 reply; 5+ messages in thread
From: Miquel van Smoorenburg @ 2012-08-24 11:49 UTC (permalink / raw)
To: Dmitrijs Ledkovs; +Cc: NeilBrown, linux-raid
On 24-08-12 1:12 PM, Dmitrijs Ledkovs wrote:
> On 24 August 2012 10:57, Miquel van Smoorenburg <mikevs@xs4all.net> wrote:
>> Some daemons should not be killed when the system is shutting down. In
>> debian this is achieved by putting a file with the pid of the daemon in it
>> in /run/sendsigs.omit.d (or a symlink to its pidfile).
>>
>> This patch lets mdmon automatically create a symlink in /run/sendsigs.omit.d
>> to its pidfile.
>>
>> See also debian bug 684708 at
>> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684708 ,
>> where I submitted a previous version of this patch.
>>
>> Comments welcome.
>>
>
> For upstream, it might be more appropriate to have a configurable
> MDMON_PIDDIR, which defaults to $MDMON_DIR. As far as I know,
> sendssigs.omit.d is very specific to Debian and it's derivatives, and
> it's not used in the brave new systemd world.
Well, I'm not sure if there's a guideline for this in debian, but the
convention appears to be to put the pidfiles in /run or a
package-specific subdir of /run, and then to create a symlink from the
sendsigs.omit.d directory to the pidfile- which is exactly what this
patch does. If you're saying that something debian-specific like this
should not be in the upstream package, then that's fine, and the patch
will just be carried in debian. No problem.
Note that I am not the debian mdadm maintainer, it's just that often
it's appreciated if a bug/patch submitter works with upstream.
Thanks,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d
2012-08-24 11:49 ` Miquel van Smoorenburg
@ 2012-08-24 12:31 ` NeilBrown
2012-09-03 14:50 ` Miquel van Smoorenburg
0 siblings, 1 reply; 5+ messages in thread
From: NeilBrown @ 2012-08-24 12:31 UTC (permalink / raw)
To: Miquel van Smoorenburg; +Cc: Dmitrijs Ledkovs, linux-raid
[-- Attachment #1: Type: text/plain, Size: 2706 bytes --]
On Fri, 24 Aug 2012 13:49:52 +0200 Miquel van Smoorenburg <mikevs@xs4all.net>
wrote:
> On 24-08-12 1:12 PM, Dmitrijs Ledkovs wrote:
> > On 24 August 2012 10:57, Miquel van Smoorenburg <mikevs@xs4all.net> wrote:
> >> Some daemons should not be killed when the system is shutting down. In
> >> debian this is achieved by putting a file with the pid of the daemon in it
> >> in /run/sendsigs.omit.d (or a symlink to its pidfile).
> >>
> >> This patch lets mdmon automatically create a symlink in /run/sendsigs.omit.d
> >> to its pidfile.
> >>
> >> See also debian bug 684708 at
> >> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684708 ,
> >> where I submitted a previous version of this patch.
> >>
> >> Comments welcome.
> >>
> >
> > For upstream, it might be more appropriate to have a configurable
> > MDMON_PIDDIR, which defaults to $MDMON_DIR. As far as I know,
> > sendssigs.omit.d is very specific to Debian and it's derivatives, and
> > it's not used in the brave new systemd world.
No, the "brave new systemd world" requires that $ARGV[0] start with '@' to
avoid being killed, and mdmon has special code to support that.
So it would not be unreasonable to add special code to support
sendsigs.omit.d.
However if we only need to protect things at shutdown I wonder it you could
just add something like:
cd /run/mdadm/
for file in md*.pid
do ln -s /run/mdadm/$file /.../sendsigs.omit.d/mdadm-$file
done
in some script that gets run before the 'killall' happens.
That would be simple and should work.
If we really need mdmon to create the symlink I'd want:
1/ the compiled-in path (SENDSIGS_OMIT_DIR) to contain a %s which is replaced
by the devname, so e.g.
-DSENDSIGS_OMIT_DIR=/var/run/omit.dir/mdmon-%d.pid
and probably use asprintf rather than a fixed size buffer that the proposed
patch uses (yes, I know I used fixed size buffers all the time. I'm bad -
show my how much better a real coder can do and I might learn to change my
ways!! :-)
Thanks,
NeilBrown
>
> Well, I'm not sure if there's a guideline for this in debian, but the
> convention appears to be to put the pidfiles in /run or a
> package-specific subdir of /run, and then to create a symlink from the
> sendsigs.omit.d directory to the pidfile- which is exactly what this
> patch does. If you're saying that something debian-specific like this
> should not be in the upstream package, then that's fine, and the patch
> will just be carried in debian. No problem.
>
> Note that I am not the debian mdadm maintainer, it's just that often
> it's appreciated if a bug/patch submitter works with upstream.
>
> Thanks,
>
> Mike.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d
2012-08-24 12:31 ` NeilBrown
@ 2012-09-03 14:50 ` Miquel van Smoorenburg
0 siblings, 0 replies; 5+ messages in thread
From: Miquel van Smoorenburg @ 2012-09-03 14:50 UTC (permalink / raw)
To: NeilBrown; +Cc: Dmitrijs Ledkovs, linux-raid
On 24-08-12 2:31 PM, NeilBrown wrote:
> On Fri, 24 Aug 2012 13:49:52 +0200 Miquel van Smoorenburg <mikevs@xs4all.net>
> wrote:
>
>> On 24-08-12 1:12 PM, Dmitrijs Ledkovs wrote:
>>> On 24 August 2012 10:57, Miquel van Smoorenburg <mikevs@xs4all.net> wrote:
>>>> Some daemons should not be killed when the system is shutting down. In
>>>> debian this is achieved by putting a file with the pid of the daemon in it
>>>> in /run/sendsigs.omit.d (or a symlink to its pidfile).
>>>>
>>>> This patch lets mdmon automatically create a symlink in /run/sendsigs.omit.d
>>>> to its pidfile.
>
> However if we only need to protect things at shutdown I wonder it you could
> just add something like:
>
> cd /run/mdadm/
> for file in md*.pid
> do ln -s /run/mdadm/$file /.../sendsigs.omit.d/mdadm-$file
> done
>
> in some script that gets run before the 'killall' happens.
Yes that would work. Very good idea!
Forget about the patch. I'll just add something like that to the stop
section of the mdadm-raid initscript.
Thanks!
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-03 14:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-24 9:57 [PATCH] debian: symlink mdmon pidfile into /run/sendsigs.omit.d Miquel van Smoorenburg
2012-08-24 11:12 ` Dmitrijs Ledkovs
2012-08-24 11:49 ` Miquel van Smoorenburg
2012-08-24 12:31 ` NeilBrown
2012-09-03 14:50 ` Miquel van Smoorenburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).