diff options
author | NeilBrown <neilb@suse.de> | 2013-08-01 11:16:14 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-08-01 13:58:10 +1000 |
commit | 84d11e6c6a3b827b2daa32e16303235ce33d49f5 (patch) | |
tree | baf3f292e7ed7262240d0bc85b936cf856f65b00 /Grow.c | |
parent | d81cc6a72e5a9ca66c54219758eb6cf07fcd9de2 (diff) |
Grow: exit background thread cleanly on SIGTERM.
If the mdadm thread that monitors a reshape gets SIGTERM it should
exit cleanly and clear the 'suspended' region of the array.
However it mustn't clear 'sync_max' as that would allow the
reshape to continue unmonitored.
If the thread ever does get killed, the array should really be
shutdown soon after if possible.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r-- | Grow.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -25,6 +25,7 @@ #include "dlink.h" #include <sys/mman.h> #include <stdint.h> +#include <signal.h> #if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN) #error no endian defined @@ -729,7 +730,8 @@ void abort_reshape(struct mdinfo *sra) sysfs_set_num(sra, NULL, "suspend_hi", 0); sysfs_set_num(sra, NULL, "suspend_lo", 0); sysfs_set_num(sra, NULL, "sync_min", 0); - sysfs_set_str(sra, NULL, "sync_max", "max"); + // It isn't safe to reset sync_max as we aren't monitoring. + // Array really should be stopped at this point. } int remove_disks_for_takeover(struct supertype *st, @@ -2726,6 +2728,12 @@ static int impose_level(int fd, int level, char *devname, int verbose) return 0; } +int sigterm = 0; +static void catch_term(int sig) +{ + sigterm = 1; +} + static int reshape_array(char *container, int fd, char *devname, struct supertype *st, struct mdinfo *info, int force, struct mddev_dev *devlist, @@ -3260,6 +3268,8 @@ started: fd = -1; mlockall(MCL_FUTURE); + signal(SIGTERM, catch_term); + if (st->ss->external) { /* metadata handler takes it from here */ done = st->ss->manage_reshape( @@ -4243,7 +4253,8 @@ int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape, forget_backup(dests, destfd, destoffsets, 1); } - + if (sigterm) + rv = -2; if (rv < 0) { if (rv == -1) done = 1; |