2004-10-15 20:31:54 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-23 07:32:36 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-10-15 20:31:54 +04:00
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/constants.h"
|
2004-10-15 20:31:54 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_PWD_H
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <pwd.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <sys/param.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_SYS_PARAM_H */
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <sys/types.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_SYS_TYPES_H */
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <sys/stat.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <unistd.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <errno.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_DIRENT_H
|
2004-10-15 20:31:54 +04:00
|
|
|
#include <dirent.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_DIRENT_H */
|
2008-03-24 02:10:15 +03:00
|
|
|
#ifdef HAVE_PWD_H
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif /* HAVE_PWD_H */
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2008-06-24 21:50:56 +04:00
|
|
|
#include "opal/util/argv.h"
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2005-07-04 05:59:52 +04:00
|
|
|
#include "opal/util/os_path.h"
|
2006-07-04 02:23:07 +04:00
|
|
|
#include "opal/util/os_dirpath.h"
|
2006-08-23 07:32:36 +04:00
|
|
|
#include "opal/util/basename.h"
|
2008-03-31 21:10:08 +04:00
|
|
|
#include "opal/util/opal_environ.h"
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
2008-06-24 21:50:56 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/runtime/runtime.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/runtime/orte_globals.h"
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/util/session_dir.h"
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*******************************
|
|
|
|
* Local function Declarations
|
|
|
|
*******************************/
|
|
|
|
static int orte_create_dir(char *directory);
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
static bool orte_dir_check_file(const char *root, const char *path);
|
2008-02-28 04:57:57 +03:00
|
|
|
static bool orte_dir_check_file_output(const char *root, const char *path);
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2009-06-23 20:07:41 +04:00
|
|
|
static char *orte_build_job_session_dir(char *top_dir,
|
|
|
|
orte_process_name_t *proc,
|
|
|
|
orte_jobid_t jobid);
|
|
|
|
|
2005-06-27 03:11:37 +04:00
|
|
|
#define OMPI_PRINTF_FIX_STRING(a) ((NULL == a) ? "(null)" : a)
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/****************************
|
|
|
|
* Funcationality
|
|
|
|
****************************/
|
|
|
|
/*
|
|
|
|
* Check and create the directory requested
|
|
|
|
*/
|
|
|
|
static int orte_create_dir(char *directory)
|
|
|
|
{
|
2007-04-01 20:16:54 +04:00
|
|
|
mode_t my_mode = S_IRWXU; /* I'm looking for full rights */
|
2006-06-29 01:03:31 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Sanity check before creating the directory with the proper mode,
|
|
|
|
* Make sure it doesn't exist already */
|
2010-05-18 03:08:56 +04:00
|
|
|
if( ORTE_ERR_NOT_FOUND !=
|
2011-11-23 01:24:35 +04:00
|
|
|
(ret = opal_os_dirpath_access(directory, my_mode)) ) {
|
2006-07-04 02:23:07 +04:00
|
|
|
/* Failure because opal_os_dirpath_access() indicated that either:
|
2006-06-29 01:03:31 +04:00
|
|
|
* - The directory exists and we can access it (no need to create it again),
|
2006-07-04 02:23:07 +04:00
|
|
|
* return OPAL_SUCCESS, or
|
|
|
|
* - don't have access rights, return OPAL_ERROR
|
2006-06-29 01:03:31 +04:00
|
|
|
*/
|
2007-07-18 23:50:54 +04:00
|
|
|
if (ORTE_SUCCESS != ret) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
return(ret);
|
|
|
|
}
|
2007-07-18 23:50:54 +04:00
|
|
|
|
|
|
|
/* Get here if the directory doesn't exist, so create it */
|
|
|
|
if (ORTE_SUCCESS != (ret = opal_os_dirpath_create(directory, my_mode))) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2007-07-18 23:50:54 +04:00
|
|
|
return ret;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Construct the fullpath to the session directory
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
orte_session_dir_get_name(char **fulldirpath,
|
2007-04-23 22:25:36 +04:00
|
|
|
char **return_prefix, /* This will come back as the valid tmp dir */
|
|
|
|
char **return_frontend,
|
2008-03-24 02:10:15 +03:00
|
|
|
char *hostid,
|
2008-02-28 04:57:57 +03:00
|
|
|
char *batchid,
|
2008-07-29 22:58:35 +04:00
|
|
|
orte_process_name_t *proc) {
|
2006-06-29 01:03:31 +04:00
|
|
|
char *hostname = NULL,
|
|
|
|
*batchname = NULL,
|
|
|
|
*sessions = NULL,
|
|
|
|
*user = NULL,
|
2007-04-23 22:25:36 +04:00
|
|
|
*prefix = NULL,
|
2008-07-29 22:58:35 +04:00
|
|
|
*frontend = NULL,
|
|
|
|
*jobfam = NULL,
|
|
|
|
*job = NULL,
|
|
|
|
*vpidstr = NULL;
|
2007-04-23 22:25:36 +04:00
|
|
|
bool prefix_provided = false;
|
2006-06-29 01:03:31 +04:00
|
|
|
int exit_status = ORTE_SUCCESS;
|
2010-04-27 07:40:44 +04:00
|
|
|
size_t len;
|
2008-03-24 02:10:15 +03:00
|
|
|
int uid;
|
2013-02-28 21:31:47 +04:00
|
|
|
struct passwd *pwdent;
|
2006-06-29 01:03:31 +04:00
|
|
|
|
|
|
|
/* Ensure that system info is set */
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_proc_info();
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2008-03-24 02:10:15 +03:00
|
|
|
/* get the name of the user */
|
|
|
|
uid = getuid();
|
|
|
|
#ifdef HAVE_GETPWUID
|
|
|
|
pwdent = getpwuid(uid);
|
|
|
|
#else
|
|
|
|
pwdent = NULL;
|
|
|
|
#endif
|
|
|
|
if (NULL != pwdent) {
|
|
|
|
user = strdup(pwdent->pw_name);
|
|
|
|
} else {
|
|
|
|
if (0 > asprintf(&user, "%d", uid)) {
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2008-03-24 02:10:15 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* set the 'hostname'
|
|
|
|
*/
|
|
|
|
if( NULL != hostid) { /* User specified version */
|
|
|
|
hostname = strdup(hostid);
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
else { /* check if it is set elsewhere */
|
2009-03-06 00:56:03 +03:00
|
|
|
if( NULL != orte_process_info.nodename)
|
|
|
|
hostname = strdup(orte_process_info.nodename);
|
2006-06-29 01:03:31 +04:00
|
|
|
else {
|
|
|
|
/* Couldn't find it, so fail */
|
2007-07-18 23:50:54 +04:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
exit_status = ORTE_ERR_BAD_PARAM;
|
2006-06-29 01:03:31 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* set the 'batchid'
|
|
|
|
*/
|
|
|
|
if (NULL != batchid)
|
|
|
|
batchname = strdup(batchid);
|
|
|
|
else
|
|
|
|
batchname = strdup("0");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get the front part of the session directory
|
|
|
|
* Will look something like:
|
|
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID
|
|
|
|
*/
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL != orte_process_info.top_session_dir) {
|
|
|
|
frontend = strdup(orte_process_info.top_session_dir);
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
|
|
|
else { /* If not set then construct it */
|
2007-04-23 22:25:36 +04:00
|
|
|
if (0 > asprintf(&frontend, "openmpi-sessions-%s@%s_%s", user, hostname, batchname)) {
|
2007-07-18 23:50:54 +04:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
2006-06-29 01:03:31 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Construct the session directory
|
|
|
|
*/
|
2008-07-29 22:58:35 +04:00
|
|
|
/* If we were given a valid vpid then we can construct it fully into:
|
|
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID/VPID
|
2006-06-29 01:03:31 +04:00
|
|
|
*/
|
|
|
|
if( NULL != proc) {
|
2008-07-29 22:58:35 +04:00
|
|
|
if (ORTE_VPID_INVALID != proc->vpid) {
|
|
|
|
|
|
|
|
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != orte_util_convert_vpid_to_string(&vpidstr, proc->vpid)) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
sessions = opal_os_path( false, frontend, jobfam, job, vpidstr, NULL );
|
|
|
|
if( NULL == sessions ) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
|
|
exit_status = ORTE_ERROR;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2008-07-29 22:58:35 +04:00
|
|
|
/* If we were given a valid jobid then we can construct it partially into:
|
|
|
|
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID/JOB-FAMILY/JOBID
|
|
|
|
*/
|
|
|
|
else if (ORTE_JOBID_INVALID != proc->jobid) {
|
|
|
|
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
sessions = opal_os_path( false, frontend, jobfam, job, NULL );
|
|
|
|
if( NULL == sessions ) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERROR);
|
|
|
|
exit_status = ORTE_ERROR;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} /* if both are invalid */
|
|
|
|
else {
|
|
|
|
sessions = strdup(frontend); /* must dup this to avoid double-free later */
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2008-07-29 22:58:35 +04:00
|
|
|
|
|
|
|
} /* If we were not given a proc at all, then we just set it to frontend
|
2006-07-11 20:54:07 +04:00
|
|
|
*/
|
|
|
|
else {
|
2008-02-28 04:57:57 +03:00
|
|
|
sessions = strdup(frontend); /* must dup this to avoid double-free later */
|
2006-07-11 20:54:07 +04:00
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the user specified an invalid prefix, or no prefix at all
|
|
|
|
* we need to keep looking
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if( NULL != fulldirpath && NULL != *fulldirpath) {
|
2006-06-29 01:03:31 +04:00
|
|
|
free(*fulldirpath);
|
|
|
|
*fulldirpath = NULL;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2007-04-23 22:25:36 +04:00
|
|
|
if( NULL != return_prefix && NULL != *return_prefix) { /* use the user specified one, if available */
|
|
|
|
prefix = strdup(*return_prefix);
|
|
|
|
prefix_provided = true;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
|
|
|
/* Try to find a proper alternative prefix */
|
2009-03-06 00:56:03 +03:00
|
|
|
else if (NULL != orte_process_info.tmpdir_base) { /* stored value */
|
|
|
|
prefix = strdup(orte_process_info.tmpdir_base);
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2008-03-31 21:10:08 +04:00
|
|
|
else { /* General Environment var */
|
|
|
|
prefix = strdup(opal_tmp_directory());
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2010-04-27 07:40:44 +04:00
|
|
|
len = strlen(prefix);
|
|
|
|
/* check for a trailing path separator */
|
|
|
|
if (OPAL_PATH_SEP[0] == prefix[len-1]) {
|
|
|
|
prefix[len-1] = '\0';
|
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
|
2008-06-24 21:50:56 +04:00
|
|
|
/* BEFORE doing anything else, check to see if this prefix is
|
|
|
|
* allowed by the system
|
|
|
|
*/
|
|
|
|
if (NULL != orte_prohibited_session_dirs) {
|
|
|
|
char **list;
|
|
|
|
int i, len;
|
|
|
|
/* break the string into tokens - it should be
|
|
|
|
* separated by ','
|
|
|
|
*/
|
|
|
|
list = opal_argv_split(orte_prohibited_session_dirs, ',');
|
|
|
|
len = opal_argv_count(list);
|
|
|
|
/* cycle through the list */
|
|
|
|
for (i=0; i < len; i++) {
|
|
|
|
/* check if prefix matches */
|
|
|
|
if (0 == strncmp(prefix, list[i], strlen(list[i]))) {
|
|
|
|
/* this is a prohibited location */
|
|
|
|
orte_show_help("help-orte-runtime.txt",
|
|
|
|
"orte:session:dir:prohibited",
|
|
|
|
true, prefix, orte_prohibited_session_dirs);
|
|
|
|
return ORTE_ERR_FATAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opal_argv_free(list); /* done with this */
|
|
|
|
}
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* Construct the absolute final path, if requested
|
2006-06-29 01:03:31 +04:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if (NULL != fulldirpath) {
|
|
|
|
*fulldirpath = opal_os_path(false, prefix, sessions, NULL);
|
|
|
|
}
|
2007-04-23 22:25:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the frontend and prefix, if user requested we do so
|
|
|
|
*/
|
|
|
|
if (NULL != return_frontend) {
|
|
|
|
*return_frontend = strdup(frontend);
|
|
|
|
}
|
|
|
|
if (!prefix_provided && NULL != return_prefix) {
|
|
|
|
*return_prefix = strdup(prefix);
|
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
cleanup:
|
|
|
|
if(NULL != hostname)
|
|
|
|
free(hostname);
|
|
|
|
if(NULL != batchname)
|
|
|
|
free(batchname);
|
|
|
|
if(NULL != sessions)
|
|
|
|
free(sessions);
|
|
|
|
if(NULL != user)
|
|
|
|
free(user);
|
2007-04-23 22:25:36 +04:00
|
|
|
if (NULL != prefix) free(prefix);
|
|
|
|
if (NULL != frontend) free(frontend);
|
2008-07-29 22:58:35 +04:00
|
|
|
if (NULL != jobfam) free(jobfam);
|
|
|
|
if (NULL != job) free(job);
|
|
|
|
if (NULL != vpidstr) free(vpidstr);
|
2007-04-23 22:25:36 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
return exit_status;
|
|
|
|
}
|
2005-03-19 02:58:36 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Construct the session directory and create it if necessary
|
|
|
|
*/
|
|
|
|
int orte_session_dir(bool create,
|
2008-03-24 02:10:15 +03:00
|
|
|
char *prefix, char *hostid,
|
2008-07-29 22:58:35 +04:00
|
|
|
char *batchid, orte_process_name_t *proc)
|
2006-06-29 01:03:31 +04:00
|
|
|
{
|
|
|
|
char *fulldirpath = NULL,
|
2009-12-03 04:57:35 +03:00
|
|
|
*frontend = NULL,
|
|
|
|
*sav = NULL;
|
|
|
|
int rc = ORTE_SUCCESS;
|
|
|
|
char *local_prefix = NULL;
|
|
|
|
|
|
|
|
/* use the specified prefix, if one was given */
|
|
|
|
if (NULL != prefix) {
|
|
|
|
local_prefix = strdup(prefix);
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Get the session directory full name
|
|
|
|
*/
|
2009-12-03 04:57:35 +03:00
|
|
|
if( ORTE_SUCCESS != ( rc = orte_session_dir_get_name(&fulldirpath,
|
|
|
|
&local_prefix,
|
|
|
|
&frontend,
|
|
|
|
hostid,
|
|
|
|
batchid, proc) ) ) {
|
2011-11-23 01:24:35 +04:00
|
|
|
if (ORTE_ERR_FATAL == rc) {
|
2009-12-03 04:57:35 +03:00
|
|
|
/* this indicates we should abort quietly */
|
|
|
|
rc = ORTE_ERR_SILENT;
|
2006-06-29 01:03:31 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
/* otherwise, bark a little first */
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Now that we have the full path, go ahead and create it if necessary
|
|
|
|
*/
|
|
|
|
if( create ) {
|
2009-12-03 04:57:35 +03:00
|
|
|
if( ORTE_SUCCESS != (rc = orte_create_dir(fulldirpath) ) ) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* if we are not creating, then just verify that the path is OK
|
|
|
|
*/
|
|
|
|
else {
|
2009-12-03 04:57:35 +03:00
|
|
|
if( ORTE_SUCCESS != (rc = opal_os_dirpath_access(fulldirpath, 0) )) {
|
|
|
|
/* it is okay for the path not to be found - don't error
|
|
|
|
* log that case, but do error log others
|
|
|
|
*/
|
2011-11-23 01:24:35 +04:00
|
|
|
if (ORTE_ERR_NOT_FOUND != rc) {
|
2009-12-03 04:57:35 +03:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
goto cleanup;
|
2006-06-29 01:03:31 +04:00
|
|
|
}
|
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
2009-12-03 04:57:35 +03:00
|
|
|
* If we are creating the directory tree, then force overwrite of the
|
2006-06-29 01:03:31 +04:00
|
|
|
* global structure fields
|
|
|
|
*/
|
|
|
|
if (create) {
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL != orte_process_info.tmpdir_base) {
|
|
|
|
free(orte_process_info.tmpdir_base);
|
|
|
|
orte_process_info.tmpdir_base = NULL;
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL != orte_process_info.top_session_dir) {
|
|
|
|
free(orte_process_info.top_session_dir);
|
|
|
|
orte_process_info.top_session_dir = NULL;
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Update some of the global structures if they are empty
|
|
|
|
*/
|
2011-03-08 20:37:28 +03:00
|
|
|
if (NULL == orte_process_info.tmpdir_base) {
|
2009-12-03 04:57:35 +03:00
|
|
|
orte_process_info.tmpdir_base = strdup(local_prefix);
|
2011-03-08 20:37:28 +03:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2011-03-08 20:37:28 +03:00
|
|
|
if (NULL == orte_process_info.top_session_dir &&
|
|
|
|
NULL != frontend) {
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_process_info.top_session_dir = strdup(frontend);
|
2011-03-08 20:37:28 +03:00
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Set the process session directory
|
|
|
|
*/
|
2008-07-29 22:58:35 +04:00
|
|
|
if (ORTE_VPID_INVALID != proc->vpid) {
|
2005-03-19 02:58:36 +03:00
|
|
|
if (create) { /* overwrite if creating */
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL != orte_process_info.proc_session_dir) {
|
|
|
|
free(orte_process_info.proc_session_dir);
|
|
|
|
orte_process_info.proc_session_dir = NULL;
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
|
|
|
}
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL == orte_process_info.proc_session_dir) {
|
|
|
|
orte_process_info.proc_session_dir = strdup(fulldirpath);
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/* Strip off last part of directory structure */
|
2006-08-23 07:32:36 +04:00
|
|
|
sav = opal_dirname(fulldirpath);
|
2006-06-29 01:03:31 +04:00
|
|
|
free(fulldirpath);
|
2006-08-23 07:32:36 +04:00
|
|
|
fulldirpath = sav;
|
2006-06-29 01:03:31 +04:00
|
|
|
sav = NULL;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2006-06-29 01:03:31 +04:00
|
|
|
/*
|
|
|
|
* Set the job session directory
|
|
|
|
*/
|
2008-07-29 22:58:35 +04:00
|
|
|
if (ORTE_JOBID_INVALID != proc->jobid) {
|
2005-03-19 02:58:36 +03:00
|
|
|
if (create) { /* overwrite if creating */
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL != orte_process_info.job_session_dir) {
|
|
|
|
free(orte_process_info.job_session_dir);
|
|
|
|
orte_process_info.job_session_dir = NULL;
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
|
|
|
}
|
2009-03-06 00:56:03 +03:00
|
|
|
if (NULL == orte_process_info.job_session_dir) {
|
|
|
|
orte_process_info.job_session_dir = strdup(fulldirpath);
|
2005-03-19 02:58:36 +03:00
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "procdir: %s",
|
2009-03-06 00:56:03 +03:00
|
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.proc_session_dir));
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "jobdir: %s",
|
2009-03-06 00:56:03 +03:00
|
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.job_session_dir));
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "top: %s",
|
2009-03-06 00:56:03 +03:00
|
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.top_session_dir));
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "tmp: %s",
|
2009-03-06 00:56:03 +03:00
|
|
|
OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
|
|
|
cleanup:
|
2011-03-08 20:37:28 +03:00
|
|
|
if (NULL != local_prefix) {
|
|
|
|
free(local_prefix);
|
|
|
|
}
|
|
|
|
if(NULL != fulldirpath) {
|
2004-10-15 20:31:54 +04:00
|
|
|
free(fulldirpath);
|
2011-03-08 20:37:28 +03:00
|
|
|
}
|
|
|
|
if(NULL != frontend) {
|
2006-06-29 01:03:31 +04:00
|
|
|
free(frontend);
|
2011-03-08 20:37:28 +03:00
|
|
|
}
|
2009-12-03 04:57:35 +03:00
|
|
|
|
|
|
|
return rc;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-02-16 03:16:22 +03:00
|
|
|
/*
|
2006-06-29 01:03:31 +04:00
|
|
|
* A job has aborted - so force cleanup of the session directory
|
2006-02-16 03:16:22 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
orte_session_dir_cleanup(orte_jobid_t jobid)
|
|
|
|
{
|
2009-06-23 20:07:41 +04:00
|
|
|
int rc = ORTE_SUCCESS;
|
2006-02-16 03:16:22 +03:00
|
|
|
char *tmp;
|
2009-06-23 20:07:41 +04:00
|
|
|
char *job_session_dir=NULL;
|
2006-02-16 03:16:22 +03:00
|
|
|
|
2010-03-02 18:18:33 +03:00
|
|
|
if (!orte_create_session_dirs) {
|
|
|
|
/* didn't create them */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-02-16 03:16:22 +03:00
|
|
|
/* need to setup the top_session_dir with the prefix */
|
|
|
|
tmp = opal_os_path(false,
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_process_info.tmpdir_base,
|
|
|
|
orte_process_info.top_session_dir, NULL);
|
2008-07-29 22:58:35 +04:00
|
|
|
|
|
|
|
/* we can only blow away session directories for our job family */
|
2009-06-23 20:07:41 +04:00
|
|
|
job_session_dir = orte_build_job_session_dir(tmp, ORTE_PROC_MY_NAME, jobid);
|
|
|
|
if (NULL == job_session_dir) {
|
2008-07-29 22:58:35 +04:00
|
|
|
rc = ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
2006-02-16 03:16:22 +03:00
|
|
|
|
Bring in the generalized xcast communication system along with the correspondingly revised orted launch. I will send a message out to developers explaining the basic changes. In brief:
1. generalize orte_rml.xcast to become a general broadcast-like messaging system. Messages can now be sent to any tag on the daemons or processes. Note that any message sent via xcast will be delivered to ALL processes in the specified job - you don't get to pick and choose. At a later date, we will introduce an augmented capability that will use the daemons as relays, but will allow you to send to a specified array of process names.
2. extended orte_rml.xcast so it supports more scalable message routing methodologies. At the moment, we support three: (a) direct, which sends the message directly to all recipients; (b) linear, which sends the message to the local daemon on each node, which then relays it to its own local procs; and (b) binomial, which sends the message via a binomial algo across all the daemons, each of which then relays to its own local procs. The crossover points between the algos are adjustable via MCA param, or you can simply demand that a specific algo be used.
3. orteds no longer exhibit two types of behavior: bootproxy or VM. Orteds now always behave like they are part of a virtual machine - they simply launch a job if mpirun tells them to do so. This is another step towards creating an "orteboot" functionality, but also provided a clean system for supporting message relaying.
Note one major impact of this commit: multiple daemons on a node cannot be supported any longer! Only a single daemon/node is now allowed.
This commit is known to break support for the following environments: POE, Xgrid, Xcpu, Windows. It has been tested on rsh, SLURM, and Bproc. Modifications for TM support have been made but could not be verified due to machine problems at LANL. Modifications for SGE have been made but could not be verified. The developers for the non-verified environments will be separately notified along with suggestions on how to fix the problems.
This commit was SVN r15007.
2007-06-12 17:28:54 +04:00
|
|
|
if (ORTE_JOBID_WILDCARD != jobid) {
|
2009-06-23 20:07:41 +04:00
|
|
|
opal_os_dirpath_destroy(job_session_dir, true, orte_dir_check_file);
|
Bring in the generalized xcast communication system along with the correspondingly revised orted launch. I will send a message out to developers explaining the basic changes. In brief:
1. generalize orte_rml.xcast to become a general broadcast-like messaging system. Messages can now be sent to any tag on the daemons or processes. Note that any message sent via xcast will be delivered to ALL processes in the specified job - you don't get to pick and choose. At a later date, we will introduce an augmented capability that will use the daemons as relays, but will allow you to send to a specified array of process names.
2. extended orte_rml.xcast so it supports more scalable message routing methodologies. At the moment, we support three: (a) direct, which sends the message directly to all recipients; (b) linear, which sends the message to the local daemon on each node, which then relays it to its own local procs; and (b) binomial, which sends the message via a binomial algo across all the daemons, each of which then relays to its own local procs. The crossover points between the algos are adjustable via MCA param, or you can simply demand that a specific algo be used.
3. orteds no longer exhibit two types of behavior: bootproxy or VM. Orteds now always behave like they are part of a virtual machine - they simply launch a job if mpirun tells them to do so. This is another step towards creating an "orteboot" functionality, but also provided a clean system for supporting message relaying.
Note one major impact of this commit: multiple daemons on a node cannot be supported any longer! Only a single daemon/node is now allowed.
This commit is known to break support for the following environments: POE, Xgrid, Xcpu, Windows. It has been tested on rsh, SLURM, and Bproc. Modifications for TM support have been made but could not be verified due to machine problems at LANL. Modifications for SGE have been made but could not be verified. The developers for the non-verified environments will be separately notified along with suggestions on how to fix the problems.
This commit was SVN r15007.
2007-06-12 17:28:54 +04:00
|
|
|
} else {
|
|
|
|
/* if we want the session_dir removed for ALL jobids, then
|
2008-07-29 22:58:35 +04:00
|
|
|
* just recursively blow the whole session away for our job family,
|
|
|
|
* saving only output files
|
Bring in the generalized xcast communication system along with the correspondingly revised orted launch. I will send a message out to developers explaining the basic changes. In brief:
1. generalize orte_rml.xcast to become a general broadcast-like messaging system. Messages can now be sent to any tag on the daemons or processes. Note that any message sent via xcast will be delivered to ALL processes in the specified job - you don't get to pick and choose. At a later date, we will introduce an augmented capability that will use the daemons as relays, but will allow you to send to a specified array of process names.
2. extended orte_rml.xcast so it supports more scalable message routing methodologies. At the moment, we support three: (a) direct, which sends the message directly to all recipients; (b) linear, which sends the message to the local daemon on each node, which then relays it to its own local procs; and (b) binomial, which sends the message via a binomial algo across all the daemons, each of which then relays to its own local procs. The crossover points between the algos are adjustable via MCA param, or you can simply demand that a specific algo be used.
3. orteds no longer exhibit two types of behavior: bootproxy or VM. Orteds now always behave like they are part of a virtual machine - they simply launch a job if mpirun tells them to do so. This is another step towards creating an "orteboot" functionality, but also provided a clean system for supporting message relaying.
Note one major impact of this commit: multiple daemons on a node cannot be supported any longer! Only a single daemon/node is now allowed.
This commit is known to break support for the following environments: POE, Xgrid, Xcpu, Windows. It has been tested on rsh, SLURM, and Bproc. Modifications for TM support have been made but could not be verified due to machine problems at LANL. Modifications for SGE have been made but could not be verified. The developers for the non-verified environments will be separately notified along with suggestions on how to fix the problems.
This commit was SVN r15007.
2007-06-12 17:28:54 +04:00
|
|
|
*/
|
2008-07-29 22:58:35 +04:00
|
|
|
opal_os_dirpath_destroy(job_session_dir, true, orte_dir_check_file_output);
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
|
2008-07-29 22:58:35 +04:00
|
|
|
/* now attempt to eliminate the top level directory itself - this
|
|
|
|
* will fail if anything is present, but ensures we cleanup if
|
|
|
|
* we are the last one out
|
|
|
|
*/
|
|
|
|
opal_os_dirpath_destroy(tmp, false, orte_dir_check_file);
|
2006-07-04 02:23:07 +04:00
|
|
|
|
This commit represents a bunch of work on a Mercurial side branch. As
such, the commit message back to the master SVN repository is fairly
long.
= ORTE Job-Level Output Messages =
Add two new interfaces that should be used for all new code throughout
the ORTE and OMPI layers (we already make the search-and-replace on
the existing ORTE / OMPI layers):
* orte_output(): (and corresponding friends ORTE_OUTPUT,
orte_output_verbose, etc.) This function sends the output directly
to the HNP for processing as part of a job-specific output
channel. It supports all the same outputs as opal_output()
(syslog, file, stdout, stderr), but for stdout/stderr, the output
is sent to the HNP for processing and output. More on this below.
* orte_show_help(): This function is a drop-in-replacement for
opal_show_help(), with two differences in functionality:
1. the rendered text help message output is sent to the HNP for
display (rather than outputting directly into the process' stderr
stream)
1. the HNP detects duplicate help messages and does not display them
(so that you don't see the same error message N times, once from
each of your N MPI processes); instead, it counts "new" instances
of the help message and displays a message every ~5 seconds when
there are new ones ("I got X new copies of the help message...")
opal_show_help and opal_output still exist, but they only output in
the current process. The intent for the new orte_* functions is that
they can apply job-level intelligence to the output. As such, we
recommend that all new ORTE and OMPI code use the new orte_*
functions, not thei opal_* functions.
=== New code ===
For ORTE and OMPI programmers, here's what you need to do differently
in new code:
* Do not include opal/util/show_help.h or opal/util/output.h.
Instead, include orte/util/output.h (this one header file has
declarations for both the orte_output() series of functions and
orte_show_help()).
* Effectively s/opal_output/orte_output/gi throughout your code.
Note that orte_output_open() takes a slightly different argument
list (as a way to pass data to the filtering stream -- see below),
so you if explicitly call opal_output_open(), you'll need to
slightly adapt to the new signature of orte_output_open().
* Literally s/opal_show_help/orte_show_help/. The function signature
is identical.
=== Notes ===
* orte_output'ing to stream 0 will do similar to what
opal_output'ing did, so leaving a hard-coded "0" as the first
argument is safe.
* For systems that do not use ORTE's RML or the HNP, the effect of
orte_output_* and orte_show_help will be identical to their opal
counterparts (the additional information passed to
orte_output_open() will be lost!). Indeed, the orte_* functions
simply become trivial wrappers to their opal_* counterparts. Note
that we have not tested this; the code is simple but it is quite
possible that we mucked something up.
= Filter Framework =
Messages sent view the new orte_* functions described above and
messages output via the IOF on the HNP will now optionally be passed
through a new "filter" framework before being output to
stdout/stderr. The "filter" OPAL MCA framework is intended to allow
preprocessing to messages before they are sent to their final
destinations. The first component that was written in the filter
framework was to create an XML stream, segregating all the messages
into different XML tags, etc. This will allow 3rd party tools to read
the stdout/stderr from the HNP and be able to know exactly what each
text message is (e.g., a help message, another OMPI infrastructure
message, stdout from the user process, stderr from the user process,
etc.).
Filtering is not active by default. Filter components must be
specifically requested, such as:
{{{
$ mpirun --mca filter xml ...
}}}
There can only be one filter component active.
= New MCA Parameters =
The new functionality described above introduces two new MCA
parameters:
* '''orte_base_help_aggregate''': Defaults to 1 (true), meaning that
help messages will be aggregated, as described above. If set to 0,
all help messages will be displayed, even if they are duplicates
(i.e., the original behavior).
* '''orte_base_show_output_recursions''': An MCA parameter to help
debug one of the known issues, described below. It is likely that
this MCA parameter will disappear before v1.3 final.
= Known Issues =
* The XML filter component is not complete. The current output from
this component is preliminary and not real XML. A bit more work
needs to be done to configure.m4 search for an appropriate XML
library/link it in/use it at run time.
* There are possible recursion loops in the orte_output() and
orte_show_help() functions -- e.g., if RML send calls orte_output()
or orte_show_help(). We have some ideas how to fix these, but
figured that it was ok to commit before feature freeze with known
issues. The code currently contains sub-optimal workarounds so
that this will not be a problem, but it would be good to actually
solve the problem rather than have hackish workarounds before v1.3 final.
This commit was SVN r18434.
2008-05-14 00:00:55 +04:00
|
|
|
if (NULL != job_session_dir && opal_os_dirpath_is_empty(job_session_dir)) {
|
2006-02-16 03:16:22 +03:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
rmdir(job_session_dir);
|
|
|
|
} else {
|
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
if (opal_os_dirpath_is_empty(tmp)) {
|
2006-02-16 03:16:22 +03:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
rmdir(tmp);
|
|
|
|
} else {
|
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
free(tmp);
|
Bring in the generalized xcast communication system along with the correspondingly revised orted launch. I will send a message out to developers explaining the basic changes. In brief:
1. generalize orte_rml.xcast to become a general broadcast-like messaging system. Messages can now be sent to any tag on the daemons or processes. Note that any message sent via xcast will be delivered to ALL processes in the specified job - you don't get to pick and choose. At a later date, we will introduce an augmented capability that will use the daemons as relays, but will allow you to send to a specified array of process names.
2. extended orte_rml.xcast so it supports more scalable message routing methodologies. At the moment, we support three: (a) direct, which sends the message directly to all recipients; (b) linear, which sends the message to the local daemon on each node, which then relays it to its own local procs; and (b) binomial, which sends the message via a binomial algo across all the daemons, each of which then relays to its own local procs. The crossover points between the algos are adjustable via MCA param, or you can simply demand that a specific algo be used.
3. orteds no longer exhibit two types of behavior: bootproxy or VM. Orteds now always behave like they are part of a virtual machine - they simply launch a job if mpirun tells them to do so. This is another step towards creating an "orteboot" functionality, but also provided a clean system for supporting message relaying.
Note one major impact of this commit: multiple daemons on a node cannot be supported any longer! Only a single daemon/node is now allowed.
This commit is known to break support for the following environments: POE, Xgrid, Xcpu, Windows. It has been tested on rsh, SLURM, and Bproc. Modifications for TM support have been made but could not be verified due to machine problems at LANL. Modifications for SGE have been made but could not be verified. The developers for the non-verified environments will be separately notified along with suggestions on how to fix the problems.
This commit was SVN r15007.
2007-06-12 17:28:54 +04:00
|
|
|
if (NULL != job_session_dir) free(job_session_dir);
|
2009-06-23 20:07:41 +04:00
|
|
|
return rc;
|
2006-02-16 03:16:22 +03:00
|
|
|
}
|
|
|
|
|
2004-10-15 20:31:54 +04:00
|
|
|
|
|
|
|
int
|
2005-04-14 05:04:26 +04:00
|
|
|
orte_session_dir_finalize(orte_process_name_t *proc)
|
2004-10-15 20:31:54 +04:00
|
|
|
{
|
2005-04-14 05:04:26 +04:00
|
|
|
int rc;
|
2005-04-07 23:19:48 +04:00
|
|
|
char *tmp;
|
2009-06-23 20:07:41 +04:00
|
|
|
char *job_session_dir, *vpid, *proc_session_dir;
|
2005-05-13 01:44:23 +04:00
|
|
|
|
2010-03-02 18:18:33 +03:00
|
|
|
if (!orte_create_session_dirs) {
|
|
|
|
/* didn't create them */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-04-07 23:19:48 +04:00
|
|
|
/* need to setup the top_session_dir with the prefix */
|
2005-08-30 01:35:01 +04:00
|
|
|
tmp = opal_os_path(false,
|
2009-03-06 00:56:03 +03:00
|
|
|
orte_process_info.tmpdir_base,
|
|
|
|
orte_process_info.top_session_dir, NULL);
|
2005-04-07 23:19:48 +04:00
|
|
|
|
2005-04-14 05:04:26 +04:00
|
|
|
/* define the proc and job session directories for this process */
|
2008-02-28 04:57:57 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_util_convert_vpid_to_string(&vpid, proc->vpid))) {
|
2005-04-14 05:04:26 +04:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
free(tmp);
|
|
|
|
return rc;
|
|
|
|
}
|
2009-06-23 20:07:41 +04:00
|
|
|
job_session_dir = orte_build_job_session_dir(tmp, proc, proc->jobid);
|
|
|
|
if( NULL == job_session_dir) {
|
2005-04-14 05:04:26 +04:00
|
|
|
free(tmp);
|
|
|
|
free(vpid);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2006-08-23 07:32:36 +04:00
|
|
|
proc_session_dir = opal_os_path( false, job_session_dir, vpid, NULL );
|
|
|
|
if( NULL == proc_session_dir ) {
|
2005-04-14 05:04:26 +04:00
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
free(tmp);
|
|
|
|
free(vpid);
|
|
|
|
free(job_session_dir);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
opal_os_dirpath_destroy(proc_session_dir,
|
|
|
|
false, orte_dir_check_file);
|
|
|
|
opal_os_dirpath_destroy(job_session_dir,
|
|
|
|
false, orte_dir_check_file);
|
|
|
|
opal_os_dirpath_destroy(tmp,
|
|
|
|
false, orte_dir_check_file);
|
|
|
|
|
|
|
|
if (opal_os_dirpath_is_empty(proc_session_dir)) {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
2005-04-14 05:04:26 +04:00
|
|
|
rmdir(proc_session_dir);
|
2004-10-15 20:31:54 +04:00
|
|
|
} else {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
2005-04-14 05:04:26 +04:00
|
|
|
goto CLEANUP;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
if (opal_os_dirpath_is_empty(job_session_dir)) {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
2005-04-14 05:04:26 +04:00
|
|
|
rmdir(job_session_dir);
|
2004-10-15 20:31:54 +04:00
|
|
|
} else {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
2005-04-14 05:04:26 +04:00
|
|
|
goto CLEANUP;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
if (opal_os_dirpath_is_empty(tmp)) {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
|
|
|
rmdir(tmp);
|
2004-10-15 20:31:54 +04:00
|
|
|
} else {
|
2005-04-07 23:19:48 +04:00
|
|
|
if (orte_debug_flag) {
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
|
2005-04-07 23:19:48 +04:00
|
|
|
}
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2005-04-14 05:04:26 +04:00
|
|
|
CLEANUP:
|
2005-04-07 23:19:48 +04:00
|
|
|
free(tmp);
|
2005-04-14 05:04:26 +04:00
|
|
|
free(vpid);
|
|
|
|
free(job_session_dir);
|
|
|
|
free(proc_session_dir);
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
|
|
|
|
2006-07-04 02:23:07 +04:00
|
|
|
static bool
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_dir_check_file(const char *root, const char *path)
|
|
|
|
{
|
2006-07-04 02:23:07 +04:00
|
|
|
/*
|
|
|
|
* Keep:
|
|
|
|
* - files starting with "output-"
|
2008-02-28 04:57:57 +03:00
|
|
|
* - files that indicate abort
|
2006-07-04 02:23:07 +04:00
|
|
|
*/
|
|
|
|
if( (0 == strncmp(path, "output-", strlen("output-"))) ||
|
2008-02-28 04:57:57 +03:00
|
|
|
(0 == strcmp(path, "abort"))) {
|
2006-07-04 02:23:07 +04:00
|
|
|
return false;
|
2004-11-03 00:48:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-10-15 20:31:54 +04:00
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
|
|
|
|
static bool
|
|
|
|
orte_dir_check_file_output(const char *root, const char *path)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Keep:
|
|
|
|
* - files starting with "output-"
|
|
|
|
*/
|
|
|
|
if( 0 == strncmp(path, "output-", strlen("output-"))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-23 20:07:41 +04:00
|
|
|
static char *orte_build_job_session_dir(char *top_dir,
|
|
|
|
orte_process_name_t *proc,
|
|
|
|
orte_jobid_t jobid)
|
|
|
|
{
|
|
|
|
char *jobfam = NULL;
|
|
|
|
char *job_session_dir;
|
|
|
|
|
|
|
|
if (0 > asprintf(&jobfam, "%d", ORTE_JOB_FAMILY(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_JOBID_WILDCARD != jobid) {
|
|
|
|
char *job = NULL;
|
|
|
|
|
|
|
|
if (0 > asprintf(&job, "%d", ORTE_LOCAL_JOBID(jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
job_session_dir = NULL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
job_session_dir = opal_os_path(false, top_dir, jobfam, job, NULL);
|
|
|
|
free(job);
|
|
|
|
if (NULL == job_session_dir) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
job_session_dir = opal_os_path(false, top_dir, jobfam, NULL);
|
|
|
|
if( NULL == job_session_dir) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
free(jobfam);
|
|
|
|
return job_session_dir;
|
|
|
|
}
|