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
10 #include <afsconfig.h>
11 #include "afs/param.h"
15 #include "afs/sysincludes.h" /* Standard vendor system headers */
16 #include "afsincludes.h" /* Afs-based standard headers */
17 #include "afs/afs_stats.h"
18 #include "rx/rx_globals.h"
19 #if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
22 #include "h/hashing.h"
24 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
25 #include "netinet/in_var.h"
27 #endif /* !defined(UKERNEL) */
28 #ifdef AFS_LINUX22_ENV
29 #include "h/smp_lock.h"
33 #if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
34 #define AFS_MINBUFFERS 100
36 #define AFS_MINBUFFERS 50
40 afs_int32 hosts[MAXCELLHOSTS];
44 char afs_zeros[AFS_ZEROS];
45 char afs_rootVolumeName[64]="";
46 struct afs_icl_set *afs_iclSetp = (struct afs_icl_set*)0;
47 struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set*)0;
49 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
50 kmutex_t afs_global_lock;
51 kmutex_t afs_rxglobal_lock;
54 #if defined(AFS_SGI_ENV) && !defined(AFS_SGI64_ENV)
55 long afs_global_owner;
58 #if defined(AFS_OSF_ENV)
59 simple_lock_data_t afs_global_lock;
62 #if defined(AFS_DARWIN_ENV)
63 struct lock__bsd__ afs_global_lock;
66 #if defined(AFS_XBSD_ENV)
67 struct lock afs_global_lock;
69 struct thread *afs_global_owner;
71 struct proc *afs_global_owner;
75 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
76 thread_t afs_global_owner;
77 #endif /* AFS_OSF_ENV */
79 #if defined(AFS_AIX41_ENV)
80 simple_lock_data afs_global_lock;
83 afs_int32 afs_initState = 0;
84 afs_int32 afs_termState = 0;
85 afs_int32 afs_setTime = 0;
86 int afs_cold_shutdown = 0;
87 char afs_SynchronousCloses = '\0';
88 static int afs_CB_Running = 0;
89 static int AFS_Running = 0;
90 static int afs_CacheInit_Done = 0;
91 static int afs_Go_Done = 0;
92 extern struct interfaceAddr afs_cb_interface;
93 static int afs_RX_Running = 0;
94 static int afs_InitSetup_done = 0;
96 afs_int32 afs_rx_deadtime = AFS_RXDEADTIME;
97 afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
100 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval);
102 #if defined(AFS_HPUX_ENV)
103 extern int afs_vfs_mount();
104 #endif /* defined(AFS_HPUX_ENV) */
106 /* This is code which needs to be called once when the first daemon enters
107 * the client. A non-zero return means an error and AFS should not start.
109 static int afs_InitSetup(int preallocs)
111 extern void afs_InitStats();
114 if (afs_InitSetup_done)
119 * Set up all the AFS statistics variables. This should be done
120 * exactly once, and it should be done here, the first resource-setting
121 * routine to be called by the CM/RX.
124 #endif /* AFS_NOSTATS */
126 memset(afs_zeros, 0, AFS_ZEROS);
129 rx_extraPackets = AFS_NRXPACKETS; /* smaller # of packets */
130 code = rx_Init(htons(7001));
132 printf("AFS: RX failed to initialize.\n");
135 rx_SetRxDeadTime(afs_rx_deadtime);
136 /* resource init creates the services */
137 afs_ResourceInit(preallocs);
139 afs_InitSetup_done = 1;
140 afs_osi_Wakeup(&afs_InitSetup_done);
145 #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)
146 struct afsd_thread_info {
148 struct completion *complete;
151 static int afsd_thread(void *rock) {
152 struct afsd_thread_info *arg=rock;
153 unsigned long parm=arg->parm;
154 #ifdef SYS_SETPRIORITY_EXPORTED
155 int (*sys_setpriority)(int,int,int) = sys_call_table[__NR_setpriority];
157 daemonize(); /* doesn't do much, since we were forked from keventd, but
158 does call mm_release, which wakes up our parent (since it
161 afs_osi_MaskSignals();
163 case AFSOP_START_RXCALLBACK:
164 sprintf(current->comm, "afs_cbstart");
166 complete(arg->complete);
168 while (afs_RX_Running != 2)
169 afs_osi_Sleep(&afs_RX_Running);
170 sprintf(current->comm, "afs_callback");
171 afs_RXCallBackServer();
173 complete_and_exit(0,0);
175 case AFSOP_START_AFS:
176 sprintf(current->comm, "afs_afsstart");
178 complete(arg->complete);
180 while (afs_initState < AFSOP_START_AFS)
181 afs_osi_Sleep(&afs_initState);
182 afs_initState = AFSOP_START_BKG;
183 afs_osi_Wakeup(&afs_initState);
184 sprintf(current->comm, "afsd");
187 complete_and_exit(0,0);
189 case AFSOP_START_BKG:
190 sprintf(current->comm, "afs_bkgstart");
192 complete(arg->complete);
193 while (afs_initState < AFSOP_START_BKG)
194 afs_osi_Sleep(&afs_initState);
195 if (afs_initState < AFSOP_GO) {
196 afs_initState = AFSOP_GO;
197 afs_osi_Wakeup(&afs_initState);
199 sprintf(current->comm, "afs_background");
200 afs_BackgroundDaemon();
202 complete_and_exit(0,0);
204 case AFSOP_START_TRUNCDAEMON:
205 sprintf(current->comm, "afs_trimstart");
207 complete(arg->complete);
208 while (afs_initState < AFSOP_GO)
209 afs_osi_Sleep(&afs_initState);
210 sprintf(current->comm, "afs_cachetrim");
211 afs_CacheTruncateDaemon();
213 complete_and_exit(0,0);
216 sprintf(current->comm, "afs_checkserver");
218 complete(arg->complete);
219 afs_CheckServerDaemon();
221 complete_and_exit(0,0);
223 case AFSOP_RXEVENT_DAEMON:
224 sprintf(current->comm, "afs_evtstart");
225 #ifdef SYS_SETPRIORITY_EXPORTED
226 sys_setpriority(PRIO_PROCESS,0,-10);
228 #ifdef CURRENT_INCLUDES_NICE
233 complete(arg->complete);
234 while (afs_initState < AFSOP_START_BKG)
235 afs_osi_Sleep(&afs_initState);
236 sprintf(current->comm, "afs_rxevent");
237 afs_rxevent_daemon();
239 complete_and_exit(0,0);
241 case AFSOP_RXLISTENER_DAEMON:
242 sprintf(current->comm, "afs_lsnstart");
243 #ifdef SYS_SETPRIORITY_EXPORTED
244 sys_setpriority(PRIO_PROCESS,0,-10);
246 #ifdef CURRENT_INCLUDES_NICE
251 complete(arg->complete);
252 afs_initState = AFSOP_START_AFS;
253 afs_osi_Wakeup(&afs_initState);
255 afs_osi_Wakeup(&afs_RX_Running);
256 afs_osi_RxkRegister();
257 sprintf(current->comm, "afs_rxlistener");
260 complete_and_exit(0,0);
263 printf("Unknown op %d in StartDaemon()\n");
269 void afsd_launcher(void *rock) {
270 if (!kernel_thread(afsd_thread,rock, CLONE_VFORK|SIGCHLD))
271 printf("kernel_thread failed. afs startup will not complete\n");
274 void afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5,
278 DECLARE_COMPLETION(c);
280 struct afsd_thread_info info;
281 if (parm == AFSOP_START_RXCALLBACK) {
282 if (afs_CB_Running) return;
283 } else if (parm == AFSOP_RXLISTENER_DAEMON) {
284 if (afs_RX_Running) return;
286 code = afs_InitSetup(parm2);
288 rx_enablePeerRPCStats();
291 rx_enableProcessRPCStats();
295 } else if (parm == AFSOP_START_AFS) {
296 if (AFS_Running) return;
297 } /* other functions don't need setup in the parent */
301 INIT_LIST_HEAD(&tq.list);
302 tq.routine=afsd_launcher;
306 /* we need to wait cause we passed stack pointers around.... */
307 wait_for_completion(&c);
312 /* leaving as is, probably will barf if we add prototypes here since it's likely being called
315 afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
316 long parm, parm2, parm3, parm4, parm5, parm6;
319 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
321 #else /* AFS_SGI61_ENV */
323 #endif /* AFS_SGI61_ENV */
325 AFS_STATCNT(afs_syscall_call);
327 if (!afs_suser(CRED()) && (parm != AFSOP_GETMTU)
328 && (parm != AFSOP_GETMASK)) {
329 /* only root can run this code */
332 if (!afs_suser() && (parm != AFSOP_GETMTU)
333 && (parm != AFSOP_GETMASK)) {
334 /* only root can run this code */
335 #if defined(KERNEL_HAVE_UERROR)
339 #if defined(AFS_OSF_ENV)
341 #else /* AFS_OSF_ENV */
343 #endif /* AFS_OSF_ENV */
348 #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) && !defined(UKERNEL)
349 if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON
350 || parm == AFSOP_RXLISTENER_DAEMON) {
351 afs_DaemonOp(parm,parm2,parm3,parm4,parm5,parm6);
353 #else /* !(AFS_LINUX24_ENV && !UKERNEL) */
354 if (parm == AFSOP_START_RXCALLBACK) {
355 if (afs_CB_Running) goto out;
357 #ifndef RXK_LISTENER_ENV
358 code = afs_InitSetup(parm2);
360 #endif /* !RXK_LISTENER_ENV */
362 #ifdef RXK_LISTENER_ENV
363 while (afs_RX_Running != 2)
364 afs_osi_Sleep(&afs_RX_Running);
365 #else /* !RXK_LISTENER_ENV */
366 afs_initState = AFSOP_START_AFS;
367 afs_osi_Wakeup(&afs_initState);
368 #endif /* RXK_LISTENER_ENV */
370 afs_RXCallBackServer();
374 exit(CLD_EXITED, code);
375 #endif /* AFS_SGI_ENV */
377 #ifdef RXK_LISTENER_ENV
378 else if (parm == AFSOP_RXLISTENER_DAEMON) {
379 if (afs_RX_Running) goto out;
381 code = afs_InitSetup(parm2);
383 rx_enablePeerRPCStats();
386 rx_enableProcessRPCStats();
389 afs_initState = AFSOP_START_AFS;
390 afs_osi_Wakeup(&afs_initState);
393 afs_osi_Wakeup(&afs_RX_Running);
395 afs_osi_RxkRegister();
396 #endif /* !UKERNEL */
401 exit(CLD_EXITED, code);
402 #endif /* AFS_SGI_ENV */
404 #endif /* RXK_LISTENER_ENV */
405 else if (parm == AFSOP_START_AFS) {
407 if (AFS_Running) goto out;
409 while (afs_initState < AFSOP_START_AFS)
410 afs_osi_Sleep(&afs_initState);
412 afs_initState = AFSOP_START_BKG;
413 afs_osi_Wakeup(&afs_initState);
419 #endif /* AFS_SGI_ENV */
421 else if (parm == AFSOP_START_CS) {
423 afs_CheckServerDaemon();
427 #endif /* AFS_SGI_ENV */
429 else if (parm == AFSOP_START_BKG) {
430 while (afs_initState < AFSOP_START_BKG)
431 afs_osi_Sleep(&afs_initState);
432 if (afs_initState < AFSOP_GO) {
433 afs_initState = AFSOP_GO;
434 afs_osi_Wakeup(&afs_initState);
436 /* start the bkg daemon */
440 afs_BioDaemon(parm2);
442 #endif /* AFS_AIX32_ENV */
443 afs_BackgroundDaemon();
447 #endif /* AFS_SGI_ENV */
449 else if (parm == AFSOP_START_TRUNCDAEMON) {
450 while (afs_initState < AFSOP_GO)
451 afs_osi_Sleep(&afs_initState);
452 /* start the bkg daemon */
454 afs_CacheTruncateDaemon();
458 #endif /* AFS_SGI_ENV */
460 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
461 else if (parm == AFSOP_RXEVENT_DAEMON) {
462 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
464 afs_rxevent_daemon();
468 #endif /* AFS_SGI_ENV */
470 #endif /* AFS_SUN5_ENV || RXK_LISTENER_ENV */
471 #endif /* AFS_LINUX24_ENV && !UKERNEL */
472 else if (parm == AFSOP_BASIC_INIT) {
475 while (!afs_InitSetup_done)
476 afs_osi_Sleep(&afs_InitSetup_done);
478 #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
479 temp = AFS_MINBUFFERS; /* Should fix this soon */
481 /* number of 2k buffers we could get from all of the buffer space */
482 temp = ((afs_bufferpages * NBPG)>>11);
483 temp = temp>>2; /* don't take more than 25% (our magic parameter) */
484 if (temp < AFS_MINBUFFERS)
485 temp = AFS_MINBUFFERS; /* though we really should have this many */
488 afs_rootFid.Fid.Volume = 0;
491 else if (parm == AFSOP_ADDCELL) {
492 /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated
493 name. Parameter 4 is the length of the name, including the null. Parm 5 is the
494 home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */
495 struct afsop_cell tcell;
497 AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code);
499 if (parm4 > sizeof(tcell.cellName))
502 AFS_COPYIN((char *)parm3, tcell.cellName, parm4, code);
504 afs_NewCell(tcell.cellName, tcell.hosts, parm5,
508 } else if (parm == AFSOP_ADDCELL2) {
509 struct afsop_cell tcell;
510 char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0;
511 char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
515 /* wait for basic init - XXX can't find any reason we need this? */
516 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
519 AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code);
521 AFS_COPYINSTR((char *)parm3, tbuffer1, AFS_SMALLOCSIZ, &bufferSize, code);
524 AFS_COPYINSTR((char *)parm5, tbuffer, AFS_SMALLOCSIZ, &bufferSize, code);
527 cflags |= CLinkedCell;
531 code = afs_NewCell(tbuffer1, tcell.hosts, cflags,
535 osi_FreeSmallSpace(tbuffer);
536 osi_FreeSmallSpace(tbuffer1);
538 else if (parm == AFSOP_ADDCELLALIAS) {
541 * parm2 is the alias name
542 * parm3 is the real cell name
544 char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
545 char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
547 AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, code);
548 if (!code) AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, &bufferSize, code);
549 if (!code) afs_NewCellAlias(aliasName, cellName);
550 osi_FreeSmallSpace(aliasName);
551 osi_FreeSmallSpace(cellName);
553 else if (parm == AFSOP_SET_THISCELL) {
556 * parm2 is the primary cell name
558 char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
560 AFS_COPYINSTR((char *) parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code);
562 afs_SetPrimaryCell(cell);
563 osi_FreeSmallSpace(cell);
565 else if (parm == AFSOP_CACHEINIT) {
566 struct afs_cacheParams cparms;
568 if (afs_CacheInit_Done) goto out;
570 AFS_COPYIN((char *)parm2, (caddr_t) &cparms, sizeof(cparms), code);
572 #if defined(KERNEL_HAVE_UERROR)
578 afs_CacheInit_Done = 1;
580 struct afs_icl_log *logp;
581 /* initialize the ICL system */
582 code = afs_icl_CreateLog("cmfx", 60*1024, &logp);
584 code = afs_icl_CreateSetWithFlags("cm", logp, NULL,
585 ICL_CRSET_FLAG_DEFAULT_OFF,
587 code = afs_icl_CreateSet("cmlongterm", logp, NULL,
588 &afs_iclLongTermSetp);
590 afs_setTime = cparms.setTimeFlag;
592 code = afs_CacheInit(cparms.cacheScaches,
603 else if (parm == AFSOP_CACHEINODE) {
604 ino_t ainode = parm2;
605 /* wait for basic init */
606 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
610 ainode = (ainode << 32) | (parm3 & 0xffffffff);
612 code = afs_InitCacheFile(NULL, ainode);
614 else if (parm == AFSOP_ROOTVOLUME) {
615 /* wait for basic init */
616 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
619 AFS_COPYINSTR((char *)parm2, afs_rootVolumeName, sizeof(afs_rootVolumeName), &bufferSize, code);
620 afs_rootVolumeName[sizeof(afs_rootVolumeName)-1] = 0;
624 else if (parm == AFSOP_CACHEFILE ||
625 parm == AFSOP_CACHEINFO ||
626 parm == AFSOP_VOLUMEINFO ||
627 parm == AFSOP_AFSLOG ||
628 parm == AFSOP_CELLINFO) {
629 char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
632 AFS_COPYINSTR((char *) parm2, tbuffer, AFS_SMALLOCSIZ,
635 osi_FreeSmallSpace(tbuffer);
639 tbuffer[AFS_SMALLOCSIZ-1] = '\0'; /* null-terminate the name */
640 /* We have the cache dir copied in. Call the cache init routine */
641 if (parm == AFSOP_CACHEFILE)
642 code = afs_InitCacheFile(tbuffer, 0);
643 else if (parm == AFSOP_CACHEINFO)
644 code = afs_InitCacheInfo(tbuffer);
645 else if (parm == AFSOP_VOLUMEINFO)
646 code = afs_InitVolumeInfo(tbuffer);
647 else if (parm == AFSOP_CELLINFO)
648 code = afs_InitCellInfo(tbuffer);
650 osi_FreeSmallSpace(tbuffer);
652 else if (parm == AFSOP_GO) {
653 /* the generic initialization calls come here. One parameter: should we do the
654 set-time operation on this workstation */
655 if (afs_Go_Done) goto out;
657 while (afs_initState < AFSOP_GO) afs_osi_Sleep(&afs_initState);
660 afs_osi_Wakeup(&afs_initState);
661 #if (!defined(AFS_NONFSTRANS) && !defined(AFS_DEC_ENV)) || defined(AFS_AIX_IAUTH_ENV)
662 afs_nfsclient_init();
664 printf("found %d non-empty cache files (%d%%).\n", afs_stats_cmperf.cacheFilesReused,
665 (100*afs_stats_cmperf.cacheFilesReused) /
666 (afs_stats_cmperf.cacheNumEntries?afs_stats_cmperf.cacheNumEntries : 1));
668 else if (parm == AFSOP_ADVISEADDR) {
669 /* pass in the host address to the rx package */
670 afs_int32 count = parm2;
671 afs_int32 buffer[AFS_MAX_INTERFACE_ADDR];
672 afs_int32 maskbuffer[AFS_MAX_INTERFACE_ADDR];
673 afs_int32 mtubuffer[AFS_MAX_INTERFACE_ADDR];
677 if ( count > AFS_MAX_INTERFACE_ADDR ) {
679 count = AFS_MAX_INTERFACE_ADDR;
682 AFS_COPYIN( (char *)parm3, (char *)buffer, count*sizeof(afs_int32), code);
684 AFS_COPYIN((char *)parm4, (char *)maskbuffer, count*sizeof(afs_int32), code);
686 AFS_COPYIN((char *)parm5, (char *)mtubuffer, count*sizeof(afs_int32), code);
688 afs_cb_interface.numberOfInterfaces = count;
689 for (i=0; i < count ; i++) {
690 afs_cb_interface.addr_in[i] = buffer[i];
691 #ifdef AFS_USERSPACE_IP_ADDR
692 /* AFS_USERSPACE_IP_ADDR means we have no way of finding the
693 * machines IP addresses when in the kernel (the in_ifaddr
694 * struct is not available), so we pass the info in at
695 * startup. We also pass in the subnetmask and mtu size. The
696 * subnetmask is used when setting the rank:
697 * afsi_SetServerIPRank(); and the mtu size is used when
698 * finding the best mtu size. rxi_FindIfnet() is replaced
699 * with rxi_Findcbi().
701 afs_cb_interface.subnetmask[i] = (parm4 ? maskbuffer[i] : 0xffffffff);
702 afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500));
705 afs_uuid_create(&afs_cb_interface.uuid);
706 rxi_setaddr(buffer[0]);
710 else if (parm == AFSOP_NFSSTATICADDR) {
711 extern int (*nfs_rfsdisptab_v2)();
712 nfs_rfsdisptab_v2 = (int (*)())parm2;
714 else if (parm == AFSOP_NFSSTATICADDR2) {
715 extern int (*nfs_rfsdisptab_v2)();
717 nfs_rfsdisptab_v2 = (int (*)())((parm2<<32) | (parm3 & 0xffffffff));
719 nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff);
722 #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV)
723 else if (parm == AFSOP_SBLOCKSTATICADDR2) {
724 extern int (*afs_sblockp)();
725 extern void (*afs_sbunlockp)();
727 afs_sblockp = (int (*)())((parm2<<32) | (parm3 & 0xffffffff));
728 afs_sbunlockp = (void (*)())((parm4<<32) | (parm5 & 0xffffffff));
730 afs_sblockp = (int (*)())(parm3 & 0xffffffff);
731 afs_sbunlockp = (void (*)())(parm5 & 0xffffffff);
734 #endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
735 #endif /* AFS_SGI53_ENV */
736 else if (parm == AFSOP_SHUTDOWN) {
737 afs_cold_shutdown = 0;
738 if (parm == 1) afs_cold_shutdown = 1;
739 if (afs_globalVFS != 0) {
740 afs_warn("AFS isn't unmounted yet! Call aborted\n");
745 else if (parm == AFSOP_AFS_VFSMOUNT) {
747 vfsmount(parm2, parm3, parm4, parm5);
748 #else /* defined(AFS_HPUX_ENV) */
749 #if defined(KERNEL_HAVE_UERROR)
754 #endif /* defined(AFS_HPUX_ENV) */
756 else if (parm == AFSOP_CLOSEWAIT) {
757 afs_SynchronousCloses = 'S';
759 else if (parm == AFSOP_GETMTU) {
761 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
762 #ifdef AFS_USERSPACE_IP_ADDR
764 i = rxi_Findcbi(parm2);
765 mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
766 #else /* AFS_USERSPACE_IP_ADDR */
769 tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */
770 mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
771 #endif /* else AFS_USERSPACE_IP_ADDR */
772 #endif /* !AFS_SUN5_ENV */
774 AFS_COPYOUT ((caddr_t)&mtu, (caddr_t)parm3, sizeof(afs_int32), code);
776 /* this is disabled for now because I can't figure out how to get access
777 * to these kernel variables. It's only for supporting user-mode rx
778 * programs -- it makes a huge difference on the 220's in my testbed,
779 * though I don't know why. The bosserver does this with /etc/no, so it's
780 * being handled a different way for the servers right now. */
783 extern u_long sb_max_dflt;
786 if (sb_max_dflt < 131072) sb_max_dflt = 131072;
787 if (sb_max < 131072) sb_max = 131072;
790 #endif /* AFS_AIX32_ENV */
792 else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */
794 #if !defined(AFS_SUN5_ENV)
795 #ifdef AFS_USERSPACE_IP_ADDR
797 i = rxi_Findcbi(parm2);
799 mask = afs_cb_interface.subnetmask[i];
803 #else /* AFS_USERSPACE_IP_ADDR */
806 tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */
809 #endif /* else AFS_USERSPACE_IP_ADDR */
810 #endif /* !AFS_SUN5_ENV */
812 AFS_COPYOUT ((caddr_t)&mask, (caddr_t)parm3, sizeof(afs_int32), code);
815 else if (parm == AFSOP_AFSDB_HANDLER) {
816 int sizeArg = (int)parm4;
817 int kmsgLen = sizeArg & 0xffff;
818 int cellLen = (sizeArg & 0xffff0000) >> 16;
819 afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
820 char *cellname = afs_osi_Alloc(cellLen);
823 afs_osi_MaskSignals();
825 AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code);
826 AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code);
828 code = afs_AFSDBHandler(cellname, cellLen, kmsg);
829 if (*cellname == 1) *cellname = 0;
830 if (code == -2) { /* Shutting down? */
835 if (!code) AFS_COPYOUT(cellname, (char *)parm2, cellLen, code);
836 afs_osi_Free(kmsg, kmsgLen);
837 afs_osi_Free(cellname, cellLen);
840 else if (parm == AFSOP_SET_DYNROOT) {
841 code = afs_SetDynrootEnable(parm2);
843 else if (parm == AFSOP_SET_FAKESTAT) {
844 afs_fakestat_enable = parm2;
852 #ifdef AFS_LINUX20_ENV
861 #include "sys/lockl.h"
864 * syscall - this is the VRMIX system call entry point.
867 * THIS SHOULD BE CHANGED TO afs_syscall(), but requires
868 * all the user-level calls to `syscall' to change.
870 syscall(syscall, p1, p2, p3, p4, p5, p6) {
871 register rval1=0, code;
874 #ifndef AFS_AIX41_ENV
875 extern lock_t kernel_lock;
876 monster = lockl(&kernel_lock, LOCK_SHORT);
877 #endif /* !AFS_AIX41_ENV */
879 AFS_STATCNT(syscall);
883 rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6);
888 rval1 = afs_setpag();
894 rval1 = afs_syscall_pioctl(p1, p2, p3, p4);
898 case AFSCALL_ICREATE:
899 rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6);
903 rval1 = afs_syscall_iopen(p1, p2, p3);
907 rval1 = afs_syscall_iincdec(p1, p2, p3, -1);
911 rval1 = afs_syscall_iincdec(p1, p2, p3, 1);
916 code = Afscall_icl(p1, p2, p3, p4, p5, &retval);
918 if (!code) rval1 = retval;
919 if (!rval1) rval1 = code;
929 #ifndef AFS_AIX41_ENV
930 if (monster != LOCK_NEST)
931 unlockl(&kernel_lock);
932 #endif /* !AFS_AIX41_ENV */
933 return getuerror() ? -1 : rval1;
937 * lsetpag - interface to afs_setpag().
941 AFS_STATCNT(lsetpag);
942 return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0);
946 * lpioctl - interface to pioctl()
948 lpioctl(path, cmd, cmarg, follow)
949 char *path, *cmarg; {
951 AFS_STATCNT(lpioctl);
952 return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow);
955 #else /* !AFS_AIX32_ENV */
957 #if defined(AFS_SGI_ENV)
970 Afs_syscall (struct afsargs *uap, rval_t *rvp)
975 AFS_STATCNT(afs_syscall);
976 switch(uap->syscall) {
980 error=Afscall_icl(uap->parm1,uap->parm2,uap->parm3,uap->parm4,uap->parm5, &retval);
982 rvp->r_val1 = retval;
984 #ifdef AFS_SGI_XFS_IOPS_ENV
986 error = afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3,
987 uap->parm4, uap->parm5);
990 error = afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3,
991 uap->parm4, uap->parm5);
993 case AFSCALL_ILISTINODE64:
994 error = afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3,
995 uap->parm4, uap->parm5);
997 case AFSCALL_ICREATENAME64:
998 error = afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3,
999 uap->parm4, uap->parm5);
1002 #ifdef AFS_SGI_VNODE_GLUE
1003 case AFSCALL_INIT_KERNEL_CONFIG:
1004 error = afs_init_kernel_config(uap->parm1);
1008 error = afs_syscall_call(uap->syscall, uap->parm1, uap->parm2,
1009 uap->parm3, uap->parm4, uap->parm5);
1014 #else /* AFS_SGI_ENV */
1032 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
1034 dst->param1 = src->param1;
1035 dst->param2 = src->param2;
1036 dst->param3 = src->param3;
1037 dst->param4 = src->param4;
1041 * If you need to change copyin_iparam(), you may also need to change
1042 * copyin_afs_ioctl().
1046 copyin_iparam(caddr_t cmarg, struct iparam *dst)
1050 #if defined(AFS_HPUX_64BIT_ENV)
1051 struct iparam32 dst32;
1053 if (is_32bit(u.u_procp)) /* is_32bit() in proc_iface.h */
1055 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1057 iparam32_to_iparam(&dst32, dst);
1060 #endif /* AFS_HPUX_64BIT_ENV */
1062 #if defined(AFS_SUN57_64BIT_ENV)
1063 struct iparam32 dst32;
1065 if (get_udatamodel() == DATAMODEL_ILP32) {
1066 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1068 iparam32_to_iparam(&dst32, dst);
1071 #endif /* AFS_SUN57_64BIT_ENV */
1073 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
1074 struct iparam32 dst32;
1076 #ifdef AFS_SPARC64_LINUX24_ENV
1077 if (current->thread.flags & SPARC_FLAG_32BIT)
1078 #elif AFS_SPARC64_LINUX20_ENV
1079 if (current->tss.flags & SPARC_FLAG_32BIT)
1081 #error Not done for this linux version
1082 #endif /* AFS_SPARC64_LINUX20_ENV */
1084 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1086 iparam32_to_iparam(&dst32, dst);
1089 #endif /* AFS_LINUX_64BIT_KERNEL */
1091 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
1095 /* Main entry of all afs system calls */
1097 extern int afs_sinited;
1099 /** The 32 bit OS expects the members of this structure to be 32 bit
1100 * quantities and the 64 bit OS expects them as 64 bit quanties. Hence
1101 * to accomodate both, *long* is used instead of afs_int32
1104 #ifdef AFS_SUN57_ENV
1126 Afs_syscall(register struct afssysa *uap, rval_t *rvp)
1128 int *retval = &rvp->r_val1;
1129 #else /* AFS_SUN5_ENV */
1130 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1132 afs3_syscall(p, args, retval)
1133 #ifdef AFS_FBSD50_ENV
1149 } *uap = (struct a *)args;
1150 #else /* AFS_OSF_ENV */
1151 #ifdef AFS_LINUX20_ENV
1159 long parm6; /* not actually used - should be removed */
1161 /* Linux system calls only set up for 5 arguments. */
1162 asmlinkage int afs_syscall(long syscall, long parm1, long parm2, long parm3,
1165 struct afssysargs args, *uap = &args;
1167 long *retval = &linux_ret;
1168 long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
1169 #ifdef AFS_SPARC64_LINUX24_ENV
1170 afs_int32 eparm32[4];
1172 /* eparm is also used by AFSCALL_CALL in afsd.c */
1174 #if defined(UKERNEL)
1185 } *uap = (struct a *)u.u_ap;
1188 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
1192 #endif /* SUN && !SUN5 */
1202 } *uap = (struct a *)u.u_ap;
1203 #endif /* UKERNEL */
1204 #if defined(AFS_DEC_ENV)
1205 int *retval = &u.u_r.r_val1;
1206 #elif defined(AFS_HPUX_ENV)
1207 long *retval = &u.u_rval1;
1209 int *retval = &u.u_rval1;
1211 #endif /* AFS_LINUX20_ENV */
1212 #endif /* AFS_OSF_ENV */
1213 #endif /* AFS_SUN5_ENV */
1214 register int code = 0;
1216 AFS_STATCNT(afs_syscall);
1223 #ifdef AFS_LINUX20_ENV
1225 /* setup uap for use below - pull out the magic decoder ring to know
1226 * which syscalls have folded argument lists.
1228 uap->syscall = syscall;
1232 if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
1233 #ifdef AFS_SPARC64_LINUX24_ENV
1234 /* from arch/sparc64/kernel/sys_sparc32.c */
1236 ({ unsigned long __ret; \
1237 __asm__ ("srl %0, 0, %0" \
1244 if (current->thread.flags & SPARC_FLAG_32BIT) {
1245 AFS_COPYIN((char*)parm4, (char*)eparm32, sizeof(eparm32), code);
1246 eparm[0]=AA(eparm32[0]);
1247 eparm[1]=AA(eparm32[1]);
1248 eparm[2]=AA(eparm32[2]);
1252 AFS_COPYIN((char*)parm4, (char*)eparm, sizeof(eparm), code);
1253 uap->parm4 = eparm[0];
1254 uap->parm5 = eparm[1];
1255 uap->parm6 = eparm[2];
1264 #if defined(AFS_HPUX_ENV)
1266 * There used to be code here (duplicated from osi_Init()) for
1267 * initializing the semaphore used by AFS_GLOCK(). Was the
1268 * duplication to handle the case of a dynamically loaded kernel
1273 if (uap->syscall == AFSCALL_CALL) {
1275 code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3,
1276 uap->parm4, uap->parm5, uap->parm6, rvp, CRED());
1278 code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, uap->parm6);
1280 } else if (uap->syscall == AFSCALL_SETPAG) {
1282 register proc_t *procp;
1284 procp = ttoproc(curthread);
1286 code = afs_setpag(&procp->p_cred);
1290 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1291 code = afs_setpag(p, args, retval);
1292 #else /* AFS_OSF_ENV */
1293 code = afs_setpag();
1297 } else if (uap->syscall == AFSCALL_PIOCTL) {
1299 #if defined(AFS_SUN5_ENV)
1300 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED());
1301 #elif defined(AFS_FBSD50_ENV)
1302 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->td_ucred);
1303 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1304 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->p_cred->pc_ucred);
1306 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4);
1309 } else if (uap->syscall == AFSCALL_ICREATE) {
1310 struct iparam iparams;
1312 code = copyin_iparam((char *)uap->parm3, &iparams);
1314 #if defined(KERNEL_HAVE_UERROR)
1319 code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
1320 iparams.param3, iparams.param4, rvp, CRED());
1322 code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
1323 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1324 iparams.param3, iparams.param4, retval);
1326 iparams.param3, iparams.param4);
1328 #endif /* AFS_SUN5_ENV */
1329 } else if (uap->syscall == AFSCALL_IOPEN) {
1331 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED());
1333 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1334 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
1336 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
1338 #endif /* AFS_SUN5_ENV */
1339 } else if (uap->syscall == AFSCALL_IDEC) {
1341 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp, CRED());
1343 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1);
1344 #endif /* AFS_SUN5_ENV */
1345 } else if (uap->syscall == AFSCALL_IINC) {
1347 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp, CRED());
1349 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1);
1350 #endif /* AFS_SUN5_ENV */
1351 } else if (uap->syscall == AFSCALL_ICL) {
1353 code = Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, retval);
1355 #ifdef AFS_LINUX20_ENV
1357 /* ICL commands can return values. */
1358 code = -linux_ret; /* Gets negated again at exit below */
1362 #if defined(KERNEL_HAVE_UERROR)
1366 #endif /* !AFS_LINUX20_ENV */
1368 #if defined(KERNEL_HAVE_UERROR)
1375 #ifdef AFS_LINUX20_ENV
1381 #endif /* AFS_SGI_ENV */
1382 #endif /* !AFS_AIX32_ENV */
1385 * Initstate in the range 0 < x < 100 are early initialization states.
1386 * Initstate of 100 means a AFSOP_START operation has been done. After this,
1387 * the cache may be initialized.
1388 * Initstate of 101 means a AFSOP_GO operation has been done. This operation
1389 * is done after all the cache initialization has been done.
1390 * Initstate of 200 means that the volume has been looked up once, possibly
1392 * Initstate of 300 means that the volume has been *successfully* looked up.
1394 int afs_CheckInit(void)
1396 register int code = 0;
1398 AFS_STATCNT(afs_CheckInit);
1399 if (afs_initState <= 100)
1400 code = ENXIO; /* never finished init phase */
1401 else if (afs_initState == 101) { /* init done, wait for afs_daemon */
1402 while (afs_initState < 200) afs_osi_Sleep(&afs_initState);
1403 } else if (afs_initState == 200)
1404 code = ETIMEDOUT; /* didn't find root volume */
1408 int afs_shuttingdown = 0;
1409 void afs_shutdown(void)
1411 extern short afs_brsDaemons;
1412 extern afs_int32 afs_CheckServerDaemonStarted;
1413 extern struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler;
1414 extern struct osi_file *afs_cacheInodep;
1416 AFS_STATCNT(afs_shutdown);
1417 if (afs_shuttingdown) return;
1418 afs_shuttingdown = 1;
1419 if (afs_cold_shutdown) afs_warn("COLD ");
1420 else afs_warn("WARM ");
1421 afs_warn("shutting down of: CB... ");
1423 afs_termState = AFSOP_STOP_RXCALLBACK;
1424 rx_WakeupServerProcs();
1425 /* shutdown_rxkernel(); */
1426 while (afs_termState == AFSOP_STOP_RXCALLBACK)
1427 afs_osi_Sleep(&afs_termState);
1429 afs_warn("afs... ");
1430 while (afs_termState == AFSOP_STOP_AFS) {
1431 afs_osi_CancelWait(&AFS_WaitHandler);
1432 afs_osi_Sleep(&afs_termState);
1434 if (afs_CheckServerDaemonStarted) {
1435 while (afs_termState == AFSOP_STOP_CS) {
1436 afs_osi_CancelWait(&AFS_CSWaitHandler);
1437 afs_osi_Sleep(&afs_termState);
1440 afs_warn("BkG... ");
1441 /* Wake-up afs_brsDaemons so that we don't have to wait for a bkg job! */
1442 while (afs_termState == AFSOP_STOP_BKG) {
1443 afs_osi_Wakeup(&afs_brsDaemons);
1444 afs_osi_Sleep(&afs_termState);
1446 afs_warn("CTrunc... ");
1447 /* Cancel cache truncate daemon. */
1448 while (afs_termState == AFSOP_STOP_TRUNCDAEMON) {
1449 afs_osi_Wakeup((char*)&afs_CacheTruncateDaemon);
1450 afs_osi_Sleep(&afs_termState);
1452 #ifdef AFS_AFSDB_ENV
1453 afs_warn("AFSDB... ");
1455 while (afs_termState == AFSOP_STOP_AFSDB)
1456 afs_osi_Sleep(&afs_termState);
1458 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
1459 afs_warn("RxEvent... ");
1460 /* cancel rx event daemon */
1461 while (afs_termState == AFSOP_STOP_RXEVENT)
1462 afs_osi_Sleep(&afs_termState);
1463 #if defined(RXK_LISTENER_ENV)
1465 afs_warn("UnmaskRxkSignals... ");
1466 afs_osi_UnmaskRxkSignals();
1468 /* cancel rx listener */
1469 afs_warn("RxListener... ");
1470 osi_StopListener(); /* This closes rx_socket. */
1471 while (afs_termState == AFSOP_STOP_RXK_LISTENER) {
1472 afs_warn("Sleep... ");
1473 afs_osi_Sleep(&afs_termState);
1477 afs_termState = AFSOP_STOP_COMPLETE;
1481 /* Close file only after daemons which can write to it are stopped. */
1482 if (afs_cacheInodep) /* memcache won't set this */
1484 osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */
1485 afs_cacheInodep = 0;
1487 return; /* Just kill daemons for now */
1491 shutdown_rxkernel();
1495 shutdown_bufferpackage();
1501 shutdown_vnodeops();
1503 shutdown_exporter();
1504 shutdown_memcache();
1505 #if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)
1506 #if !defined(AFS_DEC_ENV) && !defined(AFS_OSF_ENV)
1507 /* this routine does not exist in Ultrix systems... 93.01.19 */
1509 #endif /* AFS_DEC_ENV */
1512 /* The following hold the cm stats */
1514 memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
1515 memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf));
1516 memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
1518 afs_warn(" ALL allocated tables\n");
1519 afs_shuttingdown = 0;
1523 void shutdown_afstest(void)
1525 AFS_STATCNT(shutdown_afstest);
1526 afs_initState = afs_termState = afs_setTime = 0;
1527 AFS_Running = afs_CB_Running = 0;
1528 afs_CacheInit_Done = afs_Go_Done = 0;
1529 if (afs_cold_shutdown) {
1530 *afs_rootVolumeName = 0;
1535 /* In case there is a bunch of dynamically build bkg daemons to free */
1536 void afs_shutdown_BKG(void)
1538 AFS_STATCNT(shutdown_BKG);
1542 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
1543 /* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
1544 #if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
1545 int afs_icl_sizeofLong = 1;
1547 int afs_icl_sizeofLong = 2;
1550 int afs_icl_sizeofLong = 1;
1553 int afs_icl_inited = 0;
1555 /* init function, called once, under afs_icl_lock */
1556 int afs_icl_Init(void)
1562 extern struct afs_icl_log *afs_icl_FindLog();
1563 extern struct afs_icl_set *afs_icl_FindSet();
1567 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
1569 afs_int32 *lp, elts, flags;
1570 register afs_int32 code;
1571 struct afs_icl_log *logp;
1572 struct afs_icl_set *setp;
1573 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1575 #else /* AFS_SGI61_ENV */
1577 #endif /* AFS_SGI61_ENV */
1579 afs_int32 startCookie;
1580 afs_int32 allocated;
1581 struct afs_icl_log *tlp;
1584 if (!afs_suser(CRED())) { /* only root can run this code */
1588 if (!afs_suser()) { /* only root can run this code */
1589 #if defined(KERNEL_HAVE_UERROR)
1598 case ICL_OP_COPYOUTCLR: /* copy out data then clear */
1599 case ICL_OP_COPYOUT: /* copy ouy data */
1600 /* copyout: p1=logname, p2=&buffer, p3=size(words), p4=&cookie
1601 * return flags<<24 + nwords.
1602 * updates cookie to updated start (not end) if we had to
1603 * skip some records.
1605 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1606 if (code) return code;
1607 AFS_COPYIN((char *)p4, (char *)&startCookie, sizeof(afs_int32), code);
1608 if (code) return code;
1609 logp = afs_icl_FindLog(tname);
1610 if (!logp) return ENOENT;
1611 #define BUFFERSIZE AFS_LRALLOCSIZ
1612 lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
1613 elts = BUFFERSIZE / sizeof(afs_int32);
1614 if (p3 < elts) elts = p3;
1615 flags = (opcode == ICL_OP_COPYOUT) ? 0 : ICL_COPYOUTF_CLRAFTERREAD;
1616 code = afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) &startCookie,
1619 osi_FreeLargeSpace((struct osi_buffer *) lp);
1622 AFS_COPYOUT((char *)lp, (char *)p2, elts * sizeof(afs_int32), code);
1623 if (code) goto done;
1624 AFS_COPYOUT((char *) &startCookie, (char *)p4, sizeof(afs_int32), code);
1625 if (code) goto done;
1626 *retval = (flags<<24) | (elts & 0xffffff);
1628 afs_icl_LogRele(logp);
1629 osi_FreeLargeSpace((struct osi_buffer *) lp);
1632 case ICL_OP_ENUMLOGS: /* enumerate logs */
1633 /* enumerate logs: p1=index, p2=&name, p3=sizeof(name), p4=&size.
1634 * return 0 for success, otherwise error.
1636 for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) {
1637 if (p1-- == 0) break;
1639 if (!tlp) return ENOENT; /* past the end of file */
1640 temp = strlen(tlp->name)+1;
1641 if (temp > p3) return EINVAL;
1642 AFS_COPYOUT(tlp->name, (char *) p2, temp, code);
1643 if (!code) /* copy out size of log */
1644 AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof (afs_int32), code);
1647 case ICL_OP_ENUMLOGSBYSET: /* enumerate logs by set name */
1648 /* enumerate logs: p1=setname, p2=index, p3=&name, p4=sizeof(name).
1649 * return 0 for success, otherwise error.
1651 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1652 if (code) return code;
1653 setp = afs_icl_FindSet(tname);
1654 if (!setp) return ENOENT;
1655 if (p2 > ICL_LOGSPERSET)
1657 if (!(tlp = setp->logs[p2]))
1659 temp = strlen(tlp->name)+1;
1660 if (temp > p4) return EINVAL;
1661 AFS_COPYOUT(tlp->name, (char *)p3, temp, code);
1664 case ICL_OP_CLRLOG: /* clear specified log */
1665 /* zero out the specified log: p1=logname */
1666 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1667 if (code) return code;
1668 logp = afs_icl_FindLog(tname);
1669 if (!logp) return ENOENT;
1670 code = afs_icl_ZeroLog(logp);
1671 afs_icl_LogRele(logp);
1674 case ICL_OP_CLRSET: /* clear specified set */
1675 /* zero out the specified set: p1=setname */
1676 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1677 if (code) return code;
1678 setp = afs_icl_FindSet(tname);
1679 if (!setp) return ENOENT;
1680 code = afs_icl_ZeroSet(setp);
1681 afs_icl_SetRele(setp);
1684 case ICL_OP_CLRALL: /* clear all logs */
1685 /* zero out all logs -- no args */
1687 ObtainWriteLock(&afs_icl_lock,178);
1688 for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) {
1689 tlp->refCount++; /* hold this guy */
1690 ReleaseWriteLock(&afs_icl_lock);
1691 /* don't clear persistent logs */
1692 if ((tlp->states & ICL_LOGF_PERSISTENT) == 0)
1693 code = afs_icl_ZeroLog(tlp);
1694 ObtainWriteLock(&afs_icl_lock,179);
1695 if (--tlp->refCount == 0)
1696 afs_icl_ZapLog(tlp);
1699 ReleaseWriteLock(&afs_icl_lock);
1702 case ICL_OP_ENUMSETS: /* enumerate all sets */
1703 /* enumerate sets: p1=index, p2=&name, p3=sizeof(name), p4=&states.
1704 * return 0 for success, otherwise error.
1706 for(setp = afs_icl_allSets; setp; setp = setp->nextp) {
1707 if (p1-- == 0) break;
1709 if (!setp) return ENOENT; /* past the end of file */
1710 temp = strlen(setp->name)+1;
1711 if (temp > p3) return EINVAL;
1712 AFS_COPYOUT(setp->name, (char *)p2, temp, code);
1713 if (!code) /* copy out size of log */
1714 AFS_COPYOUT((char *)&setp->states,(char *)p4, sizeof (afs_int32), code);
1717 case ICL_OP_SETSTAT: /* set status on a set */
1718 /* activate the specified set: p1=setname, p2=op */
1719 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1720 if (code) return code;
1721 setp = afs_icl_FindSet(tname);
1722 if (!setp) return ENOENT;
1723 code = afs_icl_SetSetStat(setp, p2);
1724 afs_icl_SetRele(setp);
1727 case ICL_OP_SETSTATALL: /* set status on all sets */
1728 /* activate the specified set: p1=op */
1730 ObtainWriteLock(&afs_icl_lock,180);
1731 for(setp = afs_icl_allSets; setp; setp=setp->nextp) {
1732 setp->refCount++; /* hold this guy */
1733 ReleaseWriteLock(&afs_icl_lock);
1734 /* don't set states on persistent sets */
1735 if ((setp->states & ICL_SETF_PERSISTENT) == 0)
1736 code = afs_icl_SetSetStat(setp, p1);
1737 ObtainWriteLock(&afs_icl_lock,181);
1738 if (--setp->refCount == 0)
1739 afs_icl_ZapSet(setp);
1742 ReleaseWriteLock(&afs_icl_lock);
1745 case ICL_OP_SETLOGSIZE: /* set size of log */
1746 /* set the size of the specified log: p1=logname, p2=size (in words) */
1747 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1748 if (code) return code;
1749 logp = afs_icl_FindLog(tname);
1750 if (!logp) return ENOENT;
1751 code = afs_icl_LogSetSize(logp, p2);
1752 afs_icl_LogRele(logp);
1755 case ICL_OP_GETLOGINFO: /* get size of log */
1756 /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */
1757 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1758 if (code) return code;
1759 logp = afs_icl_FindLog(tname);
1760 if (!logp) return ENOENT;
1761 allocated = !!logp->datap;
1762 AFS_COPYOUT((char *)&logp->logSize, (char *) p2, sizeof(afs_int32), code);
1764 AFS_COPYOUT((char *)&allocated, (char *) p3, sizeof(afs_int32), code);
1765 afs_icl_LogRele(logp);
1768 case ICL_OP_GETSETINFO: /* get state of set */
1769 /* zero out the specified set: p1=setname, p2=&state */
1770 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1771 if (code) return code;
1772 setp = afs_icl_FindSet(tname);
1773 if (!setp) return ENOENT;
1774 AFS_COPYOUT((char *)&setp->states, (char *) p2, sizeof(afs_int32), code);
1775 afs_icl_SetRele(setp);
1786 afs_lock_t afs_icl_lock;
1788 /* exported routine: a 4 parameter event */
1789 int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
1790 afs_int32 lAndT, long p1, long p2, long p3, long p4)
1794 register afs_int32 tmask;
1797 /* If things aren't init'ed yet (or the set is inactive), don't panic */
1798 if (!ICL_SETACTIVE(setp))
1802 mask = lAndT>>24 & 0xff; /* mask of which logs to log to */
1803 ix = ICL_EVENTBYTE(eventID);
1804 ObtainReadLock(&setp->lock);
1805 if (setp->eventFlags[ix] & ICL_EVENTMASK(eventID)) {
1806 for(i=0, tmask = 1; i<ICL_LOGSPERSET; i++, tmask <<= 1) {
1808 afs_icl_AppendRecord(setp->logs[i], eventID, lAndT & 0xffffff,
1812 if (mask == 0) break; /* break early */
1815 ReleaseReadLock(&setp->lock);
1819 /* Next 4 routines should be implemented via var-args or something.
1820 * Whole purpose is to avoid compiler warnings about parameter # mismatches.
1821 * Otherwise, could call afs_icl_Event4 directly.
1823 int afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID,
1824 afs_int32 lAndT, long p1, long p2, long p3)
1826 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
1829 int afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID,
1830 afs_int32 lAndT, long p1, long p2)
1832 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
1835 int afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
1836 afs_int32 lAndT, long p1)
1838 return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0, (long)0);
1841 int afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID,
1844 return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0, (long)0);
1847 struct afs_icl_log *afs_icl_allLogs = 0;
1849 /* function to purge records from the start of the log, until there
1850 * is at least minSpace long's worth of space available without
1851 * making the head and the tail point to the same word.
1853 * Log must be write-locked.
1855 static void afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
1857 register unsigned int tsize;
1859 while (logp->logSize - logp->logElements <= minSpace) {
1861 tsize = ((logp->datap[logp->firstUsed]) >> 24) & 0xff;
1862 logp->logElements -= tsize;
1863 logp->firstUsed += tsize;
1864 if (logp->firstUsed >= logp->logSize)
1865 logp->firstUsed -= logp->logSize;
1866 logp->baseCookie += tsize;
1870 /* append string astr to buffer, including terminating null char.
1872 * log must be write-locked.
1874 #define ICL_CHARSPERLONG 4
1875 static void afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
1877 char *op; /* ptr to char to write */
1879 register int bib; /* bytes in buffer */
1882 op = (char *) &(logp->datap[logp->firstFree]);
1886 if (++bib >= ICL_CHARSPERLONG) {
1889 if (++(logp->firstFree) >= logp->logSize) {
1890 logp->firstFree = 0;
1891 op = (char *) &(logp->datap[0]);
1893 logp->logElements++;
1898 /* if we've used this word at all, allocate it */
1899 if (++(logp->firstFree) >= logp->logSize) {
1900 logp->firstFree = 0;
1902 logp->logElements++;
1906 /* add a long to the log, ignoring overflow (checked already) */
1907 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
1908 #define ICL_APPENDINT32(lp, x) \
1910 (lp)->datap[(lp)->firstFree] = (x); \
1911 if (++((lp)->firstFree) >= (lp)->logSize) { \
1912 (lp)->firstFree = 0; \
1914 (lp)->logElements++; \
1917 #define ICL_APPENDLONG(lp, x) \
1919 ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
1920 ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
1923 #else /* AFS_ALPHA_ENV */
1924 #define ICL_APPENDLONG(lp, x) \
1926 (lp)->datap[(lp)->firstFree] = (x); \
1927 if (++((lp)->firstFree) >= (lp)->logSize) { \
1928 (lp)->firstFree = 0; \
1930 (lp)->logElements++; \
1932 #define ICL_APPENDINT32(lp, x) ICL_APPENDLONG((lp), (x))
1933 #endif /* AFS_ALPHA_ENV */
1935 /* routine to tell whether we're dealing with the address or the
1938 int afs_icl_UseAddr(int type)
1940 if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
1941 || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
1947 /* Function to append a record to the log. Written for speed
1948 * since we know that we're going to have to make this work fast
1949 * pretty soon, anyway. The log must be unlocked.
1952 void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
1953 afs_int32 types, long p1, long p2, long p3, long p4)
1955 int rsize; /* record size in longs */
1956 register int tsize; /* temp size */
1960 t4 = types & 0x3f; /* decode types */
1968 osi_GetTime(&tv); /* It panics for solaris if inside */
1969 ObtainWriteLock(&logp->lock,182);
1971 ReleaseWriteLock(&logp->lock);
1975 /* get timestamp as # of microseconds since some time that doesn't
1976 * change that often. This algorithm ticks over every 20 minutes
1977 * or so (1000 seconds). Write a timestamp record if it has.
1979 if (tv.tv_sec - logp->lastTS > 1024)
1981 /* the timer has wrapped -- write a timestamp record */
1982 if (logp->logSize - logp->logElements <= 5)
1983 afs_icl_GetLogSpace(logp, 5);
1985 ICL_APPENDINT32(logp, (afs_int32)(5<<24) + (ICL_TYPE_UNIXDATE<<18));
1986 ICL_APPENDINT32(logp, (afs_int32)ICL_INFO_TIMESTAMP);
1987 ICL_APPENDINT32(logp, (afs_int32)0); /* use thread ID zero for clocks */
1988 ICL_APPENDINT32(logp,
1989 (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
1990 ICL_APPENDINT32(logp, (afs_int32)tv.tv_sec);
1992 logp->lastTS = tv.tv_sec;
1995 rsize = 4; /* base case */
1997 /* compute size of parameter p1. Only tricky case is string.
1998 * In that case, we have to call strlen to get the string length.
2000 ICL_SIZEHACK(t1, p1);
2003 /* compute size of parameter p2. Only tricky case is string.
2004 * In that case, we have to call strlen to get the string length.
2006 ICL_SIZEHACK(t2, p2);
2009 /* compute size of parameter p3. Only tricky case is string.
2010 * In that case, we have to call strlen to get the string length.
2012 ICL_SIZEHACK(t3, p3);
2015 /* compute size of parameter p4. Only tricky case is string.
2016 * In that case, we have to call strlen to get the string length.
2018 ICL_SIZEHACK(t4, p4);
2021 /* At this point, we've computed all of the parameter sizes, and
2022 * have in rsize the size of the entire record we want to append.
2023 * Next, we check that we actually have room in the log to do this
2024 * work, and then we do the append.
2027 ReleaseWriteLock(&logp->lock);
2028 return; /* log record too big to express */
2031 if (logp->logSize - logp->logElements <= rsize)
2032 afs_icl_GetLogSpace(logp, rsize);
2034 ICL_APPENDINT32(logp,
2035 (afs_int32)(rsize<<24) + (t1<<18) + (t2<<12) + (t3<<6) + t4);
2036 ICL_APPENDINT32(logp, (afs_int32)op);
2037 ICL_APPENDINT32(logp, (afs_int32)osi_ThreadUnique());
2038 ICL_APPENDINT32(logp, (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
2041 /* marshall parameter 1 now */
2042 if (t1 == ICL_TYPE_STRING) {
2043 afs_icl_AppendString(logp, (char *) p1);
2045 else if (t1 == ICL_TYPE_HYPER) {
2046 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->high);
2047 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->low);
2049 else if (t1 == ICL_TYPE_INT64) {
2050 #ifdef AFSLITTLE_ENDIAN
2051 #ifdef AFS_64BIT_CLIENT
2052 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2053 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2054 #else /* AFS_64BIT_CLIENT */
2055 ICL_APPENDINT32(logp, (afs_int32) p1);
2056 ICL_APPENDINT32(logp, (afs_int32) 0);
2057 #endif /* AFS_64BIT_CLIENT */
2058 #else /* AFSLITTLE_ENDIAN */
2059 #ifdef AFS_64BIT_CLIENT
2060 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2061 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2062 #else /* AFS_64BIT_CLIENT */
2063 ICL_APPENDINT32(logp, (afs_int32) 0);
2064 ICL_APPENDINT32(logp, (afs_int32) p1);
2065 #endif /* AFS_64BIT_CLIENT */
2066 #endif /* AFSLITTLE_ENDIAN */
2068 else if (t1 == ICL_TYPE_FID) {
2069 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2070 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2071 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[2]);
2072 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[3]);
2074 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2075 else if (t1 == ICL_TYPE_INT32)
2076 ICL_APPENDINT32(logp, (afs_int32)p1);
2077 #endif /* AFS_ALPHA_ENV */
2078 else ICL_APPENDLONG(logp, p1);
2081 /* marshall parameter 2 now */
2082 if (t2 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p2);
2083 else if (t2 == ICL_TYPE_HYPER) {
2084 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->high);
2085 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->low);
2087 else if (t2 == ICL_TYPE_INT64) {
2088 #ifdef AFSLITTLE_ENDIAN
2089 #ifdef AFS_64BIT_CLIENT
2090 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2091 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2092 #else /* AFS_64BIT_CLIENT */
2093 ICL_APPENDINT32(logp, (afs_int32) p2);
2094 ICL_APPENDINT32(logp, (afs_int32) 0);
2095 #endif /* AFS_64BIT_CLIENT */
2096 #else /* AFSLITTLE_ENDIAN */
2097 #ifdef AFS_64BIT_CLIENT
2098 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2099 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2100 #else /* AFS_64BIT_CLIENT */
2101 ICL_APPENDINT32(logp, (afs_int32) 0);
2102 ICL_APPENDINT32(logp, (afs_int32) p2);
2103 #endif /* AFS_64BIT_CLIENT */
2104 #endif /* AFSLITTLE_ENDIAN */
2106 else if (t2 == ICL_TYPE_FID) {
2107 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2108 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2109 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[2]);
2110 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[3]);
2112 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2113 else if (t2 == ICL_TYPE_INT32)
2114 ICL_APPENDINT32(logp, (afs_int32)p2);
2115 #endif /* AFS_ALPHA_ENV */
2116 else ICL_APPENDLONG(logp, p2);
2119 /* marshall parameter 3 now */
2120 if (t3 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p3);
2121 else if (t3 == ICL_TYPE_HYPER) {
2122 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->high);
2123 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->low);
2125 else if (t3 == ICL_TYPE_INT64) {
2126 #ifdef AFSLITTLE_ENDIAN
2127 #ifdef AFS_64BIT_CLIENT
2128 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2129 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2130 #else /* AFS_64BIT_CLIENT */
2131 ICL_APPENDINT32(logp, (afs_int32) p3);
2132 ICL_APPENDINT32(logp, (afs_int32) 0);
2133 #endif /* AFS_64BIT_CLIENT */
2134 #else /* AFSLITTLE_ENDIAN */
2135 #ifdef AFS_64BIT_CLIENT
2136 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2137 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2138 #else /* AFS_64BIT_CLIENT */
2139 ICL_APPENDINT32(logp, (afs_int32) 0);
2140 ICL_APPENDINT32(logp, (afs_int32) p3);
2141 #endif /* AFS_64BIT_CLIENT */
2142 #endif /* AFSLITTLE_ENDIAN */
2144 else if (t3 == ICL_TYPE_FID) {
2145 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2146 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2147 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[2]);
2148 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[3]);
2150 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2151 else if (t3 == ICL_TYPE_INT32)
2152 ICL_APPENDINT32(logp, (afs_int32)p3);
2153 #endif /* AFS_ALPHA_ENV */
2154 else ICL_APPENDLONG(logp, p3);
2157 /* marshall parameter 4 now */
2158 if (t4 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p4);
2159 else if (t4 == ICL_TYPE_HYPER) {
2160 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->high);
2161 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->low);
2163 else if (t4 == ICL_TYPE_INT64) {
2164 #ifdef AFSLITTLE_ENDIAN
2165 #ifdef AFS_64BIT_CLIENT
2166 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2167 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2168 #else /* AFS_64BIT_CLIENT */
2169 ICL_APPENDINT32(logp, (afs_int32) p4);
2170 ICL_APPENDINT32(logp, (afs_int32) 0);
2171 #endif /* AFS_64BIT_CLIENT */
2172 #else /* AFSLITTLE_ENDIAN */
2173 #ifdef AFS_64BIT_CLIENT
2174 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2175 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2176 #else /* AFS_64BIT_CLIENT */
2177 ICL_APPENDINT32(logp, (afs_int32) 0);
2178 ICL_APPENDINT32(logp, (afs_int32) p4);
2179 #endif /* AFS_64BIT_CLIENT */
2180 #endif /* AFSLITTLE_ENDIAN */
2182 else if (t4 == ICL_TYPE_FID) {
2183 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2184 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2185 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[2]);
2186 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[3]);
2188 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2189 else if (t4 == ICL_TYPE_INT32)
2190 ICL_APPENDINT32(logp, (afs_int32)p4);
2191 #endif /* AFS_ALPHA_ENV */
2192 else ICL_APPENDLONG(logp, p4);
2194 ReleaseWriteLock(&logp->lock);
2197 /* create a log with size logSize; return it in *outLogpp and tag
2198 * it with name "name."
2200 int afs_icl_CreateLog(char *name, afs_int32 logSize, struct afs_icl_log **outLogpp)
2202 return afs_icl_CreateLogWithFlags(name, logSize, /*flags*/0, outLogpp);
2205 /* create a log with size logSize; return it in *outLogpp and tag
2206 * it with name "name." 'flags' can be set to make the log unclearable.
2208 int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
2209 struct afs_icl_log **outLogpp)
2211 register struct afs_icl_log *logp;
2213 /* add into global list under lock */
2214 ObtainWriteLock(&afs_icl_lock,183);
2215 if (!afs_icl_inited) afs_icl_Init();
2217 for (logp = afs_icl_allLogs; logp; logp=logp->nextp) {
2218 if (strcmp(logp->name, name) == 0) {
2219 /* found it already created, just return it */
2222 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2224 ObtainWriteLock(&logp->lock,184);
2225 logp->states |= ICL_LOGF_PERSISTENT;
2226 ReleaseWriteLock(&logp->lock);
2228 ReleaseWriteLock(&afs_icl_lock);
2233 logp = (struct afs_icl_log *)
2234 osi_AllocSmallSpace(sizeof(struct afs_icl_log));
2235 memset((caddr_t)logp, 0, sizeof(*logp));
2238 logp->name = osi_AllocSmallSpace(strlen(name)+1);
2239 strcpy(logp->name, name);
2240 LOCK_INIT(&logp->lock, "logp lock");
2241 logp->logSize = logSize;
2242 logp->datap = NULL; /* don't allocate it until we need it */
2244 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2245 logp->states |= ICL_LOGF_PERSISTENT;
2247 logp->nextp = afs_icl_allLogs;
2248 afs_icl_allLogs = logp;
2249 ReleaseWriteLock(&afs_icl_lock);
2255 /* called with a log, a pointer to a buffer, the size of the buffer
2256 * (in *bufSizep), the starting cookie (in *cookiep, use 0 at the start)
2257 * and returns data in the provided buffer, and returns output flags
2258 * in *flagsp. The flag ICL_COPYOUTF_MISSEDSOME is set if we can't
2259 * find the record with cookie value cookie.
2261 int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp,
2262 afs_int32 *bufSizep, afs_uint32 *cookiep, afs_int32 *flagsp)
2264 afs_int32 nwords; /* number of words to copy out */
2265 afs_uint32 startCookie; /* first cookie to use */
2266 afs_int32 outWords; /* words we've copied out */
2267 afs_int32 inWords; /* max words to copy out */
2268 afs_int32 code; /* return code */
2269 afs_int32 ix; /* index we're copying from */
2270 afs_int32 outFlags; /* return flags */
2271 afs_int32 inFlags; /* flags passed in */
2274 inWords = *bufSizep; /* max to copy out */
2275 outWords = 0; /* amount copied out */
2276 startCookie = *cookiep;
2281 ObtainWriteLock(&logp->lock,185);
2283 ReleaseWriteLock(&logp->lock);
2287 /* first, compute the index of the start cookie we've been passed */
2289 /* (re-)compute where we should start */
2290 if (startCookie < logp->baseCookie) {
2291 if (startCookie) /* missed some output */
2292 outFlags |= ICL_COPYOUTF_MISSEDSOME;
2293 /* skip to the first available record */
2294 startCookie = logp->baseCookie;
2295 *cookiep = startCookie;
2298 /* compute where we find the first element to copy out */
2299 ix = logp->firstUsed + startCookie - logp->baseCookie;
2300 if (ix >= logp->logSize) ix -= logp->logSize;
2302 /* if have some data now, break out and process it */
2303 if (startCookie - logp->baseCookie < logp->logElements) break;
2305 /* At end of log, so clear it if we need to */
2306 if (inFlags & ICL_COPYOUTF_CLRAFTERREAD)
2308 logp->firstUsed = logp->firstFree = 0;
2309 logp->logElements = 0;
2311 /* otherwise, either wait for the data to arrive, or return */
2312 if (!(inFlags & ICL_COPYOUTF_WAITIO)) {
2313 ReleaseWriteLock(&logp->lock);
2317 logp->states |= ICL_LOGF_WAITING;
2318 ReleaseWriteLock(&logp->lock);
2319 afs_osi_Sleep(&logp->lock);
2320 ObtainWriteLock(&logp->lock,186);
2322 /* copy out data from ix to logSize or firstFree, depending
2323 * upon whether firstUsed <= firstFree (no wrap) or otherwise.
2324 * be careful not to copy out more than nwords.
2326 if (ix >= logp->firstUsed) {
2327 if (logp->firstUsed <= logp->firstFree)
2329 end = logp->firstFree; /* first element not to copy */
2331 end = logp->logSize;
2332 nwords = inWords; /* don't copy more than this */
2333 if (end - ix < nwords)
2336 memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
2341 /* if we're going to copy more out below, we'll start here */
2344 /* now, if active part of the log has wrapped, there's more stuff
2345 * starting at the head of the log. Copy out more from there.
2347 if (logp->firstUsed > logp->firstFree
2348 && ix < logp->firstFree && inWords > 0) {
2349 /* (more to) copy out from the wrapped section at the
2350 * start of the log. May get here even if didn't copy any
2351 * above, if the cookie points directly into the wrapped section.
2354 if (logp->firstFree - ix < nwords)
2355 nwords = logp->firstFree - ix;
2356 memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
2362 ReleaseWriteLock(&logp->lock);
2366 *bufSizep = outWords;
2372 /* return basic parameter information about a log */
2373 int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep,
2374 afs_int32 *curSizep)
2376 ObtainReadLock(&logp->lock);
2377 *maxSizep = logp->logSize;
2378 *curSizep = logp->logElements;
2379 ReleaseReadLock(&logp->lock);
2384 /* hold and release logs */
2385 int afs_icl_LogHold(register struct afs_icl_log *logp)
2387 ObtainWriteLock(&afs_icl_lock,187);
2389 ReleaseWriteLock(&afs_icl_lock);
2393 /* hold and release logs, called with lock already held */
2394 int afs_icl_LogHoldNL(register struct afs_icl_log *logp)
2400 /* keep track of how many sets believe the log itself is allocated */
2401 int afs_icl_LogUse(register struct afs_icl_log *logp)
2403 ObtainWriteLock(&logp->lock,188);
2404 if (logp->setCount == 0) {
2405 /* this is the first set actually using the log -- allocate it */
2406 if (logp->logSize == 0) {
2407 /* we weren't passed in a hint and it wasn't set */
2408 logp->logSize = ICL_DEFAULT_LOGSIZE;
2410 logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
2411 #ifdef KERNEL_HAVE_PIN
2412 pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2416 ReleaseWriteLock(&logp->lock);
2420 /* decrement the number of real users of the log, free if possible */
2421 int afs_icl_LogFreeUse(register struct afs_icl_log *logp)
2423 ObtainWriteLock(&logp->lock,189);
2424 if (--logp->setCount == 0) {
2425 /* no more users -- free it (but keep log structure around)*/
2426 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2427 #ifdef KERNEL_HAVE_PIN
2428 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2430 logp->firstUsed = logp->firstFree = 0;
2431 logp->logElements = 0;
2434 ReleaseWriteLock(&logp->lock);
2438 /* set the size of the log to 'logSize' */
2439 int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
2441 ObtainWriteLock(&logp->lock,190);
2443 /* nothing to worry about since it's not allocated */
2444 logp->logSize = logSize;
2448 logp->firstUsed = logp->firstFree = 0;
2449 logp->logElements = 0;
2451 /* free and allocate a new one */
2452 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2453 #ifdef KERNEL_HAVE_PIN
2454 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2456 logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
2457 #ifdef KERNEL_HAVE_PIN
2458 pin((char *)logp->datap, sizeof(afs_int32) * logSize);
2460 logp->logSize = logSize;
2462 ReleaseWriteLock(&logp->lock);
2467 /* free a log. Called with afs_icl_lock locked. */
2468 int afs_icl_ZapLog(register struct afs_icl_log *logp)
2470 register struct afs_icl_log **lpp, *tp;
2472 for(lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2474 /* found the dude we want to remove */
2476 osi_FreeSmallSpace(logp->name);
2477 osi_FreeSmallSpace(logp->datap);
2478 osi_FreeSmallSpace(logp);
2479 break; /* won't find it twice */
2485 /* do the release, watching for deleted entries */
2486 int afs_icl_LogRele(register struct afs_icl_log *logp)
2488 ObtainWriteLock(&afs_icl_lock,191);
2489 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2490 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2492 ReleaseWriteLock(&afs_icl_lock);
2496 /* do the release, watching for deleted entries, log already held */
2497 int afs_icl_LogReleNL(register struct afs_icl_log *logp)
2499 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2500 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2505 /* zero out the log */
2506 int afs_icl_ZeroLog(register struct afs_icl_log *logp)
2508 ObtainWriteLock(&logp->lock,192);
2509 logp->firstUsed = logp->firstFree = 0;
2510 logp->logElements = 0;
2511 logp->baseCookie = 0;
2512 ReleaseWriteLock(&logp->lock);
2516 /* free a log entry, and drop its reference count */
2517 int afs_icl_LogFree(register struct afs_icl_log *logp)
2519 ObtainWriteLock(&logp->lock,193);
2520 logp->states |= ICL_LOGF_DELETED;
2521 ReleaseWriteLock(&logp->lock);
2522 afs_icl_LogRele(logp);
2526 /* find a log by name, returning it held */
2527 struct afs_icl_log *afs_icl_FindLog(char *name)
2529 register struct afs_icl_log *tp;
2530 ObtainWriteLock(&afs_icl_lock,194);
2531 for(tp = afs_icl_allLogs; tp; tp=tp->nextp) {
2532 if (strcmp(tp->name, name) == 0) {
2533 /* this is the dude we want */
2538 ReleaseWriteLock(&afs_icl_lock);
2542 int afs_icl_EnumerateLogs(int (*aproc)(), char *arock)
2544 register struct afs_icl_log *tp;
2545 register afs_int32 code;
2548 ObtainWriteLock(&afs_icl_lock,195);
2549 for(tp = afs_icl_allLogs; tp; tp=tp->nextp) {
2550 tp->refCount++; /* hold this guy */
2551 ReleaseWriteLock(&afs_icl_lock);
2552 ObtainReadLock(&tp->lock);
2553 code = (*aproc)(tp->name, arock, tp);
2554 ReleaseReadLock(&tp->lock);
2555 ObtainWriteLock(&afs_icl_lock,196);
2556 if (--tp->refCount == 0)
2560 ReleaseWriteLock(&afs_icl_lock);
2564 struct afs_icl_set *afs_icl_allSets = 0;
2566 int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp,
2567 struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp)
2569 return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp,
2570 /*flags*/0, outSetpp);
2573 /* create a set, given pointers to base and fatal logs, if any.
2574 * Logs are unlocked, but referenced, and *outSetpp is returned
2575 * referenced. Function bumps reference count on logs, since it
2576 * addds references from the new afs_icl_set. When the set is destroyed,
2577 * those references will be released.
2579 int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
2580 struct afs_icl_log *fatalLogp, afs_uint32 flags, struct afs_icl_set **outSetpp)
2582 register struct afs_icl_set *setp;
2584 afs_int32 states = ICL_DEFAULT_SET_STATES;
2586 ObtainWriteLock(&afs_icl_lock,197);
2587 if (!afs_icl_inited) afs_icl_Init();
2589 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
2590 if (strcmp(setp->name, name) == 0) {
2593 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2595 ObtainWriteLock(&setp->lock,198);
2596 setp->states |= ICL_SETF_PERSISTENT;
2597 ReleaseWriteLock(&setp->lock);
2599 ReleaseWriteLock(&afs_icl_lock);
2604 /* determine initial state */
2605 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2606 states = ICL_SETF_ACTIVE;
2607 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2608 states = ICL_SETF_FREED;
2609 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2610 states |= ICL_SETF_PERSISTENT;
2612 setp = (struct afs_icl_set *) afs_osi_Alloc(sizeof(struct afs_icl_set));
2613 memset((caddr_t)setp, 0, sizeof(*setp));
2615 if (states & ICL_SETF_FREED)
2616 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2617 setp->states = states;
2619 LOCK_INIT(&setp->lock, "setp lock");
2620 /* next lock is obtained in wrong order, hierarchy-wise, but
2621 * it doesn't matter, since no one can find this lock yet, since
2622 * the afs_icl_lock is still held, and thus the obtain can't block.
2624 ObtainWriteLock(&setp->lock,199);
2625 setp->name = osi_AllocSmallSpace(strlen(name)+1);
2626 strcpy(setp->name, name);
2627 setp->nevents = ICL_DEFAULTEVENTS;
2628 setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
2629 #ifdef KERNEL_HAVE_PIN
2630 pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2632 for(i=0; i<ICL_DEFAULTEVENTS; i++)
2633 setp->eventFlags[i] = 0xff; /* default to enabled */
2635 /* update this global info under the afs_icl_lock */
2636 setp->nextp = afs_icl_allSets;
2637 afs_icl_allSets = setp;
2638 ReleaseWriteLock(&afs_icl_lock);
2640 /* set's basic lock is still held, so we can finish init */
2642 setp->logs[0] = baseLogp;
2643 afs_icl_LogHold(baseLogp);
2644 if (!(setp->states & ICL_SETF_FREED))
2645 afs_icl_LogUse(baseLogp); /* log is actually being used */
2648 setp->logs[1] = fatalLogp;
2649 afs_icl_LogHold(fatalLogp);
2650 if (!(setp->states & ICL_SETF_FREED))
2651 afs_icl_LogUse(fatalLogp); /* log is actually being used */
2653 ReleaseWriteLock(&setp->lock);
2659 /* function to change event enabling information for a particular set */
2660 int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
2664 ObtainWriteLock(&setp->lock,200);
2665 if (!ICL_EVENTOK(setp, eventID)) {
2666 ReleaseWriteLock(&setp->lock);
2669 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2671 *tp |= ICL_EVENTMASK(eventID);
2673 *tp &= ~(ICL_EVENTMASK(eventID));
2674 ReleaseWriteLock(&setp->lock);
2678 /* return indication of whether a particular event ID is enabled
2679 * for tracing. If *getValuep is set to 0, the event is disabled,
2680 * otherwise it is enabled. All events start out enabled by default.
2682 int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID,
2685 ObtainReadLock(&setp->lock);
2686 if (!ICL_EVENTOK(setp, eventID)) {
2687 ReleaseWriteLock(&setp->lock);
2690 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2694 ReleaseReadLock(&setp->lock);
2698 /* hold and release event sets */
2699 int afs_icl_SetHold(register struct afs_icl_set *setp)
2701 ObtainWriteLock(&afs_icl_lock,201);
2703 ReleaseWriteLock(&afs_icl_lock);
2707 /* free a set. Called with afs_icl_lock locked */
2708 int afs_icl_ZapSet(register struct afs_icl_set *setp)
2710 register struct afs_icl_set **lpp, *tp;
2712 register struct afs_icl_log *tlp;
2714 for(lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2716 /* found the dude we want to remove */
2718 osi_FreeSmallSpace(setp->name);
2719 afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
2720 #ifdef KERNEL_HAVE_PIN
2721 unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2723 for(i=0; i < ICL_LOGSPERSET; i++) {
2724 if ((tlp = setp->logs[i]))
2725 afs_icl_LogReleNL(tlp);
2727 osi_FreeSmallSpace(setp);
2728 break; /* won't find it twice */
2734 /* do the release, watching for deleted entries */
2735 int afs_icl_SetRele(register struct afs_icl_set *setp)
2737 ObtainWriteLock(&afs_icl_lock,202);
2738 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2739 afs_icl_ZapSet(setp); /* destroys setp's lock! */
2741 ReleaseWriteLock(&afs_icl_lock);
2745 /* free a set entry, dropping its reference count */
2746 int afs_icl_SetFree(register struct afs_icl_set *setp)
2748 ObtainWriteLock(&setp->lock,203);
2749 setp->states |= ICL_SETF_DELETED;
2750 ReleaseWriteLock(&setp->lock);
2751 afs_icl_SetRele(setp);
2755 /* find a set by name, returning it held */
2756 struct afs_icl_set *afs_icl_FindSet(char *name)
2758 register struct afs_icl_set *tp;
2759 ObtainWriteLock(&afs_icl_lock,204);
2760 for(tp = afs_icl_allSets; tp; tp=tp->nextp) {
2761 if (strcmp(tp->name, name) == 0) {
2762 /* this is the dude we want */
2767 ReleaseWriteLock(&afs_icl_lock);
2771 /* zero out all the logs in the set */
2772 int afs_icl_ZeroSet(struct afs_icl_set *setp)
2777 struct afs_icl_log *logp;
2779 ObtainReadLock(&setp->lock);
2780 for(i = 0; i < ICL_LOGSPERSET; i++) {
2781 logp = setp->logs[i];
2783 afs_icl_LogHold(logp);
2784 tcode = afs_icl_ZeroLog(logp);
2785 if (tcode != 0) code = tcode; /* save the last bad one */
2786 afs_icl_LogRele(logp);
2789 ReleaseReadLock(&setp->lock);
2793 int afs_icl_EnumerateSets(int (*aproc)(), char *arock)
2795 register struct afs_icl_set *tp, *np;
2796 register afs_int32 code;
2799 ObtainWriteLock(&afs_icl_lock,205);
2800 for(tp = afs_icl_allSets; tp; tp=np) {
2801 tp->refCount++; /* hold this guy */
2802 ReleaseWriteLock(&afs_icl_lock);
2803 code = (*aproc)(tp->name, arock, tp);
2804 ObtainWriteLock(&afs_icl_lock,206);
2805 np = tp->nextp; /* tp may disappear next, but not np */
2806 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2810 ReleaseWriteLock(&afs_icl_lock);
2814 int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
2819 ObtainWriteLock(&setp->lock,207);
2820 for(i = 0; i < ICL_LOGSPERSET; i++) {
2821 if (!setp->logs[i]) {
2822 setp->logs[i] = newlogp;
2824 afs_icl_LogHold(newlogp);
2825 if (!(setp->states & ICL_SETF_FREED)) {
2826 /* bump up the number of sets using the log */
2827 afs_icl_LogUse(newlogp);
2832 ReleaseWriteLock(&setp->lock);
2836 int afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
2840 struct afs_icl_log *logp;
2842 ObtainWriteLock(&setp->lock,208);
2844 case ICL_OP_SS_ACTIVATE: /* activate a log */
2846 * If we are not already active, see if we have released
2847 * our demand that the log be allocated (FREED set). If
2848 * we have, reassert our desire.
2850 if (!(setp->states & ICL_SETF_ACTIVE)) {
2851 if (setp->states & ICL_SETF_FREED) {
2852 /* have to reassert desire for logs */
2853 for(i = 0; i < ICL_LOGSPERSET; i++) {
2854 logp = setp->logs[i];
2856 afs_icl_LogHold(logp);
2857 afs_icl_LogUse(logp);
2858 afs_icl_LogRele(logp);
2861 setp->states &= ~ICL_SETF_FREED;
2863 setp->states |= ICL_SETF_ACTIVE;
2868 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2869 /* this doesn't require anything beyond clearing the ACTIVE flag */
2870 setp->states &= ~ICL_SETF_ACTIVE;
2874 case ICL_OP_SS_FREE: /* deassert design for log */
2876 * if we are already in this state, do nothing; otherwise
2877 * deassert desire for log
2879 if (setp->states & ICL_SETF_ACTIVE)
2882 if (!(setp->states & ICL_SETF_FREED)) {
2883 for(i = 0; i < ICL_LOGSPERSET; i++) {
2884 logp = setp->logs[i];
2886 afs_icl_LogHold(logp);
2887 afs_icl_LogFreeUse(logp);
2888 afs_icl_LogRele(logp);
2891 setp->states |= ICL_SETF_FREED;
2900 ReleaseWriteLock(&setp->lock);