Skip to content

Commit 88ca53a

Browse files
authored
Merge pull request #2862 from edgargabriel/pr/sharedfp-append-fix-v2.x
Pr/sharedfp append fix v2.x
2 parents ac60b7f + 1b8ccec commit 88ca53a

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

ompi/mca/fs/ufs/fs_ufs_file_open.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
7171

7272
if ( 0 == rank ) {
7373
/* MODE_CREATE and MODE_EXCL can only be set by one process */
74-
if ( access_mode & MPI_MODE_CREATE )
75-
amode = amode | O_CREAT;
76-
if (access_mode & MPI_MODE_EXCL)
77-
amode = amode | O_EXCL;
74+
if ( !(fh->f_flags & OMPIO_SHAREDFP_IS_SET)) {
75+
if ( access_mode & MPI_MODE_CREATE )
76+
amode = amode | O_CREAT;
77+
if (access_mode & MPI_MODE_EXCL)
78+
amode = amode | O_EXCL;
79+
}
7880
fh->fd = open (filename, amode, perm);
7981
ret = fh->fd;
8082
}

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
114114
/* No need to duplicate the communicator if the file_open is called
115115
from the sharedfp component, since the comm used as an input
116116
is already a dup of the user level comm. */
117-
ompio_fh->f_flags |= OMPIO_SHAREDFP_IS_SET;
118117
ompio_fh->f_comm = comm;
119118
}
120119

@@ -195,26 +194,9 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
195194
** function will return an error code.
196195
*/
197196
}
198-
199-
/* open the file once more for the shared file pointer if required.
200-
** Can be disabled by the user if no shared file pointer operations
201-
** are used by his application.
202-
*/
203-
if ( NULL != ompio_fh->f_sharedfp &&
204-
true == use_sharedfp &&
205-
(!mca_io_ompio_sharedfp_lazy_open ||
206-
!strcmp (ompio_fh->f_sharedfp_component->mca_component_name,
207-
"addproc") )) {
208-
ret = ompio_fh->f_sharedfp->sharedfp_file_open(comm,
209-
filename,
210-
amode,
211-
info,
212-
ompio_fh);
213-
214-
if ( OMPI_SUCCESS != ret ) {
215-
goto fn_fail;
216-
}
217-
}
197+
}
198+
else {
199+
ompio_fh->f_flags |= OMPIO_SHAREDFP_IS_SET;
218200
}
219201

220202
/*Determine topology information if set*/
@@ -231,15 +213,31 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
231213
info,
232214
ompio_fh);
233215

234-
235-
236-
237216
if ( OMPI_SUCCESS != ret ) {
238217
ret = MPI_ERR_FILE;
239218
goto fn_fail;
240219
}
241220

242221

222+
if ( true == use_sharedfp ) {
223+
/* open the file once more for the shared file pointer if required.
224+
** Can be disabled by the user if no shared file pointer operations
225+
** are used by his application.
226+
*/
227+
if ( NULL != ompio_fh->f_sharedfp &&
228+
!mca_io_ompio_sharedfp_lazy_open ) {
229+
ret = ompio_fh->f_sharedfp->sharedfp_file_open(comm,
230+
filename,
231+
amode,
232+
info,
233+
ompio_fh);
234+
235+
if ( OMPI_SUCCESS != ret ) {
236+
goto fn_fail;
237+
}
238+
}
239+
}
240+
243241
/* If file has been opened in the append mode, move the internal
244242
file pointer of OMPIO to the very end of the file. */
245243
if ( ompio_fh->f_amode & MPI_MODE_APPEND ) {
@@ -251,16 +249,14 @@ ompio_io_ompio_file_open (ompi_communicator_t *comm,
251249
ompi_io_ompio_set_explicit_offset (ompio_fh, current_size);
252250
if ( true == use_sharedfp ) {
253251
if ( NULL != ompio_fh->f_sharedfp &&
254-
(!mca_io_ompio_sharedfp_lazy_open ||
255-
!strcmp (ompio_fh->f_sharedfp_component->mca_component_name,
256-
"addproc") )) {
252+
!mca_io_ompio_sharedfp_lazy_open ) {
257253

258254
shared_fp_base_module = ompio_fh->f_sharedfp;
259255
ret = shared_fp_base_module->sharedfp_seek(ompio_fh,current_size, MPI_SEEK_SET);
260256
}
261257
else {
262258
opal_output(1, "mca_common_ompio_file_open: Could not adjust position of "
263-
"shared file pointer whith MPI_MODE_APPEND\n");
259+
"shared file pointer with MPI_MODE_APPEND\n");
264260
ret = MPI_ERR_OTHER;
265261
goto fn_fail;
266262
}
@@ -412,7 +408,7 @@ ompio_io_ompio_file_close (mca_io_ompio_file_t *ompio_fh)
412408
}
413409

414410

415-
if (MPI_COMM_NULL != ompio_fh->f_comm && (ompio_fh->f_flags & OMPIO_SHAREDFP_IS_SET) ) {
411+
if (MPI_COMM_NULL != ompio_fh->f_comm && !(ompio_fh->f_flags & OMPIO_SHAREDFP_IS_SET) ) {
416412
ompi_comm_free (&ompio_fh->f_comm);
417413
}
418414

ompi/mca/io/ompio/io_ompio_file_set_view.c

Lines changed: 7 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) 2008-2016 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-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$
@@ -98,8 +98,12 @@ int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh,
9898
}
9999

100100
/* Reset the flags first */
101-
fh->f_flags = 0;
102-
101+
if ( fh->f_flags & OMPIO_CONTIGUOUS_FVIEW ) {
102+
fh->f_flags &= ~OMPIO_CONTIGUOUS_FVIEW;
103+
}
104+
if ( fh->f_flags & OMPIO_UNIFORM_FVIEW ) {
105+
fh->f_flags &= ~OMPIO_UNIFORM_FVIEW;
106+
}
103107
fh->f_flags |= OMPIO_FILE_VIEW_IS_SET;
104108
fh->f_datarep = strdup (datarep);
105109
datatype_duplicate (filetype, &fh->f_orig_filetype );

0 commit comments

Comments
 (0)