Bug Summary

File:afs/afs_analyze.c
Location:line 598, column 7
Description:Value stored to 'shouldRetry' is never read

Annotated Source Code

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_ENV1)
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_ENV1) && !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(5376L)
48#define ERROR_TABLE_BASE_U(5376L) (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(49733376L)
53#define ERROR_TABLE_BASE_uae(49733376L) (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(363520L)
58#define ERROR_TABLE_BASE_VL(363520L) (363520L)
59#define VL_NOENT(363524L) (363524L)
60#endif /* vlserver error base define */
61
62
63int afs_BusyWaitPeriod = 15; /* poll every 15 seconds */
64
65afs_int32 hm_retry_RO = 0; /* don't wait */
66afs_int32 hm_retry_RW = 0; /* don't wait */
67afs_int32 hm_retry_int = 0; /* don't wait */
68
69#define VSleep(at)afs_osi_Wait((at)*1000, 0, 0) afs_osi_Wait((at)*1000, 0, 0)
70
71
72int 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 DIFFERENT0 0
85#define SAME1 1
86#define DUNNO2 2
87static int
88VLDB_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[CVBS12]; /* biggest volume id is 2^32, ~ 4*10^9 */
101 unsigned int changed;
102 struct server *(oldhosts[NMAXNSERVERS13]);
103 struct rx_connection *rxconn;
104
105 AFS_STATCNT(CheckVLDB)((afs_cmstats.callInfo.C_CheckVLDB)++);
106 afs_FinalizeReq(areq);
107
108 if ((i = afs_InitReq(&treq, afs_osi_credp)))
109 return DUNNO2;
110 v = afs_osi_Alloc(sizeof(*v));
111 osi_Assert(v != NULL)(void)((v != ((void *)0)) || (osi_AssertFailK( "v != NULL" , "/home/wollman/openafs/src/afs/afs_analyze.c"
, 111), 0))
;
112 tcell = afs_GetCell(afid->Cell, READ_LOCK1);
113 bp = afs_cv2string(&tbuf[CVBS12], afid->Fid.Volume);
114 do {
115 VSleep(2)afs_osi_Wait((2)*1000, 0, 0); /* Better safe than sorry. */
116 tconn =
117 afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
118 &treq, SHARED_LOCK4, &rxconn);
119 if (tconn) {
120 if ( tconn->parent->srvr->server->flags & SNO_LHOSTS0x04) {
121 type = 0;
122 RX_AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/afs_analyze.c", 122); } while
(0)
;
123 i = VL_GetEntryByNameO(rxconn, bp, &v->tve);
124 RX_AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/afs_analyze.c"
, 124); (void)0; } while (0)
;
125 } else if (tconn->parent->srvr->server->flags & SYES_LHOSTS0x08) {
126 type = 1;
127 RX_AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/afs_analyze.c", 127); } while
(0)
;
128 i = VL_GetEntryByNameN(rxconn, bp, &v->ntve);
129 RX_AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/afs_analyze.c"
, 129); (void)0; } while (0)
;
130 } else {
131 type = 2;
132 RX_AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/afs_analyze.c", 132); } while
(0)
;
133 i = VL_GetEntryByNameU(rxconn, bp, &v->utve);
134 RX_AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/afs_analyze.c"
, 134); (void)0; } while (0)
;
135 if (!(tconn->parent->srvr->server->flags & SVLSRV_UUID0x10)) {
136 if (i == RXGEN_OPCODE-455) {
137 type = 1;
138 RX_AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/afs_analyze.c", 138); } while
(0)
;
139 i = VL_GetEntryByNameN(rxconn, bp, &v->ntve);
140 RX_AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/afs_analyze.c"
, 140); (void)0; } while (0)
;
141 if (i == RXGEN_OPCODE-455) {
142 type = 0;
143 tconn->parent->srvr->server->flags |= SNO_LHOSTS0x04;
144 RX_AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/afs_analyze.c", 144); } while
(0)
;
145 i = VL_GetEntryByNameO(rxconn, bp, &v->tve);
146 RX_AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/afs_analyze.c"
, 146); (void)0; } while (0)
;
147 } else if (!i)
148 tconn->parent->srvr->server->flags |= SYES_LHOSTS0x08;
149 } else if (!i)
150 tconn->parent->srvr->server->flags |= SVLSRV_UUID0x10;
151 }
152 lastcode = i;
153 }
154 } else
155 i = -1;
156 } while (afs_Analyze(tconn, rxconn, i, NULL((void *)0), &treq, -1, /* no op code for this */
157 SHARED_LOCK4, tcell));
158
159 afs_PutCell(tcell, READ_LOCK);
160 afs_Trace2(afs_iclSetp, CM_TRACE_CHECKVLDB, ICL_TYPE_FID, &afid,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ?
afs_icl_Event2(afs_iclSetp, (701087811L), (1<<24)+((5)
<<18)+((7)<<12), (long)(&afid), (long)(i)) : 0
)
161 ICL_TYPE_INT32, i)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ?
afs_icl_Event2(afs_iclSetp, (701087811L), (1<<24)+((5)
<<18)+((7)<<12), (long)(&afid), (long)(i)) : 0
)
;
162
163 if (i) {
164 afs_osi_Free(v, sizeof(*v));
165 return DUNNO2;
166 }
167 /* have info, copy into serverHost array */
168 changed = 0;
169 tvp = afs_FindVolume(afid, WRITE_LOCK2);
170 if (tvp) {
171 ObtainWriteLock(&tvp->lock, 107)do { ; if (!(&tvp->lock)->excl_locked && !(
&tvp->lock)->readers_reading) (&tvp->lock) ->
excl_locked = 2; else Afs_Lock_Obtain(&tvp->lock, 2);
(&tvp->lock)->pid_writer = (((__curthread())->td_proc
)->p_pid ); (&tvp->lock)->src_indicator = 107; }
while (0)
;
172 for (i = 0; i < NMAXNSERVERS13 && 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 < NMAXNSERVERS13 && 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)do { ; (&tvp->lock)->excl_locked &= ~2; if ((&
tvp->lock)->wait_states) Afs_Lock_ReleaseR(&tvp->
lock); (&tvp->lock)->pid_writer=0; } while (0)
;
194 afs_PutVolume(tvp, WRITE_LOCK)((tvp)->refCount--);
195 } else { /* can't find volume */
196 tvp = afs_GetVolume(afid, &treq, WRITE_LOCK2);
197 if (tvp) {
198 afs_PutVolume(tvp, WRITE_LOCK)((tvp)->refCount--);
199 afs_osi_Free(v, sizeof(*v));
200 return DIFFERENT0;
201 } else {
202 afs_osi_Free(v, sizeof(*v));
203 return DUNNO2;
204 }
205 }
206
207 afs_osi_Free(v, sizeof(*v));
208 return (changed ? DIFFERENT0 : SAME1);
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 *------------------------------------------------------------------------*/
239static afs_int32
240afs_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_LOCK1);
249 if (tvp) {
250 for (i = 0; i < AFS_MAXHOSTS13; 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_ISDOWN0x20)) {
257 areq->skipserver[i] = 1;
258 }
259 }
260 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
261 for (i = 0; i < AFS_MAXHOSTS13; 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 *------------------------------------------------------------------------*/
306int
307afs_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((void *)0);
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_is_disconnected) && !AFS_IN_SYNC(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)((afs_cmstats.callInfo.C_afs_Analyze)++);
335 afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ?
afs_icl_Event4(afs_iclSetp, (701087813L), (1<<24)+((7)
<<18)+((2)<<12)+((7)<<6)+(1), (long)(op), (
long)(aconn), (long)(acode), (long)(areq->uid)) : 0)
336 ICL_TYPE_POINTER, aconn, ICL_TYPE_INT32, acode, ICL_TYPE_LONG,(((afs_iclSetp) && (afs_iclSetp->states & 2)) ?
afs_icl_Event4(afs_iclSetp, (701087813L), (1<<24)+((7)
<<18)+((2)<<12)+((7)<<6)+(1), (long)(op), (
long)(aconn), (long)(acode), (long)(areq->uid)) : 0)
337 areq->uid)(((afs_iclSetp) && (afs_iclSetp->states & 2)) ?
afs_icl_Event4(afs_iclSetp, (701087813L), (1<<24)+((7)
<<18)+((2)<<12)+((7)<<6)+(1), (long)(op), (
long)(aconn), (long)(acode), (long)(areq->uid)) : 0)
;
338
339 aerrP = (struct afs_stats_RPCErrors *)0;
340
341 if ((op >= 0) && (op < AFS_STATS_NUM_FS_RPC_OPS29))
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_LOCK1);
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_MAXHOSTS13; 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)((tvp)->refCount--);
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 = VOLBUSY2;
373 shouldRetry = 0;
374 } else {
375 VSleep(afs_BusyWaitPeriod)afs_osi_Wait((afs_BusyWaitPeriod)*1000, 0, 0); /* 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_NONBLOCK0x0004) && /* "hard" mount */
388 ((afid && afs_IsPrimaryCellNum(afid->Cell))
389 || (cellp && afs_IsPrimaryCell(cellp)))) {
390 if (!afid) {
391 static int afs_vl_hm = 0;
392 int warn = 0;
393 if (!afs_vl_hm) {
394 afs_vl_hm = warn = 1;
395 }
396 if (warn) {
397 afs_warnuser
398 ("afs: hard-mount waiting for a vlserver to return to service\n");
399 }
400 VSleep(hm_retry_int)afs_osi_Wait((hm_retry_int)*1000, 0, 0);
401 afs_CheckServers(1, cellp);
402 shouldRetry = 1;
403
404 if (warn) {
405 afs_vl_hm = 0;
406 }
407 } else {
408 static int afs_unknown_vhm = 0;
409 int warn = 0, vp_vhm = 0;
410
411 tvp = afs_FindVolume(afid, READ_LOCK1);
412 if (!tvp || (tvp->states & VRO1)) {
413 shouldRetry = hm_retry_RO;
414 } else {
415 shouldRetry = hm_retry_RW;
416 }
417
418 /* Set 'warn' if we should afs_warnuser. Only let one
419 * caller call afs_warnuser per hm_retry_int interval per
420 * volume. */
421 if (shouldRetry) {
422 if (tvp) {
423 if (!(tvp->states & VHardMount32)) {
424 tvp->states |= VHardMount32;
425 warn = vp_vhm = 1;
426 }
427 } else {
428 if (!afs_unknown_vhm) {
429 afs_unknown_vhm = 1;
430 warn = 1;
431 }
432 }
433 }
434
435 if (tvp)
436 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
437
438 if (shouldRetry) {
439 if (warn) {
440 afs_warnuser
441 ("afs: hard-mount waiting for volume %u\n",
442 afid->Fid.Volume);
443 }
444
445 VSleep(hm_retry_int)afs_osi_Wait((hm_retry_int)*1000, 0, 0);
446 afs_CheckServers(1, cellp);
447
448 if (vp_vhm) {
449 tvp = afs_FindVolume(afid, READ_LOCK1);
450 if (tvp) {
451 tvp->states &= ~VHardMount32;
452 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
453 }
454 } else if (warn) {
455 afs_unknown_vhm = 0;
456 }
457 }
458 }
459 } /* if (hm_retry_int ... */
460 else {
461 if (acode == RX_MSGSIZE(-8))
462 shouldRetry = 1;
463 else
464 areq->networkError = 1;
465 }
466 }
467 return shouldRetry;
468 }
469
470 /* Find server associated with this connection. */
471 sa = aconn->parent->srvr;
472 tsp = sa->server;
473 address = ntohl(sa->sa_ip)(__builtin_constant_p(sa->sa_ip) ? ((((__uint32_t)(sa->
sa_ip)) >> 24) | ((((__uint32_t)(sa->sa_ip)) & (
0xff << 16)) >> 8) | ((((__uint32_t)(sa->sa_ip
)) & (0xff << 8)) << 8) | (((__uint32_t)(sa->
sa_ip)) << 24)) : __bswap32_var(sa->sa_ip))
;
474
475 /* Before we do anything with acode, make sure we translate it back to
476 * a system error */
477 if ((acode & ~0xff) == ERROR_TABLE_BASE_uae(49733376L))
478 acode = et_to_sys_error(acode);
479
480 if (acode == 0) {
481 /* If we previously took an error, mark this volume not busy */
482 if (areq->volumeError) {
483 tvp = afs_FindVolume(afid, READ_LOCK1);
484 if (tvp) {
485 for (i = 0; i < AFS_MAXHOSTS13; i++) {
486 if (tvp->serverHost[i] == tsp) {
487 tvp->status[i] = not_busy;
488 }
489 }
490 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
491 }
492 }
493
494 afs_PutConn(aconn, rxconn, locktype);
495 return 0;
496 }
497
498 /* If network troubles, mark server as having bogued out again. */
499 /* VRESTARTING is < 0 because of backward compatibility issues
500 * with 3.4 file servers and older cache managers */
501#ifdef AFS_64BIT_CLIENT1
502 if (acode == -455)
503 acode = 455;
504#endif /* AFS_64BIT_CLIENT */
505 if ((acode < 0) && (acode != VRESTARTING-100)) {
506 if (acode == RX_MSGSIZE(-8)) {
507 shouldRetry = 1;
508 goto out;
509 }
510 if (acode == RX_CALL_TIMEOUT(-3)) {
511 serversleft = afs_BlackListOnce(areq, afid, tsp);
512 if (afid)
513 tvp = afs_FindVolume(afid, READ_LOCK1);
514 if (!afid || !tvp || (tvp->states & VRO1))
515 areq->idleError++;
516 if ((serversleft == 0) && tvp &&
517 ((tvp->states & VRO1) || (tvp->states & VBackup4))) {
518 shouldRetry = 0;
519 } else {
520 shouldRetry = 1;
521 }
522 if (tvp)
523 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
524 /* By doing this, we avoid ever marking a server down
525 * in an idle timeout case. That's because the server is
526 * still responding and may only be letting a single vnode
527 * time out. We otherwise risk having the server continually
528 * be marked down, then up, then down again...
529 */
530 goto out;
531 }
532 afs_ServerDown(sa);
533 ForceNewConnections(sa); /**multi homed clients lock:afs_xsrvAddr? */
534 if (aerrP)
535 (aerrP->err_Server)++;
536 }
537
538 if (acode == VBUSY110 || acode == VRESTARTING-100) {
539 if (acode == VBUSY110) {
540 areq->busyCount++;
541 if (aerrP)
542 (aerrP->err_VolumeBusies)++;
543 } else
544 areq->busyCount = 1;
545
546 tvp = afs_FindVolume(afid, READ_LOCK1);
547 if (tvp) {
548 for (i = 0; i < AFS_MAXHOSTS13; i++) {
549 if (tvp->serverHost[i] == tsp) {
550 tvp->status[i] = rdwr_busy; /* can't tell which yet */
551 /* to tell which, have to look at the op code. */
552 }
553 }
554 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
555 } else {
556 afs_warnuser("afs: Waiting for busy volume %u in cell %s (server %d.%d.%d.%d)\n",
557 (afid ? afid->Fid.Volume : 0), tsp->cell->cellName,
558 (address >> 24), (address >> 16) & 0xff,
559 (address >> 8) & 0xff, (address) & 0xff);
560 VSleep(afs_BusyWaitPeriod)afs_osi_Wait((afs_BusyWaitPeriod)*1000, 0, 0); /* poll periodically */
561 }
562 shouldRetry = 1;
563 acode = 0;
564 } else if (acode == VICETOKENDEAD1235
565 || (acode & ~0xff) == ERROR_TABLE_BASE_RXK(19270400L)) {
566 /* any rxkad error is treated as token expiration */
567 struct unixuser *tu;
568 /*
569 * I'm calling these errors protection errors, since they involve
570 * faulty authentication.
571 */
572 if (aerrP)
573 (aerrP->err_Protection)++;
574
575 tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK1);
576 if (tu) {
577 if (acode == VICETOKENDEAD1235) {
578 aconn->forceConnectFS = 1;
579 } else if (acode == RXKADEXPIRED(19270409L)) {
580 aconn->forceConnectFS = 0; /* don't check until new tokens set */
581 aconn->parent->user->states |= UTokensBad2;
582 afs_NotifyUser(tu, UTokensDropped2);
583 afs_warnuser
584 ("afs: Tokens for user of AFS id %d for cell %s have expired (server %d.%d.%d.%d)\n",
585 tu->viceId, aconn->parent->srvr->server->cell->cellName,
586 (address >> 24), (address >> 16) & 0xff,
587 (address >> 8) & 0xff, (address) & 0xff);
588 } else {
589 serversleft = afs_BlackListOnce(areq, afid, tsp);
590 areq->tokenError++;
591
592 if (serversleft) {
593 afs_warnuser
594 ("afs: Tokens for user of AFS id %d for cell %s: rxkad error=%d (server %d.%d.%d.%d)\n",
595 tu->viceId, aconn->parent->srvr->server->cell->cellName, acode,
596 (address >> 24), (address >> 16) & 0xff,
597 (address >> 8) & 0xff, (address) & 0xff);
598 shouldRetry = 1;
Value stored to 'shouldRetry' is never read
599 } else {
600 areq->tokenError = 0;
601 aconn->forceConnectFS = 0; /* don't check until new tokens set */
602 aconn->parent->user->states |= UTokensBad2;
603 afs_NotifyUser(tu, UTokensDropped2);
604 afs_warnuser
605 ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d, server %d.%d.%d.%d)\n",
606 tu->viceId, aconn->parent->srvr->server->cell->cellName, acode,
607 (address >> 24), (address >> 16) & 0xff,
608 (address >> 8) & 0xff, (address) & 0xff);
609 }
610 }
611 afs_PutUser(tu, READ_LOCK1);
612 } else {
613 /* The else case shouldn't be possible and should probably be replaced by a panic? */
614 if (acode == VICETOKENDEAD1235) {
615 aconn->forceConnectFS = 1;
616 } else if (acode == RXKADEXPIRED(19270409L)) {
617 aconn->forceConnectFS = 0; /* don't check until new tokens set */
618 aconn->parent->user->states |= UTokensBad2;
619 afs_NotifyUser(tu, UTokensDropped2);
620 afs_warnuser
621 ("afs: Tokens for user %d for cell %s have expired (server %d.%d.%d.%d)\n",
622 areq->uid, aconn->parent->srvr->server->cell->cellName,
623 (address >> 24), (address >> 16) & 0xff,
624 (address >> 8) & 0xff, (address) & 0xff);
625 } else {
626 aconn->forceConnectFS = 0; /* don't check until new tokens set */
627 aconn->parent->user->states |= UTokensBad2;
628 afs_NotifyUser(tu, UTokensDropped2);
629 afs_warnuser
630 ("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d, server %d.%d.%d.%d)\n",
631 areq->uid, aconn->parent->srvr->server->cell->cellName,
632 acode,
633 (address >> 24), (address >> 16) & 0xff,
634 (address >> 8) & 0xff, (address) & 0xff);
635
636 }
637 }
638 shouldRetry = 1; /* Try again (as root). */
639 }
640 /* Check for access violation. */
641 else if (acode == EACCES13) {
642 /* should mark access error in non-existent per-user global structure */
643 if (aerrP)
644 (aerrP->err_Protection)++;
645 areq->accessError = 1;
646 if (op == AFS_STATS_FS_RPCIDX_STOREDATA3)
647 areq->permWriteError = 1;
648 shouldRetry = 0;
649 }
650 /* check for ubik errors; treat them like crashed servers */
651 else if (acode >= ERROR_TABLE_BASE_U(5376L) && acode < ERROR_TABLE_BASE_U(5376L) + 255) {
652 afs_ServerDown(sa);
653 if (aerrP)
654 (aerrP->err_Server)++;
655 shouldRetry = 1; /* retryable (maybe one is working) */
656 VSleep(1)afs_osi_Wait((1)*1000, 0, 0); /* just in case */
657 }
658 /* Check for bad volume data base / missing volume. */
659 else if (acode == VSALVAGE101 || acode == VOFFLINE106 || acode == VNOVOL103
660 || acode == VNOSERVICE105 || acode == VMOVED111) {
661 struct cell *tcell;
662 int same;
663
664 shouldRetry = 1;
665 areq->volumeError = VOLMISSING1;
666 if (aerrP)
667 (aerrP->err_Volume)++;
668 if (afid && (tcell = afs_GetCell(afid->Cell, 0))) {
669 same = VLDB_Same(afid, areq);
670 tvp = afs_FindVolume(afid, READ_LOCK1);
671 if (tvp) {
672 for (i = 0; i < AFS_MAXHOSTS13 && tvp->serverHost[i]; i++) {
673 if (tvp->serverHost[i] == tsp) {
674 if (tvp->status[i] == end_not_busy)
675 tvp->status[i] = offline;
676 else
677 tvp->status[i]++;
678 } else if (!same) {
679 tvp->status[i] = not_busy; /* reset the others */
680 }
681 }
682 afs_PutVolume(tvp, READ_LOCK)((tvp)->refCount--);
683 }
684 }
685 } else if (acode >= ERROR_TABLE_BASE_VL(363520L) && acode <= ERROR_TABLE_BASE_VL(363520L) + 255) { /* vlserver errors */
686 shouldRetry = 0;
687 areq->volumeError = VOLMISSING1;
688 } else if (acode >= 0) {
689 if (aerrP)
690 (aerrP->err_Other)++;
691 if (op == AFS_STATS_FS_RPCIDX_STOREDATA3)
692 areq->permWriteError = 1;
693 shouldRetry = 0; /* Other random Vice error. */
694 } else if (acode == RX_MSGSIZE(-8)) { /* same meaning as EMSGSIZE... */
695 afs_warnuser
696 ("afs: Path MTU may have been exceeded, retrying (server %d.%d.%d.%d)\n",
697 (address >> 24), (address >> 16) & 0xff,
698 (address >> 8) & 0xff, (address) & 0xff);
699
700 VSleep(1)afs_osi_Wait((1)*1000, 0, 0); /* Just a hack for desperate times. */
701 if (aerrP)
702 (aerrP->err_Other)++;
703 shouldRetry = 1; /* packet was too big, please retry call */
704 }
705
706 if (acode < 0 && acode != RX_MSGSIZE(-8) && acode != VRESTARTING-100) {
707 /* If we get here, code < 0 and we have network/Server troubles.
708 * areq->networkError is not set here, since we always
709 * retry in case there is another server. However, if we find
710 * no connection (aconn == 0) we set the networkError flag.
711 */
712 afs_MarkServerUpOrDown(sa, SRVR_ISDOWN0x20);
713 if (aerrP)
714 (aerrP->err_Server)++;
715 VSleep(1)afs_osi_Wait((1)*1000, 0, 0); /* Just a hack for desperate times. */
716 shouldRetry = 1;
717 }
718out:
719 /* now unlock the connection and return */
720 afs_PutConn(aconn, rxconn, locktype);
721 return (shouldRetry);
722} /*afs_Analyze */