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