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"
16 #include "afs/sysincludes.h" /* Standard vendor system headers */
17 #include "afsincludes.h" /* Afs-based standard headers */
18 #include "afs/afs_stats.h"
19 #include "rx/rx_globals.h"
20 #if !defined(UKERNEL) && !defined(AFS_LINUX20_ENV)
23 #include "h/hashing.h"
25 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
26 #include "netinet/in_var.h"
28 #endif /* !defined(UKERNEL) */
29 #ifdef AFS_LINUX22_ENV
30 #include "h/smp_lock.h"
34 #if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
35 #define AFS_MINBUFFERS 100
37 #define AFS_MINBUFFERS 50
41 afs_int32 hosts[MAXCELLHOSTS];
45 char afs_zeros[AFS_ZEROS];
46 char afs_rootVolumeName[64] = "";
47 struct afs_icl_set *afs_iclSetp = (struct afs_icl_set *)0;
48 struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set *)0;
50 #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
51 kmutex_t afs_global_lock;
52 kmutex_t afs_rxglobal_lock;
55 #if defined(AFS_SGI_ENV) && !defined(AFS_SGI64_ENV)
56 long afs_global_owner;
59 #if defined(AFS_OSF_ENV)
60 simple_lock_data_t afs_global_lock;
63 #if defined(AFS_DARWIN_ENV)
64 struct lock__bsd__ afs_global_lock;
67 #if defined(AFS_XBSD_ENV) && !defined(AFS_FBSD50_ENV)
68 struct lock afs_global_lock;
69 struct proc *afs_global_owner;
72 struct mtx afs_global_mtx;
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.
110 afs_InitSetup(int preallocs)
112 extern void afs_InitStats();
115 if (afs_InitSetup_done)
120 * Set up all the AFS statistics variables. This should be done
121 * exactly once, and it should be done here, the first resource-setting
122 * routine to be called by the CM/RX.
125 #endif /* AFS_NOSTATS */
127 memset(afs_zeros, 0, AFS_ZEROS);
130 rx_extraPackets = AFS_NRXPACKETS; /* smaller # of packets */
131 code = rx_Init(htons(7001));
133 printf("AFS: RX failed to initialize.\n");
136 rx_SetRxDeadTime(afs_rx_deadtime);
137 /* resource init creates the services */
138 afs_ResourceInit(preallocs);
140 afs_InitSetup_done = 1;
141 afs_osi_Wakeup(&afs_InitSetup_done);
146 #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS)
147 struct afsd_thread_info {
149 struct completion *complete;
153 afsd_thread(void *rock)
155 struct afsd_thread_info *arg = rock;
156 unsigned long parm = arg->parm;
157 #ifdef SYS_SETPRIORITY_EXPORTED
158 int (*sys_setpriority) (int, int, int) = sys_call_table[__NR_setpriority];
160 #if defined(AFS_LINUX26_ENV)
165 /* doesn't do much, since we were forked from keventd, but
166 * does call mm_release, which wakes up our parent (since it
167 * used CLONE_VFORK) */
168 #if !defined(AFS_LINUX26_ENV)
171 afs_osi_MaskSignals();
173 case AFSOP_START_RXCALLBACK:
174 sprintf(current->comm, "afs_cbstart");
176 complete(arg->complete);
178 while (afs_RX_Running != 2)
179 afs_osi_Sleep(&afs_RX_Running);
180 sprintf(current->comm, "afs_callback");
181 afs_RXCallBackServer();
183 complete_and_exit(0, 0);
185 case AFSOP_START_AFS:
186 sprintf(current->comm, "afs_afsstart");
188 complete(arg->complete);
190 while (afs_initState < AFSOP_START_AFS)
191 afs_osi_Sleep(&afs_initState);
192 afs_initState = AFSOP_START_BKG;
193 afs_osi_Wakeup(&afs_initState);
194 sprintf(current->comm, "afsd");
197 complete_and_exit(0, 0);
199 case AFSOP_START_BKG:
200 sprintf(current->comm, "afs_bkgstart");
202 complete(arg->complete);
203 while (afs_initState < AFSOP_START_BKG)
204 afs_osi_Sleep(&afs_initState);
205 if (afs_initState < AFSOP_GO) {
206 afs_initState = AFSOP_GO;
207 afs_osi_Wakeup(&afs_initState);
209 sprintf(current->comm, "afs_background");
210 afs_BackgroundDaemon();
212 complete_and_exit(0, 0);
214 case AFSOP_START_TRUNCDAEMON:
215 sprintf(current->comm, "afs_trimstart");
217 complete(arg->complete);
218 while (afs_initState < AFSOP_GO)
219 afs_osi_Sleep(&afs_initState);
220 sprintf(current->comm, "afs_cachetrim");
221 afs_CacheTruncateDaemon();
223 complete_and_exit(0, 0);
226 sprintf(current->comm, "afs_checkserver");
228 complete(arg->complete);
229 afs_CheckServerDaemon();
231 complete_and_exit(0, 0);
233 case AFSOP_RXEVENT_DAEMON:
234 sprintf(current->comm, "afs_evtstart");
235 #ifdef SYS_SETPRIORITY_EXPORTED
236 sys_setpriority(PRIO_PROCESS, 0, -10);
238 #ifdef CURRENT_INCLUDES_NICE
243 complete(arg->complete);
244 while (afs_initState < AFSOP_START_BKG)
245 afs_osi_Sleep(&afs_initState);
246 sprintf(current->comm, "afs_rxevent");
247 afs_rxevent_daemon();
249 complete_and_exit(0, 0);
251 case AFSOP_RXLISTENER_DAEMON:
252 sprintf(current->comm, "afs_lsnstart");
253 #ifdef SYS_SETPRIORITY_EXPORTED
254 sys_setpriority(PRIO_PROCESS, 0, -10);
256 #ifdef CURRENT_INCLUDES_NICE
261 complete(arg->complete);
262 afs_initState = AFSOP_START_AFS;
263 afs_osi_Wakeup(&afs_initState);
265 afs_osi_Wakeup(&afs_RX_Running);
266 afs_osi_RxkRegister();
267 sprintf(current->comm, "afs_rxlistener");
270 complete_and_exit(0, 0);
273 printf("Unknown op %d in StartDaemon()\n");
280 afsd_launcher(void *rock)
282 if (!kernel_thread(afsd_thread, rock, CLONE_VFORK | SIGCHLD))
283 printf("kernel_thread failed. afs startup will not complete\n");
287 afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5,
291 DECLARE_COMPLETION(c);
292 #if defined(AFS_LINUX26_ENV)
293 struct work_struct tq;
297 struct afsd_thread_info info;
298 if (parm == AFSOP_START_RXCALLBACK) {
301 } else if (parm == AFSOP_RXLISTENER_DAEMON) {
305 code = afs_InitSetup(parm2);
307 rx_enablePeerRPCStats();
310 rx_enableProcessRPCStats();
314 } else if (parm == AFSOP_START_AFS) {
317 } /* other functions don't need setup in the parent */
320 #if defined(AFS_LINUX26_ENV)
321 INIT_WORK(&tq, afsd_launcher, &info);
325 INIT_LIST_HEAD(&tq.list);
326 tq.routine = afsd_launcher;
331 /* we need to wait cause we passed stack pointers around.... */
332 wait_for_completion(&c);
337 /* leaving as is, probably will barf if we add prototypes here since it's likely being called
340 afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
341 long parm, parm2, parm3, parm4, parm5, parm6;
344 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
346 #else /* AFS_SGI61_ENV */
348 #endif /* AFS_SGI61_ENV */
350 AFS_STATCNT(afs_syscall_call);
352 if (!afs_suser(CRED()) && (parm != AFSOP_GETMTU)
353 && (parm != AFSOP_GETMASK)) {
354 /* only root can run this code */
357 if (!afs_suser() && (parm != AFSOP_GETMTU)
358 && (parm != AFSOP_GETMASK)) {
359 /* only root can run this code */
360 #if defined(KERNEL_HAVE_UERROR)
364 #if defined(AFS_OSF_ENV)
366 #else /* AFS_OSF_ENV */
368 #endif /* AFS_OSF_ENV */
373 #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) && !defined(UKERNEL)
374 if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON
375 || parm == AFSOP_RXLISTENER_DAEMON) {
376 afs_DaemonOp(parm, parm2, parm3, parm4, parm5, parm6);
378 #else /* !(AFS_LINUX24_ENV && !UKERNEL) */
379 if (parm == AFSOP_START_RXCALLBACK) {
383 #ifndef RXK_LISTENER_ENV
384 code = afs_InitSetup(parm2);
386 #endif /* !RXK_LISTENER_ENV */
388 #ifdef RXK_LISTENER_ENV
389 while (afs_RX_Running != 2)
390 afs_osi_Sleep(&afs_RX_Running);
391 #else /* !RXK_LISTENER_ENV */
392 afs_initState = AFSOP_START_AFS;
393 afs_osi_Wakeup(&afs_initState);
394 #endif /* RXK_LISTENER_ENV */
396 afs_RXCallBackServer();
400 exit(CLD_EXITED, code);
401 #endif /* AFS_SGI_ENV */
403 #ifdef RXK_LISTENER_ENV
404 else if (parm == AFSOP_RXLISTENER_DAEMON) {
408 code = afs_InitSetup(parm2);
410 rx_enablePeerRPCStats();
413 rx_enableProcessRPCStats();
416 afs_initState = AFSOP_START_AFS;
417 afs_osi_Wakeup(&afs_initState);
420 afs_osi_Wakeup(&afs_RX_Running);
422 afs_osi_RxkRegister();
423 #endif /* !UKERNEL */
428 exit(CLD_EXITED, code);
429 #endif /* AFS_SGI_ENV */
431 #endif /* RXK_LISTENER_ENV */
432 else if (parm == AFSOP_START_AFS) {
437 while (afs_initState < AFSOP_START_AFS)
438 afs_osi_Sleep(&afs_initState);
440 afs_initState = AFSOP_START_BKG;
441 afs_osi_Wakeup(&afs_initState);
447 #endif /* AFS_SGI_ENV */
448 } else if (parm == AFSOP_START_CS) {
450 afs_CheckServerDaemon();
454 #endif /* AFS_SGI_ENV */
455 } else if (parm == AFSOP_START_BKG) {
456 while (afs_initState < AFSOP_START_BKG)
457 afs_osi_Sleep(&afs_initState);
458 if (afs_initState < AFSOP_GO) {
459 afs_initState = AFSOP_GO;
460 afs_osi_Wakeup(&afs_initState);
462 /* start the bkg daemon */
466 afs_BioDaemon(parm2);
468 #endif /* AFS_AIX32_ENV */
469 afs_BackgroundDaemon();
473 #endif /* AFS_SGI_ENV */
474 } else if (parm == AFSOP_START_TRUNCDAEMON) {
475 while (afs_initState < AFSOP_GO)
476 afs_osi_Sleep(&afs_initState);
477 /* start the bkg daemon */
479 afs_CacheTruncateDaemon();
483 #endif /* AFS_SGI_ENV */
485 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
486 else if (parm == AFSOP_RXEVENT_DAEMON) {
487 while (afs_initState < AFSOP_START_BKG)
488 afs_osi_Sleep(&afs_initState);
490 afs_rxevent_daemon();
494 #endif /* AFS_SGI_ENV */
496 #endif /* AFS_SUN5_ENV || RXK_LISTENER_ENV */
497 #endif /* AFS_LINUX24_ENV && !UKERNEL */
498 else if (parm == AFSOP_BASIC_INIT) {
501 while (!afs_InitSetup_done)
502 afs_osi_Sleep(&afs_InitSetup_done);
504 #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)
505 temp = AFS_MINBUFFERS; /* Should fix this soon */
507 /* number of 2k buffers we could get from all of the buffer space */
508 temp = ((afs_bufferpages * NBPG) >> 11);
509 temp = temp >> 2; /* don't take more than 25% (our magic parameter) */
510 if (temp < AFS_MINBUFFERS)
511 temp = AFS_MINBUFFERS; /* though we really should have this many */
514 afs_rootFid.Fid.Volume = 0;
516 } else if (parm == AFSOP_ADDCELL) {
517 /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated
518 * name. Parameter 4 is the length of the name, including the null. Parm 5 is the
519 * home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */
520 struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell));
522 AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts),
525 if (parm4 > sizeof(tcell->cellName))
528 AFS_COPYIN((char *)parm3, tcell->cellName, parm4, code);
530 afs_NewCell(tcell->cellName, tcell->hosts, parm5, NULL, 0,
534 afs_osi_Free(tcell, sizeof(struct afsop_cell));
535 } else if (parm == AFSOP_ADDCELL2) {
536 struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell));
537 char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0;
538 char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
542 /* wait for basic init - XXX can't find any reason we need this? */
543 while (afs_initState < AFSOP_START_BKG)
544 afs_osi_Sleep(&afs_initState);
547 AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts),
550 AFS_COPYINSTR((char *)parm3, tbuffer1, AFS_SMALLOCSIZ,
554 AFS_COPYINSTR((char *)parm5, tbuffer, AFS_SMALLOCSIZ,
558 cflags |= CLinkedCell;
563 afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep,
567 afs_osi_Free(tcell, sizeof(struct afsop_cell));
568 osi_FreeSmallSpace(tbuffer);
569 osi_FreeSmallSpace(tbuffer1);
570 } else if (parm == AFSOP_ADDCELLALIAS) {
573 * parm2 is the alias name
574 * parm3 is the real cell name
576 char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
577 char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
579 AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize,
582 AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ,
585 afs_NewCellAlias(aliasName, cellName);
586 osi_FreeSmallSpace(aliasName);
587 osi_FreeSmallSpace(cellName);
588 } else if (parm == AFSOP_SET_THISCELL) {
591 * parm2 is the primary cell name
593 char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
595 AFS_COPYINSTR((char *)parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code);
597 afs_SetPrimaryCell(cell);
598 osi_FreeSmallSpace(cell);
599 } else if (parm == AFSOP_CACHEINIT) {
600 struct afs_cacheParams cparms;
602 if (afs_CacheInit_Done)
605 AFS_COPYIN((char *)parm2, (caddr_t) & cparms, sizeof(cparms), code);
607 #if defined(KERNEL_HAVE_UERROR)
613 afs_CacheInit_Done = 1;
615 struct afs_icl_log *logp;
616 /* initialize the ICL system */
617 code = afs_icl_CreateLog("cmfx", 60 * 1024, &logp);
620 afs_icl_CreateSetWithFlags("cm", logp, NULL,
621 ICL_CRSET_FLAG_DEFAULT_OFF,
624 afs_icl_CreateSet("cmlongterm", logp, NULL,
625 &afs_iclLongTermSetp);
627 afs_setTime = cparms.setTimeFlag;
630 afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles,
631 cparms.cacheBlocks, cparms.cacheDcaches,
632 cparms.cacheVolumes, cparms.chunkSize,
633 cparms.memCacheFlag, cparms.inodes, cparms.users);
635 } else if (parm == AFSOP_CACHEINODE) {
636 ino_t ainode = parm2;
637 /* wait for basic init */
638 while (afs_initState < AFSOP_START_BKG)
639 afs_osi_Sleep(&afs_initState);
643 ainode = (ainode << 32) | (parm3 & 0xffffffff);
645 code = afs_InitCacheFile(NULL, ainode);
646 } else if (parm == AFSOP_ROOTVOLUME) {
647 /* wait for basic init */
648 while (afs_initState < AFSOP_START_BKG)
649 afs_osi_Sleep(&afs_initState);
652 AFS_COPYINSTR((char *)parm2, afs_rootVolumeName,
653 sizeof(afs_rootVolumeName), &bufferSize, code);
654 afs_rootVolumeName[sizeof(afs_rootVolumeName) - 1] = 0;
657 } else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO
658 || parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG
659 || parm == AFSOP_CELLINFO) {
660 char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
663 AFS_COPYINSTR((char *)parm2, tbuffer, AFS_SMALLOCSIZ, &bufferSize,
666 osi_FreeSmallSpace(tbuffer);
670 tbuffer[AFS_SMALLOCSIZ - 1] = '\0'; /* null-terminate the name */
671 /* We have the cache dir copied in. Call the cache init routine */
672 if (parm == AFSOP_CACHEFILE)
673 code = afs_InitCacheFile(tbuffer, 0);
674 else if (parm == AFSOP_CACHEINFO)
675 code = afs_InitCacheInfo(tbuffer);
676 else if (parm == AFSOP_VOLUMEINFO)
677 code = afs_InitVolumeInfo(tbuffer);
678 else if (parm == AFSOP_CELLINFO)
679 code = afs_InitCellInfo(tbuffer);
681 osi_FreeSmallSpace(tbuffer);
682 } else if (parm == AFSOP_GO) {
683 /* the generic initialization calls come here. One parameter: should we do the
684 * set-time operation on this workstation */
688 while (afs_initState < AFSOP_GO)
689 afs_osi_Sleep(&afs_initState);
692 afs_osi_Wakeup(&afs_initState);
693 #if (!defined(AFS_NONFSTRANS) && !defined(AFS_DEC_ENV)) || defined(AFS_AIX_IAUTH_ENV)
694 afs_nfsclient_init();
696 printf("found %d non-empty cache files (%d%%).\n",
697 afs_stats_cmperf.cacheFilesReused,
698 (100 * afs_stats_cmperf.cacheFilesReused) /
699 (afs_stats_cmperf.cacheNumEntries ? afs_stats_cmperf.
700 cacheNumEntries : 1));
701 } else if (parm == AFSOP_ADVISEADDR) {
702 /* pass in the host address to the rx package */
703 afs_int32 count = parm2;
705 afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
706 afs_int32 *maskbuffer =
707 afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
708 afs_int32 *mtubuffer =
709 afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
713 if (count > AFS_MAX_INTERFACE_ADDR) {
715 count = AFS_MAX_INTERFACE_ADDR;
718 AFS_COPYIN((char *)parm3, (char *)buffer, count * sizeof(afs_int32),
721 AFS_COPYIN((char *)parm4, (char *)maskbuffer,
722 count * sizeof(afs_int32), code);
724 AFS_COPYIN((char *)parm5, (char *)mtubuffer,
725 count * sizeof(afs_int32), code);
727 afs_cb_interface.numberOfInterfaces = count;
728 for (i = 0; i < count; i++) {
729 afs_cb_interface.addr_in[i] = buffer[i];
730 #ifdef AFS_USERSPACE_IP_ADDR
731 /* AFS_USERSPACE_IP_ADDR means we have no way of finding the
732 * machines IP addresses when in the kernel (the in_ifaddr
733 * struct is not available), so we pass the info in at
734 * startup. We also pass in the subnetmask and mtu size. The
735 * subnetmask is used when setting the rank:
736 * afsi_SetServerIPRank(); and the mtu size is used when
737 * finding the best mtu size. rxi_FindIfnet() is replaced
738 * with rxi_Findcbi().
740 afs_cb_interface.subnetmask[i] =
741 (parm4 ? maskbuffer[i] : 0xffffffff);
742 afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500));
745 afs_uuid_create(&afs_cb_interface.uuid);
746 rxi_setaddr(buffer[0]);
747 afs_osi_Free(buffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
748 afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
749 afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
752 else if (parm == AFSOP_NFSSTATICADDR) {
753 extern int (*nfs_rfsdisptab_v2) ();
754 nfs_rfsdisptab_v2 = (int (*)())parm2;
755 } else if (parm == AFSOP_NFSSTATICADDR2) {
756 extern int (*nfs_rfsdisptab_v2) ();
758 nfs_rfsdisptab_v2 = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff));
760 nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff);
763 #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV)
764 else if (parm == AFSOP_SBLOCKSTATICADDR2) {
765 extern int (*afs_sblockp) ();
766 extern void (*afs_sbunlockp) ();
768 afs_sblockp = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff));
769 afs_sbunlockp = (void (*)())((parm4 << 32) | (parm5 & 0xffffffff));
771 afs_sblockp = (int (*)())(parm3 & 0xffffffff);
772 afs_sbunlockp = (void (*)())(parm5 & 0xffffffff);
775 #endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
776 #endif /* AFS_SGI53_ENV */
777 else if (parm == AFSOP_SHUTDOWN) {
778 afs_cold_shutdown = 0;
780 afs_cold_shutdown = 1;
781 #ifndef AFS_DARWIN_ENV
782 if (afs_globalVFS != 0) {
783 afs_warn("AFS isn't unmounted yet! Call aborted\n");
788 } else if (parm == AFSOP_AFS_VFSMOUNT) {
790 vfsmount(parm2, parm3, parm4, parm5);
791 #else /* defined(AFS_HPUX_ENV) */
792 #if defined(KERNEL_HAVE_UERROR)
797 #endif /* defined(AFS_HPUX_ENV) */
798 } else if (parm == AFSOP_CLOSEWAIT) {
799 afs_SynchronousCloses = 'S';
800 } else if (parm == AFSOP_GETMTU) {
802 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
803 #ifdef AFS_USERSPACE_IP_ADDR
805 i = rxi_Findcbi(parm2);
806 mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
807 #else /* AFS_USERSPACE_IP_ADDR */
810 tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */
811 mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
812 #endif /* else AFS_USERSPACE_IP_ADDR */
813 #endif /* !AFS_SUN5_ENV */
815 AFS_COPYOUT((caddr_t) & mtu, (caddr_t) parm3, sizeof(afs_int32),
818 /* this is disabled for now because I can't figure out how to get access
819 * to these kernel variables. It's only for supporting user-mode rx
820 * programs -- it makes a huge difference on the 220's in my testbed,
821 * though I don't know why. The bosserver does this with /etc/no, so it's
822 * being handled a different way for the servers right now. */
825 extern u_long sb_max_dflt;
828 if (sb_max_dflt < 131072) sb_max_dflt = 131072;
829 if (sb_max < 131072) sb_max = 131072;
832 #endif /* AFS_AIX32_ENV */
833 } else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */
835 #if !defined(AFS_SUN5_ENV)
836 #ifdef AFS_USERSPACE_IP_ADDR
838 i = rxi_Findcbi(parm2);
840 mask = afs_cb_interface.subnetmask[i];
844 #else /* AFS_USERSPACE_IP_ADDR */
847 tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */
850 #endif /* else AFS_USERSPACE_IP_ADDR */
851 #endif /* !AFS_SUN5_ENV */
853 AFS_COPYOUT((caddr_t) & mask, (caddr_t) parm3, sizeof(afs_int32),
857 else if (parm == AFSOP_AFSDB_HANDLER) {
858 int sizeArg = (int)parm4;
859 int kmsgLen = sizeArg & 0xffff;
860 int cellLen = (sizeArg & 0xffff0000) >> 16;
861 afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
862 char *cellname = afs_osi_Alloc(cellLen);
865 afs_osi_MaskSignals();
867 AFS_COPYIN((afs_int32 *) parm2, cellname, cellLen, code);
868 AFS_COPYIN((afs_int32 *) parm3, kmsg, kmsgLen, code);
870 code = afs_AFSDBHandler(cellname, cellLen, kmsg);
873 if (code == -2) { /* Shutting down? */
879 AFS_COPYOUT(cellname, (char *)parm2, cellLen, code);
880 afs_osi_Free(kmsg, kmsgLen);
881 afs_osi_Free(cellname, cellLen);
884 else if (parm == AFSOP_SET_DYNROOT) {
885 code = afs_SetDynrootEnable(parm2);
886 } else if (parm == AFSOP_SET_FAKESTAT) {
887 afs_fakestat_enable = parm2;
889 } else if (parm == AFSOP_SET_BACKUPTREE) {
890 afs_bkvolpref = parm2;
896 #ifdef AFS_LINUX20_ENV
905 #include "sys/lockl.h"
908 * syscall - this is the VRMIX system call entry point.
911 * THIS SHOULD BE CHANGED TO afs_syscall(), but requires
912 * all the user-level calls to `syscall' to change.
914 syscall(syscall, p1, p2, p3, p4, p5, p6)
916 register rval1 = 0, code;
919 #ifndef AFS_AIX41_ENV
920 extern lock_t kernel_lock;
921 monster = lockl(&kernel_lock, LOCK_SHORT);
922 #endif /* !AFS_AIX41_ENV */
924 AFS_STATCNT(syscall);
928 rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6);
933 rval1 = afs_setpag();
939 rval1 = afs_syscall_pioctl(p1, p2, p3, p4);
943 case AFSCALL_ICREATE:
944 rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6);
948 rval1 = afs_syscall_iopen(p1, p2, p3);
952 rval1 = afs_syscall_iincdec(p1, p2, p3, -1);
956 rval1 = afs_syscall_iincdec(p1, p2, p3, 1);
961 code = Afscall_icl(p1, p2, p3, p4, p5, &retval);
976 #ifndef AFS_AIX41_ENV
977 if (monster != LOCK_NEST)
978 unlockl(&kernel_lock);
979 #endif /* !AFS_AIX41_ENV */
980 return getuerror()? -1 : rval1;
984 * lsetpag - interface to afs_setpag().
989 AFS_STATCNT(lsetpag);
990 return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0);
994 * lpioctl - interface to pioctl()
996 lpioctl(path, cmd, cmarg, follow)
1000 AFS_STATCNT(lpioctl);
1001 return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow);
1004 #else /* !AFS_AIX32_ENV */
1006 #if defined(AFS_SGI_ENV)
1018 Afs_syscall(struct afsargs *uap, rval_t * rvp)
1023 AFS_STATCNT(afs_syscall);
1024 switch (uap->syscall) {
1029 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1030 uap->parm5, &retval);
1032 rvp->r_val1 = retval;
1034 #ifdef AFS_SGI_XFS_IOPS_ENV
1035 case AFSCALL_IDEC64:
1037 afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1040 case AFSCALL_IINC64:
1042 afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1045 case AFSCALL_ILISTINODE64:
1047 afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3,
1048 uap->parm4, uap->parm5);
1050 case AFSCALL_ICREATENAME64:
1052 afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3,
1053 uap->parm4, uap->parm5);
1056 #ifdef AFS_SGI_VNODE_GLUE
1057 case AFSCALL_INIT_KERNEL_CONFIG:
1058 error = afs_init_kernel_config(uap->parm1);
1063 afs_syscall_call(uap->syscall, uap->parm1, uap->parm2, uap->parm3,
1064 uap->parm4, uap->parm5);
1069 #else /* AFS_SGI_ENV */
1087 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
1089 dst->param1 = src->param1;
1090 dst->param2 = src->param2;
1091 dst->param3 = src->param3;
1092 dst->param4 = src->param4;
1096 * If you need to change copyin_iparam(), you may also need to change
1097 * copyin_afs_ioctl().
1101 copyin_iparam(caddr_t cmarg, struct iparam *dst)
1105 #if defined(AFS_HPUX_64BIT_ENV)
1106 struct iparam32 dst32;
1108 if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */
1109 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1111 iparam32_to_iparam(&dst32, dst);
1114 #endif /* AFS_HPUX_64BIT_ENV */
1116 #if defined(AFS_SUN57_64BIT_ENV)
1117 struct iparam32 dst32;
1119 if (get_udatamodel() == DATAMODEL_ILP32) {
1120 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1122 iparam32_to_iparam(&dst32, dst);
1125 #endif /* AFS_SUN57_64BIT_ENV */
1127 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
1128 struct iparam32 dst32;
1130 #ifdef AFS_SPARC64_LINUX24_ENV
1131 if (current->thread.flags & SPARC_FLAG_32BIT)
1132 #elif defined(AFS_SPARC64_LINUX20_ENV)
1133 if (current->tss.flags & SPARC_FLAG_32BIT)
1134 #elif defined(AFS_AMD64_LINUX20_ENV)
1135 if (current->thread.flags & THREAD_IA32)
1136 #elif defined(AFS_PPC64_LINUX20_ENV)
1137 if (current->thread.flags & PPC_FLAG_32BIT)
1139 #error Not done for this linux version
1142 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1144 iparam32_to_iparam(&dst32, dst);
1147 #endif /* AFS_LINUX_64BIT_KERNEL */
1149 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
1153 /* Main entry of all afs system calls */
1155 extern int afs_sinited;
1157 /** The 32 bit OS expects the members of this structure to be 32 bit
1158 * quantities and the 64 bit OS expects them as 64 bit quanties. Hence
1159 * to accomodate both, *long* is used instead of afs_int32
1162 #ifdef AFS_SUN57_ENV
1184 Afs_syscall(register struct afssysa *uap, rval_t * rvp)
1186 int *retval = &rvp->r_val1;
1187 #else /* AFS_SUN5_ENV */
1188 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1190 afs3_syscall(p, args, retval)
1191 #ifdef AFS_FBSD50_ENV
1207 } *uap = (struct a *)args;
1208 #else /* AFS_OSF_ENV */
1209 #ifdef AFS_LINUX20_ENV
1217 long parm6; /* not actually used - should be removed */
1219 /* Linux system calls only set up for 5 arguments. */
1221 afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4)
1223 struct afssysargs args, *uap = &args;
1225 long *retval = &linux_ret;
1226 long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
1227 #ifdef AFS_SPARC64_LINUX24_ENV
1228 afs_int32 eparm32[4];
1230 /* eparm is also used by AFSCALL_CALL in afsd.c */
1232 #if defined(UKERNEL)
1243 } *uap = (struct a *)u.u_ap;
1246 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
1250 #endif /* SUN && !SUN5 */
1260 } *uap = (struct a *)u.u_ap;
1261 #endif /* UKERNEL */
1262 #if defined(AFS_DEC_ENV)
1263 int *retval = &u.u_r.r_val1;
1264 #elif defined(AFS_HPUX_ENV)
1265 long *retval = &u.u_rval1;
1267 int *retval = &u.u_rval1;
1269 #endif /* AFS_LINUX20_ENV */
1270 #endif /* AFS_OSF_ENV */
1271 #endif /* AFS_SUN5_ENV */
1272 register int code = 0;
1274 AFS_STATCNT(afs_syscall);
1281 #ifdef AFS_LINUX20_ENV
1283 /* setup uap for use below - pull out the magic decoder ring to know
1284 * which syscalls have folded argument lists.
1286 uap->syscall = syscall;
1290 if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
1291 #ifdef AFS_SPARC64_LINUX24_ENV
1292 /* from arch/sparc64/kernel/sys_sparc32.c */
1294 ({ unsigned long __ret; \
1295 __asm__ ("srl %0, 0, %0" \
1302 if (current->thread.flags & SPARC_FLAG_32BIT) {
1303 AFS_COPYIN((char *)parm4, (char *)eparm32, sizeof(eparm32), code);
1304 eparm[0] = AA(eparm32[0]);
1305 eparm[1] = AA(eparm32[1]);
1306 eparm[2] = AA(eparm32[2]);
1310 AFS_COPYIN((char *)parm4, (char *)eparm, sizeof(eparm), code);
1311 uap->parm4 = eparm[0];
1312 uap->parm5 = eparm[1];
1313 uap->parm6 = eparm[2];
1321 #if defined(AFS_HPUX_ENV)
1323 * There used to be code here (duplicated from osi_Init()) for
1324 * initializing the semaphore used by AFS_GLOCK(). Was the
1325 * duplication to handle the case of a dynamically loaded kernel
1330 if (uap->syscall == AFSCALL_CALL) {
1333 afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1334 uap->parm5, uap->parm6, rvp, CRED());
1337 afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1338 uap->parm5, uap->parm6);
1340 } else if (uap->syscall == AFSCALL_SETPAG) {
1342 register proc_t *procp;
1344 procp = ttoproc(curthread);
1346 code = afs_setpag(&procp->p_cred);
1350 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1351 code = afs_setpag(p, args, retval);
1352 #else /* AFS_OSF_ENV */
1353 code = afs_setpag();
1357 } else if (uap->syscall == AFSCALL_PIOCTL) {
1359 #if defined(AFS_SUN5_ENV)
1361 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1363 #elif defined(AFS_FBSD50_ENV)
1365 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1367 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1369 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1370 p->p_cred->pc_ucred);
1373 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
1377 } else if (uap->syscall == AFSCALL_ICREATE) {
1378 struct iparam iparams;
1380 code = copyin_iparam((char *)uap->parm3, &iparams);
1382 #if defined(KERNEL_HAVE_UERROR)
1388 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
1389 iparams.param2, iparams.param3,
1390 iparams.param4, rvp, CRED());
1393 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
1395 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1396 iparams.param3, iparams.param4, retval);
1398 iparams.param3, iparams.param4);
1400 #endif /* AFS_SUN5_ENV */
1401 } else if (uap->syscall == AFSCALL_IOPEN) {
1404 afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp,
1407 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1408 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
1410 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
1412 #endif /* AFS_SUN5_ENV */
1413 } else if (uap->syscall == AFSCALL_IDEC) {
1416 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp,
1419 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1);
1420 #endif /* AFS_SUN5_ENV */
1421 } else if (uap->syscall == AFSCALL_IINC) {
1424 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp,
1427 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1);
1428 #endif /* AFS_SUN5_ENV */
1429 } else if (uap->syscall == AFSCALL_ICL) {
1432 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1433 uap->parm5, retval);
1435 #ifdef AFS_LINUX20_ENV
1437 /* ICL commands can return values. */
1438 code = -linux_ret; /* Gets negated again at exit below */
1442 #if defined(KERNEL_HAVE_UERROR)
1446 #endif /* !AFS_LINUX20_ENV */
1448 #if defined(KERNEL_HAVE_UERROR)
1455 #ifdef AFS_LINUX20_ENV
1461 #endif /* AFS_SGI_ENV */
1462 #endif /* !AFS_AIX32_ENV */
1465 * Initstate in the range 0 < x < 100 are early initialization states.
1466 * Initstate of 100 means a AFSOP_START operation has been done. After this,
1467 * the cache may be initialized.
1468 * Initstate of 101 means a AFSOP_GO operation has been done. This operation
1469 * is done after all the cache initialization has been done.
1470 * Initstate of 200 means that the volume has been looked up once, possibly
1472 * Initstate of 300 means that the volume has been *successfully* looked up.
1477 register int code = 0;
1479 AFS_STATCNT(afs_CheckInit);
1480 if (afs_initState <= 100)
1481 code = ENXIO; /* never finished init phase */
1482 else if (afs_initState == 101) { /* init done, wait for afs_daemon */
1483 while (afs_initState < 200)
1484 afs_osi_Sleep(&afs_initState);
1485 } else if (afs_initState == 200)
1486 code = ETIMEDOUT; /* didn't find root volume */
1490 int afs_shuttingdown = 0;
1494 extern short afs_brsDaemons;
1495 extern afs_int32 afs_CheckServerDaemonStarted;
1496 extern struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler;
1497 extern struct osi_file *afs_cacheInodep;
1499 AFS_STATCNT(afs_shutdown);
1500 if (afs_shuttingdown)
1502 afs_shuttingdown = 1;
1503 if (afs_cold_shutdown)
1507 afs_warn("shutting down of: CB... ");
1509 afs_termState = AFSOP_STOP_RXCALLBACK;
1510 rx_WakeupServerProcs();
1511 /* shutdown_rxkernel(); */
1512 while (afs_termState == AFSOP_STOP_RXCALLBACK)
1513 afs_osi_Sleep(&afs_termState);
1515 afs_warn("afs... ");
1516 while (afs_termState == AFSOP_STOP_AFS) {
1517 afs_osi_CancelWait(&AFS_WaitHandler);
1518 afs_osi_Sleep(&afs_termState);
1520 if (afs_CheckServerDaemonStarted) {
1521 while (afs_termState == AFSOP_STOP_CS) {
1522 afs_osi_CancelWait(&AFS_CSWaitHandler);
1523 afs_osi_Sleep(&afs_termState);
1526 afs_warn("BkG... ");
1527 /* Wake-up afs_brsDaemons so that we don't have to wait for a bkg job! */
1528 while (afs_termState == AFSOP_STOP_BKG) {
1529 afs_osi_Wakeup(&afs_brsDaemons);
1530 afs_osi_Sleep(&afs_termState);
1532 afs_warn("CTrunc... ");
1533 /* Cancel cache truncate daemon. */
1534 while (afs_termState == AFSOP_STOP_TRUNCDAEMON) {
1535 afs_osi_Wakeup((char *)&afs_CacheTruncateDaemon);
1536 afs_osi_Sleep(&afs_termState);
1538 #ifdef AFS_AFSDB_ENV
1539 afs_warn("AFSDB... ");
1541 while (afs_termState == AFSOP_STOP_AFSDB)
1542 afs_osi_Sleep(&afs_termState);
1544 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
1545 afs_warn("RxEvent... ");
1546 /* cancel rx event daemon */
1547 while (afs_termState == AFSOP_STOP_RXEVENT)
1548 afs_osi_Sleep(&afs_termState);
1549 #if defined(RXK_LISTENER_ENV)
1551 afs_warn("UnmaskRxkSignals... ");
1552 afs_osi_UnmaskRxkSignals();
1554 /* cancel rx listener */
1555 afs_warn("RxListener... ");
1556 osi_StopListener(); /* This closes rx_socket. */
1557 while (afs_termState == AFSOP_STOP_RXK_LISTENER) {
1558 afs_warn("Sleep... ");
1559 afs_osi_Sleep(&afs_termState);
1563 afs_termState = AFSOP_STOP_COMPLETE;
1567 /* Close file only after daemons which can write to it are stopped. */
1568 if (afs_cacheInodep) { /* memcache won't set this */
1569 osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */
1570 afs_cacheInodep = 0;
1572 return; /* Just kill daemons for now */
1576 shutdown_rxkernel();
1580 shutdown_bufferpackage();
1586 shutdown_vnodeops();
1588 shutdown_exporter();
1589 shutdown_memcache();
1590 #if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)
1591 #if !defined(AFS_DEC_ENV) && !defined(AFS_OSF_ENV)
1592 /* this routine does not exist in Ultrix systems... 93.01.19 */
1594 #endif /* AFS_DEC_ENV */
1597 /* The following hold the cm stats */
1599 memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
1600 memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf));
1601 memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
1603 afs_warn(" ALL allocated tables\n");
1604 afs_shuttingdown = 0;
1609 shutdown_afstest(void)
1611 AFS_STATCNT(shutdown_afstest);
1612 afs_initState = afs_termState = afs_setTime = 0;
1613 AFS_Running = afs_CB_Running = 0;
1614 afs_CacheInit_Done = afs_Go_Done = 0;
1615 if (afs_cold_shutdown) {
1616 *afs_rootVolumeName = 0;
1621 /* In case there is a bunch of dynamically build bkg daemons to free */
1623 afs_shutdown_BKG(void)
1625 AFS_STATCNT(shutdown_BKG);
1629 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
1630 /* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
1631 #if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
1632 int afs_icl_sizeofLong = 1;
1634 int afs_icl_sizeofLong = 2;
1637 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1638 int afs_icl_sizeofLong = 2;
1640 int afs_icl_sizeofLong = 1;
1644 int afs_icl_inited = 0;
1646 /* init function, called once, under afs_icl_lock */
1654 extern struct afs_icl_log *afs_icl_FindLog();
1655 extern struct afs_icl_set *afs_icl_FindSet();
1659 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
1661 afs_int32 *lp, elts, flags;
1662 register afs_int32 code;
1663 struct afs_icl_log *logp;
1664 struct afs_icl_set *setp;
1665 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1667 #else /* AFS_SGI61_ENV */
1668 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1673 #endif /* AFS_SGI61_ENV */
1675 afs_int32 startCookie;
1676 afs_int32 allocated;
1677 struct afs_icl_log *tlp;
1680 if (!afs_suser(CRED())) { /* only root can run this code */
1684 if (!afs_suser()) { /* only root can run this code */
1685 #if defined(KERNEL_HAVE_UERROR)
1694 case ICL_OP_COPYOUTCLR: /* copy out data then clear */
1695 case ICL_OP_COPYOUT: /* copy ouy data */
1696 /* copyout: p1=logname, p2=&buffer, p3=size(words), p4=&cookie
1697 * return flags<<24 + nwords.
1698 * updates cookie to updated start (not end) if we had to
1699 * skip some records.
1701 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1704 AFS_COPYIN((char *)p4, (char *)&startCookie, sizeof(afs_int32), code);
1707 logp = afs_icl_FindLog(tname);
1710 #define BUFFERSIZE AFS_LRALLOCSIZ
1711 lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
1712 elts = BUFFERSIZE / sizeof(afs_int32);
1715 flags = (opcode == ICL_OP_COPYOUT) ? 0 : ICL_COPYOUTF_CLRAFTERREAD;
1717 afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) & startCookie,
1720 osi_FreeLargeSpace((struct osi_buffer *)lp);
1723 AFS_COPYOUT((char *)lp, (char *)p2, elts * sizeof(afs_int32), code);
1726 AFS_COPYOUT((char *)&startCookie, (char *)p4, sizeof(afs_int32),
1730 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1732 *retval = ((long)((flags << 24) | (elts & 0xffffff))) << 32;
1735 *retval = (flags << 24) | (elts & 0xffffff);
1737 afs_icl_LogRele(logp);
1738 osi_FreeLargeSpace((struct osi_buffer *)lp);
1741 case ICL_OP_ENUMLOGS: /* enumerate logs */
1742 /* enumerate logs: p1=index, p2=&name, p3=sizeof(name), p4=&size.
1743 * return 0 for success, otherwise error.
1745 for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) {
1750 return ENOENT; /* past the end of file */
1751 temp = strlen(tlp->name) + 1;
1754 AFS_COPYOUT(tlp->name, (char *)p2, temp, code);
1755 if (!code) /* copy out size of log */
1756 AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof(afs_int32),
1760 case ICL_OP_ENUMLOGSBYSET: /* enumerate logs by set name */
1761 /* enumerate logs: p1=setname, p2=index, p3=&name, p4=sizeof(name).
1762 * return 0 for success, otherwise error.
1764 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1767 setp = afs_icl_FindSet(tname);
1770 if (p2 > ICL_LOGSPERSET)
1772 if (!(tlp = setp->logs[p2]))
1774 temp = strlen(tlp->name) + 1;
1777 AFS_COPYOUT(tlp->name, (char *)p3, temp, code);
1780 case ICL_OP_CLRLOG: /* clear specified log */
1781 /* zero out the specified log: p1=logname */
1782 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1785 logp = afs_icl_FindLog(tname);
1788 code = afs_icl_ZeroLog(logp);
1789 afs_icl_LogRele(logp);
1792 case ICL_OP_CLRSET: /* clear specified set */
1793 /* zero out the specified set: p1=setname */
1794 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1797 setp = afs_icl_FindSet(tname);
1800 code = afs_icl_ZeroSet(setp);
1801 afs_icl_SetRele(setp);
1804 case ICL_OP_CLRALL: /* clear all logs */
1805 /* zero out all logs -- no args */
1807 ObtainWriteLock(&afs_icl_lock, 178);
1808 for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) {
1809 tlp->refCount++; /* hold this guy */
1810 ReleaseWriteLock(&afs_icl_lock);
1811 /* don't clear persistent logs */
1812 if ((tlp->states & ICL_LOGF_PERSISTENT) == 0)
1813 code = afs_icl_ZeroLog(tlp);
1814 ObtainWriteLock(&afs_icl_lock, 179);
1815 if (--tlp->refCount == 0)
1816 afs_icl_ZapLog(tlp);
1820 ReleaseWriteLock(&afs_icl_lock);
1823 case ICL_OP_ENUMSETS: /* enumerate all sets */
1824 /* enumerate sets: p1=index, p2=&name, p3=sizeof(name), p4=&states.
1825 * return 0 for success, otherwise error.
1827 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
1832 return ENOENT; /* past the end of file */
1833 temp = strlen(setp->name) + 1;
1836 AFS_COPYOUT(setp->name, (char *)p2, temp, code);
1837 if (!code) /* copy out size of log */
1838 AFS_COPYOUT((char *)&setp->states, (char *)p4, sizeof(afs_int32),
1842 case ICL_OP_SETSTAT: /* set status on a set */
1843 /* activate the specified set: p1=setname, p2=op */
1844 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1847 setp = afs_icl_FindSet(tname);
1850 code = afs_icl_SetSetStat(setp, p2);
1851 afs_icl_SetRele(setp);
1854 case ICL_OP_SETSTATALL: /* set status on all sets */
1855 /* activate the specified set: p1=op */
1857 ObtainWriteLock(&afs_icl_lock, 180);
1858 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
1859 setp->refCount++; /* hold this guy */
1860 ReleaseWriteLock(&afs_icl_lock);
1861 /* don't set states on persistent sets */
1862 if ((setp->states & ICL_SETF_PERSISTENT) == 0)
1863 code = afs_icl_SetSetStat(setp, p1);
1864 ObtainWriteLock(&afs_icl_lock, 181);
1865 if (--setp->refCount == 0)
1866 afs_icl_ZapSet(setp);
1870 ReleaseWriteLock(&afs_icl_lock);
1873 case ICL_OP_SETLOGSIZE: /* set size of log */
1874 /* set the size of the specified log: p1=logname, p2=size (in words) */
1875 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1878 logp = afs_icl_FindLog(tname);
1881 code = afs_icl_LogSetSize(logp, p2);
1882 afs_icl_LogRele(logp);
1885 case ICL_OP_GETLOGINFO: /* get size of log */
1886 /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */
1887 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1890 logp = afs_icl_FindLog(tname);
1893 allocated = !!logp->datap;
1894 AFS_COPYOUT((char *)&logp->logSize, (char *)p2, sizeof(afs_int32),
1897 AFS_COPYOUT((char *)&allocated, (char *)p3, sizeof(afs_int32),
1899 afs_icl_LogRele(logp);
1902 case ICL_OP_GETSETINFO: /* get state of set */
1903 /* zero out the specified set: p1=setname, p2=&state */
1904 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1907 setp = afs_icl_FindSet(tname);
1910 AFS_COPYOUT((char *)&setp->states, (char *)p2, sizeof(afs_int32),
1912 afs_icl_SetRele(setp);
1923 afs_lock_t afs_icl_lock;
1925 /* exported routine: a 4 parameter event */
1927 afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
1928 afs_int32 lAndT, long p1, long p2, long p3, long p4)
1932 register afs_int32 tmask;
1935 /* If things aren't init'ed yet (or the set is inactive), don't panic */
1936 if (!ICL_SETACTIVE(setp))
1940 mask = lAndT >> 24 & 0xff; /* mask of which logs to log to */
1941 ix = ICL_EVENTBYTE(eventID);
1942 ObtainReadLock(&setp->lock);
1943 if (setp->eventFlags[ix] & ICL_EVENTMASK(eventID)) {
1944 for (i = 0, tmask = 1; i < ICL_LOGSPERSET; i++, tmask <<= 1) {
1946 afs_icl_AppendRecord(setp->logs[i], eventID, lAndT & 0xffffff,
1951 break; /* break early */
1954 ReleaseReadLock(&setp->lock);
1958 /* Next 4 routines should be implemented via var-args or something.
1959 * Whole purpose is to avoid compiler warnings about parameter # mismatches.
1960 * Otherwise, could call afs_icl_Event4 directly.
1963 afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID,
1964 afs_int32 lAndT, long p1, long p2, long p3)
1966 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
1970 afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID,
1971 afs_int32 lAndT, long p1, long p2)
1973 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
1977 afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
1978 afs_int32 lAndT, long p1)
1980 return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0,
1985 afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID,
1988 return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0,
1992 struct afs_icl_log *afs_icl_allLogs = 0;
1994 /* function to purge records from the start of the log, until there
1995 * is at least minSpace long's worth of space available without
1996 * making the head and the tail point to the same word.
1998 * Log must be write-locked.
2001 afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
2003 register unsigned int tsize;
2005 while (logp->logSize - logp->logElements <= minSpace) {
2007 tsize = ((logp->datap[logp->firstUsed]) >> 24) & 0xff;
2008 logp->logElements -= tsize;
2009 logp->firstUsed += tsize;
2010 if (logp->firstUsed >= logp->logSize)
2011 logp->firstUsed -= logp->logSize;
2012 logp->baseCookie += tsize;
2016 /* append string astr to buffer, including terminating null char.
2018 * log must be write-locked.
2020 #define ICL_CHARSPERLONG 4
2022 afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
2024 char *op; /* ptr to char to write */
2026 register int bib; /* bytes in buffer */
2029 op = (char *)&(logp->datap[logp->firstFree]);
2033 if (++bib >= ICL_CHARSPERLONG) {
2036 if (++(logp->firstFree) >= logp->logSize) {
2037 logp->firstFree = 0;
2038 op = (char *)&(logp->datap[0]);
2040 logp->logElements++;
2046 /* if we've used this word at all, allocate it */
2047 if (++(logp->firstFree) >= logp->logSize) {
2048 logp->firstFree = 0;
2050 logp->logElements++;
2054 /* add a long to the log, ignoring overflow (checked already) */
2055 #define ICL_APPENDINT32(lp, x) \
2057 (lp)->datap[(lp)->firstFree] = (x); \
2058 if (++((lp)->firstFree) >= (lp)->logSize) { \
2059 (lp)->firstFree = 0; \
2061 (lp)->logElements++; \
2064 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2065 #define ICL_APPENDLONG(lp, x) \
2067 ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
2068 ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
2071 #else /* AFS_ALPHA_ENV */
2072 #define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
2073 #endif /* AFS_ALPHA_ENV */
2075 /* routine to tell whether we're dealing with the address or the
2079 afs_icl_UseAddr(int type)
2081 if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
2082 || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
2088 /* Function to append a record to the log. Written for speed
2089 * since we know that we're going to have to make this work fast
2090 * pretty soon, anyway. The log must be unlocked.
2094 afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
2095 afs_int32 types, long p1, long p2, long p3, long p4)
2097 int rsize; /* record size in longs */
2098 register int tsize; /* temp size */
2102 t4 = types & 0x3f; /* decode types */
2110 osi_GetTime(&tv); /* It panics for solaris if inside */
2111 ObtainWriteLock(&logp->lock, 182);
2113 ReleaseWriteLock(&logp->lock);
2117 /* get timestamp as # of microseconds since some time that doesn't
2118 * change that often. This algorithm ticks over every 20 minutes
2119 * or so (1000 seconds). Write a timestamp record if it has.
2121 if (tv.tv_sec - logp->lastTS > 1024) {
2122 /* the timer has wrapped -- write a timestamp record */
2123 if (logp->logSize - logp->logElements <= 5)
2124 afs_icl_GetLogSpace(logp, 5);
2126 ICL_APPENDINT32(logp,
2127 (afs_int32) (5 << 24) + (ICL_TYPE_UNIXDATE << 18));
2128 ICL_APPENDINT32(logp, (afs_int32) ICL_INFO_TIMESTAMP);
2129 ICL_APPENDINT32(logp, (afs_int32) 0); /* use thread ID zero for clocks */
2130 ICL_APPENDINT32(logp,
2131 (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 +
2133 ICL_APPENDINT32(logp, (afs_int32) tv.tv_sec);
2135 logp->lastTS = tv.tv_sec;
2138 rsize = 4; /* base case */
2140 /* compute size of parameter p1. Only tricky case is string.
2141 * In that case, we have to call strlen to get the string length.
2143 ICL_SIZEHACK(t1, p1);
2146 /* compute size of parameter p2. Only tricky case is string.
2147 * In that case, we have to call strlen to get the string length.
2149 ICL_SIZEHACK(t2, p2);
2152 /* compute size of parameter p3. Only tricky case is string.
2153 * In that case, we have to call strlen to get the string length.
2155 ICL_SIZEHACK(t3, p3);
2158 /* compute size of parameter p4. Only tricky case is string.
2159 * In that case, we have to call strlen to get the string length.
2161 ICL_SIZEHACK(t4, p4);
2164 /* At this point, we've computed all of the parameter sizes, and
2165 * have in rsize the size of the entire record we want to append.
2166 * Next, we check that we actually have room in the log to do this
2167 * work, and then we do the append.
2170 ReleaseWriteLock(&logp->lock);
2171 return; /* log record too big to express */
2174 if (logp->logSize - logp->logElements <= rsize)
2175 afs_icl_GetLogSpace(logp, rsize);
2177 ICL_APPENDINT32(logp,
2178 (afs_int32) (rsize << 24) + (t1 << 18) + (t2 << 12) +
2180 ICL_APPENDINT32(logp, (afs_int32) op);
2181 ICL_APPENDINT32(logp, (afs_int32) osi_ThreadUnique());
2182 ICL_APPENDINT32(logp,
2183 (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
2186 /* marshall parameter 1 now */
2187 if (t1 == ICL_TYPE_STRING) {
2188 afs_icl_AppendString(logp, (char *)p1);
2189 } else if (t1 == ICL_TYPE_HYPER) {
2190 ICL_APPENDINT32(logp,
2191 (afs_int32) ((struct afs_hyper_t *)p1)->high);
2192 ICL_APPENDINT32(logp,
2193 (afs_int32) ((struct afs_hyper_t *)p1)->low);
2194 } else if (t1 == ICL_TYPE_INT64) {
2195 #ifdef AFSLITTLE_ENDIAN
2196 #ifdef AFS_64BIT_CLIENT
2197 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2198 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2199 #else /* AFS_64BIT_CLIENT */
2200 ICL_APPENDINT32(logp, (afs_int32) p1);
2201 ICL_APPENDINT32(logp, (afs_int32) 0);
2202 #endif /* AFS_64BIT_CLIENT */
2203 #else /* AFSLITTLE_ENDIAN */
2204 #ifdef AFS_64BIT_CLIENT
2205 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2206 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2207 #else /* AFS_64BIT_CLIENT */
2208 ICL_APPENDINT32(logp, (afs_int32) 0);
2209 ICL_APPENDINT32(logp, (afs_int32) p1);
2210 #endif /* AFS_64BIT_CLIENT */
2211 #endif /* AFSLITTLE_ENDIAN */
2212 } else if (t1 == ICL_TYPE_FID) {
2213 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2214 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2215 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[2]);
2216 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[3]);
2218 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2219 else if (t1 == ICL_TYPE_INT32)
2220 ICL_APPENDINT32(logp, (afs_int32) p1);
2221 #endif /* AFS_ALPHA_ENV */
2223 ICL_APPENDLONG(logp, p1);
2226 /* marshall parameter 2 now */
2227 if (t2 == ICL_TYPE_STRING)
2228 afs_icl_AppendString(logp, (char *)p2);
2229 else if (t2 == ICL_TYPE_HYPER) {
2230 ICL_APPENDINT32(logp,
2231 (afs_int32) ((struct afs_hyper_t *)p2)->high);
2232 ICL_APPENDINT32(logp,
2233 (afs_int32) ((struct afs_hyper_t *)p2)->low);
2234 } else if (t2 == ICL_TYPE_INT64) {
2235 #ifdef AFSLITTLE_ENDIAN
2236 #ifdef AFS_64BIT_CLIENT
2237 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2238 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2239 #else /* AFS_64BIT_CLIENT */
2240 ICL_APPENDINT32(logp, (afs_int32) p2);
2241 ICL_APPENDINT32(logp, (afs_int32) 0);
2242 #endif /* AFS_64BIT_CLIENT */
2243 #else /* AFSLITTLE_ENDIAN */
2244 #ifdef AFS_64BIT_CLIENT
2245 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2246 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2247 #else /* AFS_64BIT_CLIENT */
2248 ICL_APPENDINT32(logp, (afs_int32) 0);
2249 ICL_APPENDINT32(logp, (afs_int32) p2);
2250 #endif /* AFS_64BIT_CLIENT */
2251 #endif /* AFSLITTLE_ENDIAN */
2252 } else if (t2 == ICL_TYPE_FID) {
2253 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2254 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2255 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[2]);
2256 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[3]);
2258 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2259 else if (t2 == ICL_TYPE_INT32)
2260 ICL_APPENDINT32(logp, (afs_int32) p2);
2261 #endif /* AFS_ALPHA_ENV */
2263 ICL_APPENDLONG(logp, p2);
2266 /* marshall parameter 3 now */
2267 if (t3 == ICL_TYPE_STRING)
2268 afs_icl_AppendString(logp, (char *)p3);
2269 else if (t3 == ICL_TYPE_HYPER) {
2270 ICL_APPENDINT32(logp,
2271 (afs_int32) ((struct afs_hyper_t *)p3)->high);
2272 ICL_APPENDINT32(logp,
2273 (afs_int32) ((struct afs_hyper_t *)p3)->low);
2274 } else if (t3 == ICL_TYPE_INT64) {
2275 #ifdef AFSLITTLE_ENDIAN
2276 #ifdef AFS_64BIT_CLIENT
2277 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2278 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2279 #else /* AFS_64BIT_CLIENT */
2280 ICL_APPENDINT32(logp, (afs_int32) p3);
2281 ICL_APPENDINT32(logp, (afs_int32) 0);
2282 #endif /* AFS_64BIT_CLIENT */
2283 #else /* AFSLITTLE_ENDIAN */
2284 #ifdef AFS_64BIT_CLIENT
2285 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2286 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2287 #else /* AFS_64BIT_CLIENT */
2288 ICL_APPENDINT32(logp, (afs_int32) 0);
2289 ICL_APPENDINT32(logp, (afs_int32) p3);
2290 #endif /* AFS_64BIT_CLIENT */
2291 #endif /* AFSLITTLE_ENDIAN */
2292 } else if (t3 == ICL_TYPE_FID) {
2293 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2294 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2295 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[2]);
2296 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[3]);
2298 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2299 else if (t3 == ICL_TYPE_INT32)
2300 ICL_APPENDINT32(logp, (afs_int32) p3);
2301 #endif /* AFS_ALPHA_ENV */
2303 ICL_APPENDLONG(logp, p3);
2306 /* marshall parameter 4 now */
2307 if (t4 == ICL_TYPE_STRING)
2308 afs_icl_AppendString(logp, (char *)p4);
2309 else if (t4 == ICL_TYPE_HYPER) {
2310 ICL_APPENDINT32(logp,
2311 (afs_int32) ((struct afs_hyper_t *)p4)->high);
2312 ICL_APPENDINT32(logp,
2313 (afs_int32) ((struct afs_hyper_t *)p4)->low);
2314 } else if (t4 == ICL_TYPE_INT64) {
2315 #ifdef AFSLITTLE_ENDIAN
2316 #ifdef AFS_64BIT_CLIENT
2317 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2318 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2319 #else /* AFS_64BIT_CLIENT */
2320 ICL_APPENDINT32(logp, (afs_int32) p4);
2321 ICL_APPENDINT32(logp, (afs_int32) 0);
2322 #endif /* AFS_64BIT_CLIENT */
2323 #else /* AFSLITTLE_ENDIAN */
2324 #ifdef AFS_64BIT_CLIENT
2325 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2326 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2327 #else /* AFS_64BIT_CLIENT */
2328 ICL_APPENDINT32(logp, (afs_int32) 0);
2329 ICL_APPENDINT32(logp, (afs_int32) p4);
2330 #endif /* AFS_64BIT_CLIENT */
2331 #endif /* AFSLITTLE_ENDIAN */
2332 } else if (t4 == ICL_TYPE_FID) {
2333 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2334 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2335 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[2]);
2336 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[3]);
2338 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2339 else if (t4 == ICL_TYPE_INT32)
2340 ICL_APPENDINT32(logp, (afs_int32) p4);
2341 #endif /* AFS_ALPHA_ENV */
2343 ICL_APPENDLONG(logp, p4);
2345 ReleaseWriteLock(&logp->lock);
2348 /* create a log with size logSize; return it in *outLogpp and tag
2349 * it with name "name."
2352 afs_icl_CreateLog(char *name, afs_int32 logSize,
2353 struct afs_icl_log **outLogpp)
2355 return afs_icl_CreateLogWithFlags(name, logSize, /*flags */ 0, outLogpp);
2358 /* create a log with size logSize; return it in *outLogpp and tag
2359 * it with name "name." 'flags' can be set to make the log unclearable.
2362 afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
2363 struct afs_icl_log **outLogpp)
2365 register struct afs_icl_log *logp;
2367 /* add into global list under lock */
2368 ObtainWriteLock(&afs_icl_lock, 183);
2369 if (!afs_icl_inited)
2372 for (logp = afs_icl_allLogs; logp; logp = logp->nextp) {
2373 if (strcmp(logp->name, name) == 0) {
2374 /* found it already created, just return it */
2377 if (flags & ICL_CRLOG_FLAG_PERSISTENT) {
2378 ObtainWriteLock(&logp->lock, 184);
2379 logp->states |= ICL_LOGF_PERSISTENT;
2380 ReleaseWriteLock(&logp->lock);
2382 ReleaseWriteLock(&afs_icl_lock);
2387 logp = (struct afs_icl_log *)
2388 osi_AllocSmallSpace(sizeof(struct afs_icl_log));
2389 memset((caddr_t) logp, 0, sizeof(*logp));
2392 logp->name = osi_AllocSmallSpace(strlen(name) + 1);
2393 strcpy(logp->name, name);
2394 LOCK_INIT(&logp->lock, "logp lock");
2395 logp->logSize = logSize;
2396 logp->datap = NULL; /* don't allocate it until we need it */
2398 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2399 logp->states |= ICL_LOGF_PERSISTENT;
2401 logp->nextp = afs_icl_allLogs;
2402 afs_icl_allLogs = logp;
2403 ReleaseWriteLock(&afs_icl_lock);
2409 /* called with a log, a pointer to a buffer, the size of the buffer
2410 * (in *bufSizep), the starting cookie (in *cookiep, use 0 at the start)
2411 * and returns data in the provided buffer, and returns output flags
2412 * in *flagsp. The flag ICL_COPYOUTF_MISSEDSOME is set if we can't
2413 * find the record with cookie value cookie.
2416 afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 * bufferp,
2417 afs_int32 * bufSizep, afs_uint32 * cookiep,
2420 afs_int32 nwords; /* number of words to copy out */
2421 afs_uint32 startCookie; /* first cookie to use */
2422 afs_int32 outWords; /* words we've copied out */
2423 afs_int32 inWords; /* max words to copy out */
2424 afs_int32 code; /* return code */
2425 afs_int32 ix; /* index we're copying from */
2426 afs_int32 outFlags; /* return flags */
2427 afs_int32 inFlags; /* flags passed in */
2430 inWords = *bufSizep; /* max to copy out */
2431 outWords = 0; /* amount copied out */
2432 startCookie = *cookiep;
2437 ObtainWriteLock(&logp->lock, 185);
2439 ReleaseWriteLock(&logp->lock);
2443 /* first, compute the index of the start cookie we've been passed */
2445 /* (re-)compute where we should start */
2446 if (startCookie < logp->baseCookie) {
2447 if (startCookie) /* missed some output */
2448 outFlags |= ICL_COPYOUTF_MISSEDSOME;
2449 /* skip to the first available record */
2450 startCookie = logp->baseCookie;
2451 *cookiep = startCookie;
2454 /* compute where we find the first element to copy out */
2455 ix = logp->firstUsed + startCookie - logp->baseCookie;
2456 if (ix >= logp->logSize)
2457 ix -= logp->logSize;
2459 /* if have some data now, break out and process it */
2460 if (startCookie - logp->baseCookie < logp->logElements)
2463 /* At end of log, so clear it if we need to */
2464 if (inFlags & ICL_COPYOUTF_CLRAFTERREAD) {
2465 logp->firstUsed = logp->firstFree = 0;
2466 logp->logElements = 0;
2468 /* otherwise, either wait for the data to arrive, or return */
2469 if (!(inFlags & ICL_COPYOUTF_WAITIO)) {
2470 ReleaseWriteLock(&logp->lock);
2474 logp->states |= ICL_LOGF_WAITING;
2475 ReleaseWriteLock(&logp->lock);
2476 afs_osi_Sleep(&logp->lock);
2477 ObtainWriteLock(&logp->lock, 186);
2479 /* copy out data from ix to logSize or firstFree, depending
2480 * upon whether firstUsed <= firstFree (no wrap) or otherwise.
2481 * be careful not to copy out more than nwords.
2483 if (ix >= logp->firstUsed) {
2484 if (logp->firstUsed <= logp->firstFree)
2486 end = logp->firstFree; /* first element not to copy */
2488 end = logp->logSize;
2489 nwords = inWords; /* don't copy more than this */
2490 if (end - ix < nwords)
2493 memcpy((char *)bufferp, (char *)&logp->datap[ix],
2494 sizeof(afs_int32) * nwords);
2499 /* if we're going to copy more out below, we'll start here */
2502 /* now, if active part of the log has wrapped, there's more stuff
2503 * starting at the head of the log. Copy out more from there.
2505 if (logp->firstUsed > logp->firstFree && ix < logp->firstFree
2507 /* (more to) copy out from the wrapped section at the
2508 * start of the log. May get here even if didn't copy any
2509 * above, if the cookie points directly into the wrapped section.
2512 if (logp->firstFree - ix < nwords)
2513 nwords = logp->firstFree - ix;
2514 memcpy((char *)bufferp, (char *)&logp->datap[ix],
2515 sizeof(afs_int32) * nwords);
2521 ReleaseWriteLock(&logp->lock);
2525 *bufSizep = outWords;
2531 /* return basic parameter information about a log */
2533 afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep,
2534 afs_int32 * curSizep)
2536 ObtainReadLock(&logp->lock);
2537 *maxSizep = logp->logSize;
2538 *curSizep = logp->logElements;
2539 ReleaseReadLock(&logp->lock);
2544 /* hold and release logs */
2546 afs_icl_LogHold(register struct afs_icl_log *logp)
2548 ObtainWriteLock(&afs_icl_lock, 187);
2550 ReleaseWriteLock(&afs_icl_lock);
2554 /* hold and release logs, called with lock already held */
2556 afs_icl_LogHoldNL(register struct afs_icl_log *logp)
2562 /* keep track of how many sets believe the log itself is allocated */
2564 afs_icl_LogUse(register struct afs_icl_log *logp)
2566 ObtainWriteLock(&logp->lock, 188);
2567 if (logp->setCount == 0) {
2568 /* this is the first set actually using the log -- allocate it */
2569 if (logp->logSize == 0) {
2570 /* we weren't passed in a hint and it wasn't set */
2571 logp->logSize = ICL_DEFAULT_LOGSIZE;
2574 (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
2575 #ifdef KERNEL_HAVE_PIN
2576 pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2580 ReleaseWriteLock(&logp->lock);
2584 /* decrement the number of real users of the log, free if possible */
2586 afs_icl_LogFreeUse(register struct afs_icl_log *logp)
2588 ObtainWriteLock(&logp->lock, 189);
2589 if (--logp->setCount == 0) {
2590 /* no more users -- free it (but keep log structure around) */
2591 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2592 #ifdef KERNEL_HAVE_PIN
2593 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2595 logp->firstUsed = logp->firstFree = 0;
2596 logp->logElements = 0;
2599 ReleaseWriteLock(&logp->lock);
2603 /* set the size of the log to 'logSize' */
2605 afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
2607 ObtainWriteLock(&logp->lock, 190);
2609 /* nothing to worry about since it's not allocated */
2610 logp->logSize = logSize;
2613 logp->firstUsed = logp->firstFree = 0;
2614 logp->logElements = 0;
2616 /* free and allocate a new one */
2617 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2618 #ifdef KERNEL_HAVE_PIN
2619 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2622 (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
2623 #ifdef KERNEL_HAVE_PIN
2624 pin((char *)logp->datap, sizeof(afs_int32) * logSize);
2626 logp->logSize = logSize;
2628 ReleaseWriteLock(&logp->lock);
2633 /* free a log. Called with afs_icl_lock locked. */
2635 afs_icl_ZapLog(register struct afs_icl_log *logp)
2637 register struct afs_icl_log **lpp, *tp;
2639 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2641 /* found the dude we want to remove */
2643 osi_FreeSmallSpace(logp->name);
2644 osi_FreeSmallSpace(logp->datap);
2645 osi_FreeSmallSpace(logp);
2646 break; /* won't find it twice */
2652 /* do the release, watching for deleted entries */
2654 afs_icl_LogRele(register struct afs_icl_log *logp)
2656 ObtainWriteLock(&afs_icl_lock, 191);
2657 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2658 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2660 ReleaseWriteLock(&afs_icl_lock);
2664 /* do the release, watching for deleted entries, log already held */
2666 afs_icl_LogReleNL(register struct afs_icl_log *logp)
2668 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2669 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2674 /* zero out the log */
2676 afs_icl_ZeroLog(register struct afs_icl_log *logp)
2678 ObtainWriteLock(&logp->lock, 192);
2679 logp->firstUsed = logp->firstFree = 0;
2680 logp->logElements = 0;
2681 logp->baseCookie = 0;
2682 ReleaseWriteLock(&logp->lock);
2686 /* free a log entry, and drop its reference count */
2688 afs_icl_LogFree(register struct afs_icl_log *logp)
2690 ObtainWriteLock(&logp->lock, 193);
2691 logp->states |= ICL_LOGF_DELETED;
2692 ReleaseWriteLock(&logp->lock);
2693 afs_icl_LogRele(logp);
2697 /* find a log by name, returning it held */
2698 struct afs_icl_log *
2699 afs_icl_FindLog(char *name)
2701 register struct afs_icl_log *tp;
2702 ObtainWriteLock(&afs_icl_lock, 194);
2703 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2704 if (strcmp(tp->name, name) == 0) {
2705 /* this is the dude we want */
2710 ReleaseWriteLock(&afs_icl_lock);
2715 afs_icl_EnumerateLogs(int (*aproc)
2716 (char *name, char *arock, struct afs_icl_log * tp),
2719 register struct afs_icl_log *tp;
2720 register afs_int32 code;
2723 ObtainWriteLock(&afs_icl_lock, 195);
2724 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2725 tp->refCount++; /* hold this guy */
2726 ReleaseWriteLock(&afs_icl_lock);
2727 ObtainReadLock(&tp->lock);
2728 code = (*aproc) (tp->name, arock, tp);
2729 ReleaseReadLock(&tp->lock);
2730 ObtainWriteLock(&afs_icl_lock, 196);
2731 if (--tp->refCount == 0)
2736 ReleaseWriteLock(&afs_icl_lock);
2740 struct afs_icl_set *afs_icl_allSets = 0;
2743 afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp,
2744 struct afs_icl_log *fatalLogp,
2745 struct afs_icl_set **outSetpp)
2747 return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp,
2748 /*flags */ 0, outSetpp);
2751 /* create a set, given pointers to base and fatal logs, if any.
2752 * Logs are unlocked, but referenced, and *outSetpp is returned
2753 * referenced. Function bumps reference count on logs, since it
2754 * addds references from the new afs_icl_set. When the set is destroyed,
2755 * those references will be released.
2758 afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
2759 struct afs_icl_log *fatalLogp, afs_uint32 flags,
2760 struct afs_icl_set **outSetpp)
2762 register struct afs_icl_set *setp;
2764 afs_int32 states = ICL_DEFAULT_SET_STATES;
2766 ObtainWriteLock(&afs_icl_lock, 197);
2767 if (!afs_icl_inited)
2770 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
2771 if (strcmp(setp->name, name) == 0) {
2774 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2775 ObtainWriteLock(&setp->lock, 198);
2776 setp->states |= ICL_SETF_PERSISTENT;
2777 ReleaseWriteLock(&setp->lock);
2779 ReleaseWriteLock(&afs_icl_lock);
2784 /* determine initial state */
2785 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2786 states = ICL_SETF_ACTIVE;
2787 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2788 states = ICL_SETF_FREED;
2789 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2790 states |= ICL_SETF_PERSISTENT;
2792 setp = (struct afs_icl_set *)afs_osi_Alloc(sizeof(struct afs_icl_set));
2793 memset((caddr_t) setp, 0, sizeof(*setp));
2795 if (states & ICL_SETF_FREED)
2796 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2797 setp->states = states;
2799 LOCK_INIT(&setp->lock, "setp lock");
2800 /* next lock is obtained in wrong order, hierarchy-wise, but
2801 * it doesn't matter, since no one can find this lock yet, since
2802 * the afs_icl_lock is still held, and thus the obtain can't block.
2804 ObtainWriteLock(&setp->lock, 199);
2805 setp->name = osi_AllocSmallSpace(strlen(name) + 1);
2806 strcpy(setp->name, name);
2807 setp->nevents = ICL_DEFAULTEVENTS;
2808 setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
2809 #ifdef KERNEL_HAVE_PIN
2810 pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2812 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2813 setp->eventFlags[i] = 0xff; /* default to enabled */
2815 /* update this global info under the afs_icl_lock */
2816 setp->nextp = afs_icl_allSets;
2817 afs_icl_allSets = setp;
2818 ReleaseWriteLock(&afs_icl_lock);
2820 /* set's basic lock is still held, so we can finish init */
2822 setp->logs[0] = baseLogp;
2823 afs_icl_LogHold(baseLogp);
2824 if (!(setp->states & ICL_SETF_FREED))
2825 afs_icl_LogUse(baseLogp); /* log is actually being used */
2828 setp->logs[1] = fatalLogp;
2829 afs_icl_LogHold(fatalLogp);
2830 if (!(setp->states & ICL_SETF_FREED))
2831 afs_icl_LogUse(fatalLogp); /* log is actually being used */
2833 ReleaseWriteLock(&setp->lock);
2839 /* function to change event enabling information for a particular set */
2841 afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
2845 ObtainWriteLock(&setp->lock, 200);
2846 if (!ICL_EVENTOK(setp, eventID)) {
2847 ReleaseWriteLock(&setp->lock);
2850 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2852 *tp |= ICL_EVENTMASK(eventID);
2854 *tp &= ~(ICL_EVENTMASK(eventID));
2855 ReleaseWriteLock(&setp->lock);
2859 /* return indication of whether a particular event ID is enabled
2860 * for tracing. If *getValuep is set to 0, the event is disabled,
2861 * otherwise it is enabled. All events start out enabled by default.
2864 afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep)
2866 ObtainReadLock(&setp->lock);
2867 if (!ICL_EVENTOK(setp, eventID)) {
2868 ReleaseWriteLock(&setp->lock);
2871 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2875 ReleaseReadLock(&setp->lock);
2879 /* hold and release event sets */
2881 afs_icl_SetHold(register struct afs_icl_set *setp)
2883 ObtainWriteLock(&afs_icl_lock, 201);
2885 ReleaseWriteLock(&afs_icl_lock);
2889 /* free a set. Called with afs_icl_lock locked */
2891 afs_icl_ZapSet(register struct afs_icl_set *setp)
2893 register struct afs_icl_set **lpp, *tp;
2895 register struct afs_icl_log *tlp;
2897 for (lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2899 /* found the dude we want to remove */
2901 osi_FreeSmallSpace(setp->name);
2902 afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
2903 #ifdef KERNEL_HAVE_PIN
2904 unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2906 for (i = 0; i < ICL_LOGSPERSET; i++) {
2907 if ((tlp = setp->logs[i]))
2908 afs_icl_LogReleNL(tlp);
2910 osi_FreeSmallSpace(setp);
2911 break; /* won't find it twice */
2917 /* do the release, watching for deleted entries */
2919 afs_icl_SetRele(register struct afs_icl_set *setp)
2921 ObtainWriteLock(&afs_icl_lock, 202);
2922 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2923 afs_icl_ZapSet(setp); /* destroys setp's lock! */
2925 ReleaseWriteLock(&afs_icl_lock);
2929 /* free a set entry, dropping its reference count */
2931 afs_icl_SetFree(register struct afs_icl_set *setp)
2933 ObtainWriteLock(&setp->lock, 203);
2934 setp->states |= ICL_SETF_DELETED;
2935 ReleaseWriteLock(&setp->lock);
2936 afs_icl_SetRele(setp);
2940 /* find a set by name, returning it held */
2941 struct afs_icl_set *
2942 afs_icl_FindSet(char *name)
2944 register struct afs_icl_set *tp;
2945 ObtainWriteLock(&afs_icl_lock, 204);
2946 for (tp = afs_icl_allSets; tp; tp = tp->nextp) {
2947 if (strcmp(tp->name, name) == 0) {
2948 /* this is the dude we want */
2953 ReleaseWriteLock(&afs_icl_lock);
2957 /* zero out all the logs in the set */
2959 afs_icl_ZeroSet(struct afs_icl_set *setp)
2964 struct afs_icl_log *logp;
2966 ObtainReadLock(&setp->lock);
2967 for (i = 0; i < ICL_LOGSPERSET; i++) {
2968 logp = setp->logs[i];
2970 afs_icl_LogHold(logp);
2971 tcode = afs_icl_ZeroLog(logp);
2973 code = tcode; /* save the last bad one */
2974 afs_icl_LogRele(logp);
2977 ReleaseReadLock(&setp->lock);
2982 afs_icl_EnumerateSets(int (*aproc)
2983 (char *name, char *arock, struct afs_icl_log * tp),
2986 register struct afs_icl_set *tp, *np;
2987 register afs_int32 code;
2990 ObtainWriteLock(&afs_icl_lock, 205);
2991 for (tp = afs_icl_allSets; tp; tp = np) {
2992 tp->refCount++; /* hold this guy */
2993 ReleaseWriteLock(&afs_icl_lock);
2994 code = (*aproc) (tp->name, arock, tp);
2995 ObtainWriteLock(&afs_icl_lock, 206);
2996 np = tp->nextp; /* tp may disappear next, but not np */
2997 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
3002 ReleaseWriteLock(&afs_icl_lock);
3007 afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
3012 ObtainWriteLock(&setp->lock, 207);
3013 for (i = 0; i < ICL_LOGSPERSET; i++) {
3014 if (!setp->logs[i]) {
3015 setp->logs[i] = newlogp;
3017 afs_icl_LogHold(newlogp);
3018 if (!(setp->states & ICL_SETF_FREED)) {
3019 /* bump up the number of sets using the log */
3020 afs_icl_LogUse(newlogp);
3025 ReleaseWriteLock(&setp->lock);
3030 afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
3034 struct afs_icl_log *logp;
3036 ObtainWriteLock(&setp->lock, 208);
3038 case ICL_OP_SS_ACTIVATE: /* activate a log */
3040 * If we are not already active, see if we have released
3041 * our demand that the log be allocated (FREED set). If
3042 * we have, reassert our desire.
3044 if (!(setp->states & ICL_SETF_ACTIVE)) {
3045 if (setp->states & ICL_SETF_FREED) {
3046 /* have to reassert desire for logs */
3047 for (i = 0; i < ICL_LOGSPERSET; i++) {
3048 logp = setp->logs[i];
3050 afs_icl_LogHold(logp);
3051 afs_icl_LogUse(logp);
3052 afs_icl_LogRele(logp);
3055 setp->states &= ~ICL_SETF_FREED;
3057 setp->states |= ICL_SETF_ACTIVE;
3062 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
3063 /* this doesn't require anything beyond clearing the ACTIVE flag */
3064 setp->states &= ~ICL_SETF_ACTIVE;
3068 case ICL_OP_SS_FREE: /* deassert design for log */
3070 * if we are already in this state, do nothing; otherwise
3071 * deassert desire for log
3073 if (setp->states & ICL_SETF_ACTIVE)
3076 if (!(setp->states & ICL_SETF_FREED)) {
3077 for (i = 0; i < ICL_LOGSPERSET; i++) {
3078 logp = setp->logs[i];
3080 afs_icl_LogHold(logp);
3081 afs_icl_LogFreeUse(logp);
3082 afs_icl_LogRele(logp);
3085 setp->states |= ICL_SETF_FREED;
3094 ReleaseWriteLock(&setp->lock);