[mpich-commits] r10640 - in mpich2/trunk/src/mpi/romio/adio: ad_nfs common include

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue Nov 20 16:20:58 CST 2012


Author: goodell
Date: 2012-11-20 16:20:58 -0600 (Tue, 20 Nov 2012)
New Revision: 10640

Modified:
   mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_open.c
   mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_resize.c
   mpich2/trunk/src/mpi/romio/adio/common/ad_fstype.c
   mpich2/trunk/src/mpi/romio/adio/common/ad_opencoll_failsafe.c
   mpich2/trunk/src/mpi/romio/adio/common/ad_resize.c
   mpich2/trunk/src/mpi/romio/adio/common/adi_close.c
   mpich2/trunk/src/mpi/romio/adio/common/error.c
   mpich2/trunk/src/mpi/romio/adio/include/adioi.h
Log:
update error checkings in ADIO

Adds a new helper function, ADIOI_Err_create_code.

Contributed by IBM.  Based on patch 0012 from code discussions.

Modified: mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_open.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_open.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_open.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -91,6 +91,19 @@
 					       __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,

Modified: mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_resize.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_resize.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/ad_nfs/ad_nfs_resize.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -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-- */

Modified: mpich2/trunk/src/mpi/romio/adio/common/ad_fstype.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/common/ad_fstype.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/common/ad_fstype.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -264,18 +264,24 @@
 	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 @@
 	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 @@
 	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) {

Modified: mpich2/trunk/src/mpi/romio/adio/common/ad_opencoll_failsafe.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/common/ad_opencoll_failsafe.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/common/ad_opencoll_failsafe.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -74,6 +74,7 @@
     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;
 

Modified: mpich2/trunk/src/mpi/romio/adio/common/ad_resize.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/common/ad_resize.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/common/ad_resize.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -29,9 +29,7 @@
 
     /* --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-- */

Modified: mpich2/trunk/src/mpi/romio/adio/common/adi_close.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/common/adi_close.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/common/adi_close.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -39,10 +39,7 @@
     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;
 }

Modified: mpich2/trunk/src/mpi/romio/adio/common/error.c
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/common/error.c	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/common/error.c	2012-11-20 22:20:58 UTC (rev 10640)
@@ -36,3 +36,66 @@
     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;
+}

Modified: mpich2/trunk/src/mpi/romio/adio/include/adioi.h
===================================================================
--- mpich2/trunk/src/mpi/romio/adio/include/adioi.h	2012-11-20 22:20:57 UTC (rev 10639)
+++ mpich2/trunk/src/mpi/romio/adio/include/adioi.h	2012-11-20 22:20:58 UTC (rev 10640)
@@ -561,6 +561,7 @@
 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,



More information about the commits mailing list