From 852ee3e40e8e32abf354cc68738e5e3f9e43ae23 Mon Sep 17 00:00:00 2001 From: "Julian M. Kunkel" Date: Thu, 21 Jan 2021 11:06:13 +0000 Subject: [PATCH] AIORI POSIX use internal debug macros, include errno in msg. --- src/aiori-POSIX.c | 40 +++++++++++++++------------------------- src/aiori-debug.h | 12 ++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index 8beaa09..fc99c61 100755 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -378,9 +378,10 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param) MPI_CHECK(MPI_Barrier(testComm), "barrier error"); fd_oflag |= O_RDWR; *fd = open64(testFileName, fd_oflag, mode); - if (*fd < 0) - ERRF("open64(\"%s\", %d, %#o) failed", - testFileName, fd_oflag, mode); + if (*fd < 0){ + ERRF("open64(\"%s\", %d, %#o) failed. Error: %s", + testFileName, fd_oflag, mode, strerror(errno)); + } } else { struct lov_user_md opts = { 0 }; @@ -396,19 +397,14 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param) fd_oflag |= O_CREAT | O_EXCL | O_RDWR | O_LOV_DELAY_CREATE; *fd = open64(testFileName, fd_oflag, mode); if (*fd < 0) { - fprintf(stdout, "\nUnable to open '%s': %s\n", + ERRF("Unable to open '%s': %s\n", testFileName, strerror(errno)); - MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), - "MPI_Abort() error"); } else if (ioctl(*fd, LL_IOC_LOV_SETSTRIPE, &opts)) { char *errmsg = "stripe already set"; if (errno != EEXIST && errno != EALREADY) errmsg = strerror(errno); - fprintf(stdout, - "\nError on ioctl for '%s' (%d): %s\n", + ERRF("Error on ioctl for '%s' (%d): %s\n", testFileName, *fd, errmsg); - MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), - "MPI_Abort() error"); } if (!hints->filePerProc) MPI_CHECK(MPI_Barrier(testComm), @@ -435,9 +431,10 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param) #endif /* HAVE_BEEGFS_BEEGFS_H */ *fd = open64(testFileName, fd_oflag, mode); - if (*fd < 0) - ERRF("open64(\"%s\", %d, %#o) failed", - testFileName, fd_oflag, mode); + if (*fd < 0){ + ERRF("open64(\"%s\", %d, %#o) failed. Error: %s", + testFileName, fd_oflag, mode, strerror(errno)); + } #ifdef HAVE_LUSTRE_USER } @@ -503,8 +500,7 @@ aiori_fd_t *POSIX_Open(char *testFileName, int flags, aiori_mod_opt_t * param) if (o->lustre_ignore_locks) { int lustre_ioctl_flags = LL_FILE_IGNORE_LOCK; if (verbose >= VERBOSE_1) { - fprintf(stdout, - "** Disabling lustre range locking **\n"); + EINFO("** Disabling lustre range locking **\n"); } if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1) ERRF("ioctl(%d, LL_IOC_SETFLAGS, ...) failed", *fd); @@ -552,8 +548,7 @@ static IOR_offset_t POSIX_Xfer(int access, aiori_fd_t *file, IOR_size_t * buffer /* write/read file */ if (access == WRITE) { /* WRITE */ if (verbose >= VERBOSE_4) { - fprintf(stdout, - "task %d writing to offset %lld\n", + EINFO("task %d writing to offset %lld\n", rank, offset + length - remaining); } @@ -566,8 +561,7 @@ static IOR_offset_t POSIX_Xfer(int access, aiori_fd_t *file, IOR_size_t * buffer } } else { /* READ or CHECK */ if (verbose >= VERBOSE_4) { - fprintf(stdout, - "task %d reading from offset %lld\n", + EINFO("task %d reading from offset %lld\n", rank, offset + length - remaining); } @@ -580,16 +574,12 @@ static IOR_offset_t POSIX_Xfer(int access, aiori_fd_t *file, IOR_size_t * buffer fd, (void*)ptr, remaining); } if (rc < remaining) { - fprintf(stdout, - "WARNING: Task %d, partial %s, %lld of %lld bytes at offset %lld\n", + EWARNF("task %d, partial %s, %lld of %lld bytes at offset %lld\n", rank, access == WRITE ? "write()" : "read()", rc, remaining, offset + length - remaining); - if (hints->singleXferAttempt == TRUE) - MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), - "barrier error"); - if (xferRetries > MAX_RETRY) + if (xferRetries > MAX_RETRY || hints->singleXferAttempt) ERR("too many retries -- aborting"); } assert(rc >= 0); diff --git a/src/aiori-debug.h b/src/aiori-debug.h index bb5dd71..32db28f 100644 --- a/src/aiori-debug.h +++ b/src/aiori-debug.h @@ -61,6 +61,18 @@ extern int aiori_warning_as_errors; } while (0) +/* warning with format string and errno printed */ +#define EINFO(FORMAT, ...) do { \ + if (verbose > VERBOSE_2) { \ + fprintf(out_logfile, "INFO: " FORMAT ", (%s:%d).\n", \ + __VA_ARGS__, __FILE__, __LINE__); \ + } else { \ + fprintf(out_logfile, "INFO: " FORMAT "\n", \ + __VA_ARGS__); \ + } \ + fflush(out_logfile); \ +} while (0) + /* display error message with format string and terminate execution */ #define ERRF(FORMAT, ...) do { \ fprintf(out_logfile, "ERROR: " FORMAT ", (%s:%d)\n", \