Added some extra debug including ERRF, WARNF, and MPI_CHECKF format string macros.

master
Josh Schwartz 2019-08-30 15:11:25 -06:00
parent 0d9f46e980
commit 0bd979637e
4 changed files with 85 additions and 52 deletions

View File

@ -178,8 +178,8 @@ static void *MPIIO_Open(char *testFileName, IOR_param_t * param)
fprintf(stdout, "}\n");
}
if(! param->dryRun){
MPI_CHECK(MPI_File_open(comm, testFileName, fd_mode, mpiHints, fd),
"cannot open file");
MPI_CHECKF(MPI_File_open(comm, testFileName, fd_mode, mpiHints, fd),
"cannot open file: %s", testFileName);
}
/* show hints actually attached to file handle */
@ -428,8 +428,8 @@ void MPIIO_Delete(char *testFileName, IOR_param_t * param)
{
if(param->dryRun)
return;
MPI_CHECK(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
"cannot delete file");
MPI_CHECKF(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
"cannot delete file: %s", testFileName);
}
/*
@ -504,9 +504,9 @@ IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
comm = testComm;
}
MPI_CHECK(MPI_File_open(comm, testFileName, MPI_MODE_RDONLY,
MPI_INFO_NULL, &fd),
"cannot open file to get file size");
MPI_CHECKF(MPI_File_open(comm, testFileName, MPI_MODE_RDONLY,
MPI_INFO_NULL, &fd),
"cannot open file to get file size: %s", testFileName);
MPI_CHECK(MPI_File_get_size(fd, (MPI_Offset *) & aggFileSizeFromStat),
"cannot get file size");
MPI_CHECK(MPI_File_close(&fd), "cannot close file");

View File

@ -146,7 +146,7 @@ void gpfs_free_all_locks(int fd)
rc = gpfs_fcntl(fd, &release_all);
if (verbose >= VERBOSE_0 && rc != 0) {
EWARN("gpfs_fcntl release all locks hint failed.");
EWARNF("gpfs_fcntl(%d, ...) release all locks hint failed.", fd);
}
}
void gpfs_access_start(int fd, IOR_offset_t length, IOR_param_t *param, int access)
@ -169,7 +169,7 @@ void gpfs_access_start(int fd, IOR_offset_t length, IOR_param_t *param, int acce
rc = gpfs_fcntl(fd, &take_locks);
if (verbose >= VERBOSE_2 && rc != 0) {
EWARN("gpfs_fcntl access range hint failed.");
EWARNF("gpfs_fcntl(fd, ...) access range hint failed.", fd);
}
}
@ -193,7 +193,7 @@ void gpfs_access_end(int fd, IOR_offset_t length, IOR_param_t *param, int access
rc = gpfs_fcntl(fd, &free_locks);
if (verbose >= VERBOSE_2 && rc != 0) {
EWARN("gpfs_fcntl free range hint failed.");
EWARNF("gpfs_fcntl(fd, ...) free range hint failed.", fd);
}
}
@ -260,14 +260,14 @@ bool beegfs_createFilePath(char* filepath, mode_t mode, int numTargets, int chun
char* dir = dirname(dirTmp);
DIR* parentDirS = opendir(dir);
if (!parentDirS) {
ERR("Failed to get directory");
ERRF("Failed to get directory: %s", dir);
}
else
{
int parentDirFd = dirfd(parentDirS);
if (parentDirFd < 0)
{
ERR("Failed to get directory descriptor");
ERRF("Failed to get directory descriptor: %s", dir);
}
else
{
@ -319,6 +319,7 @@ bool beegfs_createFilePath(char* filepath, mode_t mode, int numTargets, int chun
void *POSIX_Create(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
int mode = 0664;
int *fd;
fd = (int *)malloc(sizeof(int));
@ -346,9 +347,10 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param)
if (!param->filePerProc && rank != 0) {
MPI_CHECK(MPI_Barrier(testComm), "barrier error");
fd_oflag |= O_RDWR;
*fd = open64(testFileName, fd_oflag, 0664);
*fd = open64(testFileName, fd_oflag, mode);
if (*fd < 0)
ERR("open64() failed");
ERRF("open64(\"%s\", %d, %#o) failed",
testFileName, fd_oflag, mode);
} else {
struct lov_user_md opts = { 0 };
@ -363,7 +365,7 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param)
fd_oflag |=
O_CREAT | O_EXCL | O_RDWR | O_LOV_DELAY_CREATE;
*fd = open64(testFileName, fd_oflag, 0664);
*fd = open64(testFileName, fd_oflag, mode);
if (*fd < 0) {
fprintf(stdout, "\nUnable to open '%s': %s\n",
testFileName, strerror(errno));
@ -392,7 +394,7 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param)
if (beegfs_isOptionSet(param->beegfs_chunkSize)
|| beegfs_isOptionSet(param->beegfs_numTargets)) {
bool result = beegfs_createFilePath(testFileName,
0664,
mode,
param->beegfs_numTargets,
param->beegfs_chunkSize);
if (result) {
@ -403,9 +405,10 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param)
}
#endif /* HAVE_BEEGFS_BEEGFS_H */
*fd = open64(testFileName, fd_oflag, 0664);
*fd = open64(testFileName, fd_oflag, mode);
if (*fd < 0)
ERR("open64() failed");
ERRF("open64(\"%s\", %d, %#o) failed",
testFileName, fd_oflag, mode);
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
}
@ -413,7 +416,7 @@ void *POSIX_Create(char *testFileName, IOR_param_t * param)
if (param->lustre_ignore_locks) {
int lustre_ioctl_flags = LL_FILE_IGNORE_LOCK;
if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1)
ERR("ioctl(LL_IOC_SETFLAGS) failed");
ERRF("ioctl(%d, LL_IOC_SETFLAGS, ...) failed", *fd);
}
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
@ -469,7 +472,7 @@ void *POSIX_Open(char *testFileName, IOR_param_t * param)
*fd = open64(testFileName, fd_oflag);
if (*fd < 0)
ERR("open64 failed");
ERRF("open64(\"%s\", %d) failed", testFileName, fd_oflag);
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
if (param->lustre_ignore_locks) {
@ -479,7 +482,7 @@ void *POSIX_Open(char *testFileName, IOR_param_t * param)
"** Disabling lustre range locking **\n");
}
if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1)
ERR("ioctl(LL_IOC_SETFLAGS) failed");
ERRF("ioctl(%d, LL_IOC_SETFLAGS, ...) failed", *fd);
}
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
@ -517,7 +520,7 @@ static IOR_offset_t POSIX_Xfer(int access, void *file, IOR_size_t * buffer,
/* seek to offset */
if (lseek64(fd, param->offset, SEEK_SET) == -1)
ERR("lseek64() failed");
ERRF("lseek64(%d, %lld, SEEK_SET) failed", fd, param->offset);
while (remaining > 0) {
/* write/read file */
@ -530,7 +533,8 @@ static IOR_offset_t POSIX_Xfer(int access, void *file, IOR_size_t * buffer,
}
rc = write(fd, ptr, remaining);
if (rc == -1)
ERR("write() failed");
ERRF("write(%d, %p, %lld) failed",
fd, (void*)ptr, remaining);
if (param->fsyncPerWrite == TRUE)
POSIX_Fsync(&fd, param);
} else { /* READ or CHECK */
@ -542,9 +546,11 @@ static IOR_offset_t POSIX_Xfer(int access, void *file, IOR_size_t * buffer,
}
rc = read(fd, ptr, remaining);
if (rc == 0)
ERR("read() returned EOF prematurely");
ERRF("read(%d, %p, %lld) returned EOF prematurely",
fd, (void*)ptr, remaining);
if (rc == -1)
ERR("read() failed");
ERRF("read(%d, %p, %lld) failed",
fd, (void*)ptr, remaining);
}
if (rc < remaining) {
fprintf(stdout,
@ -579,7 +585,7 @@ static IOR_offset_t POSIX_Xfer(int access, void *file, IOR_size_t * buffer,
static void POSIX_Fsync(void *fd, IOR_param_t * param)
{
if (fsync(*(int *)fd) != 0)
EWARN("fsync() failed");
EWARNF("fsync(%d) failed", *(int *)fd);
}
/*
@ -590,7 +596,7 @@ void POSIX_Close(void *fd, IOR_param_t * param)
if(param->dryRun)
return;
if (close(*(int *)fd) != 0)
ERR("close() failed");
ERRF("close(%d) failed", *(int *)fd);
free(fd);
}
@ -602,10 +608,8 @@ void POSIX_Delete(char *testFileName, IOR_param_t * param)
if(param->dryRun)
return;
if (unlink(testFileName) != 0){
char errmsg[256];
sprintf(errmsg, "[RANK %03d]: unlink() of file \"%s\" failed\n",
rank, testFileName);
EWARN(errmsg);
EWARNF("[RANK %03d]: unlink() of file \"%s\" failed\n",
rank, testFileName);
}
}
@ -621,7 +625,7 @@ IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
if (stat(testFileName, &stat_buf) != 0) {
ERR("stat() failed");
ERRF("stat(\"%s\", ...) failed", testFileName);
}
aggFileSizeFromStat = stat_buf.st_size;

View File

@ -822,14 +822,14 @@ static char *PrependDir(IOR_param_t * test, char *rootDir)
/* dir doesn't exist, so create */
if (backend->access(dir, F_OK, test) != 0) {
if (backend->mkdir(dir, S_IRWXU, test) < 0) {
ERR("cannot create directory");
ERRF("cannot create directory: %s", dir);
}
/* check if correct permissions */
} else if (backend->access(dir, R_OK, test) != 0 ||
backend->access(dir, W_OK, test) != 0 ||
backend->access(dir, X_OK, test) != 0) {
ERR("invalid directory permissions");
ERRF("invalid directory permissions: %s", dir);
}
/* concatenate dir and file names */
@ -900,6 +900,10 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
GetTestFileName(testFileName, test);
}
if (backend->access(testFileName, F_OK, test) == 0) {
if (verbose >= VERBOSE_3) {
fprintf(out_logfile, "task %d removing %s\n", rank,
testFileName);
}
backend->delete(testFileName, test);
}
if (test->reorderTasksRandom == TRUE) {
@ -908,6 +912,10 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
}
} else {
if ((rank == 0) && (backend->access(testFileName, F_OK, test) == 0)) {
if (verbose >= VERBOSE_3) {
fprintf(out_logfile, "task %d removing %s\n", rank,
testFileName);
}
backend->delete(testFileName, test);
}
}
@ -1667,11 +1675,8 @@ static void ValidateTests(IOR_param_t * test)
#if (H5_VERS_MAJOR > 0 && H5_VERS_MINOR > 5)
;
#else
char errorString[MAX_STR];
sprintf(errorString,
"'no fill' option not available in %s",
ERRF("'no fill' option not available in %s",
test->apiVersion);
ERR(errorString);
#endif
#else
WARN("unable to determine HDF5 version for 'no fill' usage");

View File

@ -151,28 +151,41 @@ typedef long long int IOR_size_t;
fflush(stdout); \
} while (0)
/* warning with errno printed */
#define EWARN(MSG) do { \
/* warning with format string and errno printed */
#define EWARNF(FORMAT, ...) do { \
if (verbose > VERBOSE_2) { \
fprintf(stdout, "ior WARNING: %s, errno %d, %s (%s:%d).\n", \
MSG, errno, strerror(errno), __FILE__, __LINE__); \
fprintf(stdout, "ior WARNING: " FORMAT ", errno %d, %s (%s:%d).\n", \
__VA_ARGS__, errno, strerror(errno), __FILE__, __LINE__); \
} else { \
fprintf(stdout, "ior WARNING: %s, errno %d, %s \n", \
MSG, errno, strerror(errno)); \
fprintf(stdout, "ior WARNING: " FORMAT ", errno %d, %s \n", \
__VA_ARGS__, errno, strerror(errno)); \
} \
fflush(stdout); \
} while (0)
/* display error message and terminate execution */
#define ERR(MSG) do { \
fprintf(stdout, "ior ERROR: %s, errno %d, %s (%s:%d)\n", \
MSG, errno, strerror(errno), __FILE__, __LINE__); \
/* warning with errno printed */
#define EWARN(MSG) do { \
EWARNF("%s", MSG); \
} while (0)
/* display error message with format string and terminate execution */
#define ERRF(FORMAT, ...) do { \
fprintf(stdout, "ior ERROR: " FORMAT ", errno %d, %s (%s:%d)\n", \
__VA_ARGS__, errno, strerror(errno), __FILE__, __LINE__); \
fflush(stdout); \
MPI_Abort(MPI_COMM_WORLD, -1); \
} while (0)
/* display error message and terminate execution */
#define ERR(MSG) do { \
ERRF("%s", MSG); \
} while (0)
/* display a simple error message (i.e. errno is not set) and terminate execution */
#define ERR_SIMPLE(MSG) do { \
fprintf(stdout, "ior ERROR: %s, (%s:%d)\n", \
@ -184,24 +197,35 @@ typedef long long int IOR_size_t;
/******************************************************************************/
/*
* MPI_CHECK will display a custom error message as well as an error string
* MPI_CHECKF will display a custom format string as well as an error string
* from the MPI_STATUS and then exit the program
*/
#define MPI_CHECK(MPI_STATUS, MSG) do { \
#define MPI_CHECKF(MPI_STATUS, FORMAT, ...) do { \
char resultString[MPI_MAX_ERROR_STRING]; \
int resultLength; \
\
if (MPI_STATUS != MPI_SUCCESS) { \
MPI_Error_string(MPI_STATUS, resultString, &resultLength); \
fprintf(stdout, "ior ERROR: %s, MPI %s, (%s:%d)\n", \
MSG, resultString, __FILE__, __LINE__); \
fprintf(stdout, "ior ERROR: " FORMAT ", MPI %s, (%s:%d)\n", \
__VA_ARGS__, resultString, __FILE__, __LINE__); \
fflush(stdout); \
MPI_Abort(MPI_COMM_WORLD, -1); \
} \
} while(0)
/******************************************************************************/
/*
* MPI_CHECK will display a custom error message as well as an error string
* from the MPI_STATUS and then exit the program
*/
#define MPI_CHECK(MPI_STATUS, MSG) do { \
MPI_CHECKF(MPI_STATUS, "%s", MSG); \
} while(0)
/******************************************************************************/
/*
* System info for Windows.