diff --git a/src/plugins/switch/federation/federation.c b/src/plugins/switch/federation/federation.c index 193010ead3e3d099f859a289636b245d04044868..9a06b268c7b208ebcd3e941686b4534f0c42a823 100644 --- a/src/plugins/switch/federation/federation.c +++ b/src/plugins/switch/federation/federation.c @@ -339,7 +339,7 @@ _fill_in_adapter_cache(void) int i; adapters = hostlist_iterator_create(adapter_list); - for (i = 0; adapter_name = hostlist_next(adapters); i++) { + for (i = 0; (adapter_name = hostlist_next(adapters)); i++) { rc = ntbl_adapter_resources(NTBL_VERSION, adapter_name, &res); if (rc != NTBL_SUCCESS) return SLURM_ERROR; @@ -535,7 +535,7 @@ _get_adapters(fed_adapter_t *list, int *count) assert(adapter_list != NULL); adapter_iter = hostlist_iterator_create(adapter_list); - for (i = 0; adapter = hostlist_next(adapter_iter); i++) { + for (i = 0; (adapter = hostlist_next(adapter_iter)); i++) { if(_set_up_adapter(list + i, adapter) == SLURM_ERROR) fatal("Failed to set up adapter %s.", adapter); free(adapter); @@ -1034,7 +1034,7 @@ static fed_nodeinfo_t * _alloc_node(fed_libstate_t *lp, char *name) { fed_nodeinfo_t *n = NULL; - int old_bufsize, new_bufsize; + int new_bufsize; bool need_hash_rebuild = false; assert(lp); @@ -1298,23 +1298,6 @@ _next_key(void) return key; } -/* Given an index into a node's adapter list, return the lid of the - * corresponding adapter. - * - * Used by: slurmctld - */ -static int -_get_lid(fed_nodeinfo_t *np, int index) -{ - fed_adapter_t *ap = np->adapter_list; - - assert(np); - assert(index >= 0); - - return ap[index].lid; -} - - /* FIXME - this could be a little smarter than walking the whole list each time */ static fed_window_t * _find_free_window(fed_adapter_t *adapter) { @@ -1472,7 +1455,7 @@ _window_state_set(int adapter_cnt, fed_tableinfo_t *tableinfo, char *hostname, int task_id, enum NTBL_RC state) { fed_nodeinfo_t *node; - fed_adapter_t *adapter; + fed_adapter_t *adapter = NULL; fed_window_t *window; NTBL *table; int i, j; @@ -1687,7 +1670,6 @@ fed_build_jobinfo(fed_jobinfo_t *jp, hostlist_t hl, int nprocs, hostlist_iterator_t hi; char *host; int proc_cnt = 0; - char *cur_idx; int i, j; fed_nodeinfo_t *node; int rc; @@ -1798,7 +1780,7 @@ fail: void _pack_tableinfo(fed_tableinfo_t *tableinfo, Buf buf) { - int i, j; + int i; pack32(tableinfo->table_length, buf); for (i = 0; i < tableinfo->table_length; i++) { @@ -1813,7 +1795,7 @@ _pack_tableinfo(fed_tableinfo_t *tableinfo, Buf buf) int fed_pack_jobinfo(fed_jobinfo_t *j, Buf buf) { - int i, k; + int i; assert(j); assert(j->magic == FED_JOBINFO_MAGIC); @@ -2314,34 +2296,6 @@ _alloc_libstate(void) return tmp; } -/* Used by: slurmctld */ -static void -_copy_libstate(fed_libstate_t *dest, fed_libstate_t *src) -{ - int i; - int err; - fed_nodeinfo_t *tmp; - - assert(dest); - assert(src); - assert(dest->magic == FED_LIBSTATE_MAGIC); - assert(src->magic == FED_LIBSTATE_MAGIC); - assert(dest->node_count == 0); - - _lock(); - /* note: dest->node_count set by _alloc_node */ - for(i = 0; i < src->node_count; i++) { - tmp = _alloc_node(dest, NULL); - err = _copy_node(tmp, &src->node_list[i]); - if(err != SLURM_SUCCESS) { - error("_copy_libstate: %m"); - break; - } - } - dest->key_index = src->key_index; - _unlock(); -} - /* Allocate and initialize memory for the persistent libstate. * * Used by: slurmctld @@ -2369,24 +2323,6 @@ fed_fini(void) return SLURM_SUCCESS; } -static void -_free_libstate(fed_libstate_t *lp) -{ - int i; - - if (!lp) - return; - if (lp->node_list != NULL) { - for (i = 0; i < lp->node_count; i++) - fed_free_nodeinfo(&lp->node_list[i], true); - free(lp->node_list); - } - if (lp->hash_table != NULL) - xfree(lp->hash_table); - xfree(lp); -} - - /* Used by: slurmctld */ static int _pack_libstate(fed_libstate_t *lp, Buf buffer) @@ -2449,8 +2385,6 @@ unpack_error: int fed_libstate_restore(Buf buffer) { - int err; - _lock(); assert(!fed_state); diff --git a/src/plugins/switch/federation/federation.h b/src/plugins/switch/federation/federation.h index 3cc166720826ab57d1441ff3daec20a778b69d61..a3848ad5fff7cc0f9d63ea55d96a34db92cf7db0 100644 --- a/src/plugins/switch/federation/federation.h +++ b/src/plugins/switch/federation/federation.h @@ -90,5 +90,8 @@ int fed_libstate_restore(Buf buffer); int fed_job_step_complete(fed_jobinfo_t *jp, hostlist_t hl); int fed_job_step_allocated(fed_jobinfo_t *jp, hostlist_t hl); int fed_libstate_clear(void); +int fed_slurmctld_init(void); +int fed_slurmd_init(void); +int fed_slurmd_step_init(void); #endif /* _FEDERATION_INCLUDED */ diff --git a/src/plugins/switch/federation/switch_federation.c b/src/plugins/switch/federation/switch_federation.c index fa7eb2c9bc813a264c39efaa3933da4f21729350..a4de81c9acf277da7e70595bef820d047b8b9888 100644 --- a/src/plugins/switch/federation/switch_federation.c +++ b/src/plugins/switch/federation/switch_federation.c @@ -30,6 +30,7 @@ # include "config.h" #endif +#include <stdlib.h> #include <fcntl.h> #include <signal.h> #include <sys/types.h> @@ -39,7 +40,7 @@ #include "src/common/slurm_xlator.h" #include "src/plugins/switch/federation/federation.h" -#define BUF_SIZE 1024 +#define FED_BUF_SIZE 4096 bool fed_need_state_save = false; @@ -150,7 +151,6 @@ int switch_p_slurmd_step_init( void ) */ int switch_p_libstate_save ( char * dir_name ) { - int err; Buf buffer; char *file_name; int ret = SLURM_SUCCESS; @@ -218,11 +218,11 @@ int switch_p_libstate_restore ( char * dir_name, bool recover ) xstrcat(file_name, "/fed_state"); state_fd = open (file_name, O_RDONLY); if (state_fd >= 0) { - data_allocated = BUF_SIZE; + data_allocated = FED_BUF_SIZE; data = xmalloc(data_allocated); while (1) { data_read = read (state_fd, &data[data_size], - BUF_SIZE); + FED_BUF_SIZE); if ((data_read < 0) && (errno == EINTR)) continue; if (data_read < 0) { @@ -395,7 +395,7 @@ int switch_p_build_jobinfo(switch_jobinfo_t switch_job, char *nodelist, || strstr(network, "SN_SINGLE")) { debug3("Found sn_single in network string"); sn_all = false; - } else if (adapter_name = adapter_name_check(network)) { + } else if ((adapter_name = adapter_name_check(network))) { debug3("Found adapter %s in network string", adapter_name); sn_all = false;