Commit 1afe0227 authored by David Goodell's avatar David Goodell
Browse files

[svn-r10640] update error checkings in ADIO

Adds a new helper function, ADIOI_Err_create_code.

Contributed by IBM.  Based on patch 0012 from code discussions.
parent 52d6aa36
......@@ -91,6 +91,19 @@ void ADIOI_NFS_Open(ADIO_File fd, int *error_code)
__LINE__, MPI_ERR_READ_ONLY,
"**ioneedrd", 0);
}
else if(errno == EISDIR) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_BAD_FILE,
"**filename", 0);
}
else if(errno == EEXIST) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_FILE_EXISTS,
"**fileexist", 0);
}
else {
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
......
......@@ -20,15 +20,13 @@
void ADIOI_NFS_Resize(ADIO_File fd, ADIO_Offset size, int *error_code)
{
int err;
static char myname[] = "ADIOI_GEN_RESIZE";
static char myname[] = "ADIOI_NFS_RESIZE";
err = ftruncate(fd->fd_sys, size);
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO,
"**io", "**io %s", strerror(errno));
*error_code = ADIOI_Err_create_code(myname, fd->filename, errno);
return;
}
/* --END ERROR HANDLING-- */
......
......@@ -264,18 +264,24 @@ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *erro
err = statvfs(filename, &vfsbuf);
} while (err && (errno == ESTALE));
if (err && (errno == ENOENT)) {
if (err) {
/* ENOENT may be returned in two cases:
* 1) no directory entry for "filename"
* 2) "filename" is a dangling symbolic link
*
* ADIO_FileSysType_parentdir tries to deal with both cases.
*/
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = statvfs(dir, &vfsbuf);
if (errno == ENOENT) {
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = statvfs(dir, &vfsbuf);
ADIOI_Free(dir);
ADIOI_Free(dir);
}
else {
*error_code = ADIOI_Err_create_code(myname, filename, errno);
if(*error_code != MPI_SUCCESS) return;
}
}
/* --BEGIN ERROR HANDLING-- */
......@@ -315,11 +321,17 @@ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *erro
err = statfs(filename, &fsbuf);
} while (err && (errno == ESTALE));
if (err && (errno == ENOENT)) {
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = statfs(dir, &fsbuf);
ADIOI_Free(dir);
if (err) {
if(errno == ENOENT) {
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = statfs(dir, &fsbuf);
ADIOI_Free(dir);
}
else {
*error_code = ADIOI_Err_create_code(myname, filename, errno);
if(*error_code != MPI_SUCCESS) return;
}
}
/* --BEGIN ERROR HANDLING-- */
......@@ -428,11 +440,17 @@ static void ADIO_FileSysType_fncall(const char *filename, int *fstype, int *erro
err = stat(filename, &sbuf);
} while (err && (errno == ESTALE));
if (err && (errno == ENOENT)) {
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = stat(dir, &sbuf);
ADIOI_Free(dir);
if (err) {
if(errno == ENOENT) {
char *dir;
ADIO_FileSysType_parentdir(filename, &dir);
err = stat(dir, &sbuf);
ADIOI_Free(dir);
}
else{
*error_code = ADIOI_Err_create_code(myname, filename, errno);
if(*error_code != MPI_SUCCESS) return;
}
}
if (err) {
......
......@@ -74,6 +74,7 @@ void ADIOI_FAILSAFE_OpenColl(ADIO_File fd, int rank,
if (*error_code != MPI_SUCCESS)
(*(fd->fns->ADIOI_xxx_Open))(fd, error_code);
if(*error_code != MPI_SUCCESS) return;
/* if we turned off EXCL earlier, then we should turn it back on */
if (fd->access_mode != orig_amode_excl) fd->access_mode = orig_amode_excl;
......
......@@ -29,9 +29,7 @@ void ADIOI_GEN_Resize(ADIO_File fd, ADIO_Offset size, int *error_code)
/* --BEGIN ERROR HANDLING-- */
if (err == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO,
"**io", "**io %s", strerror(errno));
*error_code = ADIOI_Err_create_code(myname, fd->filename, errno);
return;
}
/* --END ERROR HANDLING-- */
......
......@@ -39,10 +39,7 @@ void ADIOI_GEN_Close(ADIO_File fd, int *error_code)
fd->fd_direct = -1;
if (err == -1 || derr == -1) {
*error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO,
"**io",
"**io %s", strerror(errno));
*error_code = ADIOI_Err_create_code(myname, fd->filename, errno);
}
else *error_code = MPI_SUCCESS;
}
......@@ -36,3 +36,66 @@ int ADIOI_Error(ADIO_File fd, int error_code, char *string)
return error_code;
}
/* Returns an MPI error code corresponding to "my_errno", for function "myname"
* and the given file, "filename". */
int ADIOI_Err_create_code(char *myname, char *filename, int my_errno)
{
int error_code = MPI_SUCCESS;
if(!my_errno) return MPI_SUCCESS;
switch(my_errno) {
case EACCES:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_ACCESS,
"**fileaccess",
"**fileaccess %s",
filename );
break;
case ENAMETOOLONG:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_BAD_FILE,
"**filenamelong",
"**filenamelong %s %d",
filename,
strlen(filename));
break;
case ENOENT:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_NO_SUCH_FILE,
"**filenoexist",
"**filenoexist %s",
filename);
break;
case EISDIR:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__,
MPI_ERR_BAD_FILE,
"**filenamedir",
"**filenamedir %s",
filename);
break;
case EROFS:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_READ_ONLY,
"**ioneedrd", 0 );
break;
case EEXIST:
error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE, myname,
__LINE__, MPI_ERR_FILE_EXISTS,
"**fileexist", 0);
break;
default:
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO, "**io",
"**io %s", strerror(my_errno));
break;
}
return error_code;
}
......@@ -561,6 +561,7 @@ int ADIOI_End_call(MPI_Comm comm, int keyval, void *attribute_val, void *extra_s
int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, int nbytes);
int ADIOI_Uses_generic_read(ADIO_File fd);
int ADIOI_Uses_generic_write(ADIO_File fd);
int ADIOI_Err_create_code(char *myname, char *filename, int my_errno);
int ADIOI_FAKE_IODone(ADIO_Request *request, ADIO_Status *status,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment