diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index 7fe1a5aa58bad920d655cd1d067589a2e28b481b..85bc33aa1a3559773ff04634c1b7330730fe7997 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -2068,7 +2068,6 @@ _unpack_job_info_members(job_info_t * job, Buf buffer) safe_unpackstr_xmalloc(&job->account, &uint32_tmp, buffer); safe_unpackstr_xmalloc(&job->network, &uint32_tmp, buffer); safe_unpackstr_xmalloc(&job->comment, &uint32_tmp, buffer); - safe_unpackstr_xmalloc(&job->dependency, &uint32_tmp, buffer); safe_unpack32(&job->exit_code, buffer); safe_unpack16(&job->num_cpu_groups, buffer); @@ -2091,9 +2090,10 @@ _unpack_job_info_members(job_info_t * job, Buf buffer) goto unpack_error; /*** unpack default job details ***/ - safe_unpackstr_xmalloc(&job->features, &uint32_tmp, buffer); - safe_unpackstr_xmalloc(&job->work_dir, &uint32_tmp, buffer); - safe_unpackstr_xmalloc(&job->command, &uint32_tmp, buffer); + safe_unpackstr_xmalloc(&job->features, &uint32_tmp, buffer); + safe_unpackstr_xmalloc(&job->work_dir, &uint32_tmp, buffer); + safe_unpackstr_xmalloc(&job->dependency, &uint32_tmp, buffer); + safe_unpackstr_xmalloc(&job->command, &uint32_tmp, buffer); safe_unpack32(&job->num_nodes, buffer); safe_unpack32(&job->max_nodes, buffer); diff --git a/src/plugins/sched/wiki2/get_jobs.c b/src/plugins/sched/wiki2/get_jobs.c index fed00aed0fc8dfe2fabd4eec602f25eea6ffd286..873b145f4b73db4d87cfafb142cab5123321d5ff 100644 --- a/src/plugins/sched/wiki2/get_jobs.c +++ b/src/plugins/sched/wiki2/get_jobs.c @@ -371,10 +371,10 @@ static void _get_job_comment(struct job_record *job_ptr, size = snprintf(buffer, buf_size, "COMMENT=\""); /* JOB DEPENDENCY */ - if (job_ptr->dependency) { + if (job_ptr->details && job_ptr->details->dependency) { /* Kludge for job dependency set via srun */ size += snprintf((buffer + size), (buf_size - size), - "DEPEND=%s", job_ptr->dependency); + "DEPEND=%s", job_ptr->details->dependency); field_sep = "?"; } diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 32f85b0161c99991c304f1130c0f5bb91c35b25f..45e753d590b4c0a3a49290fa3a3147ce75cff0a2 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -230,6 +230,9 @@ void delete_job_details(struct job_record *job_entry) xfree(job_entry->details->mc_ptr); if (job_entry->details->feature_list) list_destroy(job_entry->details->feature_list); + xfree(job_entry->details->dependency); + if (job_entry->details->depend_list) + list_destroy(job_entry->details->depend_list); xfree(job_entry->details); } @@ -519,7 +522,6 @@ static void _dump_job_state(struct job_record *dump_job_ptr, Buf buffer) packstr(dump_job_ptr->alloc_node, buffer); packstr(dump_job_ptr->account, buffer); packstr(dump_job_ptr->comment, buffer); - packstr(dump_job_ptr->dependency, buffer); packstr(dump_job_ptr->network, buffer); packstr(dump_job_ptr->mail_user, buffer); @@ -558,7 +560,6 @@ static int _load_job_state(Buf buffer) char *nodes = NULL, *partition = NULL, *name = NULL, *resp_host = NULL; char *account = NULL, *network = NULL, *mail_user = NULL; char *comment = NULL, *nodes_completing = NULL, *alloc_node = NULL; - char *dependency = NULL; struct job_record *job_ptr; struct part_record *part_ptr; int error_code; @@ -602,7 +603,6 @@ static int _load_job_state(Buf buffer) safe_unpackstr_xmalloc(&alloc_node, &name_len, buffer); safe_unpackstr_xmalloc(&account, &name_len, buffer); safe_unpackstr_xmalloc(&comment, &name_len, buffer); - safe_unpackstr_xmalloc(&dependency, &name_len, buffer); safe_unpackstr_xmalloc(&network, &name_len, buffer); safe_unpackstr_xmalloc(&mail_user, &name_len, buffer); @@ -679,7 +679,6 @@ static int _load_job_state(Buf buffer) job_ptr->tot_sus_time = tot_sus_time; job_ptr->job_state = job_state; job_ptr->next_step_id = next_step_id; - job_ptr->dependency = dependency; job_ptr->exit_code = exit_code; job_ptr->state_reason = state_reason; job_ptr->num_procs = num_procs; @@ -741,7 +740,6 @@ unpack_error: xfree(alloc_node); xfree(account); xfree(comment); - xfree(dependency); xfree(resp_host); xfree(mail_user); select_g_free_jobinfo(&select_jobinfo); @@ -778,9 +776,10 @@ void _dump_job_details(struct job_details *detail_ptr, Buf buffer) pack_time(detail_ptr->begin_time, buffer); pack_time(detail_ptr->submit_time, buffer); - packstr(detail_ptr->req_nodes, buffer); - packstr(detail_ptr->exc_nodes, buffer); - packstr(detail_ptr->features, buffer); + packstr(detail_ptr->req_nodes, buffer); + packstr(detail_ptr->exc_nodes, buffer); + packstr(detail_ptr->features, buffer); + packstr(detail_ptr->dependency, buffer); packstr(detail_ptr->err, buffer); packstr(detail_ptr->in, buffer); @@ -795,6 +794,7 @@ void _dump_job_details(struct job_details *detail_ptr, Buf buffer) static int _load_job_details(struct job_record *job_ptr, Buf buffer) { char *req_nodes = NULL, *exc_nodes = NULL, *features = NULL; + char *dependency = NULL; char *err = NULL, *in = NULL, *out = NULL, *work_dir = NULL; char **argv = (char **) NULL; uint32_t min_nodes, max_nodes; @@ -831,9 +831,10 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer) safe_unpack_time(&begin_time, buffer); safe_unpack_time(&submit_time, buffer); - safe_unpackstr_xmalloc(&req_nodes, &name_len, buffer); - safe_unpackstr_xmalloc(&exc_nodes, &name_len, buffer); - safe_unpackstr_xmalloc(&features, &name_len, buffer); + safe_unpackstr_xmalloc(&req_nodes, &name_len, buffer); + safe_unpackstr_xmalloc(&exc_nodes, &name_len, buffer); + safe_unpackstr_xmalloc(&features, &name_len, buffer); + safe_unpackstr_xmalloc(&dependency, &name_len, buffer); safe_unpackstr_xmalloc(&err, &name_len, buffer); safe_unpackstr_xmalloc(&in, &name_len, buffer); @@ -899,6 +900,7 @@ static int _load_job_details(struct job_record *job_ptr, Buf buffer) job_ptr->details->argc = argc; job_ptr->details->argv = argv; job_ptr->details->mc_ptr = mc_ptr; + job_ptr->details->dependency = dependency; return SLURM_SUCCESS; @@ -906,6 +908,7 @@ unpack_error: xfree(req_nodes); xfree(exc_nodes); xfree(features); + xfree(dependency); xfree(err); xfree(in); xfree(out); @@ -2877,9 +2880,6 @@ static void _list_delete_job(void *job_entry) xfree(job_ptr->alloc_lps); xfree(job_ptr->used_lps); xfree(job_ptr->comment); - xfree(job_ptr->dependency); - if (job_ptr->depend_list) - list_destroy(job_ptr->depend_list); select_g_free_jobinfo(&job_ptr->select_jobinfo); if (job_ptr->step_list) { delete_step_records(job_ptr, 0); @@ -3051,7 +3051,6 @@ void pack_job(struct job_record *dump_job_ptr, Buf buffer) packstr(dump_job_ptr->account, buffer); packstr(dump_job_ptr->network, buffer); packstr(dump_job_ptr->comment, buffer); - packstr(dump_job_ptr->dependency, buffer); pack32(dump_job_ptr->exit_code, buffer); @@ -3090,8 +3089,9 @@ static void _pack_default_job_details(struct job_details *detail_ptr, char *cmd_line = NULL; if (detail_ptr) { - packstr(detail_ptr->features, buffer); - packstr(detail_ptr->work_dir, buffer); + packstr(detail_ptr->features, buffer); + packstr(detail_ptr->work_dir, buffer); + packstr(detail_ptr->dependency, buffer); if (detail_ptr->argv) { for (i=0; detail_ptr->argv[i]; i++) { if (cmd_line) @@ -3895,14 +3895,14 @@ int update_job(job_desc_msg_t * job_specs, uid_t uid) } if (job_specs->dependency) { - if (!IS_JOB_PENDING(job_ptr)) + if ((!IS_JOB_PENDING(job_ptr)) || (job_ptr->details == NULL)) error_code = ESLURM_DISABLED; else if (update_job_dependency(job_ptr, job_specs->dependency) != SLURM_SUCCESS) { error_code = ESLURM_DEPENDENCY; } else { info("update_job: setting dependency to %s for " - "job_id %u", job_ptr->dependency, + "job_id %u", job_ptr->details->dependency, job_ptr->job_id); } } diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c index 74f096ce540d36891dd02b6d1f2526fafc08ba91..073dfa17a3e4e3dcd125f6a148bb047dad6d5372 100644 --- a/src/slurmctld/job_scheduler.c +++ b/src/slurmctld/job_scheduler.c @@ -498,10 +498,11 @@ extern void print_job_dependency(struct job_record *job_ptr) char *dep_str; info("Dependency information for job %u", job_ptr->job_id); - if (!job_ptr->depend_list) + if ((job_ptr->details == NULL) || + (job_ptr->details->depend_list == NULL)) return; - depend_iter = list_iterator_create(job_ptr->depend_list); + depend_iter = list_iterator_create(job_ptr->details->depend_list); if (!depend_iter) fatal("list_iterator_create memory allocation failure"); while ((dep_ptr = list_next(depend_iter))) { @@ -532,10 +533,11 @@ extern int test_job_dependency(struct job_record *job_ptr) struct depend_spec *dep_ptr; bool failure = false; - if (!job_ptr->depend_list) + if ((job_ptr->details == NULL) || + (job_ptr->details->depend_list == NULL)) return 0; - depend_iter = list_iterator_create(job_ptr->depend_list); + depend_iter = list_iterator_create(job_ptr->details->depend_list); if (!depend_iter) fatal("list_iterator_create memory allocation failure"); while ((dep_ptr = list_next(depend_iter))) { @@ -603,11 +605,14 @@ extern int update_job_dependency(struct job_record *job_ptr, char *new_depend) struct job_record *dep_job_ptr; char dep_buf[32]; + if (job_ptr->details == NULL) + return EINVAL; + /* Clear dependencies on NULL or empty dependency input */ if ((new_depend == NULL) || (new_depend[0] == '\0')) { - xfree(job_ptr->dependency); - if (job_ptr->depend_list) - list_destroy(job_ptr->depend_list); + xfree(job_ptr->details->dependency); + if (job_ptr->details->depend_list) + list_destroy(job_ptr->details->depend_list); return rc; } @@ -682,11 +687,11 @@ extern int update_job_dependency(struct job_record *job_ptr, char *new_depend) } if (rc == SLURM_SUCCESS) { - xfree(job_ptr->dependency); - job_ptr->dependency = xstrdup(new_depend); - if (job_ptr->depend_list) - list_destroy(job_ptr->depend_list); - job_ptr->depend_list = new_depend_list; + xfree(job_ptr->details->dependency); + job_ptr->details->dependency = xstrdup(new_depend); + if (job_ptr->details->depend_list) + list_destroy(job_ptr->details->depend_list); + job_ptr->details->depend_list = new_depend_list; #if _DEBUG print_job_dependency(job_ptr); #endif diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c index d6d3eafd2a674b31f68a612d7d99e40f832f94e3..7d318ac8dbb15a558d8e6937a50c074b6b7f9be1 100644 --- a/src/slurmctld/read_config.c +++ b/src/slurmctld/read_config.c @@ -1132,10 +1132,11 @@ static int _restore_job_dependencies(void) job_iterator = list_iterator_create(job_list); while ((job_ptr = (struct job_record *) list_next(job_iterator))) { - if (job_ptr->dependency == NULL) + if ((job_ptr->details == NULL) || + (job_ptr->details->dependency == NULL)) continue; - new_depend = job_ptr->dependency; - job_ptr->dependency = NULL; + new_depend = job_ptr->details->dependency; + job_ptr->details->dependency = NULL; rc = update_job_dependency(job_ptr, new_depend); if (rc != SLURM_SUCCESS) { error("Invalid dependencies discarded for job %u: %s", diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h index ce5318b6b90b88ebca8a20851ce414892dd343fc..195b0f26e681932703a26bcc6da74f76e0781ef6 100644 --- a/src/slurmctld/slurmctld.h +++ b/src/slurmctld/slurmctld.h @@ -328,6 +328,8 @@ struct job_details { uint16_t argc; /* count of argv elements */ uint16_t no_requeue; /* don't requeue job if set */ multi_core_data_t *mc_ptr; /* multi-core specific data */ + char *dependency; /* wait for other jobs */ + List depend_list; /* list of job_ptr:state pairs */ }; struct job_record { @@ -383,8 +385,6 @@ struct job_record { uint16_t other_port; /* port for client communications */ char *account; /* account number to charge */ char *comment; /* arbitrary comment */ - char *dependency; /* wait for other jobs */ - List depend_list; /* list of job_ptr:state pairs */ char *network; /* network/switch requirement spec */ struct job_record *job_next; /* next entry with same hash index */ uint16_t cr_enabled; /* specify if if Consumable