diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index 126bf13..741b842 100644 --- a/src/aiori-HDF5.c +++ b/src/aiori-HDF5.c @@ -151,7 +151,8 @@ IOR_Open_HDF5(char * testFileName, MPI_Info mpiHints = MPI_INFO_NULL; fd = (hid_t *)malloc(sizeof(hid_t)); - if (fd == NULL) ERR("Unable to malloc file descriptor"); + if (fd == NULL) + ERR("malloc() failed"); /* * HDF5 uses different flags than those for POSIX/MPIIO */ @@ -563,7 +564,8 @@ SetupDataSet_HDF5(void * fd, } #else char errorString[MAX_STR]; - sprintf(errorString, "'no fill' option not available in %s", test->apiVersion); + sprintf(errorString, "'no fill' option not available in %s", + test->apiVersion); ERR(errorString); #endif #else diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index f4ef793..b1b430f 100644 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -97,7 +97,8 @@ IOR_Open_MPIIO(char * testFileName, MPI_Info mpiHints = MPI_INFO_NULL; fd = (MPI_File *)malloc(sizeof(MPI_File)); - if (fd == NULL) ERR("Unable to malloc MPI_File"); + if (fd == NULL) + ERR("malloc failed()"); *fd = 0; diff --git a/src/aiori-NCMPI.c b/src/aiori-NCMPI.c index 39fb533..0a267e9 100644 --- a/src/aiori-NCMPI.c +++ b/src/aiori-NCMPI.c @@ -96,7 +96,8 @@ IOR_Create_NCMPI(char * testFileName, } fd = (int *)malloc(sizeof(int)); - if (fd == NULL) ERR("Unable to malloc file descriptor"); + if (fd == NULL) + ERR("malloc() failed"); fd_mode = GetFileMode(param); NCMPI_CHECK(ncmpi_create(testComm, testFileName, fd_mode, @@ -145,7 +146,8 @@ IOR_Open_NCMPI(char * testFileName, } fd = (int *)malloc(sizeof(int)); - if (fd == NULL) ERR("Unable to malloc file descriptor"); + if (fd == NULL) + ERR("malloc() failed"); fd_mode = GetFileMode(param); NCMPI_CHECK(ncmpi_open(testComm, testFileName, fd_mode, @@ -350,7 +352,8 @@ IOR_Close_NCMPI(void * fd, void IOR_Delete_NCMPI(char * testFileName, IOR_param_t * param) { - if (unlink(testFileName) != 0) WARN("cannot delete file"); + if (unlink(testFileName) != 0) + WARN("unlink() failed"); } /* IOR_Delete_NCMPI() */ diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index 4c4d7d3..2ec925f 100644 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -21,6 +21,7 @@ #include /* only for fprintf() */ #include #include +#include #ifdef HAVE_LUSTRE_LUSTRE_USER_H # include #endif /* HAVE_LUSTRE_LUSTRE_USER_H */ @@ -109,7 +110,7 @@ IOR_Create_POSIX(char * testFileName, MPI_CHECK(MPI_Barrier(testComm), "barrier error"); fd_oflag |= O_RDWR; *fd = open64(testFileName, fd_oflag, 0664); - if (*fd < 0) ERR("cannot open file"); + if (*fd < 0) ERR("open64() failed"); } else { struct lov_user_md opts = { 0 }; @@ -142,14 +143,14 @@ IOR_Create_POSIX(char * testFileName, #endif /* HAVE_LUSTRE_LUSTRE_USER_H */ fd_oflag |= O_CREAT | O_RDWR; *fd = open64(testFileName, fd_oflag, 0664); - if (*fd < 0) ERR("cannot open file"); + if (*fd < 0) ERR("open64() failed"); #ifdef HAVE_LUSTRE_LUSTRE_USER_H } if (param->lustre_ignore_locks) { int lustre_ioctl_flags = LL_FILE_IGNORE_LOCK; if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1) - ERR("cannot set ioctl"); + ERR("ioctl(LL_IOC_SETFLAGS) failed"); } #endif /* HAVE_LUSTRE_LUSTRE_USER_H */ @@ -188,7 +189,7 @@ IOR_Open_POSIX(char * testFileName, fd_oflag |= O_RDWR; *fd = open64(testFileName, fd_oflag); - if (*fd < 0) ERR("cannot open file"); + if (*fd < 0) ERR("open64 failed"); #ifdef HAVE_LUSTRE_LUSTRE_USER_H if (param->lustre_ignore_locks) { @@ -197,7 +198,7 @@ IOR_Open_POSIX(char * testFileName, fprintf(stdout, "** Disabling lustre range locking **\n"); } if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1) - ERR("cannot set ioctl"); + ERR("ioctl(LL_IOC_SETFLAGS) failed"); } #endif /* HAVE_LUSTRE_LUSTRE_USER_H */ @@ -227,7 +228,7 @@ IOR_Xfer_POSIX(int access, /* seek to offset */ if (lseek64(fd, param->offset, SEEK_SET) == -1) - ERR("seek failed"); + ERR("lseek64() failed"); while (remaining > 0) { /* write/read file */ @@ -237,7 +238,10 @@ IOR_Xfer_POSIX(int access, rank, param->offset + length - remaining); } rc = write(fd, ptr, remaining); - if (param->fsyncPerWrite == TRUE) IOR_Fsync_POSIX(&fd, param); + if (param->fsyncPerWrite == TRUE) + IOR_Fsync_POSIX(&fd, param); + if (rc == -1) + ERR("write() failed"); } else { /* READ or CHECK */ if (verbose >= VERBOSE_4) { fprintf(stdout, "task %d reading from offset %lld\n", @@ -245,40 +249,24 @@ IOR_Xfer_POSIX(int access, } rc = read(fd, ptr, remaining); if (rc == 0) - ERR("hit EOF prematurely"); - } - if (rc == -1) - ERR("transfer failed"); - if (rc != remaining) { - fprintf(stdout, - "WARNING: Task %d requested transfer of %lld bytes,\n", - rank, remaining); - fprintf(stdout, - " but transferred %lld bytes at offset %lld\n", - rc, param->offset + length - remaining); - if (param->singleXferAttempt == TRUE) - MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "barrier error"); + ERR("read() returned EOF prematurely"); + if (rc == -1) + ERR("read() failed"); } if (rc < remaining) { + fprintf(stdout, + "WARNING: Task %d, partial %s, %lld of %lld bytes at offset %lld\n", + rank, + access == WRITE ? "write()" : "read()", + rc, remaining, + param->offset+length-remaining); + if (param->singleXferAttempt == TRUE) + MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "barrier error"); if (xferRetries > MAX_RETRY) ERR("too many retries -- aborting"); - if (xferRetries == 0) { - if (access == WRITE) { - WARN("This file system requires support of partial write()s"); - } else { - WARN("This file system requires support of partial read()s"); - } - fprintf(stdout, - "WARNING: Requested xfer of %lld bytes, but xferred %lld bytes\n", - remaining, rc); - } - if (verbose >= VERBOSE_2) { - fprintf(stdout, "Only transferred %lld of %lld bytes\n", - rc, remaining); - } } - if (rc > remaining) /* this should never happen */ - ERR("too many bytes transferred!?!"); + assert(rc >= 0); + assert(rc <= remaining); remaining -= rc; ptr += rc; xferRetries++; @@ -295,7 +283,8 @@ IOR_Xfer_POSIX(int access, void IOR_Fsync_POSIX(void * fd, IOR_param_t * param) { - if (fsync(*(int *)fd) != 0) WARN("cannot perform fsync on file"); + if (fsync(*(int *)fd) != 0) + WARN("fsync() failed"); } /* IOR_Fsync_POSIX() */ @@ -308,7 +297,8 @@ void IOR_Close_POSIX(void *fd, IOR_param_t * param) { - if (close(*(int *)fd) != 0) ERR("cannot close file"); + if (close(*(int *)fd) != 0) + ERR("close() failed"); free(fd); } /* IOR_Close_POSIX() */ @@ -322,7 +312,8 @@ void IOR_Delete_POSIX(char * testFileName, IOR_param_t * param) { char errmsg[256]; - sprintf(errmsg,"[RANK %03d]:cannot delete file %s\n",rank,testFileName); + sprintf(errmsg,"[RANK %03d]: unlink() of file \"%s\" failed\n", + rank, testFileName); if (unlink(testFileName) != 0) WARN(errmsg); } /* IOR_Delete_POSIX() */ @@ -354,7 +345,7 @@ IOR_GetFileSize_POSIX(IOR_param_t * test, tmpMin, tmpMax, tmpSum; if (stat(testFileName, &stat_buf) != 0) { - ERR("cannot get status of written file"); + ERR("stat() failed"); } aggFileSizeFromStat = stat_buf.st_size; diff --git a/src/ior.c b/src/ior.c index 05a381b..b56edf9 100644 --- a/src/ior.c +++ b/src/ior.c @@ -2433,10 +2433,7 @@ ValidTests(IOR_param_t * test) #endif } } - if (test->useExistingTestFile - && (test->lustre_stripe_count != 0 - || test->lustre_stripe_size != 0 - || test->lustre_start_ost != -1)) + if (test->useExistingTestFile && test->lustre_set_striping) ERR("Lustre stripe options are incompatible with useExistingTestFile"); } /* ValidTests() */ @@ -2452,7 +2449,8 @@ GetOffsetArraySequential(IOR_param_t *test, int pretendRank) /* setup empty array */ offsetArray = (IOR_offset_t *)malloc((offsets+1) * sizeof(IOR_offset_t)); - if (offsetArray == NULL) ERR("out of memory"); + if (offsetArray == NULL) + ERR("malloc() failed"); offsetArray[offsets] = -1; /* set last offset with -1 */ /* fill with offsets */ @@ -2508,7 +2506,8 @@ GetOffsetArrayRandom(IOR_param_t *test, int pretendRank, int access) /* setup empty array */ offsetArray = (IOR_offset_t *)malloc((offsets+1) * sizeof(IOR_offset_t)); - if (offsetArray == NULL) ERR("out of memory"); + if (offsetArray == NULL) + ERR("malloc() failed"); offsetArray[offsets] = -1; /* set last offset with -1 */ if (test->filePerProc) { @@ -2596,10 +2595,12 @@ WriteOrRead(IOR_param_t * test, transfer = test->transferSize; if (access == WRITE) { amtXferred = backend->xfer(access, fd, buffer, transfer, test); - if (amtXferred != transfer) ERR("cannot write to file"); + if (amtXferred != transfer) + ERR("cannot write to file"); } else if (access == READ) { amtXferred = backend->xfer(access, fd, buffer, transfer, test); - if (amtXferred != transfer) ERR("cannot read from file"); + if (amtXferred != transfer) + ERR("cannot read from file"); } else if (access == WRITECHECK) { memset(checkBuffer, 'a', transfer); amtXferred = backend->xfer(access, fd, checkBuffer, transfer, test); diff --git a/src/parse_options.c b/src/parse_options.c index 268b8ce..80f842d 100644 --- a/src/parse_options.c +++ b/src/parse_options.c @@ -284,7 +284,7 @@ ReadConfigScript(char * scriptName) /* open the script */ file = fopen(scriptName, "r"); if (file == NULL) - ERR("cannot open file"); + ERR("fopen() failed"); /* search for the "IOR START" line */ while(fgets(linebuf, MAX_STR, file) != NULL) { @@ -311,7 +311,7 @@ ReadConfigScript(char * scriptName) if (runflag) { newTest = (IOR_queue_t *)malloc(sizeof(IOR_queue_t)); if (newTest == NULL) - ERR("malloc failed"); + ERR("malloc() failed"); newTest->testParameters = tail->testParameters; newTest->testParameters.id = test_num++; tail->nextTest = newTest; @@ -325,7 +325,7 @@ ReadConfigScript(char * scriptName) /* close the script */ if (fclose(file) != 0) - ERR("cannot close script file"); + ERR("fclose() of script file failed"); return(head); } /* ReadConfigScript() */ @@ -421,7 +421,7 @@ ParseCommandLine(int argc, char ** argv) if (tests == NULL) { tests = (IOR_queue_t *) malloc (sizeof(IOR_queue_t)); if (!tests) - ERR("malloc failed"); + ERR("malloc() failed"); tests->testParameters = initialTestParams; tests->nextTest = NULL; }