00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "ad_ufs.h"
00010
00011 void ADIOI_UFS_ReadComplete(ADIO_Request *request, ADIO_Status *status, int *error_code)
00012 {
00013 #ifndef NO_AIO
00014 #ifndef PRINT_ERR_MSG
00015 static char myname[] = "ADIOI_UFS_READCOMPLETE";
00016 #endif
00017 #ifdef AIO_SUN
00018 aio_result_t *result=0, *tmp;
00019 #else
00020 int err;
00021 #endif
00022 #ifdef AIO_HANDLE_IN_AIOCB
00023 struct aiocb *tmp1;
00024 #endif
00025 #endif
00026
00027 if (*request == ADIO_REQUEST_NULL) {
00028 *error_code = MPI_SUCCESS;
00029 return;
00030 }
00031
00032 #ifdef AIO_SUN
00033 if ((*request)->queued) {
00034 tmp = (aio_result_t *) (*request)->handle;
00035 while (tmp->aio_return == AIO_INPROGRESS) usleep(1000);
00036
00037
00038 result = (aio_result_t *) aiowait(0);
00039
00040 (*request)->nbytes = tmp->aio_return;
00041
00042 #ifdef PRINT_ERR_MSG
00043 *error_code = (tmp->aio_return == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00044 #else
00045 if (tmp->aio_return == -1) {
00046 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00047 myname, "I/O Error", "%s", strerror(tmp->aio_errno));
00048 ADIOI_Error((*request)->fd, *error_code, myname);
00049 }
00050 else *error_code = MPI_SUCCESS;
00051 #endif
00052
00053
00054
00055
00056
00057
00058 }
00059 else *error_code = MPI_SUCCESS;
00060
00061 #ifdef HAVE_STATUS_SET_BYTES
00062 if ((*request)->nbytes != -1)
00063 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
00064 #endif
00065
00066 #endif
00067
00068 #ifdef AIO_HANDLE_IN_AIOCB
00069
00070 if ((*request)->queued) {
00071 do {
00072 err = aio_suspend(1, (struct aiocb **) &((*request)->handle));
00073 } while ((err == -1) && (errno == EINTR));
00074
00075 tmp1 = (struct aiocb *) (*request)->handle;
00076 if (err != -1) {
00077 err = aio_return(tmp1->aio_handle);
00078 (*request)->nbytes = err;
00079 errno = aio_error(tmp1->aio_handle);
00080 }
00081 else (*request)->nbytes = -1;
00082
00083
00084
00085
00086
00087
00088 #ifdef PRINT_ERR_MSG
00089 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00090 #else
00091 if (err == -1) {
00092 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00093 myname, "I/O Error", "%s", strerror(errno));
00094 ADIOI_Error((*request)->fd, *error_code, myname);
00095 }
00096 else *error_code = MPI_SUCCESS;
00097 #endif
00098 }
00099 else *error_code = MPI_SUCCESS;
00100
00101 #ifdef HAVE_STATUS_SET_BYTES
00102 if ((*request)->nbytes != -1)
00103 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
00104 #endif
00105
00106 #elif (!defined(NO_AIO) && !defined(AIO_SUN))
00107
00108 if ((*request)->queued) {
00109 do {
00110 err = aio_suspend((const aiocb_t **) &((*request)->handle), 1, 0);
00111 } while ((err == -1) && (errno == EINTR));
00112
00113 if (err != -1) {
00114 err = aio_return((struct aiocb *) (*request)->handle);
00115 (*request)->nbytes = err;
00116 errno = aio_error((struct aiocb *) (*request)->handle);
00117 }
00118 else (*request)->nbytes = -1;
00119
00120 #ifdef PRINT_ERR_MSG
00121 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00122 #else
00123 if (err == -1) {
00124 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00125 myname, "I/O Error", "%s", strerror(errno));
00126 ADIOI_Error((*request)->fd, *error_code, myname);
00127 }
00128 else *error_code = MPI_SUCCESS;
00129 #endif
00130 }
00131 else *error_code = MPI_SUCCESS;
00132 #ifdef HAVE_STATUS_SET_BYTES
00133 if ((*request)->nbytes != -1)
00134 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
00135 #endif
00136 #endif
00137
00138 #ifndef NO_AIO
00139 if ((*request)->queued != -1) {
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 if ((*request)->queued) ADIOI_Del_req_from_list(request);
00152
00153 (*request)->fd->async_count--;
00154 if ((*request)->handle) ADIOI_Free((*request)->handle);
00155 ADIOI_Free_request((ADIOI_Req_node *) (*request));
00156 *request = ADIO_REQUEST_NULL;
00157 }
00158
00159 #else
00160
00161
00162 #ifdef HAVE_STATUS_SET_BYTES
00163 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
00164 #endif
00165 (*request)->fd->async_count--;
00166 ADIOI_Free_request((ADIOI_Req_node *) (*request));
00167 *request = ADIO_REQUEST_NULL;
00168 *error_code = MPI_SUCCESS;
00169 #endif
00170 }
00171
00172
00173 void ADIOI_UFS_WriteComplete(ADIO_Request *request, ADIO_Status *status, int *error_code)
00174 {
00175 ADIOI_UFS_ReadComplete(request, status, error_code);
00176 }