mca/fs: Remove unused functions and prototypes & reduce recurent code through all components
I removed the implementation and/or prototypes of all unused functions defined for all components. To reduce recurrent code, I created functions under base for the management of error codes and setting of file permission and amode. Then, I replaced these recurrent code by those function for all components. Signed-off-by: raafatfeki <fekiraafat@gmail.com> add a missing header file Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
Этот коммит содержится в:
родитель
5988297bd8
Коммит
7b2d83c898
@ -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 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 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_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_delete (char* file_name, struct opal_info_t *info);
|
||||||
OMPI_DECLSPEC int mca_fs_base_file_sync (ompio_file_t *fh);
|
OMPI_DECLSPEC int mca_fs_base_file_sync (ompio_file_t *fh);
|
||||||
|
@ -143,3 +143,81 @@ int mca_fs_base_get_fstype(char *fname )
|
|||||||
return ompio_type;
|
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;
|
||||||
|
}
|
||||||
|
@ -138,43 +138,3 @@ int mca_fs_gpfs_module_finalize (ompio_file_t *file)
|
|||||||
{
|
{
|
||||||
return OMPI_SUCCESS;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -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 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 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,
|
int mca_fs_gpfs_file_set_info(struct ompio_file_t *fh,
|
||||||
struct ompi_info_t *info);
|
struct ompi_info_t *info);
|
||||||
int mca_fs_gpfs_file_get_info(struct ompio_file_t *fh,
|
int mca_fs_gpfs_file_get_info(struct ompio_file_t *fh,
|
||||||
struct ompi_info_t **info_used);
|
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,
|
int mca_fs_gpfs_io_selection(ompio_file_t *fh,
|
||||||
struct ompi_info_t *info, struct ompi_info_t *info_selected);
|
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);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ******************************************************************
|
* ******************************************************************
|
||||||
|
@ -46,43 +46,16 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh)
|
ompio_file_t *fh)
|
||||||
{
|
{
|
||||||
int amode;
|
int perm, amode;
|
||||||
int old_mask, perm;
|
|
||||||
int ret = OMPI_SUCCESS;
|
int ret = OMPI_SUCCESS;
|
||||||
|
|
||||||
if (fh->f_perm == OMPIO_PERM_NULL) {
|
perm = mca_fs_base_get_file_perm(fh);
|
||||||
old_mask = umask(022);
|
amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(OMPIO_ROOT == fh->f_rank) {
|
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);
|
fh->fd = open (filename, amode, perm);
|
||||||
|
|
||||||
if ( 0 > fh->fd ) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( OMPIO_ROOT != fh->f_rank ) {
|
if (OMPIO_ROOT != fh->f_rank) {
|
||||||
fh->fd = open (filename, amode, perm);
|
fh->fd = open (filename, amode, perm);
|
||||||
if ( 0 > fh->fd) {
|
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;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -133,44 +133,6 @@ int mca_fs_ime_module_finalize (ompio_file_t *file)
|
|||||||
return OMPI_SUCCESS;
|
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 mca_fs_ime_native_fini()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -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_init (ompio_file_t *file);
|
||||||
int mca_fs_ime_module_finalize (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();
|
int mca_fs_ime_native_fini();
|
||||||
|
|
||||||
OMPI_MODULE_DECLSPEC extern mca_fs_base_component_2_0_0_t mca_fs_ime_component;
|
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_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 ************
|
* ************ functions implemented in this module end ************
|
||||||
|
@ -34,7 +34,7 @@ int mca_fs_ime_file_close (ompio_file_t *fh)
|
|||||||
|
|
||||||
ret = ime_native_close(fh->fd);
|
ret = ime_native_close(fh->fd);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
|
@ -33,7 +33,7 @@ int mca_fs_ime_file_delete (char* file_name,
|
|||||||
|
|
||||||
ret = ime_native_unlink(file_name);
|
ret = ime_native_unlink(file_name);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
|
@ -31,12 +31,12 @@ int mca_fs_ime_file_get_size (ompio_file_t *fh,
|
|||||||
|
|
||||||
*size = ime_native_lseek(fh->fd, 0, SEEK_END);
|
*size = ime_native_lseek(fh->fd, 0, SEEK_END);
|
||||||
if (*size < 0) {
|
if (*size < 0) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((ime_native_lseek(fh->fd, fh->f_offset, SEEK_SET)) < 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;
|
return OMPI_SUCCESS;
|
||||||
|
@ -34,41 +34,20 @@ int mca_fs_ime_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh)
|
ompio_file_t *fh)
|
||||||
{
|
{
|
||||||
int amode = 0;
|
int perm, amode;
|
||||||
int old_mask, perm;
|
int ret = OMPI_SUCCESS;
|
||||||
int rank, 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 */
|
/* Reset errno */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if ( rank == OMPIO_ROOT ) {
|
if (OMPIO_ROOT == fh->f_rank) {
|
||||||
/* 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;
|
|
||||||
|
|
||||||
fh->fd = ime_native_open(filename, amode, perm);
|
fh->fd = ime_native_open(filename, amode, perm);
|
||||||
if ( fh->fd < 0 ) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rank != OMPIO_ROOT ) {
|
if (OMPIO_ROOT != fh->f_rank) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
fh->fd = ime_native_open(filename, amode, perm);
|
fh->fd = ime_native_open(filename, amode, perm);
|
||||||
if ( fh->fd < 0 ) {
|
if ( fh->fd < 0 ) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ int mca_fs_ime_file_set_size (ompio_file_t *fh,
|
|||||||
fh->f_comm->c_coll->coll_bcast_module);
|
fh->f_comm->c_coll->coll_bcast_module);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ int mca_fs_ime_file_sync (ompio_file_t *fh)
|
|||||||
|
|
||||||
ret = ime_native_fsync(fh->fd);
|
ret = ime_native_fsync(fh->fd);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return mca_fs_ime_get_mpi_err(errno);
|
return mca_fs_base_get_mpi_err(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
|
@ -64,22 +64,6 @@ int mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh);
|
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 ************
|
* ************ functions implemented in this module end ************
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "mpi.h"
|
#include "mpi.h"
|
||||||
#include "ompi/constants.h"
|
#include "ompi/constants.h"
|
||||||
#include "ompi/mca/fs/fs.h"
|
#include "ompi/mca/fs/fs.h"
|
||||||
|
#include "ompi/mca/fs/base/base.h"
|
||||||
#include "ompi/communicator/communicator.h"
|
#include "ompi/communicator/communicator.h"
|
||||||
#include "ompi/info/info.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,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh)
|
ompio_file_t *fh)
|
||||||
{
|
{
|
||||||
int amode, rank;
|
int amode, perm;
|
||||||
int old_mask, perm;
|
|
||||||
int rc, ret=OMPI_SUCCESS;
|
int rc, ret=OMPI_SUCCESS;
|
||||||
int flag;
|
int flag;
|
||||||
int fs_lustre_stripe_size = -1;
|
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;
|
struct lov_user_md *lump=NULL;
|
||||||
|
|
||||||
if (fh->f_perm == OMPIO_PERM_NULL) {
|
perm = mca_fs_base_get_file_perm(fh);
|
||||||
old_mask = umask(022);
|
amode = mca_fs_base_get_file_amode(fh->f_rank, access_mode);
|
||||||
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;
|
|
||||||
|
|
||||||
opal_info_get (info, "stripe_size", MPI_MAX_INFO_VAL, char_stripe, &flag);
|
opal_info_get (info, "stripe_size", MPI_MAX_INFO_VAL, char_stripe, &flag);
|
||||||
if ( flag ) {
|
if ( flag ) {
|
||||||
@ -113,13 +97,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
|
|
||||||
/* Reset errno */
|
/* Reset errno */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (0 == fh->f_rank) {
|
if (OMPIO_ROOT == 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 ( (fs_lustre_stripe_size>0 || fs_lustre_stripe_width>0) &&
|
if ( (fs_lustre_stripe_size>0 || fs_lustre_stripe_width>0) &&
|
||||||
( amode&O_CREAT) &&
|
( amode&O_CREAT) &&
|
||||||
( (amode&O_RDWR)|| amode&O_WRONLY) ) {
|
( (amode&O_RDWR)|| amode&O_WRONLY) ) {
|
||||||
@ -134,28 +112,9 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
else {
|
else {
|
||||||
fh->fd = open (filename, amode, perm);
|
fh->fd = open (filename, amode, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 > fh->fd ) {
|
if ( 0 > fh->fd ) {
|
||||||
if ( EACCES == errno ) {
|
ret = mca_fs_base_get_mpi_err(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,34 +124,12 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 != rank ) {
|
if (OMPIO_ROOT != fh->f_rank) {
|
||||||
fh->fd = open (filename, amode, perm);
|
fh->fd = open (filename, amode, perm);
|
||||||
if ( 0 > fh->fd) {
|
if ( 0 > fh->fd) {
|
||||||
if ( EACCES == errno ) {
|
return mca_fs_base_get_mpi_err(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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lump = alloc_lum();
|
lump = alloc_lum();
|
||||||
if (NULL == lump ){
|
if (NULL == lump ){
|
||||||
|
@ -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_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 ************
|
* ************ functions implemented in this module end ************
|
||||||
|
@ -60,22 +60,6 @@ int mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh);
|
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 ************
|
* ************ functions implemented in this module end ************
|
||||||
|
@ -48,71 +48,18 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
ompio_file_t *fh)
|
ompio_file_t *fh)
|
||||||
{
|
{
|
||||||
int amode;
|
int amode, perm;
|
||||||
int old_mask, perm;
|
int ret=OMPI_SUCCESS;
|
||||||
int rank, 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* Reset errno */
|
/* Reset errno */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ( 0 == rank ) {
|
if (OMPIO_ROOT == 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;
|
|
||||||
|
|
||||||
fh->fd = open (filename, amode, perm);
|
fh->fd = open (filename, amode, perm);
|
||||||
if ( 0 > fh->fd ) {
|
if ( 0 > fh->fd ) {
|
||||||
if ( EACCES == errno ) {
|
ret = mca_fs_base_get_mpi_err(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,39 +69,10 @@ mca_fs_ufs_file_open (struct ompi_communicator_t *comm,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 != rank ) {
|
if (OMPIO_ROOT != fh->f_rank) {
|
||||||
fh->fd = open (filename, amode, perm);
|
fh->fd = open (filename, amode, perm);
|
||||||
if ( 0 > fh->fd) {
|
if ( 0 > fh->fd) {
|
||||||
if ( EACCES == errno ) {
|
return mca_fs_base_get_mpi_err(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user