diff --git a/ompi/mca/fs/base/base.h b/ompi/mca/fs/base/base.h index 5d2a919ec2..de57221cf8 100644 --- a/ompi/mca/fs/base/base.h +++ b/ompi/mca/fs/base/base.h @@ -52,6 +52,9 @@ OMPI_DECLSPEC int mca_fs_base_init_file (struct ompio_file_t *file); OMPI_DECLSPEC int mca_fs_base_get_param (struct ompio_file_t *file, int keyval); OMPI_DECLSPEC void mca_fs_base_get_parent_dir (char *filename, char **dirnamep); OMPI_DECLSPEC int mca_fs_base_get_fstype(char *fname); +OMPI_DECLSPEC int mca_fs_base_get_mpi_err(int errno_val); +OMPI_DECLSPEC int mca_fs_base_get_file_perm(ompio_file_t *fh); +OMPI_DECLSPEC int mca_fs_base_get_file_amode(int rank, int access_mode); OMPI_DECLSPEC int mca_fs_base_file_delete (char* file_name, struct opal_info_t *info); OMPI_DECLSPEC int mca_fs_base_file_sync (ompio_file_t *fh); diff --git a/ompi/mca/fs/base/fs_base_get_parent_dir.c b/ompi/mca/fs/base/fs_base_get_parent_dir.c index 8c687e1c3d..cd784c0caa 100644 --- a/ompi/mca/fs/base/fs_base_get_parent_dir.c +++ b/ompi/mca/fs/base/fs_base_get_parent_dir.c @@ -143,3 +143,81 @@ int mca_fs_base_get_fstype(char *fname ) return ompio_type; } +int mca_fs_base_get_mpi_err(int errno_val) +{ + int ret; + switch (errno_val) { + case EACCES: + ret = MPI_ERR_ACCESS; + break; + case ENAMETOOLONG: + case EISDIR: + ret = MPI_ERR_BAD_FILE; + break; + case ENOENT: + ret = MPI_ERR_NO_SUCH_FILE; + break; + case EROFS: + ret = MPI_ERR_READ_ONLY; + break; + case EEXIST: + ret = MPI_ERR_FILE_EXISTS; + break; + case ENOSPC: + ret = MPI_ERR_NO_SPACE; + break; + case EDQUOT: + ret = MPI_ERR_QUOTA; + break; + case ETXTBSY: + ret = MPI_ERR_FILE_IN_USE; + break; + case EBADF: + ret = MPI_ERR_FILE; + break; + default: + ret = MPI_ERR_OTHER; + break; + } + return ret; +} + +int mca_fs_base_get_file_perm(ompio_file_t *fh) +{ + int old_mask; + int perm = fh->f_perm; + + if (OMPIO_PERM_NULL == perm) { + old_mask = umask(022); + umask(old_mask); + perm = old_mask ^ 0666; + } + return perm; +} + +int mca_fs_base_get_file_amode(int rank, int access_mode) +{ + int amode = 0; + + if (access_mode & MPI_MODE_RDONLY) { + amode = amode | O_RDONLY; + } + if (access_mode & MPI_MODE_WRONLY) { + amode = amode | O_WRONLY; + } + if (access_mode & MPI_MODE_RDWR) { + amode = amode | O_RDWR; + } + + /* MODE_CREATE and MODE_EXCL should only be set by one process */ + if(OMPIO_ROOT == rank) { + if (access_mode & MPI_MODE_CREATE) { + amode = amode | O_CREAT; + } + if (access_mode & MPI_MODE_EXCL) { + amode = amode | O_EXCL; + } + } + + return amode; +} diff --git a/ompi/mca/fs/gpfs/fs_gpfs.c b/ompi/mca/fs/gpfs/fs_gpfs.c index e2bde81e85..6663b10a67 100644 --- a/ompi/mca/fs/gpfs/fs_gpfs.c +++ b/ompi/mca/fs/gpfs/fs_gpfs.c @@ -138,43 +138,3 @@ int mca_fs_gpfs_module_finalize (ompio_file_t *file) { return OMPI_SUCCESS; } - -int -mca_fs_gpfs_file_get_mpi_err (int errno_val) -{ - int ret; - switch (errno_val) { - case EACCES: - ret = MPI_ERR_ACCESS; - break; - case EISDIR: - case ENAMETOOLONG: - ret = MPI_ERR_BAD_FILE; - break; - case ENOENT: - ret = MPI_ERR_NO_SUCH_FILE; - break; - case EROFS: - ret = MPI_ERR_READ_ONLY; - break; - case EEXIST: - ret = MPI_ERR_FILE_EXISTS; - break; - case ENOSPC: - ret = MPI_ERR_NO_SPACE; - break; - case EDQUOT: - ret = MPI_ERR_QUOTA; - break; - case ETXTBSY: - ret = MPI_ERR_FILE_IN_USE; - break; - case EBADF: - ret = MPI_ERR_FILE; - break; - default: - ret = MPI_ERR_OTHER; - break; - } - return ret; -} diff --git a/ompi/mca/fs/gpfs/fs_gpfs.h b/ompi/mca/fs/gpfs/fs_gpfs.h index b17f28d593..ede1162196 100644 --- a/ompi/mca/fs/gpfs/fs_gpfs.h +++ b/ompi/mca/fs/gpfs/fs_gpfs.h @@ -50,31 +50,12 @@ OMPI_MODULE_DECLSPEC extern mca_fs_base_component_2_0_0_t mca_fs_gpfs_component; int mca_fs_gpfs_file_open(struct ompi_communicator_t *comm, const char *filename, int amode, struct opal_info_t *info, struct ompio_file_t *fh); -int mca_fs_gpfs_file_close(struct ompio_file_t *fh); -int mca_fs_gpfs_file_delete(char *filename, struct ompi_info_t *info); -int mca_fs_gpfs_file_set_size(struct ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE size); -int mca_fs_gpfs_file_get_size(struct ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE * size); -int mca_fs_gpfs_file_get_amode(struct ompi_file_t *fh, int *amode); int mca_fs_gpfs_file_set_info(struct ompio_file_t *fh, struct ompi_info_t *info); int mca_fs_gpfs_file_get_info(struct ompio_file_t *fh, struct ompi_info_t **info_used); -int mca_fs_gpfs_prefetch_hints(int access_mode, - ompio_file_t *fh, struct ompi_info_t *info); int mca_fs_gpfs_io_selection(ompio_file_t *fh, struct ompi_info_t *info, struct ompi_info_t *info_selected); -int mca_fs_gpfs_file_sync(struct ompi_file_t *fh); -//CN: Is mca_fs_gpfs_file_seek needed at all. Not used anywhere! -int -mca_fs_gpfs_file_seek(struct ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE off, - int whence); -int -mca_fs_gpfs_file_get_position(struct ompi_file_t *fh, - OMPI_MPI_OFFSET_TYPE *offset); - -int mca_fs_gpfs_file_get_mpi_err (int errno_val); /* * ****************************************************************** diff --git a/ompi/mca/fs/gpfs/fs_gpfs_file_open.c b/ompi/mca/fs/gpfs/fs_gpfs_file_open.c index a01430ea1f..497bc402f7 100644 --- a/ompi/mca/fs/gpfs/fs_gpfs_file_open.c +++ b/ompi/mca/fs/gpfs/fs_gpfs_file_open.c @@ -46,43 +46,16 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh) { - int amode; - int old_mask, perm; + int perm, amode; int ret = OMPI_SUCCESS; - if (fh->f_perm == OMPIO_PERM_NULL) { - old_mask = umask(022); - umask(old_mask); - perm = old_mask ^ 0666; - } - else { - perm = fh->f_perm; - } - - amode = 0; - - if (access_mode & MPI_MODE_RDONLY) { - amode = amode | O_RDONLY; - } - if (access_mode & MPI_MODE_WRONLY) { - amode = amode | O_WRONLY; - } - if (access_mode & MPI_MODE_RDWR) { - amode = amode | O_RDWR; - } + perm = mca_fs_base_get_file_perm(fh); + amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode); if(OMPIO_ROOT == fh->f_rank) { - if (access_mode & MPI_MODE_CREATE) { - amode = amode | O_CREAT; - } - if (access_mode & MPI_MODE_EXCL) { - amode = amode | O_EXCL; - } - fh->fd = open (filename, amode, perm); - if ( 0 > fh->fd ) { - ret = mca_fs_gpfs_file_get_mpi_err(errno); + ret = mca_fs_base_get_mpi_err(errno); } } @@ -92,10 +65,10 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm, return ret; } - if ( OMPIO_ROOT != fh->f_rank ) { + if (OMPIO_ROOT != fh->f_rank) { fh->fd = open (filename, amode, perm); if ( 0 > fh->fd) { - return mca_fs_gpfs_file_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } } @@ -104,69 +77,3 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm, return OMPI_SUCCESS; } - -int -mca_fs_gpfs_file_get_amode (ompi_file_t *fh, - int *amode) -{ - mca_common_ompio_data_t *data; - - data = (mca_common_ompio_data_t *) fh->f_io_selected_data; - - *amode = data->ompio_fh.f_amode; - - return OMPI_SUCCESS; -} - -//CN: Is mca_fs_gpfs_file_seek needed at all. Not used anywhere! -int -mca_fs_gpfs_file_seek(ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE off, int whence) { - //DEBUG: fprintf(stderr, "GPFS FILE SEEK!"); - int ret = OMPI_SUCCESS; - mca_common_ompio_data_t *data; - OMPI_MPI_OFFSET_TYPE offset, temp_offset; - - data = (mca_common_ompio_data_t *) fh->f_io_selected_data; - - offset = off * data->ompio_fh.f_etype_size; - - switch (whence) { - case MPI_SEEK_SET: - if (offset < 0) { - return OMPI_ERROR; - } - break; - case MPI_SEEK_CUR: - offset += data->ompio_fh.f_position_in_file_view; - offset += data->ompio_fh.f_disp; - if (offset < 0) { - return OMPI_ERROR; - } - break; - case MPI_SEEK_END: - ret = data->ompio_fh.f_fs->fs_file_get_size(&data->ompio_fh, - &temp_offset); - offset += temp_offset; - if (offset < 0 || OMPI_SUCCESS != ret) { - return OMPI_ERROR; - } - break; - default: - return OMPI_ERROR; - } - - ret = mca_common_ompio_set_explicit_offset(&data->ompio_fh, offset - / data->ompio_fh.f_etype_size); - return ret; -} - -int mca_fs_gpfs_file_get_position(ompi_file_t *fh, OMPI_MPI_OFFSET_TYPE *offset) { - mca_common_ompio_data_t *data; - - data = (mca_common_ompio_data_t *) fh->f_io_selected_data; - - *offset = data->ompio_fh.f_position_in_file_view - / data->ompio_fh.f_etype_size; - - return OMPI_SUCCESS; -} diff --git a/ompi/mca/fs/ime/fs_ime.c b/ompi/mca/fs/ime/fs_ime.c index 2ec211daca..1308652b14 100644 --- a/ompi/mca/fs/ime/fs_ime.c +++ b/ompi/mca/fs/ime/fs_ime.c @@ -133,44 +133,6 @@ int mca_fs_ime_module_finalize (ompio_file_t *file) return OMPI_SUCCESS; } -int mca_fs_ime_get_mpi_err(int errno_val) -{ - switch (errno_val) { - case EACCES: - return MPI_ERR_ACCESS; - - case ENAMETOOLONG: - return MPI_ERR_BAD_FILE; - - case ENOENT: - return MPI_ERR_NO_SUCH_FILE; - - case EISDIR: - return MPI_ERR_BAD_FILE; - - case EROFS: - return MPI_ERR_READ_ONLY; - - case EEXIST: - return MPI_ERR_FILE_EXISTS; - - case ENOSPC: - return MPI_ERR_NO_SPACE; - - case EDQUOT: - return MPI_ERR_QUOTA; - - case ETXTBSY: - return MPI_ERR_FILE_IN_USE; - - case EBADF: - return MPI_ERR_FILE; - - default: - return MPI_ERR_OTHER; - } -} - int mca_fs_ime_native_fini() { int ret; diff --git a/ompi/mca/fs/ime/fs_ime.h b/ompi/mca/fs/ime/fs_ime.h index 626842733d..170f03a06e 100644 --- a/ompi/mca/fs/ime/fs_ime.h +++ b/ompi/mca/fs/ime/fs_ime.h @@ -33,7 +33,6 @@ int mca_fs_ime_component_file_unquery (ompio_file_t *file); int mca_fs_ime_module_init (ompio_file_t *file); int mca_fs_ime_module_finalize (ompio_file_t *file); -int mca_fs_ime_get_mpi_err(int errno_val); int mca_fs_ime_native_fini(); OMPI_MODULE_DECLSPEC extern mca_fs_base_component_2_0_0_t mca_fs_ime_component; @@ -62,9 +61,6 @@ int mca_fs_ime_file_get_size (ompio_file_t *fh, int mca_fs_ime_file_sync (ompio_file_t *fh); -int mca_fs_ime_file_seek (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE offset, - int whence); /* * ****************************************************************** * ************ functions implemented in this module end ************ diff --git a/ompi/mca/fs/ime/fs_ime_file_close.c b/ompi/mca/fs/ime/fs_ime_file_close.c index f727786635..cb1f74261e 100644 --- a/ompi/mca/fs/ime/fs_ime_file_close.c +++ b/ompi/mca/fs/ime/fs_ime_file_close.c @@ -34,7 +34,7 @@ int mca_fs_ime_file_close (ompio_file_t *fh) ret = ime_native_close(fh->fd); if (ret != 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } return OMPI_SUCCESS; diff --git a/ompi/mca/fs/ime/fs_ime_file_delete.c b/ompi/mca/fs/ime/fs_ime_file_delete.c index 3db5a87c57..4090ad894c 100644 --- a/ompi/mca/fs/ime/fs_ime_file_delete.c +++ b/ompi/mca/fs/ime/fs_ime_file_delete.c @@ -33,7 +33,7 @@ int mca_fs_ime_file_delete (char* file_name, ret = ime_native_unlink(file_name); if (ret != 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } return OMPI_SUCCESS; diff --git a/ompi/mca/fs/ime/fs_ime_file_get_size.c b/ompi/mca/fs/ime/fs_ime_file_get_size.c index c31b34e3d3..b92e1be6ab 100644 --- a/ompi/mca/fs/ime/fs_ime_file_get_size.c +++ b/ompi/mca/fs/ime/fs_ime_file_get_size.c @@ -31,12 +31,12 @@ int mca_fs_ime_file_get_size (ompio_file_t *fh, *size = ime_native_lseek(fh->fd, 0, SEEK_END); if (*size < 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } errno = 0; if ((ime_native_lseek(fh->fd, fh->f_offset, SEEK_SET)) < 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } return OMPI_SUCCESS; diff --git a/ompi/mca/fs/ime/fs_ime_file_open.c b/ompi/mca/fs/ime/fs_ime_file_open.c index 4ec22ee80e..b0ae3e6368 100644 --- a/ompi/mca/fs/ime/fs_ime_file_open.c +++ b/ompi/mca/fs/ime/fs_ime_file_open.c @@ -34,41 +34,20 @@ int mca_fs_ime_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh) { - int amode = 0; - int old_mask, perm; - int rank, ret = OMPI_SUCCESS; + int perm, amode; + int ret = OMPI_SUCCESS; - rank = ompi_comm_rank ( comm ); + perm = mca_fs_base_get_file_perm(fh); + amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode); - if (fh->f_perm == OMPIO_PERM_NULL) { - old_mask = umask(022); - umask(old_mask); - perm = old_mask ^ 0666; - } - else { - perm = fh->f_perm; - } - - if (access_mode & MPI_MODE_RDONLY) - amode = amode | O_RDONLY; - if (access_mode & MPI_MODE_WRONLY) - amode = amode | O_WRONLY; - if (access_mode & MPI_MODE_RDWR) - amode = amode | O_RDWR; /* Reset errno */ errno = 0; - if ( rank == OMPIO_ROOT ) { - /* MODE_CREATE and MODE_EXCL should only be set by one process */ - if ( access_mode & MPI_MODE_CREATE ) - amode = amode | O_CREAT; - if (access_mode & MPI_MODE_EXCL) - amode = amode | O_EXCL; - + if (OMPIO_ROOT == fh->f_rank) { fh->fd = ime_native_open(filename, amode, perm); if ( fh->fd < 0 ) { - ret = mca_fs_ime_get_mpi_err(errno); + ret = mca_fs_base_get_mpi_err(errno); } } @@ -79,11 +58,11 @@ int mca_fs_ime_file_open (struct ompi_communicator_t *comm, return ret; } - if ( rank != OMPIO_ROOT ) { + if (OMPIO_ROOT != fh->f_rank) { errno = 0; fh->fd = ime_native_open(filename, amode, perm); if ( fh->fd < 0 ) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } } diff --git a/ompi/mca/fs/ime/fs_ime_file_set_size.c b/ompi/mca/fs/ime/fs_ime_file_set_size.c index 014ad6ac59..9ab9ebc822 100644 --- a/ompi/mca/fs/ime/fs_ime_file_set_size.c +++ b/ompi/mca/fs/ime/fs_ime_file_set_size.c @@ -43,7 +43,7 @@ int mca_fs_ime_file_set_size (ompio_file_t *fh, fh->f_comm->c_coll->coll_bcast_module); if (ret < 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } return OMPI_SUCCESS; } diff --git a/ompi/mca/fs/ime/fs_ime_file_sync.c b/ompi/mca/fs/ime/fs_ime_file_sync.c index 0db28b344c..a5e688fe68 100644 --- a/ompi/mca/fs/ime/fs_ime_file_sync.c +++ b/ompi/mca/fs/ime/fs_ime_file_sync.c @@ -25,7 +25,7 @@ int mca_fs_ime_file_sync (ompio_file_t *fh) ret = ime_native_fsync(fh->fd); if (ret != 0) { - return mca_fs_ime_get_mpi_err(errno); + return mca_fs_base_get_mpi_err(errno); } return OMPI_SUCCESS; diff --git a/ompi/mca/fs/lustre/fs_lustre.h b/ompi/mca/fs/lustre/fs_lustre.h index c1e9c211d5..6ff2fac47f 100644 --- a/ompi/mca/fs/lustre/fs_lustre.h +++ b/ompi/mca/fs/lustre/fs_lustre.h @@ -64,22 +64,6 @@ int mca_fs_lustre_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh); -int mca_fs_lustre_file_close (ompio_file_t *fh); - -int mca_fs_lustre_file_delete (char *filename, - struct opal_info_t *info); - -int mca_fs_lustre_file_set_size (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE size); - -int mca_fs_lustre_file_get_size (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE *size); - -int mca_fs_lustre_file_sync (ompio_file_t *fh); - -int mca_fs_lustre_file_seek (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE offset, - int whence); /* * ****************************************************************** * ************ functions implemented in this module end ************ diff --git a/ompi/mca/fs/lustre/fs_lustre_file_open.c b/ompi/mca/fs/lustre/fs_lustre_file_open.c index 6dc996caf3..7d8540025d 100644 --- a/ompi/mca/fs/lustre/fs_lustre_file_open.c +++ b/ompi/mca/fs/lustre/fs_lustre_file_open.c @@ -29,6 +29,7 @@ #include "mpi.h" #include "ompi/constants.h" #include "ompi/mca/fs/fs.h" +#include "ompi/mca/fs/base/base.h" #include "ompi/communicator/communicator.h" #include "ompi/info/info.h" @@ -63,8 +64,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh) { - int amode, rank; - int old_mask, perm; + int amode, perm; int rc, ret=OMPI_SUCCESS; int flag; int fs_lustre_stripe_size = -1; @@ -73,24 +73,8 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm, struct lov_user_md *lump=NULL; - if (fh->f_perm == OMPIO_PERM_NULL) { - old_mask = umask(022); - umask(old_mask); - perm = old_mask ^ 0666; - } - else { - perm = fh->f_perm; - } - - rank = fh->f_rank; - - amode = 0; - if (access_mode & MPI_MODE_RDONLY) - amode = amode | O_RDONLY; - if (access_mode & MPI_MODE_WRONLY) - amode = amode | O_WRONLY; - if (access_mode & MPI_MODE_RDWR) - amode = amode | O_RDWR; + perm = mca_fs_base_get_file_perm(fh); + amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode); opal_info_get (info, "stripe_size", MPI_MAX_INFO_VAL, char_stripe, &flag); if ( flag ) { @@ -113,13 +97,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm, /* Reset errno */ errno = 0; - if (0 == fh->f_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) - amode = amode | O_EXCL; - + if (OMPIO_ROOT == fh->f_rank) { if ( (fs_lustre_stripe_size>0 || fs_lustre_stripe_width>0) && ( amode&O_CREAT) && ( (amode&O_RDWR)|| amode&O_WRONLY) ) { @@ -134,28 +112,9 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm, else { fh->fd = open (filename, amode, perm); } + if ( 0 > fh->fd ) { - if ( EACCES == errno ) { - ret = MPI_ERR_ACCESS; - } - else if ( ENAMETOOLONG == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( ENOENT == errno ) { - ret = MPI_ERR_NO_SUCH_FILE; - } - else if ( EISDIR == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( EROFS == errno ) { - ret = MPI_ERR_READ_ONLY; - } - else if ( EEXIST == errno ) { - ret = MPI_ERR_FILE_EXISTS; - } - else { - ret = MPI_ERR_OTHER; - } + ret = mca_fs_base_get_mpi_err(errno); } } @@ -165,39 +124,17 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm, return ret; } - if ( 0 != rank ) { + if (OMPIO_ROOT != fh->f_rank) { fh->fd = open (filename, amode, perm); if ( 0 > fh->fd) { - if ( EACCES == errno ) { - ret = MPI_ERR_ACCESS; - } - else if ( ENAMETOOLONG == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( ENOENT == errno ) { - ret = MPI_ERR_NO_SUCH_FILE; - } - else if ( EISDIR == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( EROFS == errno ) { - ret = MPI_ERR_READ_ONLY; - } - else if ( EEXIST == errno ) { - ret = MPI_ERR_FILE_EXISTS; - } - else { - ret = MPI_ERR_OTHER; - } + return mca_fs_base_get_mpi_err(errno); } } - - lump = alloc_lum(); if (NULL == lump ){ - fprintf(stderr,"Cannot allocate memory for extracting stripe size\n"); - return OMPI_ERROR; + fprintf(stderr,"Cannot allocate memory for extracting stripe size\n"); + return OMPI_ERROR; } rc = llapi_file_get_stripe(filename, lump); if (rc != 0) { diff --git a/ompi/mca/fs/pvfs2/fs_pvfs2.h b/ompi/mca/fs/pvfs2/fs_pvfs2.h index 2b83bf8568..f879d7f992 100644 --- a/ompi/mca/fs/pvfs2/fs_pvfs2.h +++ b/ompi/mca/fs/pvfs2/fs_pvfs2.h @@ -89,9 +89,6 @@ int mca_fs_pvfs2_file_get_size (ompio_file_t *fh, int mca_fs_pvfs2_file_sync (ompio_file_t *fh); -int mca_fs_pvfs2_file_seek (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE offset, - int whence); /* * ****************************************************************** * ************ functions implemented in this module end ************ diff --git a/ompi/mca/fs/ufs/fs_ufs.h b/ompi/mca/fs/ufs/fs_ufs.h index 74e5607279..0ea10df68d 100644 --- a/ompi/mca/fs/ufs/fs_ufs.h +++ b/ompi/mca/fs/ufs/fs_ufs.h @@ -60,22 +60,6 @@ int mca_fs_ufs_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh); -int mca_fs_ufs_file_close (ompio_file_t *fh); - -int mca_fs_ufs_file_delete (char *filename, - struct opal_info_t *info); - -int mca_fs_ufs_file_set_size (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE size); - -int mca_fs_ufs_file_get_size (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE *size); - -int mca_fs_ufs_file_sync (ompio_file_t *fh); - -int mca_fs_ufs_file_seek (ompio_file_t *fh, - OMPI_MPI_OFFSET_TYPE offset, - int whence); /* * ****************************************************************** * ************ functions implemented in this module end ************ diff --git a/ompi/mca/fs/ufs/fs_ufs_file_open.c b/ompi/mca/fs/ufs/fs_ufs_file_open.c index 9e96b74ea4..1159de993b 100644 --- a/ompi/mca/fs/ufs/fs_ufs_file_open.c +++ b/ompi/mca/fs/ufs/fs_ufs_file_open.c @@ -48,114 +48,32 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm, struct opal_info_t *info, ompio_file_t *fh) { - int amode; - int old_mask, perm; - int rank, ret=OMPI_SUCCESS; + int amode, perm; + int ret=OMPI_SUCCESS; - rank = ompi_comm_rank ( comm ); - - if (fh->f_perm == OMPIO_PERM_NULL) { - old_mask = umask(022); - umask(old_mask); - perm = old_mask ^ 0666; - } - else { - perm = fh->f_perm; - } - - amode = 0; - - if (access_mode & MPI_MODE_RDONLY) - amode = amode | O_RDONLY; - if (access_mode & MPI_MODE_WRONLY) - amode = amode | O_WRONLY; - if (access_mode & MPI_MODE_RDWR) - amode = amode | O_RDWR; + perm = mca_fs_base_get_file_perm(fh); + amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode); /* Reset errno */ errno = 0; - 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) - amode = amode | O_EXCL; - - fh->fd = open (filename, amode, perm); - if ( 0 > fh->fd ) { - if ( EACCES == errno ) { - ret = MPI_ERR_ACCESS; - } - else if ( ENAMETOOLONG == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( ENOENT == errno ) { - ret = MPI_ERR_NO_SUCH_FILE; - } - else if ( EISDIR == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( EROFS == errno ) { - ret = MPI_ERR_READ_ONLY; - } - else if ( EEXIST == errno ) { - ret = MPI_ERR_FILE_EXISTS; - } - else if ( ENOSPC == errno ) { - ret = MPI_ERR_NO_SPACE; - } - else if ( EDQUOT == errno ) { - ret = MPI_ERR_QUOTA; - } - else if ( ETXTBSY == errno ) { - ret = MPI_ERR_FILE_IN_USE; - } - else { - ret = MPI_ERR_OTHER; - } + if (OMPIO_ROOT == fh->f_rank) { + fh->fd = open (filename, amode, perm); + if ( 0 > fh->fd ) { + ret = mca_fs_base_get_mpi_err(errno); } } comm->c_coll->coll_bcast ( &ret, 1, MPI_INT, 0, comm, comm->c_coll->coll_bcast_module); if ( OMPI_SUCCESS != ret ) { - fh->fd = -1; - return ret; + fh->fd = -1; + return ret; } - if ( 0 != rank ) { - fh->fd = open (filename, amode, perm); - if ( 0 > fh->fd) { - if ( EACCES == errno ) { - ret = MPI_ERR_ACCESS; - } - else if ( ENAMETOOLONG == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( ENOENT == errno ) { - ret = MPI_ERR_NO_SUCH_FILE; - } - else if ( EISDIR == errno ) { - ret = MPI_ERR_BAD_FILE; - } - else if ( EROFS == errno ) { - ret = MPI_ERR_READ_ONLY; - } - else if ( EEXIST == errno ) { - ret = MPI_ERR_FILE_EXISTS; - } - else if ( ENOSPC == errno ) { - ret = MPI_ERR_NO_SPACE; - } - else if ( EDQUOT == errno ) { - ret = MPI_ERR_QUOTA; - } - else if ( ETXTBSY == errno ) { - ret = MPI_ERR_FILE_IN_USE; - } - else { - ret = MPI_ERR_OTHER; - } - } + if (OMPIO_ROOT != fh->f_rank) { + fh->fd = open (filename, amode, perm); + if ( 0 > fh->fd) { + return mca_fs_base_get_mpi_err(errno); + } } fh->f_stripe_size=0;