From: Andrew Deason Date: Fri, 16 Oct 2009 19:30:34 +0000 (-0500) Subject: Log error messages in volser i/o errors X-Git-Tag: openafs-devel-1_5_66~49 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c9dc69afae4c359058f1f524a388f4cd059fdf10;p=packages%2Fo%2Fopenafs.git Log error messages in volser i/o errors Currently, in various places in src/volser/, we log/print an error message when some disk i/o error occurs, but we don't log what error was returned. Log that little bit more info to make debugging easier in some cases. Reviewed-on: http://gerrit.openafs.org/671 Tested-by: Andrew Deason Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/volser/Makefile.in b/src/volser/Makefile.in index 2033ae3b9..762605429 100644 --- a/src/volser/Makefile.in +++ b/src/volser/Makefile.in @@ -50,6 +50,7 @@ VOLDUMP_LIBS = \ ${TOP_LIBDIR}/libcmd.a \ ${TOP_LIBDIR}/util.a \ ${TOP_LIBDIR}/libsys.a \ + ${TOP_LIBDIR}/libcom_err.a \ ${TOP_LIBDIR}/libdir.a \ ${TOP_LIBDIR}/liblwp.a \ ${TOP_LIBDIR}/libacl.a diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index c7d1dc63a..7a6c3f660 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -800,7 +800,7 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP) /* Record the read error */ if (n < 0) { n = 0; - Log("1 Volser: DumpFile: Error %d reading inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode); + Log("1 Volser: DumpFile: Error reading inode %s for vnode %d: %s\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno)); } else if (!pad) { Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode); } @@ -819,7 +819,7 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP) lcode = FDH_SEEK(handleP, (size_t)((size - nbytes) + howMany), SEEK_SET); if (lcode != ((size - nbytes) + howMany)) { if (lcode < 0) { - Log("1 Volser: DumpFile: Error %d seeking in inode %s for vnode %d\n", errno, PrintInode(NULL, handleP->fd_ih->ih_ino), vnode); + Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d: %s\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno)); } else { Log("1 Volser: DumpFile: Error seeking in inode %s for vnode %d\n", PrintInode(NULL, handleP->fd_ih->ih_ino), vnode); lcode = -1; @@ -1468,12 +1468,14 @@ ReadVnodes(register struct iod *iodp, Volume * vp, int incremental, if (haveStuff) { FdHandle_t *fdP = IH_OPEN(vp->vnodeIndex[class].handle); if (fdP == NULL) { - Log("1 Volser: ReadVnodes: Error opening vnode index; restore aborted\n"); + Log("1 Volser: ReadVnodes: Error opening vnode index: %s; restore aborted\n", + afs_error_message(errno)); return VOLSERREAD_DUMPERROR; } if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) < 0) { - Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n"); + Log("1 Volser: ReadVnodes: Error seeking into vnode index: %s; restore aborted\n", + afs_error_message(errno)); FDH_REALLYCLOSE(fdP); return VOLSERREAD_DUMPERROR; } @@ -1487,12 +1489,14 @@ ReadVnodes(register struct iod *iodp, Volume * vp, int incremental, vnode->vnodeMagic = vcp->magic; if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, vnodeNumber), SEEK_SET) < 0) { - Log("1 Volser: ReadVnodes: Error seeking into vnode index; restore aborted\n"); + Log("1 Volser: ReadVnodes: Error seeking into vnode index: %s; restore aborted\n", + afs_error_message(errno)); FDH_REALLYCLOSE(fdP); return VOLSERREAD_DUMPERROR; } if (FDH_WRITE(fdP, vnode, vcp->diskSize) != vcp->diskSize) { - Log("1 Volser: ReadVnodes: Error writing vnode index; restore aborted\n"); + Log("1 Volser: ReadVnodes: Error writing vnode index: %s; restore aborted\n", + afs_error_message(errno)); FDH_REALLYCLOSE(fdP); return VOLSERREAD_DUMPERROR; } @@ -1556,7 +1560,7 @@ volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag, size = nbytes; if ((code = iod_Read(iodp, (char *) p, size)) != size) { - Log("1 Volser: WriteFile: Error reading dump file %d size=%llu nbytes=%u (%d of %u); restore aborted\n", vn, (afs_uintmax_t) filesize, nbytes, code, size); + Log("1 Volser: WriteFile: Error reading dump file %d size=%llu nbytes=%u (%d of %u): %s; restore aborted\n", vn, (afs_uintmax_t) filesize, nbytes, code, size, afs_error_message(errno)); *status = 3; break; } @@ -1564,7 +1568,7 @@ volser_WriteFile(int vn, struct iod *iodp, FdHandle_t * handleP, int tag, if (lcode > 0) written += lcode; if (lcode != size) { - Log("1 Volser: WriteFile: Error writing (%d,%u) bytes to vnode %d; restore aborted\n", (int)(lcode>>32), (int)(lcode & 0xffffffff), vn); + Log("1 Volser: WriteFile: Error writing (%d,%u) bytes to vnode %d: %s; restore aborted\n", (int)(lcode>>32), (int)(lcode & 0xffffffff), vn, afs_error_message(errno)); *status = 4; break; } diff --git a/src/volser/vol-dump.c b/src/volser/vol-dump.c index cb7672890..29b9431e7 100644 --- a/src/volser/vol-dump.c +++ b/src/volser/vol-dump.c @@ -52,6 +52,7 @@ #include #include "acl.h" #include +#include #ifdef HAVE_UNISTD_H #include @@ -855,7 +856,8 @@ DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile, int fromtim dumpfd = afs_open(dumpfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR); if (dumpfd < 0) { - fprintf(stderr, "Failed to open dump file! Exiting.\n"); + fprintf(stderr, "Failed to open dump file: %s. Exiting.\n", + afs_error_message(errno)); exit(1); } } else { diff --git a/src/volser/vos.c b/src/volser/vos.c index d5df2e5c3..105a17e92 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "dump.h" #include "lockdata.h" @@ -298,7 +299,8 @@ SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize) #endif error = USD_READ(ufd, buffer, blksize, &nbytes); if (error) { - fprintf(STDERR, "File system read failed\n"); + fprintf(STDERR, "File system read failed: %s\n", + afs_error_message(error)); break; } if (nbytes == 0) { @@ -342,7 +344,8 @@ WriteData(struct rx_call *call, void *rock) code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize); } if (code) { - fprintf(STDERR, "Could not access file '%s'\n", filename); + fprintf(STDERR, "Could not access file '%s': %s\n", filename, + afs_error_message(code)); error = VOLSERBADOP; goto wfail; } @@ -412,7 +415,8 @@ ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize) error = USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w); if (error) { - fprintf(STDERR, "File system write failed\n"); + fprintf(STDERR, "File system write failed: %s\n", + afs_error_message(error)); ERROR_EXIT(-1); } } @@ -451,7 +455,8 @@ DumpFunction(struct rx_call *call, void *rock) code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize); } if (code) { - fprintf(STDERR, "Could not create file '%s'\n", filename); + fprintf(STDERR, "Could not create file '%s': %s\n", filename, + afs_error_message(code)); ERROR_EXIT(VOLSERBADOP); } }