Skip to content

Commit 79561ee

Browse files
committed
fbtl_posix_progress: aio_return can indicate partial completion
aio_return returns the number of bytes written/read, and can indicate a partial completion. This fix ensures that a partially completed aio_read/write operation is reposted correctly. Fixes the i_bigtype test from the mpich testsuite. Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
1 parent 6168dde commit 79561ee

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

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 */

0 commit comments

Comments
 (0)