]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
libafs: log server errors on hard mount retry
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 23 Apr 2012 18:42:24 +0000 (14:42 -0400)
committerDerrick Brashear <shadow@dementix.org>
Fri, 17 Aug 2012 18:17:03 +0000 (11:17 -0700)
Save the last errors seen during a request and log those
errors if a hard-mount retry is done.

Reviewed-on: http://gerrit.openafs.org/7275
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 94a8ce970d57498583e249ea61725fce1ee53a50)

Change-Id: I9aec874fc525c823c095bb3647bd2561854dbab3
Reviewed-on: http://gerrit.openafs.org/8002
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/afs/afs.h
src/afs/afs_analyze.c

index 9f18a1de909f0ef5d660cd671ce72cc148230b18..25b69b6ac19ae62c951346280f8c0680068ae064 100644 (file)
@@ -244,6 +244,7 @@ struct vrequest {
     char tokenError;            /* a token error other than expired. */
     char idleError;             /* the server idled too long */
     char skipserver[AFS_MAXHOSTS];
+    afs_int32 lasterror[AFS_MAXHOSTS];
 };
 #define VOLMISSING 1
 #define VOLBUSY 2
index 80d50efafe426d1459a04a953603e45d2a5a42ad..c4a0cffeadd2bcf5cbb8b0951faf890caf341421 100644 (file)
@@ -333,6 +333,55 @@ afs_ClearStatus(struct VenusFid *afid, int op, struct volume *avp)
     return 0;
 }
 
+/*!
+ * \brief
+ *      Print the last errors from the servers for the volume on
+ *      this request.
+ *
+ * \param[in] areq   The request record associated with this operation.
+ * \param[in] afid   The FID of the file involved in the action.  This argument
+ *                  may be null if none was involved.
+ *
+ * \return
+ *      None
+ *
+ * \note
+ *      This routine is called before a hard-mount retry, to display
+ *      the servers by primary address and the errors encountered.
+ */
+static void
+afs_PrintServerErrors(struct vrequest *areq, struct VenusFid *afid)
+{
+    int i;
+    struct volume *tvp;
+    struct srvAddr *sa;
+    afs_uint32 address;
+    char *sep = " (";
+    char *term = "";
+
+    if (afid) {
+       tvp = afs_FindVolume(afid, READ_LOCK);
+       if (tvp) {
+           for (i = 0; i < AFS_MAXHOSTS; i++) {
+               if (tvp->serverHost[i]) {
+                   sa = tvp->serverHost[i]->addr;
+                   if (sa) {
+                       address = ntohl(sa->sa_ip);
+                       afs_warnuser("%s%d.%d.%d.%d code=%d", sep,
+                                    (address >> 24), (address >> 16) & 0xff,
+                                    (address >> 8) & 0xff, (address) & 0xff,
+                                    areq->lasterror[i]);
+                       sep = ", ";
+                       term = ")";
+                   }
+               }
+           }
+           afs_PutVolume(tvp, READ_LOCK);
+       }
+    }
+    afs_warnuser("%s\n", term);
+}
+
 /*------------------------------------------------------------------------
  * EXPORTED afs_Analyze
  *
@@ -502,8 +551,9 @@ afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
                    if (shouldRetry) {
                        if (warn) {
                            afs_warnuser
-                               ("afs: hard-mount waiting for volume %u\n",
+                               ("afs: hard-mount waiting for volume %u",
                                 afid->Fid.Volume);
+                           afs_PrintServerErrors(areq, afid);
                        }
 
                        VSleep(hm_retry_int);
@@ -567,6 +617,17 @@ afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
        return 0;
     }
 
+    /* Save the last code of this server on this request. */
+    tvp = afs_FindVolume(afid, READ_LOCK);
+    if (tvp) {
+       for (i = 0; i < AFS_MAXHOSTS; i++) {
+           if (tvp->serverHost[i] == tsp) {
+               areq->lasterror[i] = acode;
+           }
+       }
+       afs_PutVolume(tvp, READ_LOCK);
+    }
+
     /* If network troubles, mark server as having bogued out again. */
     /* VRESTARTING is < 0 because of backward compatibility issues
      * with 3.4 file servers and older cache managers */