Skip to content

Commit d7f5a83

Browse files
authored
Merge pull request #8390 from edgargabriel/topic/mpich3.4-tstsuite-fixes
Topic/mpich3.4 tstsuite fixes
2 parents 406bd3a + 0761c0b commit d7f5a83

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
lines changed

ompi/mca/common/ompio/common_ompio_file_view.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
1313
* Copyright (c) 2017-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2017 IBM Corporation. All rights reserved.
@@ -72,6 +72,16 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
7272
ptrdiff_t ftype_extent, lb, ub;
7373
ompi_datatype_t *newfiletype;
7474

75+
if ( (MPI_DISPLACEMENT_CURRENT == disp) &&
76+
(fh->f_amode & MPI_MODE_SEQUENTIAL) ) {
77+
mca_sharedfp_base_module_t * shared_fp_base_module = fh->f_sharedfp;
78+
if ( NULL == shared_fp_base_module ){
79+
opal_output(0, "No shared file pointer component found for this file. Can not execute\n");
80+
return OMPI_ERROR;
81+
}
82+
shared_fp_base_module->sharedfp_get_position(fh, &disp);
83+
}
84+
7585
if ( NULL != fh->f_etype ) {
7686
ompi_datatype_destroy (&fh->f_etype);
7787
}
@@ -167,7 +177,17 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
167177
// File view is not a multiple of the etype.
168178
return MPI_ERR_ARG;
169179
}
180+
181+
// make sure that displacement is not negative, which could
182+
// lead to an illegal access.
183+
if ( 0 < fh->f_iov_count && 0 > (off_t)fh->f_decoded_iov[0].iov_base ) {
184+
// I think MPI_ERR_TYPE would be more appropriate, but
185+
// this is the error code expected in a testsuite, so I just
186+
// go with this.
187+
return MPI_ERR_IO;
188+
}
170189

190+
171191
if( SIMPLE_PLUS == OMPIO_MCA_GET(fh, grouping_option) ) {
172192
fh->f_cc_size = get_contiguous_chunk_size (fh, 1);
173193
}

ompi/mca/fbtl/posix/fbtl_posix.c

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
1313
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2018 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
@@ -127,14 +127,57 @@ bool mca_fbtl_posix_progress ( mca_ompio_request_t *req)
127127
if ( EINPROGRESS == data->aio_req_status[i] ) {
128128
data->aio_req_status[i] = aio_error ( &data->aio_reqs[i]);
129129
if ( 0 == data->aio_req_status[i]){
130-
data->aio_open_reqs--;
131-
lcount++;
132130
/* assuming right now that aio_return will return
133131
** the number of bytes written/read and not an error code,
134132
** since aio_error should have returned an error in that
135133
** case and not 0 ( which means request is complete)
136134
*/
137-
data->aio_total_len += aio_return (&data->aio_reqs[i]);
135+
ssize_t ret2 = aio_return (&data->aio_reqs[i]);
136+
data->aio_total_len += ret2;
137+
if ( data->aio_reqs[i].aio_nbytes != (size_t)ret2 ) {
138+
/* Partial completion */
139+
data->aio_reqs[i].aio_offset += ret2;
140+
data->aio_reqs[i].aio_buf = (char*)data->aio_reqs[i].aio_buf + ret2;
141+
data->aio_reqs[i].aio_nbytes -= ret2;
142+
data->aio_reqs[i].aio_reqprio = 0;
143+
data->aio_reqs[i].aio_sigevent.sigev_notify = SIGEV_NONE;
144+
data->aio_req_status[i] = EINPROGRESS;
145+
start_offset = data->aio_reqs[i].aio_offset;
146+
total_length = data->aio_reqs[i].aio_nbytes;
147+
if ( data->aio_req_type == FBTL_POSIX_WRITE ) {
148+
ret_code = mca_fbtl_posix_lock( &data->aio_lock, data->aio_fh, F_WRLCK, start_offset, total_length, OMPIO_LOCK_ENTIRE_REGION );
149+
if ( 0 < ret_code ) {
150+
opal_output(1, "mca_fbtl_posix_progress: error in mca_fbtl_posix_lock() %d", ret_code);
151+
/* Just in case some part of the lock actually succeeded. */
152+
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
153+
return OMPI_ERROR;
154+
}
155+
if (-1 == aio_write(&data->aio_reqs[i])) {
156+
opal_output(1, "mca_fbtl_posix_progress: error in aio_write()");
157+
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
158+
return OMPI_ERROR;
159+
}
160+
}
161+
else if ( data->aio_req_type == FBTL_POSIX_READ ) {
162+
ret_code = mca_fbtl_posix_lock( &data->aio_lock, data->aio_fh, F_RDLCK, start_offset, total_length, OMPIO_LOCK_ENTIRE_REGION );
163+
if ( 0 < ret_code ) {
164+
opal_output(1, "mca_fbtl_posix_progress: error in mca_fbtl_posix_lock() %d", ret_code);
165+
/* Just in case some part of the lock actually succeeded. */
166+
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
167+
return OMPI_ERROR;
168+
}
169+
if (-1 == aio_read(&data->aio_reqs[i])) {
170+
opal_output(1, "mca_fbtl_posix_progress: error in aio_read()");
171+
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
172+
return OMPI_ERROR;
173+
}
174+
mca_fbtl_posix_unlock ( &data->aio_lock, data->aio_fh );
175+
}
176+
}
177+
else {
178+
data->aio_open_reqs--;
179+
lcount++;
180+
}
138181
}
139182
else if ( EINPROGRESS == data->aio_req_status[i]){
140183
/* not yet done */

ompi/mca/io/ompio/io_ompio_file_set_view.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
7777
file pointer, once for the shared file pointer (if it is existent)
7878
*/
7979
fh = &data->ompio_fh;
80-
80+
81+
if ( MPI_DISPLACEMENT_CURRENT == disp &&
82+
!(fh->f_amode & MPI_MODE_SEQUENTIAL ) ) {
83+
// MPI_DISPLACEMENT_CURRENT is only valid if amode is MPI_MODE_SEQUENTIAL
84+
return MPI_ERR_DISP;
85+
}
86+
87+
8188
OPAL_THREAD_LOCK(&fp->f_lock);
8289
ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
8390
OPAL_THREAD_UNLOCK(&fp->f_lock);

0 commit comments

Comments
 (0)