Skip to content

Commit 763b5e0

Browse files
authored
Merge pull request #3105 from edgargabriel/pr/sharedfp-name-collision-fix-v2.x
sharedfp/lockedfile and sm: fix name collision
2 parents e4798fb + ceb2cd3 commit 763b5e0

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

ompi/mca/sharedfp/lockedfile/sharedfp_lockedfile_file_open.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
12+
* Copyright (c) 2013-2017 University of Houston. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -25,6 +25,8 @@
2525

2626
#include "mpi.h"
2727
#include "ompi/constants.h"
28+
#include "ompi/group/group.h"
29+
#include "ompi/proc/proc.h"
2830
#include "ompi/mca/sharedfp/sharedfp.h"
2931
#include "ompi/mca/sharedfp/base/base.h"
3032

@@ -99,8 +101,23 @@ int mca_sharedfp_lockedfile_file_open (struct ompi_communicator_t *comm,
99101
return OMPI_ERR_OUT_OF_RESOURCE;
100102
}
101103

102-
lockedfilename = (char*)malloc(sizeof(char) * (strlen(filename) + 64));
103-
sprintf(lockedfilename,"%s%s",filename,".lockedfile");
104+
opal_jobid_t masterjobid;
105+
if ( 0 == comm->c_my_rank ) {
106+
ompi_proc_t *masterproc = ompi_group_peer_lookup(comm->c_local_group, 0 );
107+
masterjobid = OMPI_CAST_RTE_NAME(&masterproc->super.proc_name)->jobid;
108+
}
109+
comm->c_coll.coll_bcast ( &masterjobid, 1, MPI_UNSIGNED, 0, comm,
110+
comm->c_coll.coll_bcast_module );
111+
112+
size_t filenamelen = strlen(filename) + 16;
113+
lockedfilename = (char*)malloc(sizeof(char) * filenamelen);
114+
if ( NULL == lockedfilename ) {
115+
free (shfileHandle);
116+
free (sh);
117+
free (module_data);
118+
return OMPI_ERR_OUT_OF_RESOURCE;
119+
}
120+
snprintf(lockedfilename, filenamelen, "%s-%u%s",filename,masterjobid,".lock");
104121
module_data->filename = lockedfilename;
105122

106123
/*-------------------------------------------------*/

ompi/mca/sharedfp/sm/sharedfp_sm_file_open.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
12+
* Copyright (c) 2013-2017 University of Houston. All rights reserved.
1313
* Copyright (c) 2013 Intel, Inc. All rights reserved.
1414
* Copyright (c) 2015 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
@@ -35,6 +35,8 @@
3535

3636
#include "mpi.h"
3737
#include "ompi/constants.h"
38+
#include "ompi/group/group.h"
39+
#include "ompi/proc/proc.h"
3840
#include "ompi/mca/sharedfp/sharedfp.h"
3941
#include "ompi/mca/sharedfp/base/base.h"
4042

@@ -139,8 +141,16 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
139141
free(shfileHandle);
140142
return OMPI_ERR_OUT_OF_RESOURCE;
141143
}
142-
sprintf(sm_filename,"/tmp/OMPIO_sharedfp_sm_%s%s",filename_basename,".sm");
143144

145+
opal_jobid_t masterjobid;
146+
if ( 0 == comm->c_my_rank ) {
147+
ompi_proc_t *masterproc = ompi_group_peer_lookup(comm->c_local_group, 0 );
148+
masterjobid = OMPI_CAST_RTE_NAME(&masterproc->super.proc_name)->jobid;
149+
}
150+
comm->c_coll.coll_bcast ( &masterjobid, 1, MPI_UNSIGNED, 0, comm,
151+
comm->c_coll.coll_bcast_module );
152+
153+
sprintf(sm_filename,"/tmp/OMPIO_%s_%d_%s",filename_basename, masterjobid, ".sm");
144154
/* open shared memory file, initialize to 0, map into memory */
145155
sm_fd = open(sm_filename, O_RDWR | O_CREAT,
146156
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);

0 commit comments

Comments
 (0)