fs/lustre: update component to match fs/ufs
the fs/lustre component has missed out on a number of updates to the fs/ufs component. This commit tries to import all the changes performed on the fs/ufs component w.r.t to the file_open operation, including updates on how the amode is set, error is propegated and setting the fs_block_size value (which is required for locking purposes). Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
Этот коммит содержится в:
родитель
1885d99ac7
Коммит
91881c4fdc
@ -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-2015 University of Houston. All rights reserved.
|
* Copyright (c) 2008-2017 University of Houston. All rights reserved.
|
||||||
* Copyright (c) 2015 Research Organization for Information Science
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
|
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
|
||||||
@ -63,9 +63,9 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
struct opal_info_t *info,
|
struct opal_info_t *info,
|
||||||
mca_io_ompio_file_t *fh)
|
mca_io_ompio_file_t *fh)
|
||||||
{
|
{
|
||||||
int amode;
|
int amode, rank;
|
||||||
int old_mask, perm;
|
int old_mask, perm;
|
||||||
int rc;
|
int rc, ret=OMPI_SUCCESS;
|
||||||
int flag;
|
int flag;
|
||||||
int fs_lustre_stripe_size = -1;
|
int fs_lustre_stripe_size = -1;
|
||||||
int fs_lustre_stripe_width = -1;
|
int fs_lustre_stripe_width = -1;
|
||||||
@ -82,18 +82,15 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
perm = fh->f_perm;
|
perm = fh->f_perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rank = fh->f_rank;
|
||||||
|
|
||||||
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 (access_mode & MPI_MODE_EXCL)
|
|
||||||
amode = amode | O_EXCL;
|
|
||||||
|
|
||||||
|
|
||||||
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,33 +110,93 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
fs_lustre_stripe_width = mca_fs_lustre_stripe_width;
|
fs_lustre_stripe_width = mca_fs_lustre_stripe_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (fs_lustre_stripe_size>0 || fs_lustre_stripe_width>0) &&
|
|
||||||
(amode&O_CREAT) && (amode&O_RDWR)) {
|
/* Reset errno */
|
||||||
|
errno = 0;
|
||||||
if (0 == fh->f_rank) {
|
if (0 == fh->f_rank) {
|
||||||
|
/* MODE_CREATE and MODE_EXCL can only be set by one process */
|
||||||
|
if ( !(fh->f_flags & OMPIO_SHAREDFP_IS_SET)) {
|
||||||
|
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) &&
|
||||||
|
( amode&O_CREAT) &&
|
||||||
|
( (amode&O_RDWR)|| amode&O_WRONLY) ) {
|
||||||
llapi_file_create(filename,
|
llapi_file_create(filename,
|
||||||
fs_lustre_stripe_size,
|
fs_lustre_stripe_size,
|
||||||
-1, /* MSC need to change that */
|
-1, /* MSC need to change that */
|
||||||
fs_lustre_stripe_width,
|
fs_lustre_stripe_width,
|
||||||
0); /* MSC need to change that */
|
0); /* MSC need to change that */
|
||||||
|
|
||||||
fh->fd = open(filename, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, perm);
|
fh->fd = open(filename, amode | O_LOV_DELAY_CREATE, perm);
|
||||||
if (fh->fd < 0) {
|
}
|
||||||
fprintf(stderr, "Can't open %s file: %d (%s)\n",
|
else {
|
||||||
filename, errno, strerror(errno));
|
fh->fd = open (filename, amode, perm);
|
||||||
return OMPI_ERROR;
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
close (fh->fd);
|
|
||||||
}
|
}
|
||||||
fh->f_comm->c_coll->coll_barrier (fh->f_comm,
|
|
||||||
fh->f_comm->c_coll->coll_barrier_module);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fh->fd = open (filename, amode, perm);
|
comm->c_coll->coll_bcast ( &ret, 1, MPI_INT, 0, comm, comm->c_coll->coll_bcast_module);
|
||||||
if (fh->fd < 0) {
|
if ( OMPI_SUCCESS != ret ) {
|
||||||
opal_output(1, "error opening file %s\n", filename);
|
fh->fd = -1;
|
||||||
return OMPI_ERROR;
|
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 {
|
||||||
|
ret = MPI_ERR_OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lump = alloc_lum();
|
lump = alloc_lum();
|
||||||
if (NULL == lump ){
|
if (NULL == lump ){
|
||||||
fprintf(stderr,"Cannot allocate memory for extracting stripe size\n");
|
fprintf(stderr,"Cannot allocate memory for extracting stripe size\n");
|
||||||
@ -152,9 +209,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
|
|||||||
}
|
}
|
||||||
fh->f_stripe_size = lump->lmm_stripe_size;
|
fh->f_stripe_size = lump->lmm_stripe_size;
|
||||||
fh->f_stripe_count = lump->lmm_stripe_count;
|
fh->f_stripe_count = lump->lmm_stripe_count;
|
||||||
|
fh->f_fs_block_size = lump->lmm_stripe_size;
|
||||||
|
|
||||||
// if ( NULL != lump ) {
|
|
||||||
// free ( lump );
|
|
||||||
// }
|
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user