]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
Grow: fix removal of line in wrong case
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
index 0588590e877b8febd2aa31e6d7596846f89cd6e3..a2f4f1428787340fb4829398b5d25f17f133a68c 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -24,6 +24,7 @@
 #include       "mdadm.h"
 #include       "dlink.h"
 #include       <sys/mman.h>
+#include       <stddef.h>
 #include       <stdint.h>
 #include       <signal.h>
 #include       <sys/wait.h>
 #include       "md_u.h"
 #include       "md_p.h"
 
-#ifndef offsetof
-#define offsetof(t,f) ((size_t)&(((t*)0)->f))
-#endif
-
 int restore_backup(struct supertype *st,
                   struct mdinfo *content,
                   int working_disks,
@@ -943,7 +940,9 @@ int reshape_open_backup_file(char *backup_file,
 
        if (!restart && strncmp(backup_file, MAP_DIR, strlen(MAP_DIR)) != 0) {
                char *bu = make_backup(sys_name);
-               symlink(backup_file, bu);
+               if (symlink(backup_file, bu))
+                       pr_err("Recording backup file in " MAP_DIR "failed: %s\n",
+                              strerror(errno));
                free(bu);
        }
 
@@ -1341,7 +1340,6 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
 
                switch (re->level) {
                case 4:
-                       re->before.layout = 0;
                        re->after.layout = 0;
                        break;
                case 5:
@@ -3475,6 +3473,10 @@ int reshape_container(char *container, char *devname,
         */
        ping_monitor(container);
 
+       if (!forked && !freeze_reshape && !check_env("MDADM_NO_SYSTEMCTL"))
+               if (continue_via_systemd(container))
+                       return 0;
+
        switch (forked ? 0 : fork()) {
        case -1: /* error */
                perror("Cannot fork to complete reshape\n");
@@ -4916,7 +4918,7 @@ int Grow_continue_command(char *devname, int fd,
 
        /* continue reshape
         */
-       ret_val = Grow_continue(fd, st, content, backup_file, 0);
+       ret_val = Grow_continue(fd, st, content, backup_file, 1, 0);
 
 Grow_continue_command_exit:
        if (fd2 > -1)
@@ -4932,7 +4934,7 @@ Grow_continue_command_exit:
 }
 
 int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
-                 char *backup_file, int freeze_reshape)
+                 char *backup_file, int forked, int freeze_reshape)
 {
        int ret_val = 2;
 
@@ -4949,13 +4951,13 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
                close(cfd);
                ret_val = reshape_container(st->container_devnm, NULL, mdfd,
                                            st, info, 0, backup_file,
-                                           0, 1,
+                                           0, forked,
                                            1 | info->reshape_active,
                                            freeze_reshape);
        } else
                ret_val = reshape_array(NULL, mdfd, "array", st, info, 1,
                                        NULL, INVALID_SECTORS,
-                                       backup_file, 0, 1,
+                                       backup_file, 0, forked,
                                        1 | info->reshape_active,
                                        freeze_reshape);