From a85dc32d8b2bedd678784782980896c0d6623f9d Mon Sep 17 00:00:00 2001
From: Tim Wickberg <tim@schedmd.com>
Date: Thu, 1 Jul 2021 16:22:53 -0600
Subject: [PATCH] Change switch_{g,p}_job_preinit() to pass in the
 stepd_step_rec_t.

Instead of just the switch_job element, which can still be accessed
if needed.

Bug 11922.
---
 src/common/switch.c                               | 15 +++------------
 src/common/switch.h                               |  2 +-
 src/plugins/switch/cray_aries/switch_cray_aries.c |  2 +-
 src/plugins/switch/none/switch_none.c             |  2 +-
 src/slurmd/slurmstepd/mgr.c                       |  2 +-
 5 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/common/switch.c b/src/common/switch.c
index a43fe1dacbf..122604472de 100644
--- a/src/common/switch.c
+++ b/src/common/switch.c
@@ -80,7 +80,7 @@ typedef struct slurm_switch_ops {
 					    char *buf, size_t size);
 	int          (*node_init)         ( void );
 	int          (*node_fini)         ( void );
-	int          (*job_preinit)       ( switch_jobinfo_t *jobinfo );
+	int          (*job_preinit)       ( stepd_step_rec_t *job );
 	int          (*job_init)          ( stepd_step_rec_t *job );
 	int          (*job_suspend_test)  ( switch_jobinfo_t *jobinfo );
 	void         (*job_suspend_info_get)( switch_jobinfo_t *jobinfo,
@@ -556,21 +556,12 @@ extern int switch_g_node_fini(void)
 	return (*(ops[switch_context_default].node_fini)) ();
 }
 
-extern int switch_g_job_preinit(dynamic_plugin_data_t *jobinfo)
+extern int switch_g_job_preinit(stepd_step_rec_t *job)
 {
-	void *data = NULL;
-	uint32_t plugin_id;
-
 	if ( switch_init(0) < 0 )
 		return SLURM_ERROR;
 
-	if (jobinfo) {
-		data      = jobinfo->data;
-		plugin_id = jobinfo->plugin_id;
-	} else
-		plugin_id = switch_context_default;
-
-	return (*(ops[plugin_id].job_preinit)) (data);
+	return (*(ops[switch_context_default].job_preinit))(job);
 }
 
 extern int switch_g_job_init(stepd_step_rec_t *job)
diff --git a/src/common/switch.h b/src/common/switch.h
index 2c76c0be4a0..3f5d4a81957 100644
--- a/src/common/switch.h
+++ b/src/common/switch.h
@@ -268,7 +268,7 @@ extern int switch_g_node_fini(void);
  * that needs to be performed in the same process as switch_g_job_fini()
  *
  */
-extern int switch_g_job_preinit(dynamic_plugin_data_t *jobinfo);
+extern int switch_g_job_preinit(stepd_step_rec_t *job);
 
 /*
  * initialize switch_g on node for job. This function is run from the
diff --git a/src/plugins/switch/cray_aries/switch_cray_aries.c b/src/plugins/switch/cray_aries/switch_cray_aries.c
index 6777ceab677..e229f0db246 100644
--- a/src/plugins/switch/cray_aries/switch_cray_aries.c
+++ b/src/plugins/switch/cray_aries/switch_cray_aries.c
@@ -436,7 +436,7 @@ extern int switch_p_node_fini(void)
 	return SLURM_SUCCESS;
 }
 
-extern int switch_p_job_preinit(switch_jobinfo_t *jobinfo)
+extern int switch_p_job_preinit(stepd_step_rec_t *job)
 {
 	return SLURM_SUCCESS;
 }
diff --git a/src/plugins/switch/none/switch_none.c b/src/plugins/switch/none/switch_none.c
index 779009eb1d4..0d4c48410a6 100644
--- a/src/plugins/switch/none/switch_none.c
+++ b/src/plugins/switch/none/switch_none.c
@@ -177,7 +177,7 @@ int switch_p_node_fini ( void )
 	return SLURM_SUCCESS;
 }
 
-int switch_p_job_preinit ( switch_jobinfo_t *jobinfo )
+int switch_p_job_preinit(stepd_step_rec_t *job)
 {
 	return SLURM_SUCCESS;
 }
diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c
index 36e5527354a..3c16f4d7af4 100644
--- a/src/slurmd/slurmstepd/mgr.c
+++ b/src/slurmd/slurmstepd/mgr.c
@@ -1183,7 +1183,7 @@ job_manager(stepd_step_rec_t *job)
 
 	if (!job->batch && (job->step_id.step_id != SLURM_EXTERN_CONT) &&
 	    (job->step_id.step_id != SLURM_INTERACTIVE_STEP) &&
-	    (switch_g_job_preinit(job->switch_job) < 0)) {
+	    (switch_g_job_preinit(job) < 0)) {
 		rc = ESLURM_INTERCONNECT_FAILURE;
 		goto fail1;
 	}
-- 
GitLab