Skip to content
Snippets Groups Projects
Commit 43edb81e authored by Moe Jette's avatar Moe Jette
Browse files

for gres info unpack from node use plugin_id as key rather than plugin name

  for better speed
parent bde56d62
No related branches found
No related tags found
No related merge requests found
...@@ -402,9 +402,9 @@ extern int gres_plugin_load_node_config(void) ...@@ -402,9 +402,9 @@ extern int gres_plugin_load_node_config(void)
* *
* Data format: * Data format:
* uint32_t magic cookie * uint32_t magic cookie
* char * gres name * uint32_t plugin_id name (must be unique)
* uint32_t gres data block size * uint32_t gres data block size
* void * gres data * void * gres data packed by plugin
*/ */
extern int gres_plugin_pack_node_config(Buf buffer) extern int gres_plugin_pack_node_config(Buf buffer)
{ {
...@@ -417,7 +417,7 @@ extern int gres_plugin_pack_node_config(Buf buffer) ...@@ -417,7 +417,7 @@ extern int gres_plugin_pack_node_config(Buf buffer)
slurm_mutex_lock(&gres_context_lock); slurm_mutex_lock(&gres_context_lock);
for (i=0; ((i < gres_context_cnt) && (rc == SLURM_SUCCESS)); i++) { for (i=0; ((i < gres_context_cnt) && (rc == SLURM_SUCCESS)); i++) {
pack32(magic, buffer); pack32(magic, buffer);
packstr(gres_context[i].gres_type, buffer); pack32(*(gres_context[i].ops.plugin_id), buffer);
header_offset = get_buf_offset(buffer); header_offset = get_buf_offset(buffer);
pack32(gres_size, buffer); /* Placeholder for now */ pack32(gres_size, buffer); /* Placeholder for now */
data_offset = get_buf_offset(buffer); data_offset = get_buf_offset(buffer);
...@@ -441,8 +441,7 @@ extern int gres_plugin_pack_node_config(Buf buffer) ...@@ -441,8 +441,7 @@ extern int gres_plugin_pack_node_config(Buf buffer)
extern int gres_plugin_unpack_node_config(Buf buffer, char* node_name) extern int gres_plugin_unpack_node_config(Buf buffer, char* node_name)
{ {
int i, rc, rc2; int i, rc, rc2;
uint32_t gres_size, magic, tail_offset, uint32_tmp; uint32_t gres_size, magic, tail_offset, plugin_id;
char *gres_type = NULL;
rc = gres_plugin_init(); rc = gres_plugin_init();
...@@ -456,28 +455,25 @@ extern int gres_plugin_unpack_node_config(Buf buffer, char* node_name) ...@@ -456,28 +455,25 @@ extern int gres_plugin_unpack_node_config(Buf buffer, char* node_name)
safe_unpack32(&magic, buffer); safe_unpack32(&magic, buffer);
if (magic != GRES_MAGIC) if (magic != GRES_MAGIC)
goto unpack_error; goto unpack_error;
safe_unpackstr_xmalloc(&gres_type, &uint32_tmp, buffer); safe_unpack32(&plugin_id, buffer);
if (gres_type == NULL)
goto unpack_error;
safe_unpack32(&gres_size, buffer); safe_unpack32(&gres_size, buffer);
for (i=0; i<gres_context_cnt; i++) { for (i=0; i<gres_context_cnt; i++) {
if (!strcmp(gres_type, gres_context[i].gres_type)) if (*(gres_context[i].ops.plugin_id) == plugin_id)
break; break;
} }
if (i >= gres_context_cnt) { if (i >= gres_context_cnt) {
error("gres_plugin_unpack_node_config: no plugin " error("gres_plugin_unpack_node_config: no plugin "
"configured to unpack %s data from node %s", "configured to unpack data type %u from node %s",
gres_type, node_name); plugin_id, node_name);
/* A likely sign that GresPlugins is inconsistently /* A likely sign that GresPlugins is inconsistently
* configured. Not a fatal error, skip over the data. */ * configured. Not a fatal error, skip over the data. */
tail_offset = get_buf_offset(buffer); tail_offset = get_buf_offset(buffer);
tail_offset += gres_size; tail_offset += gres_size;
set_buf_offset(buffer, tail_offset); set_buf_offset(buffer, tail_offset);
} else { continue;
gres_context[i].unpacked_info = true;
rc = (*(gres_context[i].ops.unpack_node_config))(buffer);
} }
xfree(gres_type); gres_context[i].unpacked_info = true;
rc = (*(gres_context[i].ops.unpack_node_config))(buffer);
} }
fini: /* Insure that every gres plugin is called for unpack, even if no data fini: /* Insure that every gres plugin is called for unpack, even if no data
...@@ -498,7 +494,6 @@ fini: /* Insure that every gres plugin is called for unpack, even if no data ...@@ -498,7 +494,6 @@ fini: /* Insure that every gres plugin is called for unpack, even if no data
return rc; return rc;
unpack_error: unpack_error:
xfree(gres_type);
error("gres_plugin_unpack_node_config: unpack error from node %s", error("gres_plugin_unpack_node_config: unpack error from node %s",
node_name); node_name);
rc = SLURM_ERROR; rc = SLURM_ERROR;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment