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,
585 (struct icl_log *) 0,
586 ICL_CRSET_FLAG_DEFAULT_OFF,
588 code = afs_icl_CreateSet("cmlongterm", logp, (struct icl_log*) 0,
589 &afs_iclLongTermSetp);
591 afs_setTime = cparms.setTimeFlag;
593 code = afs_CacheInit(cparms.cacheScaches,
604 else if (parm == AFSOP_CACHEINODE) {
605 ino_t ainode = parm2;
606 /* wait for basic init */
607 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
611 ainode = (ainode << 32) | (parm3 & 0xffffffff);
613 code = afs_InitCacheFile(NULL, ainode);
615 else if (parm == AFSOP_ROOTVOLUME) {
616 /* wait for basic init */
617 while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState);
620 AFS_COPYINSTR((char *)parm2, afs_rootVolumeName, sizeof(afs_rootVolumeName), &bufferSize, code);
621 afs_rootVolumeName[sizeof(afs_rootVolumeName)-1] = 0;
625 else if (parm == AFSOP_CACHEFILE ||
626 parm == AFSOP_CACHEINFO ||
627 parm == AFSOP_VOLUMEINFO ||
628 parm == AFSOP_AFSLOG ||
629 parm == AFSOP_CELLINFO) {
630 char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
633 AFS_COPYINSTR((char *) parm2, tbuffer, AFS_SMALLOCSIZ,
636 osi_FreeSmallSpace(tbuffer);
640 tbuffer[AFS_SMALLOCSIZ-1] = '\0'; /* null-terminate the name */
641 /* We have the cache dir copied in. Call the cache init routine */
642 if (parm == AFSOP_CACHEFILE)
643 code = afs_InitCacheFile(tbuffer, 0);
644 else if (parm == AFSOP_CACHEINFO)
645 code = afs_InitCacheInfo(tbuffer);
646 else if (parm == AFSOP_VOLUMEINFO)
647 code = afs_InitVolumeInfo(tbuffer);
648 else if (parm == AFSOP_CELLINFO)
649 code = afs_InitCellInfo(tbuffer);
651 osi_FreeSmallSpace(tbuffer);
653 else if (parm == AFSOP_GO) {
654 /* the generic initialization calls come here. One parameter: should we do the
655 set-time operation on this workstation */
656 if (afs_Go_Done) goto out;
658 while (afs_initState < AFSOP_GO) afs_osi_Sleep(&afs_initState);
661 afs_osi_Wakeup(&afs_initState);
662 #if (!defined(AFS_NONFSTRANS) && !defined(AFS_DEC_ENV)) || defined(AFS_AIX_IAUTH_ENV)
663 afs_nfsclient_init();
665 printf("found %d non-empty cache files (%d%%).\n", afs_stats_cmperf.cacheFilesReused,
666 (100*afs_stats_cmperf.cacheFilesReused) /
667 (afs_stats_cmperf.cacheNumEntries?afs_stats_cmperf.cacheNumEntries : 1));
669 else if (parm == AFSOP_ADVISEADDR) {
670 /* pass in the host address to the rx package */
671 afs_int32 count = parm2;
672 afs_int32 buffer[AFS_MAX_INTERFACE_ADDR];
673 afs_int32 maskbuffer[AFS_MAX_INTERFACE_ADDR];
674 afs_int32 mtubuffer[AFS_MAX_INTERFACE_ADDR];
678 if ( count > AFS_MAX_INTERFACE_ADDR ) {
680 count = AFS_MAX_INTERFACE_ADDR;
683 AFS_COPYIN( (char *)parm3, (char *)buffer, count*sizeof(afs_int32), code);
685 AFS_COPYIN((char *)parm4, (char *)maskbuffer, count*sizeof(afs_int32), code);
687 AFS_COPYIN((char *)parm5, (char *)mtubuffer, count*sizeof(afs_int32), code);
689 afs_cb_interface.numberOfInterfaces = count;
690 for (i=0; i < count ; i++) {
691 afs_cb_interface.addr_in[i] = buffer[i];
692 #ifdef AFS_USERSPACE_IP_ADDR
693 /* AFS_USERSPACE_IP_ADDR means we have no way of finding the
694 * machines IP addresses when in the kernel (the in_ifaddr
695 * struct is not available), so we pass the info in at
696 * startup. We also pass in the subnetmask and mtu size. The
697 * subnetmask is used when setting the rank:
698 * afsi_SetServerIPRank(); and the mtu size is used when
699 * finding the best mtu size. rxi_FindIfnet() is replaced
700 * with rxi_Findcbi().
702 afs_cb_interface.subnetmask[i] = (parm4 ? maskbuffer[i] : 0xffffffff);
703 afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500));
706 afs_uuid_create(&afs_cb_interface.uuid);
707 rxi_setaddr(buffer[0]);
711 else if (parm == AFSOP_NFSSTATICADDR) {
712 extern int (*nfs_rfsdisptab_v2)();
713 nfs_rfsdisptab_v2 = (int (*)())parm2;
715 else if (parm == AFSOP_NFSSTATICADDR2) {
716 extern int (*nfs_rfsdisptab_v2)();
718 nfs_rfsdisptab_v2 = (int (*)())((parm2<<32) | (parm3 & 0xffffffff));
720 nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff);
723 #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV)
724 else if (parm == AFSOP_SBLOCKSTATICADDR2) {
725 extern int (*afs_sblockp)();
726 extern void (*afs_sbunlockp)();
728 afs_sblockp = (int (*)())((parm2<<32) | (parm3 & 0xffffffff));
729 afs_sbunlockp = (void (*)())((parm4<<32) | (parm5 & 0xffffffff));
731 afs_sblockp = (int (*)())(parm3 & 0xffffffff);
732 afs_sbunlockp = (void (*)())(parm5 & 0xffffffff);
735 #endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
736 #endif /* AFS_SGI53_ENV */
737 else if (parm == AFSOP_SHUTDOWN) {
738 afs_cold_shutdown = 0;
739 if (parm == 1) afs_cold_shutdown = 1;
740 if (afs_globalVFS != 0) {
741 afs_warn("AFS isn't unmounted yet! Call aborted\n");
746 else if (parm == AFSOP_AFS_VFSMOUNT) {
748 vfsmount(parm2, parm3, parm4, parm5);
749 #else /* defined(AFS_HPUX_ENV) */
750 #if defined(KERNEL_HAVE_UERROR)
755 #endif /* defined(AFS_HPUX_ENV) */
757 else if (parm == AFSOP_CLOSEWAIT) {
758 afs_SynchronousCloses = 'S';
760 else if (parm == AFSOP_GETMTU) {
762 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
763 #ifdef AFS_USERSPACE_IP_ADDR
765 i = rxi_Findcbi(parm2);
766 mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
767 #else /* AFS_USERSPACE_IP_ADDR */
770 tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */
771 mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
772 #endif /* else AFS_USERSPACE_IP_ADDR */
773 #endif /* !AFS_SUN5_ENV */
775 AFS_COPYOUT ((caddr_t)&mtu, (caddr_t)parm3, sizeof(afs_int32), code);
777 /* this is disabled for now because I can't figure out how to get access
778 * to these kernel variables. It's only for supporting user-mode rx
779 * programs -- it makes a huge difference on the 220's in my testbed,
780 * though I don't know why. The bosserver does this with /etc/no, so it's
781 * being handled a different way for the servers right now. */
784 extern u_long sb_max_dflt;
787 if (sb_max_dflt < 131072) sb_max_dflt = 131072;
788 if (sb_max < 131072) sb_max = 131072;
791 #endif /* AFS_AIX32_ENV */
793 else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */
795 #if !defined(AFS_SUN5_ENV)
796 #ifdef AFS_USERSPACE_IP_ADDR
798 i = rxi_Findcbi(parm2);
800 mask = afs_cb_interface.subnetmask[i];
804 #else /* AFS_USERSPACE_IP_ADDR */
807 tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */
810 #endif /* else AFS_USERSPACE_IP_ADDR */
811 #endif /* !AFS_SUN5_ENV */
813 AFS_COPYOUT ((caddr_t)&mask, (caddr_t)parm3, sizeof(afs_int32), code);
816 else if (parm == AFSOP_AFSDB_HANDLER) {
817 int sizeArg = (int)parm4;
818 int kmsgLen = sizeArg & 0xffff;
819 int cellLen = (sizeArg & 0xffff0000) >> 16;
820 afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
821 char *cellname = afs_osi_Alloc(cellLen);
824 afs_osi_MaskSignals();
826 AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code);
827 AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code);
829 code = afs_AFSDBHandler(cellname, cellLen, kmsg);
830 if (*cellname == 1) *cellname = 0;
831 if (code == -2) { /* Shutting down? */
836 if (!code) AFS_COPYOUT(cellname, (char *)parm2, cellLen, code);
837 afs_osi_Free(kmsg, kmsgLen);
838 afs_osi_Free(cellname, cellLen);
841 else if (parm == AFSOP_SET_DYNROOT) {
842 code = afs_SetDynrootEnable(parm2);
844 else if (parm == AFSOP_SET_FAKESTAT) {
845 afs_fakestat_enable = parm2;
853 #ifdef AFS_LINUX20_ENV
862 #include "sys/lockl.h"
865 * syscall - this is the VRMIX system call entry point.
868 * THIS SHOULD BE CHANGED TO afs_syscall(), but requires
869 * all the user-level calls to `syscall' to change.
871 syscall(syscall, p1, p2, p3, p4, p5, p6) {
872 register rval1=0, code;
875 #ifndef AFS_AIX41_ENV
876 extern lock_t kernel_lock;
877 monster = lockl(&kernel_lock, LOCK_SHORT);
878 #endif /* !AFS_AIX41_ENV */
880 AFS_STATCNT(syscall);
884 rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6);
889 rval1 = afs_setpag();
895 rval1 = afs_syscall_pioctl(p1, p2, p3, p4);
899 case AFSCALL_ICREATE:
900 rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6);
904 rval1 = afs_syscall_iopen(p1, p2, p3);
908 rval1 = afs_syscall_iincdec(p1, p2, p3, -1);
912 rval1 = afs_syscall_iincdec(p1, p2, p3, 1);
917 code = Afscall_icl(p1, p2, p3, p4, p5, &retval);
919 if (!code) rval1 = retval;
920 if (!rval1) rval1 = code;
930 #ifndef AFS_AIX41_ENV
931 if (monster != LOCK_NEST)
932 unlockl(&kernel_lock);
933 #endif /* !AFS_AIX41_ENV */
934 return getuerror() ? -1 : rval1;
938 * lsetpag - interface to afs_setpag().
942 AFS_STATCNT(lsetpag);
943 return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0);
947 * lpioctl - interface to pioctl()
949 lpioctl(path, cmd, cmarg, follow)
950 char *path, *cmarg; {
952 AFS_STATCNT(lpioctl);
953 return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow);
956 #else /* !AFS_AIX32_ENV */
958 #if defined(AFS_SGI_ENV)
971 Afs_syscall (struct afsargs *uap, rval_t *rvp)
976 AFS_STATCNT(afs_syscall);
977 switch(uap->syscall) {
981 error=Afscall_icl(uap->parm1,uap->parm2,uap->parm3,uap->parm4,uap->parm5, &retval);
983 rvp->r_val1 = retval;
985 #ifdef AFS_SGI_XFS_IOPS_ENV
987 error = afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3,
988 uap->parm4, uap->parm5);
991 error = afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3,
992 uap->parm4, uap->parm5);
994 case AFSCALL_ILISTINODE64:
995 error = afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3,
996 uap->parm4, uap->parm5);
998 case AFSCALL_ICREATENAME64:
999 error = afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3,
1000 uap->parm4, uap->parm5);
1003 #ifdef AFS_SGI_VNODE_GLUE
1004 case AFSCALL_INIT_KERNEL_CONFIG:
1005 error = afs_init_kernel_config(uap->parm1);
1009 error = afs_syscall_call(uap->syscall, uap->parm1, uap->parm2,
1010 uap->parm3, uap->parm4, uap->parm5);
1015 #else /* AFS_SGI_ENV */
1033 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
1035 dst->param1 = src->param1;
1036 dst->param2 = src->param2;
1037 dst->param3 = src->param3;
1038 dst->param4 = src->param4;
1042 * If you need to change copyin_iparam(), you may also need to change
1043 * copyin_afs_ioctl().
1047 copyin_iparam(caddr_t cmarg, struct iparam *dst)
1051 #if defined(AFS_HPUX_64BIT_ENV)
1052 struct iparam32 dst32;
1054 if (is_32bit(u.u_procp)) /* is_32bit() in proc_iface.h */
1056 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1058 iparam32_to_iparam(&dst32, dst);
1061 #endif /* AFS_HPUX_64BIT_ENV */
1063 #if defined(AFS_SUN57_64BIT_ENV)
1064 struct iparam32 dst32;
1066 if (get_udatamodel() == DATAMODEL_ILP32) {
1067 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1069 iparam32_to_iparam(&dst32, dst);
1072 #endif /* AFS_SUN57_64BIT_ENV */
1074 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
1075 struct iparam32 dst32;
1077 #ifdef AFS_SPARC64_LINUX24_ENV
1078 if (current->thread.flags & SPARC_FLAG_32BIT)
1079 #elif AFS_SPARC64_LINUX20_ENV
1080 if (current->tss.flags & SPARC_FLAG_32BIT)
1082 #error Not done for this linux version
1083 #endif /* AFS_SPARC64_LINUX20_ENV */
1085 AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
1087 iparam32_to_iparam(&dst32, dst);
1090 #endif /* AFS_LINUX_64BIT_KERNEL */
1092 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
1096 /* Main entry of all afs system calls */
1098 extern int afs_sinited;
1100 /** The 32 bit OS expects the members of this structure to be 32 bit
1101 * quantities and the 64 bit OS expects them as 64 bit quanties. Hence
1102 * to accomodate both, *long* is used instead of afs_int32
1105 #ifdef AFS_SUN57_ENV
1127 Afs_syscall(register struct afssysa *uap, rval_t *rvp)
1129 int *retval = &rvp->r_val1;
1130 #else /* AFS_SUN5_ENV */
1131 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1133 afs3_syscall(p, args, retval)
1146 } *uap = (struct a *)args;
1147 #else /* AFS_OSF_ENV */
1148 #ifdef AFS_LINUX20_ENV
1156 long parm6; /* not actually used - should be removed */
1158 /* Linux system calls only set up for 5 arguments. */
1159 asmlinkage int afs_syscall(long syscall, long parm1, long parm2, long parm3,
1162 struct afssysargs args, *uap = &args;
1164 long *retval = &linux_ret;
1165 long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
1166 #ifdef AFS_SPARC64_LINUX24_ENV
1167 afs_int32 eparm32[4];
1169 /* eparm is also used by AFSCALL_CALL in afsd.c */
1171 #if defined(UKERNEL)
1182 } *uap = (struct a *)u.u_ap;
1185 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
1189 #endif /* SUN && !SUN5 */
1199 } *uap = (struct a *)u.u_ap;
1200 #endif /* UKERNEL */
1201 #if defined(AFS_DEC_ENV)
1202 int *retval = &u.u_r.r_val1;
1203 #elif defined(AFS_HPUX_ENV)
1204 long *retval = &u.u_rval1;
1206 int *retval = &u.u_rval1;
1208 #endif /* AFS_LINUX20_ENV */
1209 #endif /* AFS_OSF_ENV */
1210 #endif /* AFS_SUN5_ENV */
1211 register int code = 0;
1213 AFS_STATCNT(afs_syscall);
1220 #ifdef AFS_LINUX20_ENV
1222 /* setup uap for use below - pull out the magic decoder ring to know
1223 * which syscalls have folded argument lists.
1225 uap->syscall = syscall;
1229 if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
1230 #ifdef AFS_SPARC64_LINUX24_ENV
1231 /* from arch/sparc64/kernel/sys_sparc32.c */
1233 ({ unsigned long __ret; \
1234 __asm__ ("srl %0, 0, %0" \
1241 if (current->thread.flags & SPARC_FLAG_32BIT) {
1242 AFS_COPYIN((char*)parm4, (char*)eparm32, sizeof(eparm32), code);
1243 eparm[0]=AA(eparm32[0]);
1244 eparm[1]=AA(eparm32[1]);
1245 eparm[2]=AA(eparm32[2]);
1249 AFS_COPYIN((char*)parm4, (char*)eparm, sizeof(eparm), code);
1250 uap->parm4 = eparm[0];
1251 uap->parm5 = eparm[1];
1252 uap->parm6 = eparm[2];
1261 #if defined(AFS_HPUX_ENV)
1263 * There used to be code here (duplicated from osi_Init()) for
1264 * initializing the semaphore used by AFS_GLOCK(). Was the
1265 * duplication to handle the case of a dynamically loaded kernel
1270 if (uap->syscall == AFSCALL_CALL) {
1272 code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3,
1273 uap->parm4, uap->parm5, uap->parm6, rvp, CRED());
1275 code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, uap->parm6);
1277 } else if (uap->syscall == AFSCALL_SETPAG) {
1279 register proc_t *procp;
1281 procp = ttoproc(curthread);
1283 code = afs_setpag(&procp->p_cred);
1287 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1288 code = afs_setpag(p, args, retval);
1289 #else /* AFS_OSF_ENV */
1290 code = afs_setpag();
1294 } else if (uap->syscall == AFSCALL_PIOCTL) {
1297 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED());
1299 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1300 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->p_cred->pc_ucred);
1302 code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4);
1306 } else if (uap->syscall == AFSCALL_ICREATE) {
1307 struct iparam iparams;
1309 code = copyin_iparam((char *)uap->parm3, &iparams);
1311 #if defined(KERNEL_HAVE_UERROR)
1316 code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
1317 iparams.param3, iparams.param4, rvp, CRED());
1319 code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2,
1320 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1321 iparams.param3, iparams.param4, retval);
1323 iparams.param3, iparams.param4);
1325 #endif /* AFS_SUN5_ENV */
1326 } else if (uap->syscall == AFSCALL_IOPEN) {
1328 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED());
1330 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1331 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
1333 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
1335 #endif /* AFS_SUN5_ENV */
1336 } else if (uap->syscall == AFSCALL_IDEC) {
1338 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp, CRED());
1340 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1);
1341 #endif /* AFS_SUN5_ENV */
1342 } else if (uap->syscall == AFSCALL_IINC) {
1344 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp, CRED());
1346 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1);
1347 #endif /* AFS_SUN5_ENV */
1348 } else if (uap->syscall == AFSCALL_ICL) {
1350 code = Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, retval);
1352 #ifdef AFS_LINUX20_ENV
1354 /* ICL commands can return values. */
1355 code = -linux_ret; /* Gets negated again at exit below */
1359 #if defined(KERNEL_HAVE_UERROR)
1363 #endif /* !AFS_LINUX20_ENV */
1365 #if defined(KERNEL_HAVE_UERROR)
1372 #ifdef AFS_LINUX20_ENV
1378 #endif /* AFS_SGI_ENV */
1379 #endif /* !AFS_AIX32_ENV */
1382 * Initstate in the range 0 < x < 100 are early initialization states.
1383 * Initstate of 100 means a AFSOP_START operation has been done. After this,
1384 * the cache may be initialized.
1385 * Initstate of 101 means a AFSOP_GO operation has been done. This operation
1386 * is done after all the cache initialization has been done.
1387 * Initstate of 200 means that the volume has been looked up once, possibly
1389 * Initstate of 300 means that the volume has been *successfully* looked up.
1391 int afs_CheckInit(void)
1393 register int code = 0;
1395 AFS_STATCNT(afs_CheckInit);
1396 if (afs_initState <= 100)
1397 code = ENXIO; /* never finished init phase */
1398 else if (afs_initState == 101) { /* init done, wait for afs_daemon */
1399 while (afs_initState < 200) afs_osi_Sleep(&afs_initState);
1400 } else if (afs_initState == 200)
1401 code = ETIMEDOUT; /* didn't find root volume */
1405 int afs_shuttingdown = 0;
1406 void afs_shutdown(void)
1408 extern short afs_brsDaemons;
1409 extern afs_int32 afs_CheckServerDaemonStarted;
1410 extern struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler;
1411 extern struct osi_file *afs_cacheInodep;
1413 AFS_STATCNT(afs_shutdown);
1414 if (afs_shuttingdown) return;
1415 afs_shuttingdown = 1;
1416 if (afs_cold_shutdown) afs_warn("COLD ");
1417 else afs_warn("WARM ");
1418 afs_warn("shutting down of: CB... ");
1420 afs_termState = AFSOP_STOP_RXCALLBACK;
1421 rx_WakeupServerProcs();
1422 /* shutdown_rxkernel(); */
1423 while (afs_termState == AFSOP_STOP_RXCALLBACK)
1424 afs_osi_Sleep(&afs_termState);
1426 afs_warn("afs... ");
1427 while (afs_termState == AFSOP_STOP_AFS) {
1428 afs_osi_CancelWait(&AFS_WaitHandler);
1429 afs_osi_Sleep(&afs_termState);
1431 if (afs_CheckServerDaemonStarted) {
1432 while (afs_termState == AFSOP_STOP_CS) {
1433 afs_osi_CancelWait(&AFS_CSWaitHandler);
1434 afs_osi_Sleep(&afs_termState);
1437 afs_warn("BkG... ");
1438 /* Wake-up afs_brsDaemons so that we don't have to wait for a bkg job! */
1439 while (afs_termState == AFSOP_STOP_BKG) {
1440 afs_osi_Wakeup(&afs_brsDaemons);
1441 afs_osi_Sleep(&afs_termState);
1443 afs_warn("CTrunc... ");
1444 /* Cancel cache truncate daemon. */
1445 while (afs_termState == AFSOP_STOP_TRUNCDAEMON) {
1446 afs_osi_Wakeup((char*)&afs_CacheTruncateDaemon);
1447 afs_osi_Sleep(&afs_termState);
1449 #ifdef AFS_AFSDB_ENV
1450 afs_warn("AFSDB... ");
1452 while (afs_termState == AFSOP_STOP_AFSDB)
1453 afs_osi_Sleep(&afs_termState);
1455 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
1456 afs_warn("RxEvent... ");
1457 /* cancel rx event daemon */
1458 while (afs_termState == AFSOP_STOP_RXEVENT)
1459 afs_osi_Sleep(&afs_termState);
1460 #if defined(RXK_LISTENER_ENV)
1462 afs_warn("UnmaskRxkSignals... ");
1463 afs_osi_UnmaskRxkSignals();
1465 /* cancel rx listener */
1466 afs_warn("RxListener... ");
1467 osi_StopListener(); /* This closes rx_socket. */
1468 while (afs_termState == AFSOP_STOP_RXK_LISTENER) {
1469 afs_warn("Sleep... ");
1470 afs_osi_Sleep(&afs_termState);
1474 afs_termState = AFSOP_STOP_COMPLETE;
1478 /* Close file only after daemons which can write to it are stopped. */
1479 if (afs_cacheInodep) /* memcache won't set this */
1481 osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */
1482 afs_cacheInodep = 0;
1484 return; /* Just kill daemons for now */
1488 shutdown_rxkernel();
1492 shutdown_bufferpackage();
1498 shutdown_vnodeops();
1500 shutdown_exporter();
1501 shutdown_memcache();
1502 #if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)
1503 #if !defined(AFS_DEC_ENV) && !defined(AFS_OSF_ENV)
1504 /* this routine does not exist in Ultrix systems... 93.01.19 */
1506 #endif /* AFS_DEC_ENV */
1509 /* The following hold the cm stats */
1511 memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
1512 memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf));
1513 memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
1515 afs_warn(" ALL allocated tables\n");
1516 afs_shuttingdown = 0;
1520 void shutdown_afstest(void)
1522 AFS_STATCNT(shutdown_afstest);
1523 afs_initState = afs_termState = afs_setTime = 0;
1524 AFS_Running = afs_CB_Running = 0;
1525 afs_CacheInit_Done = afs_Go_Done = 0;
1526 if (afs_cold_shutdown) {
1527 *afs_rootVolumeName = 0;
1532 /* In case there is a bunch of dynamically build bkg daemons to free */
1533 void afs_shutdown_BKG(void)
1535 AFS_STATCNT(shutdown_BKG);
1539 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
1540 /* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
1541 #if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
1542 int afs_icl_sizeofLong = 1;
1544 int afs_icl_sizeofLong = 2;
1547 int afs_icl_sizeofLong = 1;
1550 int afs_icl_inited = 0;
1552 /* init function, called once, under afs_icl_lock */
1553 int afs_icl_Init(void)
1559 extern struct afs_icl_log *afs_icl_FindLog();
1560 extern struct afs_icl_set *afs_icl_FindSet();
1564 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
1566 afs_int32 *lp, elts, flags;
1567 register afs_int32 code;
1568 struct afs_icl_log *logp;
1569 struct afs_icl_set *setp;
1570 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1572 #else /* AFS_SGI61_ENV */
1574 #endif /* AFS_SGI61_ENV */
1576 afs_int32 startCookie;
1577 afs_int32 allocated;
1578 struct afs_icl_log *tlp;
1581 if (!afs_suser(CRED())) { /* only root can run this code */
1585 if (!afs_suser()) { /* only root can run this code */
1586 #if defined(KERNEL_HAVE_UERROR)
1595 case ICL_OP_COPYOUTCLR: /* copy out data then clear */
1596 case ICL_OP_COPYOUT: /* copy ouy data */
1597 /* copyout: p1=logname, p2=&buffer, p3=size(words), p4=&cookie
1598 * return flags<<24 + nwords.
1599 * updates cookie to updated start (not end) if we had to
1600 * skip some records.
1602 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1603 if (code) return code;
1604 AFS_COPYIN((char *)p4, (char *)&startCookie, sizeof(afs_int32), code);
1605 if (code) return code;
1606 logp = afs_icl_FindLog(tname);
1607 if (!logp) return ENOENT;
1608 #define BUFFERSIZE AFS_LRALLOCSIZ
1609 lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
1610 elts = BUFFERSIZE / sizeof(afs_int32);
1611 if (p3 < elts) elts = p3;
1612 flags = (opcode == ICL_OP_COPYOUT) ? 0 : ICL_COPYOUTF_CLRAFTERREAD;
1613 code = afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) &startCookie,
1616 osi_FreeLargeSpace((struct osi_buffer *) lp);
1619 AFS_COPYOUT((char *)lp, (char *)p2, elts * sizeof(afs_int32), code);
1620 if (code) goto done;
1621 AFS_COPYOUT((char *) &startCookie, (char *)p4, sizeof(afs_int32), code);
1622 if (code) goto done;
1623 *retval = (flags<<24) | (elts & 0xffffff);
1625 afs_icl_LogRele(logp);
1626 osi_FreeLargeSpace((struct osi_buffer *) lp);
1629 case ICL_OP_ENUMLOGS: /* enumerate logs */
1630 /* enumerate logs: p1=index, p2=&name, p3=sizeof(name), p4=&size.
1631 * return 0 for success, otherwise error.
1633 for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) {
1634 if (p1-- == 0) break;
1636 if (!tlp) return ENOENT; /* past the end of file */
1637 temp = strlen(tlp->name)+1;
1638 if (temp > p3) return EINVAL;
1639 AFS_COPYOUT(tlp->name, (char *) p2, temp, code);
1640 if (!code) /* copy out size of log */
1641 AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof (afs_int32), code);
1644 case ICL_OP_ENUMLOGSBYSET: /* enumerate logs by set name */
1645 /* enumerate logs: p1=setname, p2=index, p3=&name, p4=sizeof(name).
1646 * return 0 for success, otherwise error.
1648 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1649 if (code) return code;
1650 setp = afs_icl_FindSet(tname);
1651 if (!setp) return ENOENT;
1652 if (p2 > ICL_LOGSPERSET)
1654 if (!(tlp = setp->logs[p2]))
1656 temp = strlen(tlp->name)+1;
1657 if (temp > p4) return EINVAL;
1658 AFS_COPYOUT(tlp->name, (char *)p3, temp, code);
1661 case ICL_OP_CLRLOG: /* clear specified log */
1662 /* zero out the specified log: p1=logname */
1663 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1664 if (code) return code;
1665 logp = afs_icl_FindLog(tname);
1666 if (!logp) return ENOENT;
1667 code = afs_icl_ZeroLog(logp);
1668 afs_icl_LogRele(logp);
1671 case ICL_OP_CLRSET: /* clear specified set */
1672 /* zero out the specified set: p1=setname */
1673 AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code);
1674 if (code) return code;
1675 setp = afs_icl_FindSet(tname);
1676 if (!setp) return ENOENT;
1677 code = afs_icl_ZeroSet(setp);
1678 afs_icl_SetRele(setp);
1681 case ICL_OP_CLRALL: /* clear all logs */
1682 /* zero out all logs -- no args */
1684 ObtainWriteLock(&afs_icl_lock,178);
1685 for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) {
1686 tlp->refCount++; /* hold this guy */
1687 ReleaseWriteLock(&afs_icl_lock);
1688 /* don't clear persistent logs */
1689 if ((tlp->states & ICL_LOGF_PERSISTENT) == 0)
1690 code = afs_icl_ZeroLog(tlp);
1691 ObtainWriteLock(&afs_icl_lock,179);
1692 if (--tlp->refCount == 0)
1693 afs_icl_ZapLog(tlp);
1696 ReleaseWriteLock(&afs_icl_lock);
1699 case ICL_OP_ENUMSETS: /* enumerate all sets */
1700 /* enumerate sets: p1=index, p2=&name, p3=sizeof(name), p4=&states.
1701 * return 0 for success, otherwise error.
1703 for(setp = afs_icl_allSets; setp; setp = setp->nextp) {
1704 if (p1-- == 0) break;
1706 if (!setp) return ENOENT; /* past the end of file */
1707 temp = strlen(setp->name)+1;
1708 if (temp > p3) return EINVAL;
1709 AFS_COPYOUT(setp->name, (char *)p2, temp, code);
1710 if (!code) /* copy out size of log */
1711 AFS_COPYOUT((char *)&setp->states,(char *)p4, sizeof (afs_int32), code);
1714 case ICL_OP_SETSTAT: /* set status on a set */
1715 /* activate the specified set: p1=setname, p2=op */
1716 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1717 if (code) return code;
1718 setp = afs_icl_FindSet(tname);
1719 if (!setp) return ENOENT;
1720 code = afs_icl_SetSetStat(setp, p2);
1721 afs_icl_SetRele(setp);
1724 case ICL_OP_SETSTATALL: /* set status on all sets */
1725 /* activate the specified set: p1=op */
1727 ObtainWriteLock(&afs_icl_lock,180);
1728 for(setp = afs_icl_allSets; setp; setp=setp->nextp) {
1729 setp->refCount++; /* hold this guy */
1730 ReleaseWriteLock(&afs_icl_lock);
1731 /* don't set states on persistent sets */
1732 if ((setp->states & ICL_SETF_PERSISTENT) == 0)
1733 code = afs_icl_SetSetStat(setp, p1);
1734 ObtainWriteLock(&afs_icl_lock,181);
1735 if (--setp->refCount == 0)
1736 afs_icl_ZapSet(setp);
1739 ReleaseWriteLock(&afs_icl_lock);
1742 case ICL_OP_SETLOGSIZE: /* set size of log */
1743 /* set the size of the specified log: p1=logname, p2=size (in words) */
1744 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1745 if (code) return code;
1746 logp = afs_icl_FindLog(tname);
1747 if (!logp) return ENOENT;
1748 code = afs_icl_LogSetSize(logp, p2);
1749 afs_icl_LogRele(logp);
1752 case ICL_OP_GETLOGINFO: /* get size of log */
1753 /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */
1754 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1755 if (code) return code;
1756 logp = afs_icl_FindLog(tname);
1757 if (!logp) return ENOENT;
1758 allocated = !!logp->datap;
1759 AFS_COPYOUT((char *)&logp->logSize, (char *) p2, sizeof(afs_int32), code);
1761 AFS_COPYOUT((char *)&allocated, (char *) p3, sizeof(afs_int32), code);
1762 afs_icl_LogRele(logp);
1765 case ICL_OP_GETSETINFO: /* get state of set */
1766 /* zero out the specified set: p1=setname, p2=&state */
1767 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1768 if (code) return code;
1769 setp = afs_icl_FindSet(tname);
1770 if (!setp) return ENOENT;
1771 AFS_COPYOUT((char *)&setp->states, (char *) p2, sizeof(afs_int32), code);
1772 afs_icl_SetRele(setp);
1783 afs_lock_t afs_icl_lock;
1785 /* exported routine: a 4 parameter event */
1786 int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
1787 afs_int32 lAndT, long p1, long p2, long p3, long p4)
1791 register afs_int32 tmask;
1794 /* If things aren't init'ed yet (or the set is inactive), don't panic */
1795 if (!ICL_SETACTIVE(setp))
1799 mask = lAndT>>24 & 0xff; /* mask of which logs to log to */
1800 ix = ICL_EVENTBYTE(eventID);
1801 ObtainReadLock(&setp->lock);
1802 if (setp->eventFlags[ix] & ICL_EVENTMASK(eventID)) {
1803 for(i=0, tmask = 1; i<ICL_LOGSPERSET; i++, tmask <<= 1) {
1805 afs_icl_AppendRecord(setp->logs[i], eventID, lAndT & 0xffffff,
1809 if (mask == 0) break; /* break early */
1812 ReleaseReadLock(&setp->lock);
1816 /* Next 4 routines should be implemented via var-args or something.
1817 * Whole purpose is to avoid compiler warnings about parameter # mismatches.
1818 * Otherwise, could call afs_icl_Event4 directly.
1820 int afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID,
1821 afs_int32 lAndT, long p1, long p2, long p3)
1823 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
1826 int afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID,
1827 afs_int32 lAndT, long p1, long p2)
1829 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
1832 int afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
1833 afs_int32 lAndT, long p1)
1835 return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0, (long)0);
1838 int afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID,
1841 return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0, (long)0);
1844 struct afs_icl_log *afs_icl_allLogs = 0;
1846 /* function to purge records from the start of the log, until there
1847 * is at least minSpace long's worth of space available without
1848 * making the head and the tail point to the same word.
1850 * Log must be write-locked.
1852 static void afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
1854 register unsigned int tsize;
1856 while (logp->logSize - logp->logElements <= minSpace) {
1858 tsize = ((logp->datap[logp->firstUsed]) >> 24) & 0xff;
1859 logp->logElements -= tsize;
1860 logp->firstUsed += tsize;
1861 if (logp->firstUsed >= logp->logSize)
1862 logp->firstUsed -= logp->logSize;
1863 logp->baseCookie += tsize;
1867 /* append string astr to buffer, including terminating null char.
1869 * log must be write-locked.
1871 #define ICL_CHARSPERLONG 4
1872 static void afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
1874 char *op; /* ptr to char to write */
1876 register int bib; /* bytes in buffer */
1879 op = (char *) &(logp->datap[logp->firstFree]);
1883 if (++bib >= ICL_CHARSPERLONG) {
1886 if (++(logp->firstFree) >= logp->logSize) {
1887 logp->firstFree = 0;
1888 op = (char *) &(logp->datap[0]);
1890 logp->logElements++;
1895 /* if we've used this word at all, allocate it */
1896 if (++(logp->firstFree) >= logp->logSize) {
1897 logp->firstFree = 0;
1899 logp->logElements++;
1903 /* add a long to the log, ignoring overflow (checked already) */
1904 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
1905 #define ICL_APPENDINT32(lp, x) \
1907 (lp)->datap[(lp)->firstFree] = (x); \
1908 if (++((lp)->firstFree) >= (lp)->logSize) { \
1909 (lp)->firstFree = 0; \
1911 (lp)->logElements++; \
1914 #define ICL_APPENDLONG(lp, x) \
1916 ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
1917 ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
1920 #else /* AFS_ALPHA_ENV */
1921 #define ICL_APPENDLONG(lp, x) \
1923 (lp)->datap[(lp)->firstFree] = (x); \
1924 if (++((lp)->firstFree) >= (lp)->logSize) { \
1925 (lp)->firstFree = 0; \
1927 (lp)->logElements++; \
1929 #define ICL_APPENDINT32(lp, x) ICL_APPENDLONG((lp), (x))
1930 #endif /* AFS_ALPHA_ENV */
1932 /* routine to tell whether we're dealing with the address or the
1935 int afs_icl_UseAddr(int type)
1937 if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
1938 || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
1944 /* Function to append a record to the log. Written for speed
1945 * since we know that we're going to have to make this work fast
1946 * pretty soon, anyway. The log must be unlocked.
1949 void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
1950 afs_int32 types, long p1, long p2, long p3, long p4)
1952 int rsize; /* record size in longs */
1953 register int tsize; /* temp size */
1957 t4 = types & 0x3f; /* decode types */
1965 osi_GetTime(&tv); /* It panics for solaris if inside */
1966 ObtainWriteLock(&logp->lock,182);
1968 ReleaseWriteLock(&logp->lock);
1972 /* get timestamp as # of microseconds since some time that doesn't
1973 * change that often. This algorithm ticks over every 20 minutes
1974 * or so (1000 seconds). Write a timestamp record if it has.
1976 if (tv.tv_sec - logp->lastTS > 1024)
1978 /* the timer has wrapped -- write a timestamp record */
1979 if (logp->logSize - logp->logElements <= 5)
1980 afs_icl_GetLogSpace(logp, 5);
1982 ICL_APPENDINT32(logp, (afs_int32)(5<<24) + (ICL_TYPE_UNIXDATE<<18));
1983 ICL_APPENDINT32(logp, (afs_int32)ICL_INFO_TIMESTAMP);
1984 ICL_APPENDINT32(logp, (afs_int32)0); /* use thread ID zero for clocks */
1985 ICL_APPENDINT32(logp,
1986 (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
1987 ICL_APPENDINT32(logp, (afs_int32)tv.tv_sec);
1989 logp->lastTS = tv.tv_sec;
1992 rsize = 4; /* base case */
1994 /* compute size of parameter p1. Only tricky case is string.
1995 * In that case, we have to call strlen to get the string length.
1997 ICL_SIZEHACK(t1, p1);
2000 /* compute size of parameter p2. Only tricky case is string.
2001 * In that case, we have to call strlen to get the string length.
2003 ICL_SIZEHACK(t2, p2);
2006 /* compute size of parameter p3. Only tricky case is string.
2007 * In that case, we have to call strlen to get the string length.
2009 ICL_SIZEHACK(t3, p3);
2012 /* compute size of parameter p4. Only tricky case is string.
2013 * In that case, we have to call strlen to get the string length.
2015 ICL_SIZEHACK(t4, p4);
2018 /* At this point, we've computed all of the parameter sizes, and
2019 * have in rsize the size of the entire record we want to append.
2020 * Next, we check that we actually have room in the log to do this
2021 * work, and then we do the append.
2024 ReleaseWriteLock(&logp->lock);
2025 return; /* log record too big to express */
2028 if (logp->logSize - logp->logElements <= rsize)
2029 afs_icl_GetLogSpace(logp, rsize);
2031 ICL_APPENDINT32(logp,
2032 (afs_int32)(rsize<<24) + (t1<<18) + (t2<<12) + (t3<<6) + t4);
2033 ICL_APPENDINT32(logp, (afs_int32)op);
2034 ICL_APPENDINT32(logp, (afs_int32)osi_ThreadUnique());
2035 ICL_APPENDINT32(logp, (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
2038 /* marshall parameter 1 now */
2039 if (t1 == ICL_TYPE_STRING) {
2040 afs_icl_AppendString(logp, (char *) p1);
2042 else if (t1 == ICL_TYPE_HYPER) {
2043 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->high);
2044 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->low);
2046 else if (t1 == ICL_TYPE_INT64) {
2047 #ifdef AFSLITTLE_ENDIAN
2048 #ifdef AFS_64BIT_CLIENT
2049 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2050 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2051 #else /* AFS_64BIT_CLIENT */
2052 ICL_APPENDINT32(logp, (afs_int32) p1);
2053 ICL_APPENDINT32(logp, (afs_int32) 0);
2054 #endif /* AFS_64BIT_CLIENT */
2055 #else /* AFSLITTLE_ENDIAN */
2056 #ifdef AFS_64BIT_CLIENT
2057 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2058 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2059 #else /* AFS_64BIT_CLIENT */
2060 ICL_APPENDINT32(logp, (afs_int32) 0);
2061 ICL_APPENDINT32(logp, (afs_int32) p1);
2062 #endif /* AFS_64BIT_CLIENT */
2063 #endif /* AFSLITTLE_ENDIAN */
2065 else if (t1 == ICL_TYPE_FID) {
2066 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]);
2067 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]);
2068 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[2]);
2069 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[3]);
2071 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2072 else if (t1 == ICL_TYPE_INT32)
2073 ICL_APPENDINT32(logp, (afs_int32)p1);
2074 #endif /* AFS_ALPHA_ENV */
2075 else ICL_APPENDLONG(logp, p1);
2078 /* marshall parameter 2 now */
2079 if (t2 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p2);
2080 else if (t2 == ICL_TYPE_HYPER) {
2081 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->high);
2082 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->low);
2084 else if (t2 == ICL_TYPE_INT64) {
2085 #ifdef AFSLITTLE_ENDIAN
2086 #ifdef AFS_64BIT_CLIENT
2087 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2088 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2089 #else /* AFS_64BIT_CLIENT */
2090 ICL_APPENDINT32(logp, (afs_int32) p2);
2091 ICL_APPENDINT32(logp, (afs_int32) 0);
2092 #endif /* AFS_64BIT_CLIENT */
2093 #else /* AFSLITTLE_ENDIAN */
2094 #ifdef AFS_64BIT_CLIENT
2095 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2096 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2097 #else /* AFS_64BIT_CLIENT */
2098 ICL_APPENDINT32(logp, (afs_int32) 0);
2099 ICL_APPENDINT32(logp, (afs_int32) p2);
2100 #endif /* AFS_64BIT_CLIENT */
2101 #endif /* AFSLITTLE_ENDIAN */
2103 else if (t2 == ICL_TYPE_FID) {
2104 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]);
2105 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]);
2106 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[2]);
2107 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[3]);
2109 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2110 else if (t2 == ICL_TYPE_INT32)
2111 ICL_APPENDINT32(logp, (afs_int32)p2);
2112 #endif /* AFS_ALPHA_ENV */
2113 else ICL_APPENDLONG(logp, p2);
2116 /* marshall parameter 3 now */
2117 if (t3 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p3);
2118 else if (t3 == ICL_TYPE_HYPER) {
2119 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->high);
2120 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->low);
2122 else if (t3 == ICL_TYPE_INT64) {
2123 #ifdef AFSLITTLE_ENDIAN
2124 #ifdef AFS_64BIT_CLIENT
2125 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2126 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2127 #else /* AFS_64BIT_CLIENT */
2128 ICL_APPENDINT32(logp, (afs_int32) p3);
2129 ICL_APPENDINT32(logp, (afs_int32) 0);
2130 #endif /* AFS_64BIT_CLIENT */
2131 #else /* AFSLITTLE_ENDIAN */
2132 #ifdef AFS_64BIT_CLIENT
2133 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2134 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2135 #else /* AFS_64BIT_CLIENT */
2136 ICL_APPENDINT32(logp, (afs_int32) 0);
2137 ICL_APPENDINT32(logp, (afs_int32) p3);
2138 #endif /* AFS_64BIT_CLIENT */
2139 #endif /* AFSLITTLE_ENDIAN */
2141 else if (t3 == ICL_TYPE_FID) {
2142 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]);
2143 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]);
2144 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[2]);
2145 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[3]);
2147 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2148 else if (t3 == ICL_TYPE_INT32)
2149 ICL_APPENDINT32(logp, (afs_int32)p3);
2150 #endif /* AFS_ALPHA_ENV */
2151 else ICL_APPENDLONG(logp, p3);
2154 /* marshall parameter 4 now */
2155 if (t4 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p4);
2156 else if (t4 == ICL_TYPE_HYPER) {
2157 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->high);
2158 ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->low);
2160 else if (t4 == ICL_TYPE_INT64) {
2161 #ifdef AFSLITTLE_ENDIAN
2162 #ifdef AFS_64BIT_CLIENT
2163 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2164 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2165 #else /* AFS_64BIT_CLIENT */
2166 ICL_APPENDINT32(logp, (afs_int32) p4);
2167 ICL_APPENDINT32(logp, (afs_int32) 0);
2168 #endif /* AFS_64BIT_CLIENT */
2169 #else /* AFSLITTLE_ENDIAN */
2170 #ifdef AFS_64BIT_CLIENT
2171 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2172 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2173 #else /* AFS_64BIT_CLIENT */
2174 ICL_APPENDINT32(logp, (afs_int32) 0);
2175 ICL_APPENDINT32(logp, (afs_int32) p4);
2176 #endif /* AFS_64BIT_CLIENT */
2177 #endif /* AFSLITTLE_ENDIAN */
2179 else if (t4 == ICL_TYPE_FID) {
2180 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]);
2181 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]);
2182 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[2]);
2183 ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[3]);
2185 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
2186 else if (t4 == ICL_TYPE_INT32)
2187 ICL_APPENDINT32(logp, (afs_int32)p4);
2188 #endif /* AFS_ALPHA_ENV */
2189 else ICL_APPENDLONG(logp, p4);
2191 ReleaseWriteLock(&logp->lock);
2194 /* create a log with size logSize; return it in *outLogpp and tag
2195 * it with name "name."
2197 int afs_icl_CreateLog(char *name, afs_int32 logSize, struct afs_icl_log **outLogpp)
2199 return afs_icl_CreateLogWithFlags(name, logSize, /*flags*/0, outLogpp);
2202 /* create a log with size logSize; return it in *outLogpp and tag
2203 * it with name "name." 'flags' can be set to make the log unclearable.
2205 int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
2206 struct afs_icl_log **outLogpp)
2208 register struct afs_icl_log *logp;
2210 /* add into global list under lock */
2211 ObtainWriteLock(&afs_icl_lock,183);
2212 if (!afs_icl_inited) afs_icl_Init();
2214 for (logp = afs_icl_allLogs; logp; logp=logp->nextp) {
2215 if (strcmp(logp->name, name) == 0) {
2216 /* found it already created, just return it */
2219 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2221 ObtainWriteLock(&logp->lock,184);
2222 logp->states |= ICL_LOGF_PERSISTENT;
2223 ReleaseWriteLock(&logp->lock);
2225 ReleaseWriteLock(&afs_icl_lock);
2230 logp = (struct afs_icl_log *)
2231 osi_AllocSmallSpace(sizeof(struct afs_icl_log));
2232 memset((caddr_t)logp, 0, sizeof(*logp));
2235 logp->name = osi_AllocSmallSpace(strlen(name)+1);
2236 strcpy(logp->name, name);
2237 LOCK_INIT(&logp->lock, "logp lock");
2238 logp->logSize = logSize;
2239 logp->datap = NULL; /* don't allocate it until we need it */
2241 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2242 logp->states |= ICL_LOGF_PERSISTENT;
2244 logp->nextp = afs_icl_allLogs;
2245 afs_icl_allLogs = logp;
2246 ReleaseWriteLock(&afs_icl_lock);
2252 /* called with a log, a pointer to a buffer, the size of the buffer
2253 * (in *bufSizep), the starting cookie (in *cookiep, use 0 at the start)
2254 * and returns data in the provided buffer, and returns output flags
2255 * in *flagsp. The flag ICL_COPYOUTF_MISSEDSOME is set if we can't
2256 * find the record with cookie value cookie.
2258 int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp,
2259 afs_int32 *bufSizep, afs_uint32 *cookiep, afs_int32 *flagsp)
2261 afs_int32 nwords; /* number of words to copy out */
2262 afs_uint32 startCookie; /* first cookie to use */
2263 afs_int32 outWords; /* words we've copied out */
2264 afs_int32 inWords; /* max words to copy out */
2265 afs_int32 code; /* return code */
2266 afs_int32 ix; /* index we're copying from */
2267 afs_int32 outFlags; /* return flags */
2268 afs_int32 inFlags; /* flags passed in */
2271 inWords = *bufSizep; /* max to copy out */
2272 outWords = 0; /* amount copied out */
2273 startCookie = *cookiep;
2278 ObtainWriteLock(&logp->lock,185);
2280 ReleaseWriteLock(&logp->lock);
2284 /* first, compute the index of the start cookie we've been passed */
2286 /* (re-)compute where we should start */
2287 if (startCookie < logp->baseCookie) {
2288 if (startCookie) /* missed some output */
2289 outFlags |= ICL_COPYOUTF_MISSEDSOME;
2290 /* skip to the first available record */
2291 startCookie = logp->baseCookie;
2292 *cookiep = startCookie;
2295 /* compute where we find the first element to copy out */
2296 ix = logp->firstUsed + startCookie - logp->baseCookie;
2297 if (ix >= logp->logSize) ix -= logp->logSize;
2299 /* if have some data now, break out and process it */
2300 if (startCookie - logp->baseCookie < logp->logElements) break;
2302 /* At end of log, so clear it if we need to */
2303 if (inFlags & ICL_COPYOUTF_CLRAFTERREAD)
2305 logp->firstUsed = logp->firstFree = 0;
2306 logp->logElements = 0;
2308 /* otherwise, either wait for the data to arrive, or return */
2309 if (!(inFlags & ICL_COPYOUTF_WAITIO)) {
2310 ReleaseWriteLock(&logp->lock);
2314 logp->states |= ICL_LOGF_WAITING;
2315 ReleaseWriteLock(&logp->lock);
2316 afs_osi_Sleep(&logp->lock);
2317 ObtainWriteLock(&logp->lock,186);
2319 /* copy out data from ix to logSize or firstFree, depending
2320 * upon whether firstUsed <= firstFree (no wrap) or otherwise.
2321 * be careful not to copy out more than nwords.
2323 if (ix >= logp->firstUsed) {
2324 if (logp->firstUsed <= logp->firstFree)
2326 end = logp->firstFree; /* first element not to copy */
2328 end = logp->logSize;
2329 nwords = inWords; /* don't copy more than this */
2330 if (end - ix < nwords)
2333 memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
2338 /* if we're going to copy more out below, we'll start here */
2341 /* now, if active part of the log has wrapped, there's more stuff
2342 * starting at the head of the log. Copy out more from there.
2344 if (logp->firstUsed > logp->firstFree
2345 && ix < logp->firstFree && inWords > 0) {
2346 /* (more to) copy out from the wrapped section at the
2347 * start of the log. May get here even if didn't copy any
2348 * above, if the cookie points directly into the wrapped section.
2351 if (logp->firstFree - ix < nwords)
2352 nwords = logp->firstFree - ix;
2353 memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords);
2359 ReleaseWriteLock(&logp->lock);
2363 *bufSizep = outWords;
2369 /* return basic parameter information about a log */
2370 int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep,
2371 afs_int32 *curSizep)
2373 ObtainReadLock(&logp->lock);
2374 *maxSizep = logp->logSize;
2375 *curSizep = logp->logElements;
2376 ReleaseReadLock(&logp->lock);
2381 /* hold and release logs */
2382 int afs_icl_LogHold(register struct afs_icl_log *logp)
2384 ObtainWriteLock(&afs_icl_lock,187);
2386 ReleaseWriteLock(&afs_icl_lock);
2390 /* hold and release logs, called with lock already held */
2391 int afs_icl_LogHoldNL(register struct afs_icl_log *logp)
2397 /* keep track of how many sets believe the log itself is allocated */
2398 int afs_icl_LogUse(register struct afs_icl_log *logp)
2400 ObtainWriteLock(&logp->lock,188);
2401 if (logp->setCount == 0) {
2402 /* this is the first set actually using the log -- allocate it */
2403 if (logp->logSize == 0) {
2404 /* we weren't passed in a hint and it wasn't set */
2405 logp->logSize = ICL_DEFAULT_LOGSIZE;
2407 logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
2408 #ifdef KERNEL_HAVE_PIN
2409 pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2413 ReleaseWriteLock(&logp->lock);
2417 /* decrement the number of real users of the log, free if possible */
2418 int afs_icl_LogFreeUse(register struct afs_icl_log *logp)
2420 ObtainWriteLock(&logp->lock,189);
2421 if (--logp->setCount == 0) {
2422 /* no more users -- free it (but keep log structure around)*/
2423 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2424 #ifdef KERNEL_HAVE_PIN
2425 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2427 logp->firstUsed = logp->firstFree = 0;
2428 logp->logElements = 0;
2431 ReleaseWriteLock(&logp->lock);
2435 /* set the size of the log to 'logSize' */
2436 int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
2438 ObtainWriteLock(&logp->lock,190);
2440 /* nothing to worry about since it's not allocated */
2441 logp->logSize = logSize;
2445 logp->firstUsed = logp->firstFree = 0;
2446 logp->logElements = 0;
2448 /* free and allocate a new one */
2449 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2450 #ifdef KERNEL_HAVE_PIN
2451 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2453 logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
2454 #ifdef KERNEL_HAVE_PIN
2455 pin((char *)logp->datap, sizeof(afs_int32) * logSize);
2457 logp->logSize = logSize;
2459 ReleaseWriteLock(&logp->lock);
2464 /* free a log. Called with afs_icl_lock locked. */
2465 int afs_icl_ZapLog(register struct afs_icl_log *logp)
2467 register struct afs_icl_log **lpp, *tp;
2469 for(lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2471 /* found the dude we want to remove */
2473 osi_FreeSmallSpace(logp->name);
2474 osi_FreeSmallSpace(logp->datap);
2475 osi_FreeSmallSpace(logp);
2476 break; /* won't find it twice */
2482 /* do the release, watching for deleted entries */
2483 int afs_icl_LogRele(register struct afs_icl_log *logp)
2485 ObtainWriteLock(&afs_icl_lock,191);
2486 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2487 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2489 ReleaseWriteLock(&afs_icl_lock);
2493 /* do the release, watching for deleted entries, log already held */
2494 int afs_icl_LogReleNL(register struct afs_icl_log *logp)
2496 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2497 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2502 /* zero out the log */
2503 int afs_icl_ZeroLog(register struct afs_icl_log *logp)
2505 ObtainWriteLock(&logp->lock,192);
2506 logp->firstUsed = logp->firstFree = 0;
2507 logp->logElements = 0;
2508 logp->baseCookie = 0;
2509 ReleaseWriteLock(&logp->lock);
2513 /* free a log entry, and drop its reference count */
2514 int afs_icl_LogFree(register struct afs_icl_log *logp)
2516 ObtainWriteLock(&logp->lock,193);
2517 logp->states |= ICL_LOGF_DELETED;
2518 ReleaseWriteLock(&logp->lock);
2519 afs_icl_LogRele(logp);
2523 /* find a log by name, returning it held */
2524 struct afs_icl_log *afs_icl_FindLog(char *name)
2526 register struct afs_icl_log *tp;
2527 ObtainWriteLock(&afs_icl_lock,194);
2528 for(tp = afs_icl_allLogs; tp; tp=tp->nextp) {
2529 if (strcmp(tp->name, name) == 0) {
2530 /* this is the dude we want */
2535 ReleaseWriteLock(&afs_icl_lock);
2539 int afs_icl_EnumerateLogs(int (*aproc)(), char *arock)
2541 register struct afs_icl_log *tp;
2542 register afs_int32 code;
2545 ObtainWriteLock(&afs_icl_lock,195);
2546 for(tp = afs_icl_allLogs; tp; tp=tp->nextp) {
2547 tp->refCount++; /* hold this guy */
2548 ReleaseWriteLock(&afs_icl_lock);
2549 ObtainReadLock(&tp->lock);
2550 code = (*aproc)(tp->name, arock, tp);
2551 ReleaseReadLock(&tp->lock);
2552 ObtainWriteLock(&afs_icl_lock,196);
2553 if (--tp->refCount == 0)
2557 ReleaseWriteLock(&afs_icl_lock);
2561 struct afs_icl_set *afs_icl_allSets = 0;
2563 int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp,
2564 struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp)
2566 return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp,
2567 /*flags*/0, outSetpp);
2570 /* create a set, given pointers to base and fatal logs, if any.
2571 * Logs are unlocked, but referenced, and *outSetpp is returned
2572 * referenced. Function bumps reference count on logs, since it
2573 * addds references from the new afs_icl_set. When the set is destroyed,
2574 * those references will be released.
2576 int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
2577 struct afs_icl_log *fatalLogp, afs_uint32 flags, struct afs_icl_set **outSetpp)
2579 register struct afs_icl_set *setp;
2581 afs_int32 states = ICL_DEFAULT_SET_STATES;
2583 ObtainWriteLock(&afs_icl_lock,197);
2584 if (!afs_icl_inited) afs_icl_Init();
2586 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
2587 if (strcmp(setp->name, name) == 0) {
2590 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2592 ObtainWriteLock(&setp->lock,198);
2593 setp->states |= ICL_SETF_PERSISTENT;
2594 ReleaseWriteLock(&setp->lock);
2596 ReleaseWriteLock(&afs_icl_lock);
2601 /* determine initial state */
2602 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2603 states = ICL_SETF_ACTIVE;
2604 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2605 states = ICL_SETF_FREED;
2606 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2607 states |= ICL_SETF_PERSISTENT;
2609 setp = (struct afs_icl_set *) afs_osi_Alloc(sizeof(struct afs_icl_set));
2610 memset((caddr_t)setp, 0, sizeof(*setp));
2612 if (states & ICL_SETF_FREED)
2613 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2614 setp->states = states;
2616 LOCK_INIT(&setp->lock, "setp lock");
2617 /* next lock is obtained in wrong order, hierarchy-wise, but
2618 * it doesn't matter, since no one can find this lock yet, since
2619 * the afs_icl_lock is still held, and thus the obtain can't block.
2621 ObtainWriteLock(&setp->lock,199);
2622 setp->name = osi_AllocSmallSpace(strlen(name)+1);
2623 strcpy(setp->name, name);
2624 setp->nevents = ICL_DEFAULTEVENTS;
2625 setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
2626 #ifdef KERNEL_HAVE_PIN
2627 pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2629 for(i=0; i<ICL_DEFAULTEVENTS; i++)
2630 setp->eventFlags[i] = 0xff; /* default to enabled */
2632 /* update this global info under the afs_icl_lock */
2633 setp->nextp = afs_icl_allSets;
2634 afs_icl_allSets = setp;
2635 ReleaseWriteLock(&afs_icl_lock);
2637 /* set's basic lock is still held, so we can finish init */
2639 setp->logs[0] = baseLogp;
2640 afs_icl_LogHold(baseLogp);
2641 if (!(setp->states & ICL_SETF_FREED))
2642 afs_icl_LogUse(baseLogp); /* log is actually being used */
2645 setp->logs[1] = fatalLogp;
2646 afs_icl_LogHold(fatalLogp);
2647 if (!(setp->states & ICL_SETF_FREED))
2648 afs_icl_LogUse(fatalLogp); /* log is actually being used */
2650 ReleaseWriteLock(&setp->lock);
2656 /* function to change event enabling information for a particular set */
2657 int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
2661 ObtainWriteLock(&setp->lock,200);
2662 if (!ICL_EVENTOK(setp, eventID)) {
2663 ReleaseWriteLock(&setp->lock);
2666 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2668 *tp |= ICL_EVENTMASK(eventID);
2670 *tp &= ~(ICL_EVENTMASK(eventID));
2671 ReleaseWriteLock(&setp->lock);
2675 /* return indication of whether a particular event ID is enabled
2676 * for tracing. If *getValuep is set to 0, the event is disabled,
2677 * otherwise it is enabled. All events start out enabled by default.
2679 int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID,
2682 ObtainReadLock(&setp->lock);
2683 if (!ICL_EVENTOK(setp, eventID)) {
2684 ReleaseWriteLock(&setp->lock);
2687 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2691 ReleaseReadLock(&setp->lock);
2695 /* hold and release event sets */
2696 int afs_icl_SetHold(register struct afs_icl_set *setp)
2698 ObtainWriteLock(&afs_icl_lock,201);
2700 ReleaseWriteLock(&afs_icl_lock);
2704 /* free a set. Called with afs_icl_lock locked */
2705 int afs_icl_ZapSet(register struct afs_icl_set *setp)
2707 register struct afs_icl_set **lpp, *tp;
2709 register struct afs_icl_log *tlp;
2711 for(lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2713 /* found the dude we want to remove */
2715 osi_FreeSmallSpace(setp->name);
2716 afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
2717 #ifdef KERNEL_HAVE_PIN
2718 unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2720 for(i=0; i < ICL_LOGSPERSET; i++) {
2721 if ((tlp = setp->logs[i]))
2722 afs_icl_LogReleNL(tlp);
2724 osi_FreeSmallSpace(setp);
2725 break; /* won't find it twice */
2731 /* do the release, watching for deleted entries */
2732 int afs_icl_SetRele(register struct afs_icl_set *setp)
2734 ObtainWriteLock(&afs_icl_lock,202);
2735 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2736 afs_icl_ZapSet(setp); /* destroys setp's lock! */
2738 ReleaseWriteLock(&afs_icl_lock);
2742 /* free a set entry, dropping its reference count */
2743 int afs_icl_SetFree(register struct afs_icl_set *setp)
2745 ObtainWriteLock(&setp->lock,203);
2746 setp->states |= ICL_SETF_DELETED;
2747 ReleaseWriteLock(&setp->lock);
2748 afs_icl_SetRele(setp);
2752 /* find a set by name, returning it held */
2753 struct afs_icl_set *afs_icl_FindSet(char *name)
2755 register struct afs_icl_set *tp;
2756 ObtainWriteLock(&afs_icl_lock,204);
2757 for(tp = afs_icl_allSets; tp; tp=tp->nextp) {
2758 if (strcmp(tp->name, name) == 0) {
2759 /* this is the dude we want */
2764 ReleaseWriteLock(&afs_icl_lock);
2768 /* zero out all the logs in the set */
2769 int afs_icl_ZeroSet(struct afs_icl_set *setp)
2774 struct afs_icl_log *logp;
2776 ObtainReadLock(&setp->lock);
2777 for(i = 0; i < ICL_LOGSPERSET; i++) {
2778 logp = setp->logs[i];
2780 afs_icl_LogHold(logp);
2781 tcode = afs_icl_ZeroLog(logp);
2782 if (tcode != 0) code = tcode; /* save the last bad one */
2783 afs_icl_LogRele(logp);
2786 ReleaseReadLock(&setp->lock);
2790 int afs_icl_EnumerateSets(int (*aproc)(), char *arock)
2792 register struct afs_icl_set *tp, *np;
2793 register afs_int32 code;
2796 ObtainWriteLock(&afs_icl_lock,205);
2797 for(tp = afs_icl_allSets; tp; tp=np) {
2798 tp->refCount++; /* hold this guy */
2799 ReleaseWriteLock(&afs_icl_lock);
2800 code = (*aproc)(tp->name, arock, tp);
2801 ObtainWriteLock(&afs_icl_lock,206);
2802 np = tp->nextp; /* tp may disappear next, but not np */
2803 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2807 ReleaseWriteLock(&afs_icl_lock);
2811 int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
2816 ObtainWriteLock(&setp->lock,207);
2817 for(i = 0; i < ICL_LOGSPERSET; i++) {
2818 if (!setp->logs[i]) {
2819 setp->logs[i] = newlogp;
2821 afs_icl_LogHold(newlogp);
2822 if (!(setp->states & ICL_SETF_FREED)) {
2823 /* bump up the number of sets using the log */
2824 afs_icl_LogUse(newlogp);
2829 ReleaseWriteLock(&setp->lock);
2833 int afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
2837 struct afs_icl_log *logp;
2839 ObtainWriteLock(&setp->lock,208);
2841 case ICL_OP_SS_ACTIVATE: /* activate a log */
2843 * If we are not already active, see if we have released
2844 * our demand that the log be allocated (FREED set). If
2845 * we have, reassert our desire.
2847 if (!(setp->states & ICL_SETF_ACTIVE)) {
2848 if (setp->states & ICL_SETF_FREED) {
2849 /* have to reassert desire for logs */
2850 for(i = 0; i < ICL_LOGSPERSET; i++) {
2851 logp = setp->logs[i];
2853 afs_icl_LogHold(logp);
2854 afs_icl_LogUse(logp);
2855 afs_icl_LogRele(logp);
2858 setp->states &= ~ICL_SETF_FREED;
2860 setp->states |= ICL_SETF_ACTIVE;
2865 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2866 /* this doesn't require anything beyond clearing the ACTIVE flag */
2867 setp->states &= ~ICL_SETF_ACTIVE;
2871 case ICL_OP_SS_FREE: /* deassert design for log */
2873 * if we are already in this state, do nothing; otherwise
2874 * deassert desire for log
2876 if (setp->states & ICL_SETF_ACTIVE)
2879 if (!(setp->states & ICL_SETF_FREED)) {
2880 for(i = 0; i < ICL_LOGSPERSET; i++) {
2881 logp = setp->logs[i];
2883 afs_icl_LogHold(logp);
2884 afs_icl_LogFreeUse(logp);
2885 afs_icl_LogRele(logp);
2888 setp->states |= ICL_SETF_FREED;
2897 ReleaseWriteLock(&setp->lock);