1
1

fix the problem identified by a user on the mailing list with MPI_MODE_EXCL

cmr=v1.7.4:reviewer=vvenkatesan:subject=fix a problem when opening a file with MODE_EXCL

This commit was SVN r30324.
Этот коммит содержится в:
Edgar Gabriel 2014-01-18 16:06:27 +00:00
родитель 16c061a5f8
Коммит be5d5834c5

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2008-2012 University of Houston. All rights reserved. * Copyright (c) 2008-2014 University of Houston. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -45,6 +45,9 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
{ {
int amode; int amode;
int old_mask, perm; int old_mask, perm;
int rank, ret;
rank = ompi_comm_rank ( comm );
if (fh->f_perm == OMPIO_PERM_NULL) { if (fh->f_perm == OMPIO_PERM_NULL) {
old_mask = umask(022); old_mask = umask(022);
@ -57,21 +60,34 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
amode = 0; amode = 0;
if (access_mode & MPI_MODE_CREATE)
amode = amode | O_CREAT;
if (access_mode & MPI_MODE_RDONLY) if (access_mode & MPI_MODE_RDONLY)
amode = amode | O_RDONLY; amode = amode | O_RDONLY;
if (access_mode & MPI_MODE_WRONLY) if (access_mode & MPI_MODE_WRONLY)
amode = amode | O_WRONLY; amode = amode | O_WRONLY;
if (access_mode & MPI_MODE_RDWR) if (access_mode & MPI_MODE_RDWR)
amode = amode | O_RDWR; amode = amode | O_RDWR;
if ( 0 == rank ) {
/* MODE_CREATE and MODE_EXCL can only be set by one process */
if ( access_mode & MPI_MODE_CREATE )
amode = amode | O_CREAT;
if (access_mode & MPI_MODE_EXCL) if (access_mode & MPI_MODE_EXCL)
amode = amode | O_EXCL; amode = amode | O_EXCL;
fh->fd = open (filename, amode, perm);
ret = fh->fd;
}
comm->c_coll.coll_bcast ( &ret, 1, MPI_INT, 0, comm, comm->c_coll.coll_bcast_module);
if ( -1 == ret ) {
fh->fd = ret;
return OMPI_ERROR;
}
if ( 0 != rank ) {
fh->fd = open (filename, amode, perm); fh->fd = open (filename, amode, perm);
if (-1 == fh->fd) { if (-1 == fh->fd) {
return OMPI_ERROR; return OMPI_ERROR;
} }
}
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }