Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion ompi/mca/common/ompio/common_ompio_file_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2018 University of Houston. All rights reserved.
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
* Copyright (c) 2017-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
Expand Down Expand Up @@ -72,6 +72,16 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
ptrdiff_t ftype_extent, lb, ub;
ompi_datatype_t *newfiletype;

if ( (MPI_DISPLACEMENT_CURRENT == disp) &&
(fh->f_amode & MPI_MODE_SEQUENTIAL) ) {
mca_sharedfp_base_module_t * shared_fp_base_module = fh->f_sharedfp;
if ( NULL == shared_fp_base_module ){
opal_output(0, "No shared file pointer component found for this file. Can not execute\n");
return OMPI_ERROR;
}
shared_fp_base_module->sharedfp_get_position(fh, &disp);
}

if ( NULL != fh->f_etype ) {
ompi_datatype_destroy (&fh->f_etype);
}
Expand Down Expand Up @@ -145,7 +155,17 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
// File view is not a multiple of the etype.
return MPI_ERR_ARG;
}

// make sure that displacement is not negative, which could
// lead to an illegal access.
if ( 0 < fh->f_iov_count && 0 > (off_t)fh->f_decoded_iov[0].iov_base ) {
// I think MPI_ERR_TYPE would be more appropriate, but
// this is the error code expected in a testsuite, so I just
// go with this.
return MPI_ERR_IO;
}


if( SIMPLE_PLUS == OMPIO_MCA_GET(fh, grouping_option) ) {
fh->f_cc_size = get_contiguous_chunk_size (fh, 1);
}
Expand Down
51 changes: 47 additions & 4 deletions ompi/mca/fbtl/posix/fbtl_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
Expand Down Expand Up @@ -127,14 +127,57 @@ bool mca_fbtl_posix_progress ( mca_ompio_request_t *req)
if ( EINPROGRESS == data->aio_req_status[i] ) {
data->aio_req_status[i] = aio_error ( &data->aio_reqs[i]);
if ( 0 == data->aio_req_status[i]){
data->aio_open_reqs--;
lcount++;
/* assuming right now that aio_return will return
** the number of bytes written/read and not an error code,
** since aio_error should have returned an error in that
** case and not 0 ( which means request is complete)
*/
data->aio_total_len += aio_return (&data->aio_reqs[i]);
ssize_t ret2 = aio_return (&data->aio_reqs[i]);
data->aio_total_len += ret2;
if ( data->aio_reqs[i].aio_nbytes != (size_t)ret2 ) {
/* Partial completion */
data->aio_reqs[i].aio_offset += ret2;
data->aio_reqs[i].aio_buf = (char*)data->aio_reqs[i].aio_buf + ret2;
data->aio_reqs[i].aio_nbytes -= ret2;
data->aio_reqs[i].aio_reqprio = 0;
data->aio_reqs[i].aio_sigevent.sigev_notify = SIGEV_NONE;
data->aio_req_status[i] = EINPROGRESS;
start_offset = data->aio_reqs[i].aio_offset;
total_length = data->aio_reqs[i].aio_nbytes;
if ( data->aio_req_type == FBTL_POSIX_WRITE ) {
ret_code = mca_fbtl_posix_lock( &data->aio_lock, data->aio_fh, F_WRLCK, start_offset, total_length, OMPIO_LOCK_ENTIRE_REGION );
if ( 0 < ret_code ) {
opal_output(1, "mca_fbtl_posix_progress: error in mca_fbtl_posix_lock() %d", ret_code);
/* Just in case some part of the lock actually succeeded. */
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
return OMPI_ERROR;
}
if (-1 == aio_write(&data->aio_reqs[i])) {
opal_output(1, "mca_fbtl_posix_progress: error in aio_write()");
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
return OMPI_ERROR;
}
}
else if ( data->aio_req_type == FBTL_POSIX_READ ) {
ret_code = mca_fbtl_posix_lock( &data->aio_lock, data->aio_fh, F_RDLCK, start_offset, total_length, OMPIO_LOCK_ENTIRE_REGION );
if ( 0 < ret_code ) {
opal_output(1, "mca_fbtl_posix_progress: error in mca_fbtl_posix_lock() %d", ret_code);
/* Just in case some part of the lock actually succeeded. */
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
return OMPI_ERROR;
}
if (-1 == aio_read(&data->aio_reqs[i])) {
opal_output(1, "mca_fbtl_posix_progress: error in aio_read()");
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
return OMPI_ERROR;
}
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
}
}
else {
data->aio_open_reqs--;
lcount++;
}
}
else if ( EINPROGRESS == data->aio_req_status[i]){
/* not yet done */
Expand Down
9 changes: 8 additions & 1 deletion ompi/mca/io/ompio/io_ompio_file_set_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
file pointer, once for the shared file pointer (if it is existent)
*/
fh = &data->ompio_fh;


if ( MPI_DISPLACEMENT_CURRENT == disp &&
!(fh->f_amode & MPI_MODE_SEQUENTIAL ) ) {
// MPI_DISPLACEMENT_CURRENT is only valid if amode is MPI_MODE_SEQUENTIAL
return MPI_ERR_DISP;
}


OPAL_THREAD_LOCK(&fp->f_lock);
ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
OPAL_THREAD_UNLOCK(&fp->f_lock);
Expand Down