#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,
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);
}
switch (re->level) {
case 4:
- re->before.layout = 0;
re->after.layout = 0;
break;
case 5:
*/
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");
/* 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)
}
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;
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);