fc65ca5c2896812cc767fac6e27cf978d711b43f
[openafs.git] / src / afs / afs_analyze.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Implements:
12  */
13 #include <afsconfig.h>
14 #include "afs/param.h"
15
16
17 #include "afs/stds.h"
18 #include "afs/sysincludes.h"    /* Standard vendor system headers */
19
20 #ifndef UKERNEL
21 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
22 #include <net/if.h>
23 #include <netinet/in.h>
24 #endif
25
26 #ifdef AFS_SGI62_ENV
27 #include "h/hashing.h"
28 #endif
29 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN_ENV)
30 #include <netinet/in_var.h>
31 #endif
32 #endif /* !UKERNEL */
33
34 #include "afsincludes.h"        /* Afs-based standard headers */
35 #include "afs/afs_stats.h"      /* afs statistics */
36 #include "afs/afs_util.h"
37 #include "afs/unified_afs.h"
38
39 #if     defined(AFS_SUN5_ENV)
40 #include <inet/led.h>
41 #include <inet/common.h>
42 #include <netinet/ip6.h>
43 #include <inet/ip.h>
44 #endif
45
46 /* shouldn't do it this way, but for now will do */
47 #ifndef ERROR_TABLE_BASE_U
48 #define ERROR_TABLE_BASE_U      (5376L)
49 #endif /* ubik error base define */
50
51 /* shouldn't do it this way, but for now will do */
52 #ifndef ERROR_TABLE_BASE_uae
53 #define ERROR_TABLE_BASE_uae    (49733376L)
54 #endif /* unified afs error base define */
55
56 /* same hack for vlserver error base as for ubik error base */
57 #ifndef ERROR_TABLE_BASE_VL
58 #define ERROR_TABLE_BASE_VL     (363520L)
59 #define VL_NOENT                (363524L)
60 #endif /* vlserver error base define */
61
62
63 int afs_BusyWaitPeriod = 15;    /* poll every 15 seconds */
64
65 afs_int32 hm_retry_RO = 0;      /* don't wait */
66 afs_int32 hm_retry_RW = 0;      /* don't wait */
67 afs_int32 hm_retry_int = 0;     /* don't wait */
68
69 #define VSleep(at)      afs_osi_Wait((at)*1000, 0, 0)
70
71
72 int lastcode;
73 /* returns:
74  * 0   if the vldb record for a specific volume is different from what
75  *     we have cached -- perhaps the volume has moved.
76  * 1   if the vldb record is the same
77  * 2   if we can't tell if it's the same or not.
78  *
79  * If 0, the caller will probably start over at the beginning of our
80  * list of servers for this volume and try to find one that is up.  If
81  * not 0, we will probably just keep plugging with what we have
82  * cached.   If we fail to contact the VL server, we  should just keep
83  * trying with the information we have, rather than failing. */
84 #define DIFFERENT 0
85 #define SAME 1
86 #define DUNNO 2
87 static int
88 VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
89 {
90     struct vrequest treq;
91     struct afs_conn *tconn;
92     int i, type = 0;
93     union {
94         struct vldbentry tve;
95         struct nvldbentry ntve;
96         struct uvldbentry utve;
97     } *v;
98     struct volume *tvp;
99     struct cell *tcell;
100     char *bp, tbuf[CVBS];       /* biggest volume id is 2^32, ~ 4*10^9 */
101     unsigned int changed;
102     struct server *(oldhosts[NMAXNSERVERS]);
103     struct rx_connection *rxconn;
104
105     AFS_STATCNT(CheckVLDB);
106     afs_FinalizeReq(areq);
107
108     if ((i = afs_InitReq(&treq, afs_osi_credp)))
109         return DUNNO;
110     v = afs_osi_Alloc(sizeof(*v));
111     osi_Assert(v != NULL);
112     tcell = afs_GetCell(afid->Cell, READ_LOCK);
113     bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume);
114     do {
115         VSleep(2);              /* Better safe than sorry. */
116         tconn =
117             afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
118                              &treq, SHARED_LOCK, &rxconn);
119         if (tconn) {
120             if ( tconn->parent->srvr->server->flags & SNO_LHOSTS) {
121                 type = 0;
122                 RX_AFS_GUNLOCK();
123                 i = VL_GetEntryByNameO(rxconn, bp, &v->tve);
124                 RX_AFS_GLOCK();
125             } else if (tconn->parent->srvr->server->flags & SYES_LHOSTS) {
126                 type = 1;
127                 RX_AFS_GUNLOCK();
128                 i = VL_GetEntryByNameN(rxconn, bp, &v->ntve);
129                 RX_AFS_GLOCK();
130             } else {
131                 type = 2;
132                 RX_AFS_GUNLOCK();
133                 i = VL_GetEntryByNameU(rxconn, bp, &v->utve);
134                 RX_AFS_GLOCK();
135                 if (!(tconn->parent->srvr->server->flags & SVLSRV_UUID)) {
136                     if (i == RXGEN_OPCODE) {
137                         type = 1;
138                         RX_AFS_GUNLOCK();
139                         i = VL_GetEntryByNameN(rxconn, bp, &v->ntve);
140                         RX_AFS_GLOCK();
141                         if (i == RXGEN_OPCODE) {
142                             type = 0;
143                             tconn->parent->srvr->server->flags |= SNO_LHOSTS;
144                             RX_AFS_GUNLOCK();
145                             i = VL_GetEntryByNameO(rxconn, bp, &v->tve);
146                             RX_AFS_GLOCK();
147                         } else if (!i)
148                             tconn->parent->srvr->server->flags |= SYES_LHOSTS;
149                     } else if (!i)
150                         tconn->parent->srvr->server->flags |= SVLSRV_UUID;
151                 }
152                 lastcode = i;
153             }
154         } else
155             i = -1;
156     } while (afs_Analyze(tconn, rxconn, i, NULL, &treq, -1,     /* no op code for this */
157                          SHARED_LOCK, tcell));
158
159     afs_PutCell(tcell, READ_LOCK);
160     afs_Trace2(afs_iclSetp, CM_TRACE_CHECKVLDB, ICL_TYPE_FID, &afid,
161                ICL_TYPE_INT32, i);
162
163     if (i) {
164         afs_osi_Free(v, sizeof(*v));
165         return DUNNO;
166     }
167     /* have info, copy into serverHost array */
168     changed = 0;
169     tvp = afs_FindVolume(afid, WRITE_LOCK);
170     if (tvp) {
171         ObtainWriteLock(&tvp->lock, 107);
172         for (i = 0; i < NMAXNSERVERS && tvp->serverHost[i]; i++) {
173             oldhosts[i] = tvp->serverHost[i];
174         }
175
176         if (type == 2) {
177             InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq);
178         } else if (type == 1) {
179             InstallNVolumeEntry(tvp, &v->ntve, afid->Cell);
180         } else {
181             InstallVolumeEntry(tvp, &v->tve, afid->Cell);
182         }
183
184         if (i < NMAXNSERVERS && tvp->serverHost[i]) {
185             changed = 1;
186         }
187         for (--i; !changed && i >= 0; i--) {
188             if (tvp->serverHost[i] != oldhosts[i]) {
189                 changed = 1;    /* also happens if prefs change.  big deal. */
190             }
191         }
192
193         ReleaseWriteLock(&tvp->lock);
194         afs_PutVolume(tvp, WRITE_LOCK);
195     } else {                    /* can't find volume */
196         tvp = afs_GetVolume(afid, &treq, WRITE_LOCK);
197         if (tvp) {
198             afs_PutVolume(tvp, WRITE_LOCK);
199             afs_osi_Free(v, sizeof(*v));
200             return DIFFERENT;
201         } else {
202             afs_osi_Free(v, sizeof(*v));
203             return DUNNO;
204         }
205     }
206
207     afs_osi_Free(v, sizeof(*v));
208     return (changed ? DIFFERENT : SAME);
209 }                               /*VLDB_Same */
210
211 /*------------------------------------------------------------------------
212  * afs_BlackListOnce
213  *
214  * Description:
215  *      Mark a server as invalid for further attempts of this request only.
216  *
217  * Arguments:
218  *      areq  : The request record associated with this operation.
219  *      afid  : The FID of the file involved in the action.  This argument
220  *              may be null if none was involved.
221  *      tsp   : pointer to a server struct for the server we wish to
222  *              blacklist.
223  *
224  * Returns:
225  *      Non-zero value if further servers are available to try,
226  *      zero otherwise.
227  *
228  * Environment:
229  *      This routine is typically called in situations where we believe
230  *      one server out of a pool may have an error condition.
231  *
232  * Side Effects:
233  *      As advertised.
234  *
235  * NOTE:
236  *      The afs_Conn* routines use the list of invalidated servers to
237  *      avoid reusing a server marked as invalid for this request.
238  *------------------------------------------------------------------------*/
239 static afs_int32
240 afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid,
241                   struct server *tsp)
242 {
243     struct volume *tvp;
244     afs_int32 i;
245     afs_int32 serversleft = 0;
246
247     if (afid) {
248         tvp = afs_FindVolume(afid, READ_LOCK);
249         if (tvp) {
250             for (i = 0; i < AFS_MAXHOSTS; i++) {
251                 if (tvp->serverHost[i] == tsp) {
252                     areq->skipserver[i] = 1;
253                 }
254                 if (tvp->serverHost[i] &&
255                     (tvp->serverHost[i]->addr->sa_flags &
256                       SRVR_ISDOWN)) {
257                     areq->skipserver[i] = 1;
258                 }
259             }
260             afs_PutVolume(tvp, READ_LOCK);
261             for (i = 0; i < AFS_MAXHOSTS; i++) {
262                 if (tvp->serverHost[i] && areq->skipserver[i] == 0) {
263                     serversleft = 1;
264                     break;
265                 }
266             }
267             return serversleft;
268         }
269     }
270     return serversleft;
271 }
272
273
274 /*------------------------------------------------------------------------
275  * EXPORTED afs_Analyze
276  *
277  * Description:
278  *      Analyze the outcome of an RPC operation, taking whatever support
279  *      actions are necessary.
280  *
281  * Arguments:
282  *      aconn : Ptr to the relevant connection on which the call was made.
283  *      acode : The return code experienced by the RPC.
284  *      afid  : The FID of the file involved in the action.  This argument
285  *              may be null if none was involved.
286  *      areq  : The request record associated with this operation.
287  *      op    : which RPC we are analyzing.
288  *      cellp : pointer to a cell struct.  Must provide either fid or cell.
289  *
290  * Returns:
291  *      Non-zero value if the related RPC operation should be retried,
292  *      zero otherwise.
293  *
294  * Environment:
295  *      This routine is typically called in a do-while loop, causing the
296  *      embedded RPC operation to be called repeatedly if appropriate
297  *      until whatever error condition (if any) is intolerable.
298  *
299  * Side Effects:
300  *      As advertised.
301  *
302  * NOTE:
303  *      The retry return value is used by afs_StoreAllSegments to determine
304  *      if this is a temporary or permanent error.
305  *------------------------------------------------------------------------*/
306 int
307 afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
308             afs_int32 acode, struct VenusFid *afid, struct vrequest *areq,
309             int op, afs_int32 locktype, struct cell *cellp)
310 {
311     afs_int32 i;
312     struct srvAddr *sa;
313     struct server *tsp;
314     struct volume *tvp = NULL;
315     afs_int32 shouldRetry = 0;
316     afs_int32 serversleft = 1;
317     struct afs_stats_RPCErrors *aerrP;
318     afs_uint32 address;
319
320     if (AFS_IS_DISCONNECTED && !AFS_IN_SYNC) {
321         /* On reconnection, act as connected. XXX: for now.... */
322         /* SXW - This may get very tired after a while. We should try and
323          *       intercept all RPCs before they get here ... */
324         /*printf("afs_Analyze: disconnected\n");*/
325         afs_FinalizeReq(areq);
326         if (aconn) {
327             /* SXW - I suspect that this will _never_ happen - we shouldn't
328              *       get a connection because we're disconnected !!!*/
329             afs_PutConn(aconn, rxconn, locktype);
330         }
331         return 0;
332     }
333
334     AFS_STATCNT(afs_Analyze);
335     afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,
336                ICL_TYPE_POINTER, aconn, ICL_TYPE_INT32, acode, ICL_TYPE_LONG,
337                areq->uid);
338
339     aerrP = (struct afs_stats_RPCErrors *)0;
340
341     if ((op >= 0) && (op < AFS_STATS_NUM_FS_RPC_OPS))
342         aerrP = &(afs_stats_cmfullperf.rpc.fsRPCErrors[op]);
343
344     afs_FinalizeReq(areq);
345     if (!aconn && areq->busyCount) {    /* one RPC or more got VBUSY/VRESTARTING */
346
347         tvp = afs_FindVolume(afid, READ_LOCK);
348         if (tvp) {
349             afs_warnuser("afs: Waiting for busy volume %u (%s) in cell %s\n",
350                          (afid ? afid->Fid.Volume : 0),
351                          (tvp->name ? tvp->name : ""),
352                          ((tvp->serverHost[0]
353                            && tvp->serverHost[0]->cell) ? tvp->serverHost[0]->
354                           cell->cellName : ""));
355
356             for (i = 0; i < AFS_MAXHOSTS; i++) {
357                 if (tvp->status[i] != not_busy && tvp->status[i] != offline) {
358                     tvp->status[i] = not_busy;
359                 }
360                 if (tvp->status[i] == not_busy)
361                     shouldRetry = 1;
362             }
363             afs_PutVolume(tvp, READ_LOCK);
364         } else {
365             afs_warnuser("afs: Waiting for busy volume %u\n",
366                          (afid ? afid->Fid.Volume : 0));
367         }
368
369         if (areq->busyCount > 100) {
370             if (aerrP)
371                 (aerrP->err_Volume)++;
372             areq->volumeError = VOLBUSY;
373             shouldRetry = 0;
374         } else {
375             VSleep(afs_BusyWaitPeriod); /* poll periodically */
376         }
377         if (shouldRetry != 0)
378             areq->busyCount++;
379
380         return shouldRetry;     /* should retry */
381     }
382
383     if (!aconn || !aconn->parent->srvr) {
384         if (!areq->volumeError) {
385             if (aerrP)
386                 (aerrP->err_Network)++;
387             if (hm_retry_int && !(areq->flags & O_NONBLOCK) &&  /* "hard" mount */
388                 ((afid && afs_IsPrimaryCellNum(afid->Cell))
389                  || (cellp && afs_IsPrimaryCell(cellp)))) {
390                 if (!afid) {
391                     afs_warnuser
392                         ("afs: hard-mount waiting for a vlserver to return to service\n");
393                     VSleep(hm_retry_int);
394                     afs_CheckServers(1, cellp);
395                     shouldRetry = 1;
396                 } else {
397                     tvp = afs_FindVolume(afid, READ_LOCK);
398                     if (!tvp || (tvp->states & VRO)) {
399                         shouldRetry = hm_retry_RO;
400                     } else {
401                         shouldRetry = hm_retry_RW;
402                     }
403                     if (tvp)
404                         afs_PutVolume(tvp, READ_LOCK);
405                     if (shouldRetry) {
406                         afs_warnuser
407                             ("afs: hard-mount waiting for volume %u\n",
408                              afid->Fid.Volume);
409                         VSleep(hm_retry_int);
410                         afs_CheckServers(1, cellp);
411                     }
412                 }
413             } /* if (hm_retry_int ... */
414             else {
415                 if (acode == RX_MSGSIZE)
416                     shouldRetry = 1;
417                 else
418                     areq->networkError = 1;
419             }
420         }
421         return shouldRetry;
422     }
423
424     /* Find server associated with this connection. */
425     sa = aconn->parent->srvr;
426     tsp = sa->server;
427     address = ntohl(sa->sa_ip);
428
429     /* Before we do anything with acode, make sure we translate it back to
430      * a system error */
431     if ((acode & ~0xff) == ERROR_TABLE_BASE_uae)
432         acode = et_to_sys_error(acode);
433
434     if (acode == 0) {
435         /* If we previously took an error, mark this volume not busy */
436         if (areq->volumeError) {
437             tvp = afs_FindVolume(afid, READ_LOCK);
438             if (tvp) {
439                 for (i = 0; i < AFS_MAXHOSTS; i++) {
440                     if (tvp->serverHost[i] == tsp) {
441                         tvp->status[i] = not_busy;
442                     }
443                 }
444                 afs_PutVolume(tvp, READ_LOCK);
445             }
446         }
447
448         afs_PutConn(aconn, rxconn, locktype);
449         return 0;
450     }
451
452     /* If network troubles, mark server as having bogued out again. */
453     /* VRESTARTING is < 0 because of backward compatibility issues
454      * with 3.4 file servers and older cache managers */
455 #ifdef AFS_64BIT_CLIENT
456     if (acode == -455)
457         acode = 455;
458 #endif /* AFS_64BIT_CLIENT */
459     if ((acode < 0) && (acode != VRESTARTING)) {
460         if (acode == RX_MSGSIZE) {
461             shouldRetry = 1;
462             goto out;
463         }
464         if (acode == RX_CALL_TIMEOUT) {
465             serversleft = afs_BlackListOnce(areq, afid, tsp);
466             if (afid)
467                 tvp = afs_FindVolume(afid, READ_LOCK);
468             if (!afid || !tvp || (tvp->states & VRO))
469                 areq->idleError++;
470             if ((serversleft == 0) && tvp &&
471                 ((tvp->states & VRO) || (tvp->states & VBackup))) {
472                 shouldRetry = 0;
473             } else {
474                 shouldRetry = 1;
475             }
476             if (tvp)
477                 afs_PutVolume(tvp, READ_LOCK);
478             /* By doing this, we avoid ever marking a server down
479              * in an idle timeout case. That's because the server is
480              * still responding and may only be letting a single vnode
481              * time out. We otherwise risk having the server continually
482              * be marked down, then up, then down again...
483              */
484             goto out;
485         }
486         afs_ServerDown(sa);
487         ForceNewConnections(sa); /**multi homed clients lock:afs_xsrvAddr? */
488         if (aerrP)
489             (aerrP->err_Server)++;
490     }
491
492     if (acode == VBUSY || acode == VRESTARTING) {
493         if (acode == VBUSY) {
494             areq->busyCount++;
495             if (aerrP)
496                 (aerrP->err_VolumeBusies)++;
497         } else
498             areq->busyCount = 1;
499
500         tvp = afs_FindVolume(afid, READ_LOCK);
501         if (tvp) {
502             for (i = 0; i < AFS_MAXHOSTS; i++) {
503                 if (tvp->serverHost[i] == tsp) {
504                     tvp->status[i] = rdwr_busy; /* can't tell which yet */
505                     /* to tell which, have to look at the op code. */
506                 }
507             }
508             afs_PutVolume(tvp, READ_LOCK);
509         } else {
510             afs_warnuser("afs: Waiting for busy volume %u in cell %s (server %d.%d.%d.%d)\n",
511                          (afid ? afid->Fid.Volume : 0), tsp->cell->cellName,
512                          (address >> 24), (address >> 16) & 0xff,
513                          (address >> 8) & 0xff, (address) & 0xff);
514             VSleep(afs_BusyWaitPeriod); /* poll periodically */
515         }
516         shouldRetry = 1;
517         acode = 0;
518     } else if (acode == VICETOKENDEAD
519                || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) {
520         /* any rxkad error is treated as token expiration */
521         struct unixuser *tu;
522         /*
523          * I'm calling these errors protection errors, since they involve
524          * faulty authentication.
525          */
526         if (aerrP)
527             (aerrP->err_Protection)++;
528
529         tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK);
530         if (tu) {
531             if (acode == VICETOKENDEAD) {
532                 aconn->forceConnectFS = 1;
533             } else if (acode == RXKADEXPIRED) {
534                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
535                 aconn->parent->user->states |= UTokensBad;
536                 afs_NotifyUser(tu, UTokensDropped);
537                 afs_warnuser
538                     ("afs: Tokens for user of AFS id %d for cell %s have expired (server %d.%d.%d.%d)\n",
539                      tu->viceId, aconn->parent->srvr->server->cell->cellName,
540                      (address >> 24), (address >> 16) & 0xff,
541                      (address >> 8) & 0xff, (address) & 0xff);
542             } else {
543                 serversleft = afs_BlackListOnce(areq, afid, tsp);
544                 areq->tokenError++;
545
546                 if (serversleft) {
547                     afs_warnuser
548                         ("afs: Tokens for user of AFS id %d for cell %s: rxkad error=%d (server %d.%d.%d.%d)\n",
549                          tu->viceId, aconn->parent->srvr->server->cell->cellName, acode,
550                          (address >> 24), (address >> 16) & 0xff,
551                          (address >> 8) & 0xff, (address) & 0xff);
552                     shouldRetry = 1;
553                 } else {
554                     areq->tokenError = 0;
555                     aconn->forceConnectFS = 0;  /* don't check until new tokens set */
556                     aconn->parent->user->states |= UTokensBad;
557                     afs_NotifyUser(tu, UTokensDropped);
558                     afs_warnuser
559                         ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d, server %d.%d.%d.%d)\n",
560                          tu->viceId, aconn->parent->srvr->server->cell->cellName, acode,
561                          (address >> 24), (address >> 16) & 0xff,
562                          (address >> 8) & 0xff, (address) & 0xff);
563                 }
564             }
565             afs_PutUser(tu, READ_LOCK);
566         } else {
567             /* The else case shouldn't be possible and should probably be replaced by a panic? */
568             if (acode == VICETOKENDEAD) {
569                 aconn->forceConnectFS = 1;
570             } else if (acode == RXKADEXPIRED) {
571                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
572                 aconn->parent->user->states |= UTokensBad;
573                 afs_NotifyUser(tu, UTokensDropped);
574                 afs_warnuser
575                     ("afs: Tokens for user %d for cell %s have expired (server %d.%d.%d.%d)\n",
576                      areq->uid, aconn->parent->srvr->server->cell->cellName,
577                      (address >> 24), (address >> 16) & 0xff,
578                      (address >> 8) & 0xff, (address) & 0xff);
579             } else {
580                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
581                 aconn->parent->user->states |= UTokensBad;
582                 afs_NotifyUser(tu, UTokensDropped);
583                 afs_warnuser
584                     ("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d, server %d.%d.%d.%d)\n",
585                      areq->uid, aconn->parent->srvr->server->cell->cellName,
586                      acode,
587                      (address >> 24), (address >> 16) & 0xff,
588                      (address >> 8) & 0xff, (address) & 0xff);
589
590             }
591         }
592         shouldRetry = 1;        /* Try again (as root). */
593     }
594     /* Check for access violation. */
595     else if (acode == EACCES) {
596         /* should mark access error in non-existent per-user global structure */
597         if (aerrP)
598             (aerrP->err_Protection)++;
599         areq->accessError = 1;
600         if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
601             areq->permWriteError = 1;
602         shouldRetry = 0;
603     }
604     /* check for ubik errors; treat them like crashed servers */
605     else if (acode >= ERROR_TABLE_BASE_U && acode < ERROR_TABLE_BASE_U + 255) {
606         afs_ServerDown(sa);
607         if (aerrP)
608             (aerrP->err_Server)++;
609         shouldRetry = 1;        /* retryable (maybe one is working) */
610         VSleep(1);              /* just in case */
611     }
612     /* Check for bad volume data base / missing volume. */
613     else if (acode == VSALVAGE || acode == VOFFLINE || acode == VNOVOL
614              || acode == VNOSERVICE || acode == VMOVED) {
615         struct cell *tcell;
616         int same;
617
618         shouldRetry = 1;
619         areq->volumeError = VOLMISSING;
620         if (aerrP)
621             (aerrP->err_Volume)++;
622         if (afid && (tcell = afs_GetCell(afid->Cell, 0))) {
623             same = VLDB_Same(afid, areq);
624             tvp = afs_FindVolume(afid, READ_LOCK);
625             if (tvp) {
626                 for (i = 0; i < AFS_MAXHOSTS && tvp->serverHost[i]; i++) {
627                     if (tvp->serverHost[i] == tsp) {
628                         if (tvp->status[i] == end_not_busy)
629                             tvp->status[i] = offline;
630                         else
631                             tvp->status[i]++;
632                     } else if (!same) {
633                         tvp->status[i] = not_busy;      /* reset the others */
634                     }
635                 }
636                 afs_PutVolume(tvp, READ_LOCK);
637             }
638         }
639     } else if (acode >= ERROR_TABLE_BASE_VL && acode <= ERROR_TABLE_BASE_VL + 255) {    /* vlserver errors */
640         shouldRetry = 0;
641         areq->volumeError = VOLMISSING;
642     } else if (acode >= 0) {
643         if (aerrP)
644             (aerrP->err_Other)++;
645         if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
646             areq->permWriteError = 1;
647         shouldRetry = 0;        /* Other random Vice error. */
648     } else if (acode == RX_MSGSIZE) {   /* same meaning as EMSGSIZE... */
649         afs_warnuser
650             ("afs: Path MTU may have been exceeded, retrying (server %d.%d.%d.%d)\n",
651              (address >> 24), (address >> 16) & 0xff,
652              (address >> 8) & 0xff, (address) & 0xff);
653
654         VSleep(1);              /* Just a hack for desperate times. */
655         if (aerrP)
656             (aerrP->err_Other)++;
657         shouldRetry = 1;        /* packet was too big, please retry call */
658     }
659
660     if (acode < 0 && acode != RX_MSGSIZE && acode != VRESTARTING) {
661         /* If we get here, code < 0 and we have network/Server troubles.
662          * areq->networkError is not set here, since we always
663          * retry in case there is another server.  However, if we find
664          * no connection (aconn == 0) we set the networkError flag.
665          */
666         afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
667         if (aerrP)
668             (aerrP->err_Server)++;
669         VSleep(1);              /* Just a hack for desperate times. */
670         shouldRetry = 1;
671     }
672 out:
673     /* now unlock the connection and return */
674     afs_PutConn(aconn, rxconn, locktype);
675     return (shouldRetry);
676 }                               /*afs_Analyze */