libafs: update the volume setup time when the vldb is rechecked
[openafs.git] / src / afs / afs_analyze.c
index 34db88f..c0233ef 100644 (file)
@@ -92,7 +92,7 @@ int lastcode;
 static int
 VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct afs_conn *tconn;
     int i, type = 0;
     union {
@@ -110,7 +110,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
     AFS_STATCNT(CheckVLDB);
     afs_FinalizeReq(areq);
 
-    if ((i = afs_InitReq(&treq, afs_osi_credp)))
+    if ((i = afs_CreateReq(&treq, afs_osi_credp)))
        return DUNNO;
     v = afs_osi_Alloc(sizeof(*v));
     osi_Assert(v != NULL);
@@ -120,7 +120,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
        VSleep(2);              /* Better safe than sorry. */
        tconn =
            afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
-                            &treq, SHARED_LOCK, 0, &rxconn);
+                            treq, SHARED_LOCK, 0, &rxconn);
        if (tconn) {
            if ( tconn->parent->srvr->server->flags & SNO_LHOSTS) {
                type = 0;
@@ -158,7 +158,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
            }
        } else
            i = -1;
-    } while (afs_Analyze(tconn, rxconn, i, NULL, &treq, -1,    /* no op code for this */
+    } while (afs_Analyze(tconn, rxconn, i, NULL, treq, -1,     /* no op code for this */
                         SHARED_LOCK, tcell));
 
     afs_PutCell(tcell, READ_LOCK);
@@ -166,6 +166,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
               ICL_TYPE_INT32, i);
 
     if (i) {
+       afs_DestroyReq(treq);
        afs_osi_Free(v, sizeof(*v));
        return DUNNO;
     }
@@ -180,7 +181,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
        ReleaseWriteLock(&tvp->lock);
 
        if (type == 2) {
-           LockAndInstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq);
+           LockAndInstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, treq);
        } else if (type == 1) {
            LockAndInstallNVolumeEntry(tvp, &v->ntve, afid->Cell);
        } else {
@@ -196,20 +197,26 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
            }
        }
 
+       tvp->states &= ~VRecheck;     /* Just checked it. */
+       tvp->setupTime = osi_Time();  /* Time the vldb was checked. */
+
        ReleaseWriteLock(&tvp->lock);
        afs_PutVolume(tvp, WRITE_LOCK);
     } else {                   /* can't find volume */
-       tvp = afs_GetVolume(afid, &treq, WRITE_LOCK);
+       tvp = afs_GetVolume(afid, treq, WRITE_LOCK);
        if (tvp) {
            afs_PutVolume(tvp, WRITE_LOCK);
+           afs_DestroyReq(treq);
            afs_osi_Free(v, sizeof(*v));
            return DIFFERENT;
        } else {
+           afs_DestroyReq(treq);
            afs_osi_Free(v, sizeof(*v));
            return DUNNO;
        }
     }
 
+    afs_DestroyReq(treq);
     afs_osi_Free(v, sizeof(*v));
     return (changed ? DIFFERENT : SAME);
 }                              /*VLDB_Same */
@@ -272,8 +279,8 @@ afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid,
 
 /*!
  * \brief
- *     Analyze the outcome of an RPC operation, taking whatever support
- *     actions are necessary.
+ *     Clear any cached status for the target FID of a failed fileserver
+ *     write RPC.
  *
  * \param[in]     afid   The FID of the file involved in the action.  This argument
  *                       may be null if none was involved.
@@ -356,7 +363,7 @@ afs_PrintServerErrors(struct vrequest *areq, struct VenusFid *afid)
        tvp = afs_FindVolume(afid, READ_LOCK);
        if (tvp) {
            for (i = 0; i < AFS_MAXHOSTS; i++) {
-               if (tvp->serverHost[i]) {
+               if (areq->lasterror[i] && tvp->serverHost[i]) {
                    sa = tvp->serverHost[i]->addr;
                    if (sa) {
                        address = ntohl(sa->sa_ip);
@@ -381,6 +388,7 @@ afs_PrintServerErrors(struct vrequest *areq, struct VenusFid *afid)
  *     actions are necessary.
  *
  * \param[in]     aconn  Ptr to the relevant connection on which the call was made.
+ * \param[in]     rxconn Ptr to the rx_connection.
  * \param[in]     acode  The return code experienced by the RPC.
  * \param[in]     fid    The FID of the file involved in the action.  This argument
  *                       may be null if none was involved.
@@ -617,11 +625,11 @@ afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
     if (acode == -455)
        acode = 455;
 #endif /* AFS_64BIT_CLIENT */
-    if (acode == RX_MSGSIZE || acode == RX_CALL_BUSY) {
+    if (acode == RX_MSGSIZE) {
        shouldRetry = 1;
        goto out;
     }
-    if (acode == RX_CALL_TIMEOUT || acode == RX_CALL_IDLE) {
+    if (acode == RX_CALL_TIMEOUT || acode == VNOSERVICE) {
        serversleft = afs_BlackListOnce(areq, afid, tsp);
        if (afid)
            tvp = afs_FindVolume(afid, READ_LOCK);
@@ -778,7 +786,7 @@ afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
     }
     /* Check for bad volume data base / missing volume. */
     else if (acode == VSALVAGE || acode == VOFFLINE || acode == VNOVOL
-            || acode == VNOSERVICE || acode == VMOVED) {
+            || acode == VMOVED) {
        struct cell *tcell;
        int same;