diff options
author | Ryo Nakamura <upa@haeena.net> | 2024-02-18 14:48:30 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2024-02-18 14:48:30 +0900 |
commit | 5f628b64e3d91977a787178751489cf3b3604d69 (patch) | |
tree | b6d87ad84dfb50e6e26fd5b28b219c695127290d /src/mscp.c | |
parent | 2f9c2c0f10f1cf81bb58b1603d089ac0209db8c4 (diff) |
add -W and -R option for resume checkpoint
Diffstat (limited to 'src/mscp.c')
-rw-r--r-- | src/mscp.c | 46 |
1 files changed, 32 insertions, 14 deletions
@@ -202,22 +202,32 @@ static int validate_and_set_defaut_params(struct mscp_opts *o) return 0; } -struct mscp *mscp_init(const char *remote_host, int direction, struct mscp_opts *o, - struct mscp_ssh_opts *s) +int mscp_set_remote(struct mscp *m, const char *remote_host, int direction) { - struct mscp *m; - int n; - if (!remote_host) { priv_set_errv("empty remote host"); - return NULL; + return -1; } if (!(direction == MSCP_DIRECTION_L2R || direction == MSCP_DIRECTION_R2L)) { priv_set_errv("invalid copy direction: %d", direction); - return NULL; + return -1; } + if (!(m->remote = strdup(remote_host))) { + priv_set_errv("strdup: %s", strerrno()); + return -1; + } + m->direction = direction; + + return 0; +} + +struct mscp *mscp_init(struct mscp_opts *o, struct mscp_ssh_opts *s) +{ + struct mscp *m; + int n; + set_print_severity(o->severity); if (validate_and_set_defaut_params(o) < 0) { @@ -229,7 +239,6 @@ struct mscp *mscp_init(const char *remote_host, int direction, struct mscp_opts return NULL; } memset(m, 0, sizeof(*m)); - m->direction = direction; m->opts = o; m->ssh_opts = s; chunk_pool_set_ready(m, false); @@ -259,11 +268,6 @@ struct mscp *mscp_init(const char *remote_host, int direction, struct mscp_opts goto free_out; } - if (!(m->remote = strdup(remote_host))) { - priv_set_errv("strdup: %s", strerrno()); - goto free_out; - } - if (o->coremask) { if (expand_coremask(o->coremask, &m->cores, &m->nr_cores) < 0) goto free_out; @@ -499,7 +503,21 @@ int mscp_checkpoint_get_remote(const char *pathname, char *remote, size_t len, i int mscp_checkpoint_load(struct mscp *m, const char *pathname) { - return checkpoint_load_paths(pathname, m->path_pool, m->chunk_pool); + struct chunk *c; + unsigned int i; + + if (checkpoint_load_paths(pathname, m->path_pool, m->chunk_pool) < 0) + return -1; + + /* totaling up bytes to be transferred and set chunk_pool is + * ready instead of the mscp_scan thread */ + m->total_bytes = 0; + pool_for_each(m->chunk_pool, c, i) { + m->total_bytes += c->len; + } + chunk_pool_set_ready(m, true); + + return 0; } int mscp_checkpoint_save(struct mscp *m, const char *pathname) |