Log error messages in volser i/o errors
authorAndrew Deason <adeason@sinenomine.net>
Fri, 16 Oct 2009 19:30:34 +0000 (14:30 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Sun, 18 Oct 2009 14:32:19 +0000 (07:32 -0700)
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 <adeason@sinenomine.net>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/volser/Makefile.in
src/volser/dumpstuff.c
src/volser/vol-dump.c
src/volser/vos.c

index 2033ae3..7626054 100644 (file)
@@ -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
index c7d1dc6..7a6c3f6 100644 (file)
@@ -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;
        }
index cb76728..29b9431 100644 (file)
@@ -52,6 +52,7 @@
 #include <afs/afssyscalls.h>
 #include "acl.h"
 #include <afs/dir.h>
+#include <afs/com_err.h>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -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 {
index d5df2e5..105a17e 100644 (file)
@@ -53,6 +53,7 @@
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
 #include <afs/volume.h>
+#include <afs/com_err.h>
 #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);
        }
     }