2 * Copyright 2000, International Business Machines Corporation and others.
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
13 #include <afsconfig.h>
14 #include "afs/param.h"
20 #include "afs/sysincludes.h" /* Standard vendor system headers */
23 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
25 #include <netinet/in.h>
29 #include "h/hashing.h"
31 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN60_ENV)
32 #include <netinet/in_var.h>
36 #include "afsincludes.h" /* Afs-based standard headers */
37 #include "afs/afs_stats.h" /* afs statistics */
38 #include "afs/afs_util.h"
39 #include "afs/unified_afs.h"
41 #if defined(AFS_SUN56_ENV)
43 #include <inet/common.h>
44 #if defined(AFS_SUN58_ENV)
45 #include <netinet/ip6.h>
51 /* shouldn't do it this way, but for now will do */
52 #ifndef ERROR_TABLE_BASE_U
53 #define ERROR_TABLE_BASE_U (5376L)
54 #endif /* ubik error base define */
56 /* shouldn't do it this way, but for now will do */
57 #ifndef ERROR_TABLE_BASE_uae
58 #define ERROR_TABLE_BASE_uae (49733376L)
59 #endif /* unified afs error base define */
61 /* same hack for vlserver error base as for ubik error base */
62 #ifndef ERROR_TABLE_BASE_VL
63 #define ERROR_TABLE_BASE_VL (363520L)
64 #define VL_NOENT (363524L)
65 #endif /* vlserver error base define */
68 int afs_BusyWaitPeriod = 15; /* poll every 15 seconds */
70 afs_int32 hm_retry_RO = 0; /* don't wait */
71 afs_int32 hm_retry_RW = 0; /* don't wait */
72 afs_int32 hm_retry_int = 0; /* don't wait */
74 static int et2sys[512];
77 init_et_to_sys_error(void)
79 memset(&et2sys, 0, sizeof(et2sys));
80 et2sys[(UAEPERM - ERROR_TABLE_BASE_uae)] = EPERM;
81 et2sys[(UAENOENT - ERROR_TABLE_BASE_uae)] = ENOENT;
82 et2sys[(UAESRCH - ERROR_TABLE_BASE_uae)] = ESRCH;
83 et2sys[(UAEINTR - ERROR_TABLE_BASE_uae)] = EINTR;
84 et2sys[(UAEIO - ERROR_TABLE_BASE_uae)] = EIO;
85 et2sys[(UAENXIO - ERROR_TABLE_BASE_uae)] = ENXIO;
86 et2sys[(UAE2BIG - ERROR_TABLE_BASE_uae)] = E2BIG;
87 et2sys[(UAENOEXEC - ERROR_TABLE_BASE_uae)] = ENOEXEC;
88 et2sys[(UAEBADF - ERROR_TABLE_BASE_uae)] = EBADF;
89 et2sys[(UAECHILD - ERROR_TABLE_BASE_uae)] = ECHILD;
90 et2sys[(UAEAGAIN - ERROR_TABLE_BASE_uae)] = EAGAIN;
91 et2sys[(UAENOMEM - ERROR_TABLE_BASE_uae)] = ENOMEM;
92 et2sys[(UAEACCES - ERROR_TABLE_BASE_uae)] = EACCES;
93 et2sys[(UAEFAULT - ERROR_TABLE_BASE_uae)] = EFAULT;
94 et2sys[(UAENOTBLK - ERROR_TABLE_BASE_uae)] = ENOTBLK;
95 et2sys[(UAEBUSY - ERROR_TABLE_BASE_uae)] = EBUSY;
96 et2sys[(UAEEXIST - ERROR_TABLE_BASE_uae)] = EEXIST;
97 et2sys[(UAEXDEV - ERROR_TABLE_BASE_uae)] = EXDEV;
98 et2sys[(UAENODEV - ERROR_TABLE_BASE_uae)] = ENODEV;
99 et2sys[(UAENOTDIR - ERROR_TABLE_BASE_uae)] = ENOTDIR;
100 et2sys[(UAEISDIR - ERROR_TABLE_BASE_uae)] = EISDIR;
101 et2sys[(UAEINVAL - ERROR_TABLE_BASE_uae)] = EINVAL;
102 et2sys[(UAENFILE - ERROR_TABLE_BASE_uae)] = ENFILE;
103 et2sys[(UAEMFILE - ERROR_TABLE_BASE_uae)] = EMFILE;
104 et2sys[(UAENOTTY - ERROR_TABLE_BASE_uae)] = ENOTTY;
105 et2sys[(UAETXTBSY - ERROR_TABLE_BASE_uae)] = ETXTBSY;
106 et2sys[(UAEFBIG - ERROR_TABLE_BASE_uae)] = EFBIG;
107 et2sys[(UAENOSPC - ERROR_TABLE_BASE_uae)] = ENOSPC;
108 et2sys[(UAESPIPE - ERROR_TABLE_BASE_uae)] = ESPIPE;
109 et2sys[(UAEROFS - ERROR_TABLE_BASE_uae)] = EROFS;
110 et2sys[(UAEMLINK - ERROR_TABLE_BASE_uae)] = EMLINK;
111 et2sys[(UAEPIPE - ERROR_TABLE_BASE_uae)] = EPIPE;
112 et2sys[(UAEDOM - ERROR_TABLE_BASE_uae)] = EDOM;
113 et2sys[(UAERANGE - ERROR_TABLE_BASE_uae)] = ERANGE;
114 et2sys[(UAEDEADLK - ERROR_TABLE_BASE_uae)] = EDEADLK;
115 et2sys[(UAENAMETOOLONG - ERROR_TABLE_BASE_uae)] = ENAMETOOLONG;
116 et2sys[(UAENOLCK - ERROR_TABLE_BASE_uae)] = ENOLCK;
117 et2sys[(UAENOSYS - ERROR_TABLE_BASE_uae)] = ENOSYS;
118 et2sys[(UAENOTEMPTY - ERROR_TABLE_BASE_uae)] = ENOTEMPTY;
119 et2sys[(UAELOOP - ERROR_TABLE_BASE_uae)] = ELOOP;
120 et2sys[(UAEWOULDBLOCK - ERROR_TABLE_BASE_uae)] = EWOULDBLOCK;
121 et2sys[(UAENOMSG - ERROR_TABLE_BASE_uae)] = ENOMSG;
122 et2sys[(UAEIDRM - ERROR_TABLE_BASE_uae)] = EIDRM;
123 et2sys[(UAECHRNG - ERROR_TABLE_BASE_uae)] = ECHRNG;
124 et2sys[(UAEL2NSYNC - ERROR_TABLE_BASE_uae)] = EL2NSYNC;
125 et2sys[(UAEL3HLT - ERROR_TABLE_BASE_uae)] = EL3HLT;
126 et2sys[(UAEL3RST - ERROR_TABLE_BASE_uae)] = EL3RST;
127 et2sys[(UAELNRNG - ERROR_TABLE_BASE_uae)] = ELNRNG;
128 et2sys[(UAEUNATCH - ERROR_TABLE_BASE_uae)] = EUNATCH;
129 et2sys[(UAENOCSI - ERROR_TABLE_BASE_uae)] = ENOCSI;
130 et2sys[(UAEL2HLT - ERROR_TABLE_BASE_uae)] = EL2HLT;
131 et2sys[(UAEBADE - ERROR_TABLE_BASE_uae)] = EBADE;
132 et2sys[(UAEBADR - ERROR_TABLE_BASE_uae)] = EBADR;
133 et2sys[(UAEXFULL - ERROR_TABLE_BASE_uae)] = EXFULL;
134 et2sys[(UAENOANO - ERROR_TABLE_BASE_uae)] = ENOANO;
135 et2sys[(UAEBADRQC - ERROR_TABLE_BASE_uae)] = EBADRQC;
136 et2sys[(UAEBADSLT - ERROR_TABLE_BASE_uae)] = EBADSLT;
137 et2sys[(UAEBFONT - ERROR_TABLE_BASE_uae)] = EBFONT;
138 et2sys[(UAENOSTR - ERROR_TABLE_BASE_uae)] = ENOSTR;
139 et2sys[(UAENODATA - ERROR_TABLE_BASE_uae)] = ENODATA;
140 et2sys[(UAETIME - ERROR_TABLE_BASE_uae)] = ETIME;
141 et2sys[(UAENOSR - ERROR_TABLE_BASE_uae)] = ENOSR;
142 et2sys[(UAENONET - ERROR_TABLE_BASE_uae)] = ENONET;
143 et2sys[(UAENOPKG - ERROR_TABLE_BASE_uae)] = ENOPKG;
144 et2sys[(UAEREMOTE - ERROR_TABLE_BASE_uae)] = EREMOTE;
145 et2sys[(UAENOLINK - ERROR_TABLE_BASE_uae)] = ENOLINK;
146 et2sys[(UAEADV - ERROR_TABLE_BASE_uae)] = EADV;
147 et2sys[(UAESRMNT - ERROR_TABLE_BASE_uae)] = ESRMNT;
148 et2sys[(UAECOMM - ERROR_TABLE_BASE_uae)] = ECOMM;
149 et2sys[(UAEPROTO - ERROR_TABLE_BASE_uae)] = EPROTO;
150 et2sys[(UAEMULTIHOP - ERROR_TABLE_BASE_uae)] = EMULTIHOP;
151 et2sys[(UAEDOTDOT - ERROR_TABLE_BASE_uae)] = EDOTDOT;
152 et2sys[(UAEBADMSG - ERROR_TABLE_BASE_uae)] = EBADMSG;
153 et2sys[(UAEOVERFLOW - ERROR_TABLE_BASE_uae)] = EOVERFLOW;
154 et2sys[(UAENOTUNIQ - ERROR_TABLE_BASE_uae)] = ENOTUNIQ;
155 et2sys[(UAEBADFD - ERROR_TABLE_BASE_uae)] = EBADFD;
156 et2sys[(UAEREMCHG - ERROR_TABLE_BASE_uae)] = EREMCHG;
157 et2sys[(UAELIBACC - ERROR_TABLE_BASE_uae)] = ELIBACC;
158 et2sys[(UAELIBBAD - ERROR_TABLE_BASE_uae)] = ELIBBAD;
159 et2sys[(UAELIBSCN - ERROR_TABLE_BASE_uae)] = ELIBSCN;
160 et2sys[(UAELIBMAX - ERROR_TABLE_BASE_uae)] = ELIBMAX;
161 et2sys[(UAELIBEXEC - ERROR_TABLE_BASE_uae)] = ELIBEXEC;
162 et2sys[(UAEILSEQ - ERROR_TABLE_BASE_uae)] = EILSEQ;
163 et2sys[(UAERESTART - ERROR_TABLE_BASE_uae)] = ERESTART;
164 et2sys[(UAESTRPIPE - ERROR_TABLE_BASE_uae)] = ESTRPIPE;
165 et2sys[(UAEUSERS - ERROR_TABLE_BASE_uae)] = EUSERS;
166 et2sys[(UAENOTSOCK - ERROR_TABLE_BASE_uae)] = ENOTSOCK;
167 et2sys[(UAEDESTADDRREQ - ERROR_TABLE_BASE_uae)] = EDESTADDRREQ;
168 et2sys[(UAEMSGSIZE - ERROR_TABLE_BASE_uae)] = EMSGSIZE;
169 et2sys[(UAEPROTOTYPE - ERROR_TABLE_BASE_uae)] = EPROTOTYPE;
170 et2sys[(UAENOPROTOOPT - ERROR_TABLE_BASE_uae)] = ENOPROTOOPT;
171 et2sys[(UAEPROTONOSUPPORT - ERROR_TABLE_BASE_uae)] = EPROTONOSUPPORT;
172 et2sys[(UAESOCKTNOSUPPORT - ERROR_TABLE_BASE_uae)] = ESOCKTNOSUPPORT;
173 et2sys[(UAEOPNOTSUPP - ERROR_TABLE_BASE_uae)] = EOPNOTSUPP;
174 et2sys[(UAEPFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EPFNOSUPPORT;
175 et2sys[(UAEAFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EAFNOSUPPORT;
176 et2sys[(UAEADDRINUSE - ERROR_TABLE_BASE_uae)] = EADDRINUSE;
177 et2sys[(UAEADDRNOTAVAIL - ERROR_TABLE_BASE_uae)] = EADDRNOTAVAIL;
178 et2sys[(UAENETDOWN - ERROR_TABLE_BASE_uae)] = ENETDOWN;
179 et2sys[(UAENETUNREACH - ERROR_TABLE_BASE_uae)] = ENETUNREACH;
180 et2sys[(UAENETRESET - ERROR_TABLE_BASE_uae)] = ENETRESET;
181 et2sys[(UAECONNABORTED - ERROR_TABLE_BASE_uae)] = ECONNABORTED;
182 et2sys[(UAECONNRESET - ERROR_TABLE_BASE_uae)] = ECONNRESET;
183 et2sys[(UAENOBUFS - ERROR_TABLE_BASE_uae)] = ENOBUFS;
184 et2sys[(UAEISCONN - ERROR_TABLE_BASE_uae)] = EISCONN;
185 et2sys[(UAENOTCONN - ERROR_TABLE_BASE_uae)] = ENOTCONN;
186 et2sys[(UAESHUTDOWN - ERROR_TABLE_BASE_uae)] = ESHUTDOWN;
187 et2sys[(UAETOOMANYREFS - ERROR_TABLE_BASE_uae)] = ETOOMANYREFS;
188 et2sys[(UAETIMEDOUT - ERROR_TABLE_BASE_uae)] = ETIMEDOUT;
189 et2sys[(UAECONNREFUSED - ERROR_TABLE_BASE_uae)] = ECONNREFUSED;
190 et2sys[(UAEHOSTDOWN - ERROR_TABLE_BASE_uae)] = EHOSTDOWN;
191 et2sys[(UAEHOSTUNREACH - ERROR_TABLE_BASE_uae)] = EHOSTUNREACH;
192 et2sys[(UAEALREADY - ERROR_TABLE_BASE_uae)] = EALREADY;
193 et2sys[(UAEINPROGRESS - ERROR_TABLE_BASE_uae)] = EINPROGRESS;
194 et2sys[(UAESTALE - ERROR_TABLE_BASE_uae)] = ESTALE;
195 et2sys[(UAEUCLEAN - ERROR_TABLE_BASE_uae)] = EUCLEAN;
196 et2sys[(UAENOTNAM - ERROR_TABLE_BASE_uae)] = ENOTNAM;
197 et2sys[(UAENAVAIL - ERROR_TABLE_BASE_uae)] = ENAVAIL;
198 et2sys[(UAEISNAM - ERROR_TABLE_BASE_uae)] = EISNAM;
199 et2sys[(UAEREMOTEIO - ERROR_TABLE_BASE_uae)] = EREMOTEIO;
200 et2sys[(UAEDQUOT - ERROR_TABLE_BASE_uae)] = EDQUOT;
201 et2sys[(UAENOMEDIUM - ERROR_TABLE_BASE_uae)] = ENOMEDIUM;
202 et2sys[(UAEMEDIUMTYPE - ERROR_TABLE_BASE_uae)] = EMEDIUMTYPE;
206 et_to_sys_error(afs_int32 in)
208 if (in < ERROR_TABLE_BASE_uae || in >= ERROR_TABLE_BASE_uae + 512)
210 if (et2sys[in - ERROR_TABLE_BASE_uae] != 0)
211 return et2sys[in - ERROR_TABLE_BASE_uae];
216 afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato)
218 AFS_STATCNT(afs_CopyError);
221 afs_FinalizeReq(ato);
222 if (afrom->accessError)
223 ato->accessError = 1;
224 if (afrom->volumeError)
225 ato->volumeError = 1;
226 if (afrom->networkError)
227 ato->networkError = 1;
228 if (afrom->permWriteError)
229 ato->permWriteError = 1;
234 afs_FinalizeReq(register struct vrequest *areq)
236 AFS_STATCNT(afs_FinalizeReq);
240 areq->accessError = 0;
241 areq->volumeError = 0;
242 areq->networkError = 0;
243 areq->permWriteError = 0;
249 afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where)
251 AFS_STATCNT(afs_CheckCode);
253 afs_Trace2(afs_iclSetp, CM_TRACE_CHECKCODE, ICL_TYPE_INT32, acode,
254 ICL_TYPE_INT32, where);
256 if ((acode & ~0xff) == ERROR_TABLE_BASE_uae)
257 acode = et_to_sys_error(acode);
258 if (!areq || !areq->initd)
260 if (areq->networkError)
264 if (areq->accessError)
266 if (areq->volumeError == VOLMISSING)
268 if (areq->volumeError == VOLBUSY)
270 if (acode == VNOVNODE)
272 if (acode == VDISKFULL)
274 if (acode == VOVERQUOTA)
288 #define VSleep(at) afs_osi_Wait((at)*1000, 0, 0)
293 * 0 if the vldb record for a specific volume is different from what
294 * we have cached -- perhaps the volume has moved.
295 * 1 if the vldb record is the same
296 * 2 if we can't tell if it's the same or not.
298 * If 0, the caller will probably start over at the beginning of our
299 * list of servers for this volume and try to find one that is up. If
300 * not 0, we will probably just keep plugging with what we have
301 * cached. If we fail to contact the VL server, we should just keep
302 * trying with the information we have, rather than failing. */
307 VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
309 struct vrequest treq;
313 struct vldbentry tve;
314 struct nvldbentry ntve;
315 struct uvldbentry utve;
319 char *bp, tbuf[CVBS]; /* biggest volume id is 2^32, ~ 4*10^9 */
320 unsigned int changed;
321 struct server *(oldhosts[NMAXNSERVERS]);
323 AFS_STATCNT(CheckVLDB);
324 afs_FinalizeReq(areq);
326 if ((i = afs_InitReq(&treq, &afs_osi_cred)))
328 v = afs_osi_Alloc(sizeof(*v));
329 tcell = afs_GetCell(afid->Cell, READ_LOCK);
330 bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume);
332 VSleep(2); /* Better safe than sorry. */
334 afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
337 if (tconn->srvr->server->flags & SNO_LHOSTS) {
340 i = VL_GetEntryByNameO(tconn->id, bp, &v->tve);
342 } else if (tconn->srvr->server->flags & SYES_LHOSTS) {
345 i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve);
350 i = VL_GetEntryByNameU(tconn->id, bp, &v->utve);
352 if (!(tconn->srvr->server->flags & SVLSRV_UUID)) {
353 if (i == RXGEN_OPCODE) {
356 i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve);
358 if (i == RXGEN_OPCODE) {
360 tconn->srvr->server->flags |= SNO_LHOSTS;
362 i = VL_GetEntryByNameO(tconn->id, bp, &v->tve);
365 tconn->srvr->server->flags |= SYES_LHOSTS;
367 tconn->srvr->server->flags |= SVLSRV_UUID;
373 } while (afs_Analyze(tconn, i, NULL, &treq, -1, /* no op code for this */
374 SHARED_LOCK, tcell));
376 afs_PutCell(tcell, READ_LOCK);
377 afs_Trace2(afs_iclSetp, CM_TRACE_CHECKVLDB, ICL_TYPE_FID, &afid,
381 afs_osi_Free(v, sizeof(*v));
384 /* have info, copy into serverHost array */
386 tvp = afs_FindVolume(afid, WRITE_LOCK);
388 ObtainWriteLock(&tvp->lock, 107);
389 for (i = 0; i < NMAXNSERVERS && tvp->serverHost[i]; i++) {
390 oldhosts[i] = tvp->serverHost[i];
394 InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq);
395 } else if (type == 1) {
396 InstallNVolumeEntry(tvp, &v->ntve, afid->Cell);
398 InstallVolumeEntry(tvp, &v->tve, afid->Cell);
401 if (i < NMAXNSERVERS && tvp->serverHost[i]) {
404 for (--i; !changed && i >= 0; i--) {
405 if (tvp->serverHost[i] != oldhosts[i]) {
406 changed = 1; /* also happens if prefs change. big deal. */
410 ReleaseWriteLock(&tvp->lock);
411 afs_PutVolume(tvp, WRITE_LOCK);
412 } else { /* can't find volume */
413 tvp = afs_GetVolume(afid, &treq, WRITE_LOCK);
415 afs_PutVolume(tvp, WRITE_LOCK);
416 afs_osi_Free(v, sizeof(*v));
419 afs_osi_Free(v, sizeof(*v));
424 afs_osi_Free(v, sizeof(*v));
425 return (changed ? DIFFERENT : SAME);
429 /*------------------------------------------------------------------------
430 * EXPORTED afs_Analyze
433 * Analyze the outcome of an RPC operation, taking whatever support
434 * actions are necessary.
437 * aconn : Ptr to the relevant connection on which the call was made.
438 * acode : The return code experienced by the RPC.
439 * afid : The FID of the file involved in the action. This argument
440 * may be null if none was involved.
441 * areq : The request record associated with this operation.
442 * op : which RPC we are analyzing.
443 * cellp : pointer to a cell struct. Must provide either fid or cell.
446 * Non-zero value if the related RPC operation should be retried,
450 * This routine is typically called in a do-while loop, causing the
451 * embedded RPC operation to be called repeatedly if appropriate
452 * until whatever error condition (if any) is intolerable.
458 * The retry return value is used by afs_StoreAllSegments to determine
459 * if this is a temporary or permanent error.
460 *------------------------------------------------------------------------*/
462 afs_Analyze(register struct conn *aconn, afs_int32 acode,
463 struct VenusFid *afid, register struct vrequest *areq, int op,
464 afs_int32 locktype, struct cell *cellp)
470 afs_int32 shouldRetry = 0;
471 struct afs_stats_RPCErrors *aerrP;
473 AFS_STATCNT(afs_Analyze);
474 afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,
475 ICL_TYPE_POINTER, aconn, ICL_TYPE_INT32, acode, ICL_TYPE_LONG,
478 aerrP = (struct afs_stats_RPCErrors *)0;
480 if ((op >= 0) && (op < AFS_STATS_NUM_FS_RPC_OPS))
481 aerrP = &(afs_stats_cmfullperf.rpc.fsRPCErrors[op]);
483 afs_FinalizeReq(areq);
484 if (!aconn && areq->busyCount) { /* one RPC or more got VBUSY/VRESTARTING */
486 tvp = afs_FindVolume(afid, READ_LOCK);
488 afs_warnuser("afs: Waiting for busy volume %u (%s) in cell %s\n",
489 (afid ? afid->Fid.Volume : 0),
490 (tvp->name ? tvp->name : ""),
492 && tvp->serverHost[0]->cell) ? tvp->serverHost[0]->
493 cell->cellName : ""));
495 for (i = 0; i < MAXHOSTS; i++) {
496 if (tvp->status[i] != not_busy && tvp->status[i] != offline) {
497 tvp->status[i] = not_busy;
499 if (tvp->status[i] == not_busy)
502 afs_PutVolume(tvp, READ_LOCK);
504 afs_warnuser("afs: Waiting for busy volume %u\n",
505 (afid ? afid->Fid.Volume : 0));
508 if (areq->busyCount > 100) {
510 (aerrP->err_Volume)++;
511 areq->volumeError = VOLBUSY;
514 VSleep(afs_BusyWaitPeriod); /* poll periodically */
516 if (shouldRetry != 0)
519 return shouldRetry; /* should retry */
523 if (!areq->volumeError) {
525 (aerrP->err_Network)++;
526 if (hm_retry_int && !(areq->flags & O_NONBLOCK) && /* "hard" mount */
527 ((afid && afs_IsPrimaryCellNum(afid->Cell))
528 || (cellp && afs_IsPrimaryCell(cellp)))) {
531 ("afs: hard-mount waiting for a vlserver to return to service\n");
532 VSleep(hm_retry_int);
533 afs_CheckServers(1, cellp);
536 tvp = afs_FindVolume(afid, READ_LOCK);
537 if (!tvp || (tvp->states & VRO)) {
538 shouldRetry = hm_retry_RO;
540 shouldRetry = hm_retry_RW;
543 afs_PutVolume(tvp, READ_LOCK);
546 ("afs: hard-mount waiting for volume %u\n",
548 VSleep(hm_retry_int);
549 afs_CheckServers(1, cellp);
552 } /* if (hm_retry_int ... */
554 areq->networkError = 1;
560 /* Find server associated with this connection. */
564 /* Before we do anything with acode, make sure we translate it back to
566 if ((acode & ~0xff) == ERROR_TABLE_BASE_uae)
567 acode = et_to_sys_error(acode);
570 /* If we previously took an error, mark this volume not busy */
571 if (areq->volumeError) {
572 tvp = afs_FindVolume(afid, READ_LOCK);
574 for (i = 0; i < MAXHOSTS; i++) {
575 if (tvp->serverHost[i] == tsp) {
576 tvp->status[i] = not_busy;
579 afs_PutVolume(tvp, READ_LOCK);
583 afs_PutConn(aconn, locktype);
587 /* If network troubles, mark server as having bogued out again. */
588 /* VRESTARTING is < 0 because of backward compatibility issues
589 * with 3.4 file servers and older cache managers */
590 #ifdef AFS_64BIT_CLIENT
593 #endif /* AFS_64BIT_CLIENT */
594 if ((acode < 0) && (acode != VRESTARTING)) {
596 ForceNewConnections(sa); /*multi homed clients lock:afs_xsrvAddr? */
598 (aerrP->err_Server)++;
601 if (acode == VBUSY || acode == VRESTARTING) {
602 if (acode == VBUSY) {
605 (aerrP->err_VolumeBusies)++;
609 tvp = afs_FindVolume(afid, READ_LOCK);
611 for (i = 0; i < MAXHOSTS; i++) {
612 if (tvp->serverHost[i] == tsp) {
613 tvp->status[i] = rdwr_busy; /* can't tell which yet */
614 /* to tell which, have to look at the op code. */
617 afs_PutVolume(tvp, READ_LOCK);
619 afs_warnuser("afs: Waiting for busy volume %u in cell %s\n",
620 (afid ? afid->Fid.Volume : 0), tsp->cell->cellName);
621 VSleep(afs_BusyWaitPeriod); /* poll periodically */
625 } else if (acode == VICETOKENDEAD
626 || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) {
627 /* any rxkad error is treated as token expiration */
631 * I'm calling these errors protection errors, since they involve
632 * faulty authentication.
635 (aerrP->err_Protection)++;
637 tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK);
639 if ((acode == VICETOKENDEAD) || (acode == RXKADEXPIRED))
641 ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
642 tu->vid, aconn->srvr->server->cell->cellName);
645 ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
646 tu->vid, aconn->srvr->server->cell->cellName, acode);
647 afs_PutUser(tu, READ_LOCK);
649 /* The else case shouldn't be possible and should probably be replaced by a panic? */
650 if ((acode == VICETOKENDEAD) || (acode == RXKADEXPIRED))
652 ("afs: Tokens for user %d for cell %s have expired\n",
653 areq->uid, aconn->srvr->server->cell->cellName);
656 ("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d)\n",
657 areq->uid, aconn->srvr->server->cell->cellName, acode);
659 aconn->forceConnectFS = 0; /* don't check until new tokens set */
660 aconn->user->states |= UTokensBad;
661 shouldRetry = 1; /* Try again (as root). */
663 /* Check for access violation. */
664 else if (acode == EACCES) {
665 /* should mark access error in non-existent per-user global structure */
667 (aerrP->err_Protection)++;
668 areq->accessError = 1;
669 if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
670 areq->permWriteError = 1;
673 /* check for ubik errors; treat them like crashed servers */
674 else if (acode >= ERROR_TABLE_BASE_U && acode < ERROR_TABLE_BASE_U + 255) {
677 (aerrP->err_Server)++;
678 shouldRetry = 1; /* retryable (maybe one is working) */
679 VSleep(1); /* just in case */
681 /* Check for bad volume data base / missing volume. */
682 else if (acode == VSALVAGE || acode == VOFFLINE || acode == VNOVOL
683 || acode == VNOSERVICE || acode == VMOVED) {
688 areq->volumeError = VOLMISSING;
690 (aerrP->err_Volume)++;
691 if (afid && (tcell = afs_GetCell(afid->Cell, 0))) {
692 same = VLDB_Same(afid, areq);
693 tvp = afs_FindVolume(afid, READ_LOCK);
695 for (i = 0; i < MAXHOSTS && tvp->serverHost[i]; i++) {
696 if (tvp->serverHost[i] == tsp) {
697 if (tvp->status[i] == end_not_busy)
698 tvp->status[i] = offline;
702 tvp->status[i] = not_busy; /* reset the others */
705 afs_PutVolume(tvp, READ_LOCK);
708 } else if (acode >= ERROR_TABLE_BASE_VL && acode <= ERROR_TABLE_BASE_VL + 255) { /* vlserver errors */
710 areq->volumeError = VOLMISSING;
711 } else if (acode >= 0) {
713 (aerrP->err_Other)++;
714 if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
715 areq->permWriteError = 1;
716 shouldRetry = 0; /* Other random Vice error. */
717 } else if (acode == RX_MSGSIZE) { /* same meaning as EMSGSIZE... */
718 VSleep(1); /* Just a hack for desperate times. */
720 (aerrP->err_Other)++;
721 shouldRetry = 1; /* packet was too big, please retry call */
724 if (acode < 0 && acode != RX_MSGSIZE && acode != VRESTARTING) {
725 /* If we get here, code < 0 and we have network/Server troubles.
726 * areq->networkError is not set here, since we always
727 * retry in case there is another server. However, if we find
728 * no connection (aconn == 0) we set the networkError flag.
730 afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
732 (aerrP->err_Server)++;
733 VSleep(1); /* Just a hack for desperate times. */
737 /* now unlock the connection and return */
738 afs_PutConn(aconn, locktype);
739 return (shouldRetry);