Skip to content

Commit c3d4ee3

Browse files
committed
ompi/file: add a muteex to the ompi_file_t structure
Adding a mutex to thje ompi_file_t structure allows to have a per-file handle mutex lock for both ROMIO and OMPIO. I double checked that the size of the ompi_file_t structure is still below the size of the predefined_file_t structure, so we should be good from the backward compatibility perspective.
1 parent bc04225 commit c3d4ee3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ompi/file/file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2016 University of Houston. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -106,6 +107,7 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
106107
return OMPI_ERR_OUT_OF_RESOURCE;
107108
}
108109

110+
109111
/* Save the params */
110112

111113
file->f_comm = comm;
@@ -131,6 +133,9 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
131133
return OMPI_ERR_OUT_OF_RESOURCE;
132134
}
133135

136+
/* Create the mutex */
137+
OBJ_CONSTRUCT(&file->f_mutex, opal_mutex_t);
138+
134139
/* Select a module and actually open the file */
135140

136141
if (OMPI_SUCCESS != (ret = mca_io_base_file_select(file, NULL))) {
@@ -150,6 +155,9 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
150155
*/
151156
int ompi_file_close(ompi_file_t **file)
152157
{
158+
159+
OBJ_DESTRUCT(&(*file)->f_mutex);
160+
153161
(*file)->f_flags |= OMPI_FILE_ISCLOSED;
154162
OBJ_RELEASE(*file);
155163
*file = &ompi_mpi_file_null.file;

ompi/file/file.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2016 University of Houston. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -78,6 +79,10 @@ struct ompi_file_t {
7879
indicates what member to look at in the union, below) */
7980
mca_io_base_version_t f_io_version;
8081

82+
/** Mutex to be used to protect access to the selected component
83+
on a per file-handle basis */
84+
opal_mutex_t f_mutex;
85+
8186
/** The selected component (note that this is a union) -- we need
8287
this to add and remove the component from the list of
8388
components currently in use by the io framework for

0 commit comments

Comments
 (0)