Skip to content

Commit ae2af61

Browse files
author
Ralph Castain
committed
Update the session dir structure. Restore the creation of a top-level dir based on userid so that everything is contained under the user's top-level dir. Make the next level down (the "job family" level) be either the pid (indicated by a name of "pid.N") or the job family if not launched by mpirun. This allows for proper rendezvous by direct-launched procs.
1 parent ecbedee commit ae2af61

File tree

7 files changed

+95
-48
lines changed

7 files changed

+95
-48
lines changed

orte/mca/oob/usock/oob_usock_component.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void connection_event_handler(int incoming_sd, short flags, void* cbdata)
205205
static int component_startup(void)
206206
{
207207
int rc=ORTE_SUCCESS;
208+
char *session;
208209

209210
opal_output_verbose(2, orte_oob_base_framework.framework_output,
210211
"%s USOCK STARTUP",
@@ -213,11 +214,18 @@ static int component_startup(void)
213214
/* setup the path to the daemon rendezvous point */
214215
memset(&mca_oob_usock_component.address, 0, sizeof(struct sockaddr_un));
215216
mca_oob_usock_component.address.sun_family = AF_UNIX;
217+
session = opal_os_path(false, orte_process_info.tmpdir_base,
218+
orte_process_info.top_session_dir,
219+
orte_process_info.jobfam_session_dir,
220+
"usock", NULL);
221+
if ((strlen(session) + 1) > sizeof(mca_oob_usock_component.address.sun_path)-1) {
222+
opal_output(0, "SESSION DIR TOO LONG");
223+
return ORTE_ERR_NOT_SUPPORTED;
224+
}
216225
snprintf(mca_oob_usock_component.address.sun_path,
217226
sizeof(mca_oob_usock_component.address.sun_path)-1,
218-
"%s/%s/%s/0/%s", orte_process_info.tmpdir_base,
219-
orte_process_info.top_session_dir,
220-
ORTE_JOB_FAMILY_PRINT(ORTE_PROC_MY_NAME->jobid), "usock");
227+
"%s", session);
228+
free(session);
221229
opal_output_verbose(2, orte_oob_base_framework.framework_output,
222230
"SUNPATH: %s", mca_oob_usock_component.address.sun_path);
223231

@@ -231,7 +239,7 @@ static int component_startup(void)
231239
/* if the rendezvous point isn't there, then that's an error */
232240
/* if the rendezvous file doesn't exist, that's an error */
233241
if (0 != access(mca_oob_usock_component.address.sun_path, R_OK)) {
234-
opal_output_verbose(2, orte_oob_base_framework.framework_output,
242+
opal_output_verbose(2, orte_oob_base_framework.framework_output,
235243
"SUNPATH: %s NOT READABLE", mca_oob_usock_component.address.sun_path);
236244
return OPAL_ERR_NOT_FOUND;
237245
}

orte/mca/schizo/ompi/schizo_ompi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ static int setup_fork(orte_job_t *jdata,
944944
/* forcibly set the local tmpdir base and top session dir to match ours */
945945
opal_setenv("OMPI_MCA_orte_tmpdir_base", orte_process_info.tmpdir_base, true, &app->env);
946946
opal_setenv("OMPI_MCA_orte_top_session_dir", orte_process_info.top_session_dir, true, &app->env);
947+
opal_setenv("OMPI_MCA_orte_jobfam_session_dir", orte_process_info.jobfam_session_dir, true, &app->env);
947948

948949
/* MPI-3 requires we provide some further info to the procs,
949950
* so we pass them as envars to avoid introducing further

orte/orted/pmix/pmix_server.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "opal/util/show_help.h"
5858
#include "opal/util/error.h"
5959
#include "opal/util/output.h"
60+
#include "opal/util/os_path.h"
6061
#include "opal/util/argv.h"
6162

6263
#include "orte/mca/errmgr/errmgr.h"
@@ -261,9 +262,12 @@ int pmix_server_init(void)
261262
kv = OBJ_NEW(opal_value_t);
262263
kv->key = strdup(OPAL_PMIX_SERVER_TMPDIR);
263264
kv->type = OPAL_STRING;
264-
kv->data.string = strdup(orte_process_info.tmpdir_base);
265+
kv->data.string = opal_os_path(false, orte_process_info.tmpdir_base,
266+
orte_process_info.top_session_dir,
267+
orte_process_info.jobfam_session_dir, NULL);
265268
opal_list_append(&info, &kv->super);
266-
/* use the same for the system temp directory */
269+
/* use the same for the system temp directory - this is
270+
* where the system-level tool connections will go */
267271
kv = OBJ_NEW(opal_value_t);
268272
kv->key = strdup(OPAL_PMIX_SYSTEM_TMPDIR);
269273
kv->type = OPAL_STRING;

orte/runtime/orte_mca_params.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
1414
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
1515
* All rights reserved
16-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
16+
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved
1717
* Copyright (c) 2014 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* $COPYRIGHT$
@@ -51,6 +51,7 @@ static char *orte_tmpdir_base = NULL;
5151
static char *orte_local_tmpdir_base = NULL;
5252
static char *orte_remote_tmpdir_base = NULL;
5353
static char *orte_top_session_dir = NULL;
54+
static char *orte_jobfam_session_dir = NULL;
5455

5556
int orte_register_params(void)
5657
{
@@ -165,6 +166,20 @@ int orte_register_params(void)
165166
orte_process_info.top_session_dir = strdup(orte_top_session_dir);
166167
}
167168

169+
orte_jobfam_session_dir = NULL;
170+
(void) mca_base_var_register ("orte", "orte", NULL, "jobfam_session_dir",
171+
"The jobfamily session directory for applications",
172+
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
173+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL_EQ,
174+
&orte_jobfam_session_dir);
175+
176+
if (NULL != orte_jobfam_session_dir) {
177+
if (NULL != orte_process_info.jobfam_session_dir) {
178+
free(orte_process_info.jobfam_session_dir);
179+
}
180+
orte_process_info.jobfam_session_dir = strdup(orte_jobfam_session_dir);
181+
}
182+
168183
orte_prohibited_session_dirs = NULL;
169184
(void) mca_base_var_register ("orte", "orte", NULL, "no_session_dirs",
170185
"Prohibited locations for session directories (multiple locations separated by ',', default=NULL)",

orte/util/proc_info.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2012 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved
15+
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved
1616
* $COPYRIGHT$
1717
*
1818
* Additional copyrights may follow
@@ -80,6 +80,7 @@ ORTE_DECLSPEC orte_proc_info_t orte_process_info = {
8080
.num_local_peers = 0,
8181
.tmpdir_base = NULL,
8282
.top_session_dir = NULL,
83+
.jobfam_session_dir = NULL,
8384
.job_session_dir = NULL,
8485
.proc_session_dir = NULL,
8586
.sock_stdin = NULL,
@@ -294,6 +295,11 @@ int orte_proc_info_finalize(void)
294295
orte_process_info.top_session_dir = NULL;
295296
}
296297

298+
if (NULL != orte_process_info.jobfam_session_dir) {
299+
free(orte_process_info.jobfam_session_dir);
300+
orte_process_info.jobfam_session_dir = NULL;
301+
}
302+
297303
if (NULL != orte_process_info.job_session_dir) {
298304
free(orte_process_info.job_session_dir);
299305
orte_process_info.job_session_dir = NULL;

orte/util/proc_info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1313
* All rights reserved.
14-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
14+
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -119,6 +119,7 @@ struct orte_proc_info_t {
119119
*/
120120
char *tmpdir_base; /**< Base directory of the session dir tree */
121121
char *top_session_dir; /**< Top-most directory of the session tree */
122+
char *jobfam_session_dir; /**< Session directory for this family of jobs (i.e., share same mpirun) */
122123
char *job_session_dir; /**< Session directory for job */
123124
char *proc_session_dir; /**< Session directory for the process */
124125

orte/util/session_dir.c

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,16 @@ static int orte_create_dir(char *directory)
114114

115115
/*
116116
* Construct the fullpath to the session directory - it
117-
* will consist of "ompi.<hostname>.<pid>"
117+
* will consist of "ompi.<hostname>.<effective-uid>", and
118+
* have subdirs:
119+
*
120+
* pid - the pid of the mpirun that oversees this job. Note
121+
* that direct-launched processes will have manufactured
122+
* this value
123+
*
124+
* jobid - jobid of the application being executed
125+
*
126+
* vpid - vpid of the process
118127
*/
119128
int
120129
orte_session_dir_get_name(char **fulldirpath,
@@ -132,10 +141,14 @@ orte_session_dir_get_name(char **fulldirpath,
132141
bool prefix_provided = false;
133142
int exit_status = ORTE_SUCCESS;
134143
size_t len;
144+
uid_t uid;
135145

136146
/* Ensure that system info is set */
137147
orte_proc_info();
138148

149+
/* get the effective uid */
150+
uid = geteuid();
151+
139152
/*
140153
* set the 'hostname'
141154
*/
@@ -156,30 +169,48 @@ orte_session_dir_get_name(char **fulldirpath,
156169
/* construct the frontend of the session directory*/
157170
if (NULL != orte_process_info.top_session_dir) {
158171
frontend = strdup(orte_process_info.top_session_dir);
172+
} else { /* If not set then construct it */
173+
if (0 > asprintf(&frontend, "ompi.%s.%lu", hostname, (unsigned long)uid)) {
174+
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
175+
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
176+
goto cleanup;
177+
}
159178
}
160-
else { /* If not set then construct it */
161-
if (0 > asprintf(&frontend, "ompi.%s.%lu", hostname, (unsigned long)orte_process_info.pid)) {
179+
180+
/* construct the next level down, which belongs to the
181+
* job family. This is related to the mpirun that launched
182+
* the job, or is an arbitrary (agreed upon) value if
183+
* direct launched */
184+
if (ORTE_PROC_IS_HNP) {
185+
if (0 > asprintf(&jobfam, "pid.%lu", (unsigned long)orte_process_info.pid)) {
162186
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
163187
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
164188
goto cleanup;
165189
}
190+
orte_process_info.jobfam_session_dir = strdup(jobfam);
191+
} else if (NULL != orte_process_info.jobfam_session_dir) {
192+
/* we had a job family session dir passed down to us by mpirun */
193+
jobfam = strdup(orte_process_info.jobfam_session_dir);
194+
} else {
195+
/* we were not given one, so define it */
196+
if (NULL == proc) {
197+
jobfam = strdup("jobfam");
198+
} else {
199+
if (0 > asprintf(&jobfam, "jf.%d", ORTE_JOB_FAMILY(proc->jobid))) {
200+
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
201+
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
202+
goto cleanup;
203+
}
204+
}
205+
orte_process_info.jobfam_session_dir = strdup(jobfam);
166206
}
167207

168208
/*
169209
* Construct the session directory
170210
*/
171-
/* If we were given a valid vpid then we can construct it fully into:
172-
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID/VPID
173-
*/
211+
/* If we were given a valid vpid then we can construct it fully */
174212
if( NULL != proc) {
175213
if (ORTE_VPID_INVALID != proc->vpid) {
176-
177-
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
178-
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
179-
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
180-
goto cleanup;
181-
}
182-
183214
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
184215
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
185216
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
@@ -192,23 +223,13 @@ orte_session_dir_get_name(char **fulldirpath,
192223
goto cleanup;
193224
}
194225

195-
sessions = opal_os_path( false, frontend, jobfam, job, vpidstr, NULL );
226+
sessions = opal_os_path(false, frontend, jobfam, job, vpidstr, NULL);
196227
if( NULL == sessions ) {
197228
ORTE_ERROR_LOG(ORTE_ERROR);
198229
exit_status = ORTE_ERROR;
199230
goto cleanup;
200231
}
201-
}
202-
/* If we were given a valid jobid then we can construct it partially into:
203-
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID
204-
*/
205-
else if (ORTE_JOBID_INVALID != proc->jobid) {
206-
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
207-
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
208-
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
209-
goto cleanup;
210-
}
211-
232+
} else if (ORTE_JOBID_INVALID != proc->jobid) {
212233
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
213234
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
214235
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
@@ -221,14 +242,12 @@ orte_session_dir_get_name(char **fulldirpath,
221242
exit_status = ORTE_ERROR;
222243
goto cleanup;
223244
}
224-
} /* if both are invalid */
225-
else {
245+
} else {
226246
sessions = strdup(frontend); /* must dup this to avoid double-free later */
227247
}
228248

229-
} /* If we were not given a proc at all, then we just set it to frontend
230-
*/
231-
else {
249+
} else {
250+
/* If we were not given a proc at all, then we just set it to frontend */
232251
sessions = strdup(frontend); /* must dup this to avoid double-free later */
233252
}
234253

@@ -666,14 +685,8 @@ static char *orte_build_job_session_dir(char *top_dir,
666685
orte_process_name_t *proc,
667686
orte_jobid_t jobid)
668687
{
669-
char *jobfam = NULL;
670688
char *job_session_dir;
671689

672-
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
673-
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
674-
return NULL;
675-
}
676-
677690
if (ORTE_JOBID_WILDCARD != jobid) {
678691
char *job = NULL;
679692

@@ -682,19 +695,18 @@ static char *orte_build_job_session_dir(char *top_dir,
682695
job_session_dir = NULL;
683696
goto out;
684697
}
685-
job_session_dir = opal_os_path(false, top_dir, jobfam, job, NULL);
698+
job_session_dir = opal_os_path(false, top_dir, orte_process_info.jobfam_session_dir, job, NULL);
686699
free(job);
687700
if (NULL == job_session_dir) {
688701
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
689702
}
690703
} else {
691-
job_session_dir = opal_os_path(false, top_dir, jobfam, NULL);
704+
job_session_dir = opal_os_path(false, top_dir, orte_process_info.jobfam_session_dir, NULL);
692705
if( NULL == job_session_dir) {
693706
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
694707
}
695708
}
696709

697710
out:
698-
free(jobfam);
699711
return job_session_dir;
700712
}

0 commit comments

Comments
 (0)