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 %d).\n", code);
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", parm);
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);
712 if (count > AFS_MAX_INTERFACE_ADDR) {
714 count = AFS_MAX_INTERFACE_ADDR;
717 AFS_COPYIN((char *)parm3, (char *)buffer, count * sizeof(afs_int32),
720 AFS_COPYIN((char *)parm4, (char *)maskbuffer,
721 count * sizeof(afs_int32), code);
723 AFS_COPYIN((char *)parm5, (char *)mtubuffer,
724 count * sizeof(afs_int32), code);
726 afs_cb_interface.numberOfInterfaces = count;
727 for (i = 0; i < count; i++) {
728 afs_cb_interface.addr_in[i] = buffer[i];
729 #ifdef AFS_USERSPACE_IP_ADDR
730 /* AFS_USERSPACE_IP_ADDR means we have no way of finding the
731 * machines IP addresses when in the kernel (the in_ifaddr
732 * struct is not available), so we pass the info in at
733 * startup. We also pass in the subnetmask and mtu size. The
734 * subnetmask is used when setting the rank:
735 * afsi_SetServerIPRank(); and the mtu size is used when
736 * finding the best mtu size. rxi_FindIfnet() is replaced
737 * with rxi_Findcbi().
739 afs_cb_interface.subnetmask[i] =
740 (parm4 ? maskbuffer[i] : 0xffffffff);
741 afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500));
744 afs_uuid_create(&afs_cb_interface.uuid);
745 rxi_setaddr(buffer[0]);
746 afs_osi_Free(buffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
747 afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
748 afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
751 else if (parm == AFSOP_NFSSTATICADDR) {
752 extern int (*nfs_rfsdisptab_v2) ();
753 nfs_rfsdisptab_v2 = (int (*)())parm2;
754 } else if (parm == AFSOP_NFSSTATICADDR2) {
755 extern int (*nfs_rfsdisptab_v2) ();
757 nfs_rfsdisptab_v2 = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff));
759 nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff);
762 #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV)
763 else if (parm == AFSOP_SBLOCKSTATICADDR2) {
764 extern int (*afs_sblockp) ();
765 extern void (*afs_sbunlockp) ();
767 afs_sblockp = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff));
768 afs_sbunlockp = (void (*)())((parm4 << 32) | (parm5 & 0xffffffff));
770 afs_sblockp = (int (*)())(parm3 & 0xffffffff);
771 afs_sbunlockp = (void (*)())(parm5 & 0xffffffff);
774 #endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */
775 #endif /* AFS_SGI53_ENV */
776 else if (parm == AFSOP_SHUTDOWN) {
777 afs_cold_shutdown = 0;
779 afs_cold_shutdown = 1;
780 #ifndef AFS_DARWIN_ENV
781 if (afs_globalVFS != 0) {
782 afs_warn("AFS isn't unmounted yet! Call aborted\n");
787 } else if (parm == AFSOP_AFS_VFSMOUNT) {
789 vfsmount(parm2, parm3, parm4, parm5);
790 #else /* defined(AFS_HPUX_ENV) */
791 #if defined(KERNEL_HAVE_UERROR)
796 #endif /* defined(AFS_HPUX_ENV) */
797 } else if (parm == AFSOP_CLOSEWAIT) {
798 afs_SynchronousCloses = 'S';
799 } else if (parm == AFSOP_GETMTU) {
801 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
802 #ifdef AFS_USERSPACE_IP_ADDR
804 i = rxi_Findcbi(parm2);
805 mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]);
806 #else /* AFS_USERSPACE_IP_ADDR */
809 tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */
810 mtu = (tifnp ? tifnp->if_mtu : htonl(1500));
811 #endif /* else AFS_USERSPACE_IP_ADDR */
812 #endif /* !AFS_SUN5_ENV */
814 AFS_COPYOUT((caddr_t) & mtu, (caddr_t) parm3, sizeof(afs_int32),
817 /* this is disabled for now because I can't figure out how to get access
818 * to these kernel variables. It's only for supporting user-mode rx
819 * programs -- it makes a huge difference on the 220's in my testbed,
820 * though I don't know why. The bosserver does this with /etc/no, so it's
821 * being handled a different way for the servers right now. */
824 extern u_long sb_max_dflt;
827 if (sb_max_dflt < 131072) sb_max_dflt = 131072;
828 if (sb_max < 131072) sb_max = 131072;
831 #endif /* AFS_AIX32_ENV */
832 } else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */
834 #if !defined(AFS_SUN5_ENV)
835 #ifdef AFS_USERSPACE_IP_ADDR
837 i = rxi_Findcbi(parm2);
839 mask = afs_cb_interface.subnetmask[i];
843 #else /* AFS_USERSPACE_IP_ADDR */
846 tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */
849 #endif /* else AFS_USERSPACE_IP_ADDR */
850 #endif /* !AFS_SUN5_ENV */
852 AFS_COPYOUT((caddr_t) & mask, (caddr_t) parm3, sizeof(afs_int32),
856 else if (parm == AFSOP_AFSDB_HANDLER) {
857 int sizeArg = (int)parm4;
858 int kmsgLen = sizeArg & 0xffff;
859 int cellLen = (sizeArg & 0xffff0000) >> 16;
860 afs_int32 *kmsg = afs_osi_Alloc(kmsgLen);
861 char *cellname = afs_osi_Alloc(cellLen);
864 afs_osi_MaskSignals();
866 AFS_COPYIN((afs_int32 *) parm2, cellname, cellLen, code);
867 AFS_COPYIN((afs_int32 *) parm3, kmsg, kmsgLen, code);
869 code = afs_AFSDBHandler(cellname, cellLen, kmsg);
872 if (code == -2) { /* Shutting down? */
878 AFS_COPYOUT(cellname, (char *)parm2, cellLen, code);
879 afs_osi_Free(kmsg, kmsgLen);
880 afs_osi_Free(cellname, cellLen);
883 else if (parm == AFSOP_SET_DYNROOT) {
884 code = afs_SetDynrootEnable(parm2);
885 } else if (parm == AFSOP_SET_FAKESTAT) {
886 afs_fakestat_enable = parm2;
888 } else if (parm == AFSOP_SET_BACKUPTREE) {
889 afs_bkvolpref = parm2;
895 #ifdef AFS_LINUX20_ENV
904 #include "sys/lockl.h"
907 * syscall - this is the VRMIX system call entry point.
910 * THIS SHOULD BE CHANGED TO afs_syscall(), but requires
911 * all the user-level calls to `syscall' to change.
913 syscall(syscall, p1, p2, p3, p4, p5, p6)
915 register rval1 = 0, code;
918 #ifndef AFS_AIX41_ENV
919 extern lock_t kernel_lock;
920 monster = lockl(&kernel_lock, LOCK_SHORT);
921 #endif /* !AFS_AIX41_ENV */
923 AFS_STATCNT(syscall);
927 rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6);
932 rval1 = afs_setpag();
938 rval1 = afs_syscall_pioctl(p1, p2, p3, p4);
942 case AFSCALL_ICREATE:
943 rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6);
947 rval1 = afs_syscall_iopen(p1, p2, p3);
951 rval1 = afs_syscall_iincdec(p1, p2, p3, -1);
955 rval1 = afs_syscall_iincdec(p1, p2, p3, 1);
960 code = Afscall_icl(p1, p2, p3, p4, p5, &retval);
975 #ifndef AFS_AIX41_ENV
976 if (monster != LOCK_NEST)
977 unlockl(&kernel_lock);
978 #endif /* !AFS_AIX41_ENV */
979 return getuerror()? -1 : rval1;
983 * lsetpag - interface to afs_setpag().
988 AFS_STATCNT(lsetpag);
989 return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0);
993 * lpioctl - interface to pioctl()
995 lpioctl(path, cmd, cmarg, follow)
999 AFS_STATCNT(lpioctl);
1000 return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow);
1003 #else /* !AFS_AIX32_ENV */
1005 #if defined(AFS_SGI_ENV)
1017 Afs_syscall(struct afsargs *uap, rval_t * rvp)
1022 AFS_STATCNT(afs_syscall);
1023 switch (uap->syscall) {
1028 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1029 uap->parm5, &retval);
1031 rvp->r_val1 = retval;
1033 #ifdef AFS_SGI_XFS_IOPS_ENV
1034 case AFSCALL_IDEC64:
1036 afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1039 case AFSCALL_IINC64:
1041 afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1044 case AFSCALL_ILISTINODE64:
1046 afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3,
1047 uap->parm4, uap->parm5);
1049 case AFSCALL_ICREATENAME64:
1051 afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3,
1052 uap->parm4, uap->parm5);
1055 #ifdef AFS_SGI_VNODE_GLUE
1056 case AFSCALL_INIT_KERNEL_CONFIG:
1057 error = afs_init_kernel_config(uap->parm1);
1062 afs_syscall_call(uap->syscall, uap->parm1, uap->parm2, uap->parm3,
1063 uap->parm4, uap->parm5);
1068 #else /* AFS_SGI_ENV */
1086 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
1088 dst->param1 = src->param1;
1089 dst->param2 = src->param2;
1090 dst->param3 = src->param3;
1091 dst->param4 = src->param4;
1095 * If you need to change copyin_iparam(), you may also need to change
1096 * copyin_afs_ioctl().
1100 copyin_iparam(caddr_t cmarg, struct iparam *dst)
1104 #if defined(AFS_HPUX_64BIT_ENV)
1105 struct iparam32 dst32;
1107 if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */
1108 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1110 iparam32_to_iparam(&dst32, dst);
1113 #endif /* AFS_HPUX_64BIT_ENV */
1115 #if defined(AFS_SUN57_64BIT_ENV)
1116 struct iparam32 dst32;
1118 if (get_udatamodel() == DATAMODEL_ILP32) {
1119 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1121 iparam32_to_iparam(&dst32, dst);
1124 #endif /* AFS_SUN57_64BIT_ENV */
1126 #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
1127 struct iparam32 dst32;
1129 #ifdef AFS_SPARC64_LINUX24_ENV
1130 if (current->thread.flags & SPARC_FLAG_32BIT)
1131 #elif defined(AFS_SPARC64_LINUX20_ENV)
1132 if (current->tss.flags & SPARC_FLAG_32BIT)
1133 #elif defined(AFS_AMD64_LINUX20_ENV)
1134 if (current->thread.flags & THREAD_IA32)
1135 #elif defined(AFS_PPC64_LINUX20_ENV)
1136 if (current->thread.flags & PPC_FLAG_32BIT)
1138 #error Not done for this linux version
1141 AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
1143 iparam32_to_iparam(&dst32, dst);
1146 #endif /* AFS_LINUX_64BIT_KERNEL */
1148 AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
1152 /* Main entry of all afs system calls */
1154 extern int afs_sinited;
1156 /** The 32 bit OS expects the members of this structure to be 32 bit
1157 * quantities and the 64 bit OS expects them as 64 bit quanties. Hence
1158 * to accomodate both, *long* is used instead of afs_int32
1161 #ifdef AFS_SUN57_ENV
1183 Afs_syscall(register struct afssysa *uap, rval_t * rvp)
1185 int *retval = &rvp->r_val1;
1186 #else /* AFS_SUN5_ENV */
1187 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1189 afs3_syscall(p, args, retval)
1190 #ifdef AFS_FBSD50_ENV
1206 } *uap = (struct a *)args;
1207 #else /* AFS_OSF_ENV */
1208 #ifdef AFS_LINUX20_ENV
1216 long parm6; /* not actually used - should be removed */
1218 /* Linux system calls only set up for 5 arguments. */
1220 afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4)
1222 struct afssysargs args, *uap = &args;
1224 long *retval = &linux_ret;
1225 long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */
1226 #ifdef AFS_SPARC64_LINUX24_ENV
1227 afs_int32 eparm32[4];
1229 /* eparm is also used by AFSCALL_CALL in afsd.c */
1231 #if defined(UKERNEL)
1242 } *uap = (struct a *)u.u_ap;
1245 #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
1249 #endif /* SUN && !SUN5 */
1259 } *uap = (struct a *)u.u_ap;
1260 #endif /* UKERNEL */
1261 #if defined(AFS_DEC_ENV)
1262 int *retval = &u.u_r.r_val1;
1263 #elif defined(AFS_HPUX_ENV)
1264 long *retval = &u.u_rval1;
1266 int *retval = &u.u_rval1;
1268 #endif /* AFS_LINUX20_ENV */
1269 #endif /* AFS_OSF_ENV */
1270 #endif /* AFS_SUN5_ENV */
1271 register int code = 0;
1273 AFS_STATCNT(afs_syscall);
1280 #ifdef AFS_LINUX20_ENV
1282 /* setup uap for use below - pull out the magic decoder ring to know
1283 * which syscalls have folded argument lists.
1285 uap->syscall = syscall;
1289 if (syscall == AFSCALL_ICL || syscall == AFSCALL_CALL) {
1290 #ifdef AFS_SPARC64_LINUX24_ENV
1291 /* from arch/sparc64/kernel/sys_sparc32.c */
1293 ({ unsigned long __ret; \
1294 __asm__ ("srl %0, 0, %0" \
1301 if (current->thread.flags & SPARC_FLAG_32BIT) {
1302 AFS_COPYIN((char *)parm4, (char *)eparm32, sizeof(eparm32), code);
1303 eparm[0] = AA(eparm32[0]);
1304 eparm[1] = AA(eparm32[1]);
1305 eparm[2] = AA(eparm32[2]);
1309 AFS_COPYIN((char *)parm4, (char *)eparm, sizeof(eparm), code);
1310 uap->parm4 = eparm[0];
1311 uap->parm5 = eparm[1];
1312 uap->parm6 = eparm[2];
1320 #if defined(AFS_HPUX_ENV)
1322 * There used to be code here (duplicated from osi_Init()) for
1323 * initializing the semaphore used by AFS_GLOCK(). Was the
1324 * duplication to handle the case of a dynamically loaded kernel
1329 if (uap->syscall == AFSCALL_CALL) {
1332 afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1333 uap->parm5, uap->parm6, rvp, CRED());
1336 afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1337 uap->parm5, uap->parm6);
1339 } else if (uap->syscall == AFSCALL_SETPAG) {
1341 register proc_t *procp;
1343 procp = ttoproc(curthread);
1345 code = afs_setpag(&procp->p_cred);
1349 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1350 code = afs_setpag(p, args, retval);
1351 #else /* AFS_OSF_ENV */
1352 code = afs_setpag();
1356 } else if (uap->syscall == AFSCALL_PIOCTL) {
1358 #if defined(AFS_SUN5_ENV)
1360 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1362 #elif defined(AFS_FBSD50_ENV)
1364 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1366 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1368 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1369 p->p_cred->pc_ucred);
1372 afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3,
1376 } else if (uap->syscall == AFSCALL_ICREATE) {
1377 struct iparam iparams;
1379 code = copyin_iparam((char *)uap->parm3, &iparams);
1381 #if defined(KERNEL_HAVE_UERROR)
1387 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
1388 iparams.param2, iparams.param3,
1389 iparams.param4, rvp, CRED());
1392 afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1,
1394 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1395 iparams.param3, iparams.param4, retval);
1397 iparams.param3, iparams.param4);
1399 #endif /* AFS_SUN5_ENV */
1400 } else if (uap->syscall == AFSCALL_IOPEN) {
1403 afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp,
1406 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1407 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval);
1409 code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3);
1411 #endif /* AFS_SUN5_ENV */
1412 } else if (uap->syscall == AFSCALL_IDEC) {
1415 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp,
1418 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1);
1419 #endif /* AFS_SUN5_ENV */
1420 } else if (uap->syscall == AFSCALL_IINC) {
1423 afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp,
1426 code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1);
1427 #endif /* AFS_SUN5_ENV */
1428 } else if (uap->syscall == AFSCALL_ICL) {
1431 Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4,
1432 uap->parm5, retval);
1434 #ifdef AFS_LINUX20_ENV
1436 /* ICL commands can return values. */
1437 code = -linux_ret; /* Gets negated again at exit below */
1441 #if defined(KERNEL_HAVE_UERROR)
1445 #endif /* !AFS_LINUX20_ENV */
1447 #if defined(KERNEL_HAVE_UERROR)
1454 #ifdef AFS_LINUX20_ENV
1460 #endif /* AFS_SGI_ENV */
1461 #endif /* !AFS_AIX32_ENV */
1464 * Initstate in the range 0 < x < 100 are early initialization states.
1465 * Initstate of 100 means a AFSOP_START operation has been done. After this,
1466 * the cache may be initialized.
1467 * Initstate of 101 means a AFSOP_GO operation has been done. This operation
1468 * is done after all the cache initialization has been done.
1469 * Initstate of 200 means that the volume has been looked up once, possibly
1471 * Initstate of 300 means that the volume has been *successfully* looked up.
1476 register int code = 0;
1478 AFS_STATCNT(afs_CheckInit);
1479 if (afs_initState <= 100)
1480 code = ENXIO; /* never finished init phase */
1481 else if (afs_initState == 101) { /* init done, wait for afs_daemon */
1482 while (afs_initState < 200)
1483 afs_osi_Sleep(&afs_initState);
1484 } else if (afs_initState == 200)
1485 code = ETIMEDOUT; /* didn't find root volume */
1489 int afs_shuttingdown = 0;
1493 extern short afs_brsDaemons;
1494 extern afs_int32 afs_CheckServerDaemonStarted;
1495 extern struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler;
1496 extern struct osi_file *afs_cacheInodep;
1498 AFS_STATCNT(afs_shutdown);
1499 if (afs_shuttingdown)
1501 afs_shuttingdown = 1;
1502 if (afs_cold_shutdown)
1506 afs_warn("shutting down of: CB... ");
1508 afs_termState = AFSOP_STOP_RXCALLBACK;
1509 rx_WakeupServerProcs();
1510 /* shutdown_rxkernel(); */
1511 while (afs_termState == AFSOP_STOP_RXCALLBACK)
1512 afs_osi_Sleep(&afs_termState);
1514 afs_warn("afs... ");
1515 while (afs_termState == AFSOP_STOP_AFS) {
1516 afs_osi_CancelWait(&AFS_WaitHandler);
1517 afs_osi_Sleep(&afs_termState);
1519 if (afs_CheckServerDaemonStarted) {
1520 while (afs_termState == AFSOP_STOP_CS) {
1521 afs_osi_CancelWait(&AFS_CSWaitHandler);
1522 afs_osi_Sleep(&afs_termState);
1525 afs_warn("BkG... ");
1526 /* Wake-up afs_brsDaemons so that we don't have to wait for a bkg job! */
1527 while (afs_termState == AFSOP_STOP_BKG) {
1528 afs_osi_Wakeup(&afs_brsDaemons);
1529 afs_osi_Sleep(&afs_termState);
1531 afs_warn("CTrunc... ");
1532 /* Cancel cache truncate daemon. */
1533 while (afs_termState == AFSOP_STOP_TRUNCDAEMON) {
1534 afs_osi_Wakeup((char *)&afs_CacheTruncateDaemon);
1535 afs_osi_Sleep(&afs_termState);
1537 #ifdef AFS_AFSDB_ENV
1538 afs_warn("AFSDB... ");
1540 while (afs_termState == AFSOP_STOP_AFSDB)
1541 afs_osi_Sleep(&afs_termState);
1543 #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV)
1544 afs_warn("RxEvent... ");
1545 /* cancel rx event daemon */
1546 while (afs_termState == AFSOP_STOP_RXEVENT)
1547 afs_osi_Sleep(&afs_termState);
1548 #if defined(RXK_LISTENER_ENV)
1550 afs_warn("UnmaskRxkSignals... ");
1551 afs_osi_UnmaskRxkSignals();
1553 /* cancel rx listener */
1554 afs_warn("RxListener... ");
1555 osi_StopListener(); /* This closes rx_socket. */
1556 while (afs_termState == AFSOP_STOP_RXK_LISTENER) {
1557 afs_warn("Sleep... ");
1558 afs_osi_Sleep(&afs_termState);
1562 afs_termState = AFSOP_STOP_COMPLETE;
1566 /* Close file only after daemons which can write to it are stopped. */
1567 if (afs_cacheInodep) { /* memcache won't set this */
1568 osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */
1569 afs_cacheInodep = 0;
1571 return; /* Just kill daemons for now */
1575 shutdown_rxkernel();
1579 shutdown_bufferpackage();
1585 shutdown_vnodeops();
1587 shutdown_exporter();
1588 shutdown_memcache();
1589 #if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)
1590 #if !defined(AFS_DEC_ENV) && !defined(AFS_OSF_ENV)
1591 /* this routine does not exist in Ultrix systems... 93.01.19 */
1593 #endif /* AFS_DEC_ENV */
1596 /* The following hold the cm stats */
1598 memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
1599 memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf));
1600 memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
1602 afs_warn(" ALL allocated tables\n");
1603 afs_shuttingdown = 0;
1608 shutdown_afstest(void)
1610 AFS_STATCNT(shutdown_afstest);
1611 afs_initState = afs_termState = afs_setTime = 0;
1612 AFS_Running = afs_CB_Running = 0;
1613 afs_CacheInit_Done = afs_Go_Done = 0;
1614 if (afs_cold_shutdown) {
1615 *afs_rootVolumeName = 0;
1620 /* In case there is a bunch of dynamically build bkg daemons to free */
1622 afs_shutdown_BKG(void)
1624 AFS_STATCNT(shutdown_BKG);
1628 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
1629 /* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
1630 #if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
1631 int afs_icl_sizeofLong = 1;
1633 int afs_icl_sizeofLong = 2;
1636 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1637 int afs_icl_sizeofLong = 2;
1639 int afs_icl_sizeofLong = 1;
1643 int afs_icl_inited = 0;
1645 /* init function, called once, under afs_icl_lock */
1653 extern struct afs_icl_log *afs_icl_FindLog();
1654 extern struct afs_icl_set *afs_icl_FindSet();
1658 Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
1660 afs_int32 *lp, elts, flags;
1661 register afs_int32 code;
1662 struct afs_icl_log *logp;
1663 struct afs_icl_set *setp;
1664 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
1666 #else /* AFS_SGI61_ENV */
1667 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1672 #endif /* AFS_SGI61_ENV */
1674 afs_int32 startCookie;
1675 afs_int32 allocated;
1676 struct afs_icl_log *tlp;
1679 if (!afs_suser(CRED())) { /* only root can run this code */
1683 if (!afs_suser()) { /* only root can run this code */
1684 #if defined(KERNEL_HAVE_UERROR)
1693 case ICL_OP_COPYOUTCLR: /* copy out data then clear */
1694 case ICL_OP_COPYOUT: /* copy ouy data */
1695 /* copyout: p1=logname, p2=&buffer, p3=size(words), p4=&cookie
1696 * return flags<<24 + nwords.
1697 * updates cookie to updated start (not end) if we had to
1698 * skip some records.
1700 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1703 AFS_COPYIN((char *)p4, (char *)&startCookie, sizeof(afs_int32), code);
1706 logp = afs_icl_FindLog(tname);
1709 #define BUFFERSIZE AFS_LRALLOCSIZ
1710 lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
1711 elts = BUFFERSIZE / sizeof(afs_int32);
1714 flags = (opcode == ICL_OP_COPYOUT) ? 0 : ICL_COPYOUTF_CLRAFTERREAD;
1716 afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) & startCookie,
1719 osi_FreeLargeSpace((struct osi_buffer *)lp);
1722 AFS_COPYOUT((char *)lp, (char *)p2, elts * sizeof(afs_int32), code);
1725 AFS_COPYOUT((char *)&startCookie, (char *)p4, sizeof(afs_int32),
1729 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
1731 *retval = ((long)((flags << 24) | (elts & 0xffffff))) << 32;
1734 *retval = (flags << 24) | (elts & 0xffffff);
1736 afs_icl_LogRele(logp);
1737 osi_FreeLargeSpace((struct osi_buffer *)lp);
1740 case ICL_OP_ENUMLOGS: /* enumerate logs */
1741 /* enumerate logs: p1=index, p2=&name, p3=sizeof(name), p4=&size.
1742 * return 0 for success, otherwise error.
1744 for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) {
1749 return ENOENT; /* past the end of file */
1750 temp = strlen(tlp->name) + 1;
1753 AFS_COPYOUT(tlp->name, (char *)p2, temp, code);
1754 if (!code) /* copy out size of log */
1755 AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof(afs_int32),
1759 case ICL_OP_ENUMLOGSBYSET: /* enumerate logs by set name */
1760 /* enumerate logs: p1=setname, p2=index, p3=&name, p4=sizeof(name).
1761 * return 0 for success, otherwise error.
1763 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1766 setp = afs_icl_FindSet(tname);
1769 if (p2 > ICL_LOGSPERSET)
1771 if (!(tlp = setp->logs[p2]))
1773 temp = strlen(tlp->name) + 1;
1776 AFS_COPYOUT(tlp->name, (char *)p3, temp, code);
1779 case ICL_OP_CLRLOG: /* clear specified log */
1780 /* zero out the specified log: p1=logname */
1781 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1784 logp = afs_icl_FindLog(tname);
1787 code = afs_icl_ZeroLog(logp);
1788 afs_icl_LogRele(logp);
1791 case ICL_OP_CLRSET: /* clear specified set */
1792 /* zero out the specified set: p1=setname */
1793 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1796 setp = afs_icl_FindSet(tname);
1799 code = afs_icl_ZeroSet(setp);
1800 afs_icl_SetRele(setp);
1803 case ICL_OP_CLRALL: /* clear all logs */
1804 /* zero out all logs -- no args */
1806 ObtainWriteLock(&afs_icl_lock, 178);
1807 for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) {
1808 tlp->refCount++; /* hold this guy */
1809 ReleaseWriteLock(&afs_icl_lock);
1810 /* don't clear persistent logs */
1811 if ((tlp->states & ICL_LOGF_PERSISTENT) == 0)
1812 code = afs_icl_ZeroLog(tlp);
1813 ObtainWriteLock(&afs_icl_lock, 179);
1814 if (--tlp->refCount == 0)
1815 afs_icl_ZapLog(tlp);
1819 ReleaseWriteLock(&afs_icl_lock);
1822 case ICL_OP_ENUMSETS: /* enumerate all sets */
1823 /* enumerate sets: p1=index, p2=&name, p3=sizeof(name), p4=&states.
1824 * return 0 for success, otherwise error.
1826 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
1831 return ENOENT; /* past the end of file */
1832 temp = strlen(setp->name) + 1;
1835 AFS_COPYOUT(setp->name, (char *)p2, temp, code);
1836 if (!code) /* copy out size of log */
1837 AFS_COPYOUT((char *)&setp->states, (char *)p4, sizeof(afs_int32),
1841 case ICL_OP_SETSTAT: /* set status on a set */
1842 /* activate the specified set: p1=setname, p2=op */
1843 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1846 setp = afs_icl_FindSet(tname);
1849 code = afs_icl_SetSetStat(setp, p2);
1850 afs_icl_SetRele(setp);
1853 case ICL_OP_SETSTATALL: /* set status on all sets */
1854 /* activate the specified set: p1=op */
1856 ObtainWriteLock(&afs_icl_lock, 180);
1857 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
1858 setp->refCount++; /* hold this guy */
1859 ReleaseWriteLock(&afs_icl_lock);
1860 /* don't set states on persistent sets */
1861 if ((setp->states & ICL_SETF_PERSISTENT) == 0)
1862 code = afs_icl_SetSetStat(setp, p1);
1863 ObtainWriteLock(&afs_icl_lock, 181);
1864 if (--setp->refCount == 0)
1865 afs_icl_ZapSet(setp);
1869 ReleaseWriteLock(&afs_icl_lock);
1872 case ICL_OP_SETLOGSIZE: /* set size of log */
1873 /* set the size of the specified log: p1=logname, p2=size (in words) */
1874 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1877 logp = afs_icl_FindLog(tname);
1880 code = afs_icl_LogSetSize(logp, p2);
1881 afs_icl_LogRele(logp);
1884 case ICL_OP_GETLOGINFO: /* get size of log */
1885 /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */
1886 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1889 logp = afs_icl_FindLog(tname);
1892 allocated = !!logp->datap;
1893 AFS_COPYOUT((char *)&logp->logSize, (char *)p2, sizeof(afs_int32),
1896 AFS_COPYOUT((char *)&allocated, (char *)p3, sizeof(afs_int32),
1898 afs_icl_LogRele(logp);
1901 case ICL_OP_GETSETINFO: /* get state of set */
1902 /* zero out the specified set: p1=setname, p2=&state */
1903 AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
1906 setp = afs_icl_FindSet(tname);
1909 AFS_COPYOUT((char *)&setp->states, (char *)p2, sizeof(afs_int32),
1911 afs_icl_SetRele(setp);
1922 afs_lock_t afs_icl_lock;
1924 /* exported routine: a 4 parameter event */
1926 afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
1927 afs_int32 lAndT, long p1, long p2, long p3, long p4)
1931 register afs_int32 tmask;
1934 /* If things aren't init'ed yet (or the set is inactive), don't panic */
1935 if (!ICL_SETACTIVE(setp))
1939 mask = lAndT >> 24 & 0xff; /* mask of which logs to log to */
1940 ix = ICL_EVENTBYTE(eventID);
1941 ObtainReadLock(&setp->lock);
1942 if (setp->eventFlags[ix] & ICL_EVENTMASK(eventID)) {
1943 for (i = 0, tmask = 1; i < ICL_LOGSPERSET; i++, tmask <<= 1) {
1945 afs_icl_AppendRecord(setp->logs[i], eventID, lAndT & 0xffffff,
1950 break; /* break early */
1953 ReleaseReadLock(&setp->lock);
1957 /* Next 4 routines should be implemented via var-args or something.
1958 * Whole purpose is to avoid compiler warnings about parameter # mismatches.
1959 * Otherwise, could call afs_icl_Event4 directly.
1962 afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID,
1963 afs_int32 lAndT, long p1, long p2, long p3)
1965 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
1969 afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID,
1970 afs_int32 lAndT, long p1, long p2)
1972 return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
1976 afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
1977 afs_int32 lAndT, long p1)
1979 return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0,
1984 afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID,
1987 return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0,
1991 struct afs_icl_log *afs_icl_allLogs = 0;
1993 /* function to purge records from the start of the log, until there
1994 * is at least minSpace long's worth of space available without
1995 * making the head and the tail point to the same word.
1997 * Log must be write-locked.
2000 afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
2002 register unsigned int tsize;
2004 while (logp->logSize - logp->logElements <= minSpace) {
2006 tsize = ((logp->datap[logp->firstUsed]) >> 24) & 0xff;
2007 logp->logElements -= tsize;
2008 logp->firstUsed += tsize;
2009 if (logp->firstUsed >= logp->logSize)
2010 logp->firstUsed -= logp->logSize;
2011 logp->baseCookie += tsize;
2015 /* append string astr to buffer, including terminating null char.
2017 * log must be write-locked.
2019 #define ICL_CHARSPERLONG 4
2021 afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
2023 char *op; /* ptr to char to write */
2025 register int bib; /* bytes in buffer */
2028 op = (char *)&(logp->datap[logp->firstFree]);
2032 if (++bib >= ICL_CHARSPERLONG) {
2035 if (++(logp->firstFree) >= logp->logSize) {
2036 logp->firstFree = 0;
2037 op = (char *)&(logp->datap[0]);
2039 logp->logElements++;
2045 /* if we've used this word at all, allocate it */
2046 if (++(logp->firstFree) >= logp->logSize) {
2047 logp->firstFree = 0;
2049 logp->logElements++;
2053 /* add a long to the log, ignoring overflow (checked already) */
2054 #define ICL_APPENDINT32(lp, x) \
2056 (lp)->datap[(lp)->firstFree] = (x); \
2057 if (++((lp)->firstFree) >= (lp)->logSize) { \
2058 (lp)->firstFree = 0; \
2060 (lp)->logElements++; \
2063 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2064 #define ICL_APPENDLONG(lp, x) \
2066 ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
2067 ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
2070 #else /* AFS_ALPHA_ENV */
2071 #define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
2072 #endif /* AFS_ALPHA_ENV */
2074 /* routine to tell whether we're dealing with the address or the
2078 afs_icl_UseAddr(int type)
2080 if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
2081 || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
2087 /* Function to append a record to the log. Written for speed
2088 * since we know that we're going to have to make this work fast
2089 * pretty soon, anyway. The log must be unlocked.
2093 afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
2094 afs_int32 types, long p1, long p2, long p3, long p4)
2096 int rsize; /* record size in longs */
2097 register int tsize; /* temp size */
2101 t4 = types & 0x3f; /* decode types */
2109 osi_GetTime(&tv); /* It panics for solaris if inside */
2110 ObtainWriteLock(&logp->lock, 182);
2112 ReleaseWriteLock(&logp->lock);
2116 /* get timestamp as # of microseconds since some time that doesn't
2117 * change that often. This algorithm ticks over every 20 minutes
2118 * or so (1000 seconds). Write a timestamp record if it has.
2120 if (tv.tv_sec - logp->lastTS > 1024) {
2121 /* the timer has wrapped -- write a timestamp record */
2122 if (logp->logSize - logp->logElements <= 5)
2123 afs_icl_GetLogSpace(logp, 5);
2125 ICL_APPENDINT32(logp,
2126 (afs_int32) (5 << 24) + (ICL_TYPE_UNIXDATE << 18));
2127 ICL_APPENDINT32(logp, (afs_int32) ICL_INFO_TIMESTAMP);
2128 ICL_APPENDINT32(logp, (afs_int32) 0); /* use thread ID zero for clocks */
2129 ICL_APPENDINT32(logp,
2130 (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 +
2132 ICL_APPENDINT32(logp, (afs_int32) tv.tv_sec);
2134 logp->lastTS = tv.tv_sec;
2137 rsize = 4; /* base case */
2139 /* compute size of parameter p1. Only tricky case is string.
2140 * In that case, we have to call strlen to get the string length.
2142 ICL_SIZEHACK(t1, p1);
2145 /* compute size of parameter p2. Only tricky case is string.
2146 * In that case, we have to call strlen to get the string length.
2148 ICL_SIZEHACK(t2, p2);
2151 /* compute size of parameter p3. Only tricky case is string.
2152 * In that case, we have to call strlen to get the string length.
2154 ICL_SIZEHACK(t3, p3);
2157 /* compute size of parameter p4. Only tricky case is string.
2158 * In that case, we have to call strlen to get the string length.
2160 ICL_SIZEHACK(t4, p4);
2163 /* At this point, we've computed all of the parameter sizes, and
2164 * have in rsize the size of the entire record we want to append.
2165 * Next, we check that we actually have room in the log to do this
2166 * work, and then we do the append.
2169 ReleaseWriteLock(&logp->lock);
2170 return; /* log record too big to express */
2173 if (logp->logSize - logp->logElements <= rsize)
2174 afs_icl_GetLogSpace(logp, rsize);
2176 ICL_APPENDINT32(logp,
2177 (afs_int32) (rsize << 24) + (t1 << 18) + (t2 << 12) +
2179 ICL_APPENDINT32(logp, (afs_int32) op);
2180 ICL_APPENDINT32(logp, (afs_int32) osi_ThreadUnique());
2181 ICL_APPENDINT32(logp,
2182 (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
2185 /* marshall parameter 1 now */
2186 if (t1 == ICL_TYPE_STRING) {
2187 afs_icl_AppendString(logp, (char *)p1);
2188 } else if (t1 == ICL_TYPE_HYPER) {
2189 ICL_APPENDINT32(logp,
2190 (afs_int32) ((struct afs_hyper_t *)p1)->high);
2191 ICL_APPENDINT32(logp,
2192 (afs_int32) ((struct afs_hyper_t *)p1)->low);
2193 } else if (t1 == ICL_TYPE_INT64) {
2194 #ifdef AFSLITTLE_ENDIAN
2195 #ifdef AFS_64BIT_CLIENT
2196 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2197 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2198 #else /* AFS_64BIT_CLIENT */
2199 ICL_APPENDINT32(logp, (afs_int32) p1);
2200 ICL_APPENDINT32(logp, (afs_int32) 0);
2201 #endif /* AFS_64BIT_CLIENT */
2202 #else /* AFSLITTLE_ENDIAN */
2203 #ifdef AFS_64BIT_CLIENT
2204 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2205 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2206 #else /* AFS_64BIT_CLIENT */
2207 ICL_APPENDINT32(logp, (afs_int32) 0);
2208 ICL_APPENDINT32(logp, (afs_int32) p1);
2209 #endif /* AFS_64BIT_CLIENT */
2210 #endif /* AFSLITTLE_ENDIAN */
2211 } else if (t1 == ICL_TYPE_FID) {
2212 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
2213 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
2214 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[2]);
2215 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[3]);
2217 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2218 else if (t1 == ICL_TYPE_INT32)
2219 ICL_APPENDINT32(logp, (afs_int32) p1);
2220 #endif /* AFS_ALPHA_ENV */
2222 ICL_APPENDLONG(logp, p1);
2225 /* marshall parameter 2 now */
2226 if (t2 == ICL_TYPE_STRING)
2227 afs_icl_AppendString(logp, (char *)p2);
2228 else if (t2 == ICL_TYPE_HYPER) {
2229 ICL_APPENDINT32(logp,
2230 (afs_int32) ((struct afs_hyper_t *)p2)->high);
2231 ICL_APPENDINT32(logp,
2232 (afs_int32) ((struct afs_hyper_t *)p2)->low);
2233 } else if (t2 == ICL_TYPE_INT64) {
2234 #ifdef AFSLITTLE_ENDIAN
2235 #ifdef AFS_64BIT_CLIENT
2236 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2237 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2238 #else /* AFS_64BIT_CLIENT */
2239 ICL_APPENDINT32(logp, (afs_int32) p2);
2240 ICL_APPENDINT32(logp, (afs_int32) 0);
2241 #endif /* AFS_64BIT_CLIENT */
2242 #else /* AFSLITTLE_ENDIAN */
2243 #ifdef AFS_64BIT_CLIENT
2244 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2245 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2246 #else /* AFS_64BIT_CLIENT */
2247 ICL_APPENDINT32(logp, (afs_int32) 0);
2248 ICL_APPENDINT32(logp, (afs_int32) p2);
2249 #endif /* AFS_64BIT_CLIENT */
2250 #endif /* AFSLITTLE_ENDIAN */
2251 } else if (t2 == ICL_TYPE_FID) {
2252 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
2253 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
2254 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[2]);
2255 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[3]);
2257 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2258 else if (t2 == ICL_TYPE_INT32)
2259 ICL_APPENDINT32(logp, (afs_int32) p2);
2260 #endif /* AFS_ALPHA_ENV */
2262 ICL_APPENDLONG(logp, p2);
2265 /* marshall parameter 3 now */
2266 if (t3 == ICL_TYPE_STRING)
2267 afs_icl_AppendString(logp, (char *)p3);
2268 else if (t3 == ICL_TYPE_HYPER) {
2269 ICL_APPENDINT32(logp,
2270 (afs_int32) ((struct afs_hyper_t *)p3)->high);
2271 ICL_APPENDINT32(logp,
2272 (afs_int32) ((struct afs_hyper_t *)p3)->low);
2273 } else if (t3 == ICL_TYPE_INT64) {
2274 #ifdef AFSLITTLE_ENDIAN
2275 #ifdef AFS_64BIT_CLIENT
2276 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2277 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2278 #else /* AFS_64BIT_CLIENT */
2279 ICL_APPENDINT32(logp, (afs_int32) p3);
2280 ICL_APPENDINT32(logp, (afs_int32) 0);
2281 #endif /* AFS_64BIT_CLIENT */
2282 #else /* AFSLITTLE_ENDIAN */
2283 #ifdef AFS_64BIT_CLIENT
2284 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2285 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2286 #else /* AFS_64BIT_CLIENT */
2287 ICL_APPENDINT32(logp, (afs_int32) 0);
2288 ICL_APPENDINT32(logp, (afs_int32) p3);
2289 #endif /* AFS_64BIT_CLIENT */
2290 #endif /* AFSLITTLE_ENDIAN */
2291 } else if (t3 == ICL_TYPE_FID) {
2292 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
2293 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
2294 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[2]);
2295 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[3]);
2297 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2298 else if (t3 == ICL_TYPE_INT32)
2299 ICL_APPENDINT32(logp, (afs_int32) p3);
2300 #endif /* AFS_ALPHA_ENV */
2302 ICL_APPENDLONG(logp, p3);
2305 /* marshall parameter 4 now */
2306 if (t4 == ICL_TYPE_STRING)
2307 afs_icl_AppendString(logp, (char *)p4);
2308 else if (t4 == ICL_TYPE_HYPER) {
2309 ICL_APPENDINT32(logp,
2310 (afs_int32) ((struct afs_hyper_t *)p4)->high);
2311 ICL_APPENDINT32(logp,
2312 (afs_int32) ((struct afs_hyper_t *)p4)->low);
2313 } else if (t4 == ICL_TYPE_INT64) {
2314 #ifdef AFSLITTLE_ENDIAN
2315 #ifdef AFS_64BIT_CLIENT
2316 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2317 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2318 #else /* AFS_64BIT_CLIENT */
2319 ICL_APPENDINT32(logp, (afs_int32) p4);
2320 ICL_APPENDINT32(logp, (afs_int32) 0);
2321 #endif /* AFS_64BIT_CLIENT */
2322 #else /* AFSLITTLE_ENDIAN */
2323 #ifdef AFS_64BIT_CLIENT
2324 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2325 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2326 #else /* AFS_64BIT_CLIENT */
2327 ICL_APPENDINT32(logp, (afs_int32) 0);
2328 ICL_APPENDINT32(logp, (afs_int32) p4);
2329 #endif /* AFS_64BIT_CLIENT */
2330 #endif /* AFSLITTLE_ENDIAN */
2331 } else if (t4 == ICL_TYPE_FID) {
2332 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
2333 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
2334 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[2]);
2335 ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[3]);
2337 #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
2338 else if (t4 == ICL_TYPE_INT32)
2339 ICL_APPENDINT32(logp, (afs_int32) p4);
2340 #endif /* AFS_ALPHA_ENV */
2342 ICL_APPENDLONG(logp, p4);
2344 ReleaseWriteLock(&logp->lock);
2347 /* create a log with size logSize; return it in *outLogpp and tag
2348 * it with name "name."
2351 afs_icl_CreateLog(char *name, afs_int32 logSize,
2352 struct afs_icl_log **outLogpp)
2354 return afs_icl_CreateLogWithFlags(name, logSize, /*flags */ 0, outLogpp);
2357 /* create a log with size logSize; return it in *outLogpp and tag
2358 * it with name "name." 'flags' can be set to make the log unclearable.
2361 afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
2362 struct afs_icl_log **outLogpp)
2364 register struct afs_icl_log *logp;
2366 /* add into global list under lock */
2367 ObtainWriteLock(&afs_icl_lock, 183);
2368 if (!afs_icl_inited)
2371 for (logp = afs_icl_allLogs; logp; logp = logp->nextp) {
2372 if (strcmp(logp->name, name) == 0) {
2373 /* found it already created, just return it */
2376 if (flags & ICL_CRLOG_FLAG_PERSISTENT) {
2377 ObtainWriteLock(&logp->lock, 184);
2378 logp->states |= ICL_LOGF_PERSISTENT;
2379 ReleaseWriteLock(&logp->lock);
2381 ReleaseWriteLock(&afs_icl_lock);
2386 logp = (struct afs_icl_log *)
2387 osi_AllocSmallSpace(sizeof(struct afs_icl_log));
2388 memset((caddr_t) logp, 0, sizeof(*logp));
2391 logp->name = osi_AllocSmallSpace(strlen(name) + 1);
2392 strcpy(logp->name, name);
2393 LOCK_INIT(&logp->lock, "logp lock");
2394 logp->logSize = logSize;
2395 logp->datap = NULL; /* don't allocate it until we need it */
2397 if (flags & ICL_CRLOG_FLAG_PERSISTENT)
2398 logp->states |= ICL_LOGF_PERSISTENT;
2400 logp->nextp = afs_icl_allLogs;
2401 afs_icl_allLogs = logp;
2402 ReleaseWriteLock(&afs_icl_lock);
2408 /* called with a log, a pointer to a buffer, the size of the buffer
2409 * (in *bufSizep), the starting cookie (in *cookiep, use 0 at the start)
2410 * and returns data in the provided buffer, and returns output flags
2411 * in *flagsp. The flag ICL_COPYOUTF_MISSEDSOME is set if we can't
2412 * find the record with cookie value cookie.
2415 afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 * bufferp,
2416 afs_int32 * bufSizep, afs_uint32 * cookiep,
2419 afs_int32 nwords; /* number of words to copy out */
2420 afs_uint32 startCookie; /* first cookie to use */
2421 afs_int32 outWords; /* words we've copied out */
2422 afs_int32 inWords; /* max words to copy out */
2423 afs_int32 code; /* return code */
2424 afs_int32 ix; /* index we're copying from */
2425 afs_int32 outFlags; /* return flags */
2426 afs_int32 inFlags; /* flags passed in */
2429 inWords = *bufSizep; /* max to copy out */
2430 outWords = 0; /* amount copied out */
2431 startCookie = *cookiep;
2436 ObtainWriteLock(&logp->lock, 185);
2438 ReleaseWriteLock(&logp->lock);
2442 /* first, compute the index of the start cookie we've been passed */
2444 /* (re-)compute where we should start */
2445 if (startCookie < logp->baseCookie) {
2446 if (startCookie) /* missed some output */
2447 outFlags |= ICL_COPYOUTF_MISSEDSOME;
2448 /* skip to the first available record */
2449 startCookie = logp->baseCookie;
2450 *cookiep = startCookie;
2453 /* compute where we find the first element to copy out */
2454 ix = logp->firstUsed + startCookie - logp->baseCookie;
2455 if (ix >= logp->logSize)
2456 ix -= logp->logSize;
2458 /* if have some data now, break out and process it */
2459 if (startCookie - logp->baseCookie < logp->logElements)
2462 /* At end of log, so clear it if we need to */
2463 if (inFlags & ICL_COPYOUTF_CLRAFTERREAD) {
2464 logp->firstUsed = logp->firstFree = 0;
2465 logp->logElements = 0;
2467 /* otherwise, either wait for the data to arrive, or return */
2468 if (!(inFlags & ICL_COPYOUTF_WAITIO)) {
2469 ReleaseWriteLock(&logp->lock);
2473 logp->states |= ICL_LOGF_WAITING;
2474 ReleaseWriteLock(&logp->lock);
2475 afs_osi_Sleep(&logp->lock);
2476 ObtainWriteLock(&logp->lock, 186);
2478 /* copy out data from ix to logSize or firstFree, depending
2479 * upon whether firstUsed <= firstFree (no wrap) or otherwise.
2480 * be careful not to copy out more than nwords.
2482 if (ix >= logp->firstUsed) {
2483 if (logp->firstUsed <= logp->firstFree)
2485 end = logp->firstFree; /* first element not to copy */
2487 end = logp->logSize;
2488 nwords = inWords; /* don't copy more than this */
2489 if (end - ix < nwords)
2492 memcpy((char *)bufferp, (char *)&logp->datap[ix],
2493 sizeof(afs_int32) * nwords);
2498 /* if we're going to copy more out below, we'll start here */
2501 /* now, if active part of the log has wrapped, there's more stuff
2502 * starting at the head of the log. Copy out more from there.
2504 if (logp->firstUsed > logp->firstFree && ix < logp->firstFree
2506 /* (more to) copy out from the wrapped section at the
2507 * start of the log. May get here even if didn't copy any
2508 * above, if the cookie points directly into the wrapped section.
2511 if (logp->firstFree - ix < nwords)
2512 nwords = logp->firstFree - ix;
2513 memcpy((char *)bufferp, (char *)&logp->datap[ix],
2514 sizeof(afs_int32) * nwords);
2520 ReleaseWriteLock(&logp->lock);
2524 *bufSizep = outWords;
2530 /* return basic parameter information about a log */
2532 afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep,
2533 afs_int32 * curSizep)
2535 ObtainReadLock(&logp->lock);
2536 *maxSizep = logp->logSize;
2537 *curSizep = logp->logElements;
2538 ReleaseReadLock(&logp->lock);
2543 /* hold and release logs */
2545 afs_icl_LogHold(register struct afs_icl_log *logp)
2547 ObtainWriteLock(&afs_icl_lock, 187);
2549 ReleaseWriteLock(&afs_icl_lock);
2553 /* hold and release logs, called with lock already held */
2555 afs_icl_LogHoldNL(register struct afs_icl_log *logp)
2561 /* keep track of how many sets believe the log itself is allocated */
2563 afs_icl_LogUse(register struct afs_icl_log *logp)
2565 ObtainWriteLock(&logp->lock, 188);
2566 if (logp->setCount == 0) {
2567 /* this is the first set actually using the log -- allocate it */
2568 if (logp->logSize == 0) {
2569 /* we weren't passed in a hint and it wasn't set */
2570 logp->logSize = ICL_DEFAULT_LOGSIZE;
2573 (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
2574 #ifdef KERNEL_HAVE_PIN
2575 pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2579 ReleaseWriteLock(&logp->lock);
2583 /* decrement the number of real users of the log, free if possible */
2585 afs_icl_LogFreeUse(register struct afs_icl_log *logp)
2587 ObtainWriteLock(&logp->lock, 189);
2588 if (--logp->setCount == 0) {
2589 /* no more users -- free it (but keep log structure around) */
2590 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2591 #ifdef KERNEL_HAVE_PIN
2592 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2594 logp->firstUsed = logp->firstFree = 0;
2595 logp->logElements = 0;
2598 ReleaseWriteLock(&logp->lock);
2602 /* set the size of the log to 'logSize' */
2604 afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
2606 ObtainWriteLock(&logp->lock, 190);
2608 /* nothing to worry about since it's not allocated */
2609 logp->logSize = logSize;
2612 logp->firstUsed = logp->firstFree = 0;
2613 logp->logElements = 0;
2615 /* free and allocate a new one */
2616 afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2617 #ifdef KERNEL_HAVE_PIN
2618 unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
2621 (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
2622 #ifdef KERNEL_HAVE_PIN
2623 pin((char *)logp->datap, sizeof(afs_int32) * logSize);
2625 logp->logSize = logSize;
2627 ReleaseWriteLock(&logp->lock);
2632 /* free a log. Called with afs_icl_lock locked. */
2634 afs_icl_ZapLog(register struct afs_icl_log *logp)
2636 register struct afs_icl_log **lpp, *tp;
2638 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2640 /* found the dude we want to remove */
2642 osi_FreeSmallSpace(logp->name);
2643 osi_FreeSmallSpace(logp->datap);
2644 osi_FreeSmallSpace(logp);
2645 break; /* won't find it twice */
2651 /* do the release, watching for deleted entries */
2653 afs_icl_LogRele(register struct afs_icl_log *logp)
2655 ObtainWriteLock(&afs_icl_lock, 191);
2656 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2657 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2659 ReleaseWriteLock(&afs_icl_lock);
2663 /* do the release, watching for deleted entries, log already held */
2665 afs_icl_LogReleNL(register struct afs_icl_log *logp)
2667 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2668 afs_icl_ZapLog(logp); /* destroys logp's lock! */
2673 /* zero out the log */
2675 afs_icl_ZeroLog(register struct afs_icl_log *logp)
2677 ObtainWriteLock(&logp->lock, 192);
2678 logp->firstUsed = logp->firstFree = 0;
2679 logp->logElements = 0;
2680 logp->baseCookie = 0;
2681 ReleaseWriteLock(&logp->lock);
2685 /* free a log entry, and drop its reference count */
2687 afs_icl_LogFree(register struct afs_icl_log *logp)
2689 ObtainWriteLock(&logp->lock, 193);
2690 logp->states |= ICL_LOGF_DELETED;
2691 ReleaseWriteLock(&logp->lock);
2692 afs_icl_LogRele(logp);
2696 /* find a log by name, returning it held */
2697 struct afs_icl_log *
2698 afs_icl_FindLog(char *name)
2700 register struct afs_icl_log *tp;
2701 ObtainWriteLock(&afs_icl_lock, 194);
2702 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2703 if (strcmp(tp->name, name) == 0) {
2704 /* this is the dude we want */
2709 ReleaseWriteLock(&afs_icl_lock);
2714 afs_icl_EnumerateLogs(int (*aproc)
2715 (char *name, char *arock, struct afs_icl_log * tp),
2718 register struct afs_icl_log *tp;
2719 register afs_int32 code;
2722 ObtainWriteLock(&afs_icl_lock, 195);
2723 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2724 tp->refCount++; /* hold this guy */
2725 ReleaseWriteLock(&afs_icl_lock);
2726 ObtainReadLock(&tp->lock);
2727 code = (*aproc) (tp->name, arock, tp);
2728 ReleaseReadLock(&tp->lock);
2729 ObtainWriteLock(&afs_icl_lock, 196);
2730 if (--tp->refCount == 0)
2735 ReleaseWriteLock(&afs_icl_lock);
2739 struct afs_icl_set *afs_icl_allSets = 0;
2742 afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp,
2743 struct afs_icl_log *fatalLogp,
2744 struct afs_icl_set **outSetpp)
2746 return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp,
2747 /*flags */ 0, outSetpp);
2750 /* create a set, given pointers to base and fatal logs, if any.
2751 * Logs are unlocked, but referenced, and *outSetpp is returned
2752 * referenced. Function bumps reference count on logs, since it
2753 * addds references from the new afs_icl_set. When the set is destroyed,
2754 * those references will be released.
2757 afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
2758 struct afs_icl_log *fatalLogp, afs_uint32 flags,
2759 struct afs_icl_set **outSetpp)
2761 register struct afs_icl_set *setp;
2763 afs_int32 states = ICL_DEFAULT_SET_STATES;
2765 ObtainWriteLock(&afs_icl_lock, 197);
2766 if (!afs_icl_inited)
2769 for (setp = afs_icl_allSets; setp; setp = setp->nextp) {
2770 if (strcmp(setp->name, name) == 0) {
2773 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2774 ObtainWriteLock(&setp->lock, 198);
2775 setp->states |= ICL_SETF_PERSISTENT;
2776 ReleaseWriteLock(&setp->lock);
2778 ReleaseWriteLock(&afs_icl_lock);
2783 /* determine initial state */
2784 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2785 states = ICL_SETF_ACTIVE;
2786 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2787 states = ICL_SETF_FREED;
2788 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2789 states |= ICL_SETF_PERSISTENT;
2791 setp = (struct afs_icl_set *)afs_osi_Alloc(sizeof(struct afs_icl_set));
2792 memset((caddr_t) setp, 0, sizeof(*setp));
2794 if (states & ICL_SETF_FREED)
2795 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2796 setp->states = states;
2798 LOCK_INIT(&setp->lock, "setp lock");
2799 /* next lock is obtained in wrong order, hierarchy-wise, but
2800 * it doesn't matter, since no one can find this lock yet, since
2801 * the afs_icl_lock is still held, and thus the obtain can't block.
2803 ObtainWriteLock(&setp->lock, 199);
2804 setp->name = osi_AllocSmallSpace(strlen(name) + 1);
2805 strcpy(setp->name, name);
2806 setp->nevents = ICL_DEFAULTEVENTS;
2807 setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
2808 #ifdef KERNEL_HAVE_PIN
2809 pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2811 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2812 setp->eventFlags[i] = 0xff; /* default to enabled */
2814 /* update this global info under the afs_icl_lock */
2815 setp->nextp = afs_icl_allSets;
2816 afs_icl_allSets = setp;
2817 ReleaseWriteLock(&afs_icl_lock);
2819 /* set's basic lock is still held, so we can finish init */
2821 setp->logs[0] = baseLogp;
2822 afs_icl_LogHold(baseLogp);
2823 if (!(setp->states & ICL_SETF_FREED))
2824 afs_icl_LogUse(baseLogp); /* log is actually being used */
2827 setp->logs[1] = fatalLogp;
2828 afs_icl_LogHold(fatalLogp);
2829 if (!(setp->states & ICL_SETF_FREED))
2830 afs_icl_LogUse(fatalLogp); /* log is actually being used */
2832 ReleaseWriteLock(&setp->lock);
2838 /* function to change event enabling information for a particular set */
2840 afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
2844 ObtainWriteLock(&setp->lock, 200);
2845 if (!ICL_EVENTOK(setp, eventID)) {
2846 ReleaseWriteLock(&setp->lock);
2849 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2851 *tp |= ICL_EVENTMASK(eventID);
2853 *tp &= ~(ICL_EVENTMASK(eventID));
2854 ReleaseWriteLock(&setp->lock);
2858 /* return indication of whether a particular event ID is enabled
2859 * for tracing. If *getValuep is set to 0, the event is disabled,
2860 * otherwise it is enabled. All events start out enabled by default.
2863 afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep)
2865 ObtainReadLock(&setp->lock);
2866 if (!ICL_EVENTOK(setp, eventID)) {
2867 ReleaseWriteLock(&setp->lock);
2870 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2874 ReleaseReadLock(&setp->lock);
2878 /* hold and release event sets */
2880 afs_icl_SetHold(register struct afs_icl_set *setp)
2882 ObtainWriteLock(&afs_icl_lock, 201);
2884 ReleaseWriteLock(&afs_icl_lock);
2888 /* free a set. Called with afs_icl_lock locked */
2890 afs_icl_ZapSet(register struct afs_icl_set *setp)
2892 register struct afs_icl_set **lpp, *tp;
2894 register struct afs_icl_log *tlp;
2896 for (lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2898 /* found the dude we want to remove */
2900 osi_FreeSmallSpace(setp->name);
2901 afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
2902 #ifdef KERNEL_HAVE_PIN
2903 unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
2905 for (i = 0; i < ICL_LOGSPERSET; i++) {
2906 if ((tlp = setp->logs[i]))
2907 afs_icl_LogReleNL(tlp);
2909 osi_FreeSmallSpace(setp);
2910 break; /* won't find it twice */
2916 /* do the release, watching for deleted entries */
2918 afs_icl_SetRele(register struct afs_icl_set *setp)
2920 ObtainWriteLock(&afs_icl_lock, 202);
2921 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2922 afs_icl_ZapSet(setp); /* destroys setp's lock! */
2924 ReleaseWriteLock(&afs_icl_lock);
2928 /* free a set entry, dropping its reference count */
2930 afs_icl_SetFree(register struct afs_icl_set *setp)
2932 ObtainWriteLock(&setp->lock, 203);
2933 setp->states |= ICL_SETF_DELETED;
2934 ReleaseWriteLock(&setp->lock);
2935 afs_icl_SetRele(setp);
2939 /* find a set by name, returning it held */
2940 struct afs_icl_set *
2941 afs_icl_FindSet(char *name)
2943 register struct afs_icl_set *tp;
2944 ObtainWriteLock(&afs_icl_lock, 204);
2945 for (tp = afs_icl_allSets; tp; tp = tp->nextp) {
2946 if (strcmp(tp->name, name) == 0) {
2947 /* this is the dude we want */
2952 ReleaseWriteLock(&afs_icl_lock);
2956 /* zero out all the logs in the set */
2958 afs_icl_ZeroSet(struct afs_icl_set *setp)
2963 struct afs_icl_log *logp;
2965 ObtainReadLock(&setp->lock);
2966 for (i = 0; i < ICL_LOGSPERSET; i++) {
2967 logp = setp->logs[i];
2969 afs_icl_LogHold(logp);
2970 tcode = afs_icl_ZeroLog(logp);
2972 code = tcode; /* save the last bad one */
2973 afs_icl_LogRele(logp);
2976 ReleaseReadLock(&setp->lock);
2981 afs_icl_EnumerateSets(int (*aproc)
2982 (char *name, char *arock, struct afs_icl_log * tp),
2985 register struct afs_icl_set *tp, *np;
2986 register afs_int32 code;
2989 ObtainWriteLock(&afs_icl_lock, 205);
2990 for (tp = afs_icl_allSets; tp; tp = np) {
2991 tp->refCount++; /* hold this guy */
2992 ReleaseWriteLock(&afs_icl_lock);
2993 code = (*aproc) (tp->name, arock, tp);
2994 ObtainWriteLock(&afs_icl_lock, 206);
2995 np = tp->nextp; /* tp may disappear next, but not np */
2996 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
3001 ReleaseWriteLock(&afs_icl_lock);
3006 afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
3011 ObtainWriteLock(&setp->lock, 207);
3012 for (i = 0; i < ICL_LOGSPERSET; i++) {
3013 if (!setp->logs[i]) {
3014 setp->logs[i] = newlogp;
3016 afs_icl_LogHold(newlogp);
3017 if (!(setp->states & ICL_SETF_FREED)) {
3018 /* bump up the number of sets using the log */
3019 afs_icl_LogUse(newlogp);
3024 ReleaseWriteLock(&setp->lock);
3029 afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
3033 struct afs_icl_log *logp;
3035 ObtainWriteLock(&setp->lock, 208);
3037 case ICL_OP_SS_ACTIVATE: /* activate a log */
3039 * If we are not already active, see if we have released
3040 * our demand that the log be allocated (FREED set). If
3041 * we have, reassert our desire.
3043 if (!(setp->states & ICL_SETF_ACTIVE)) {
3044 if (setp->states & ICL_SETF_FREED) {
3045 /* have to reassert desire for logs */
3046 for (i = 0; i < ICL_LOGSPERSET; i++) {
3047 logp = setp->logs[i];
3049 afs_icl_LogHold(logp);
3050 afs_icl_LogUse(logp);
3051 afs_icl_LogRele(logp);
3054 setp->states &= ~ICL_SETF_FREED;
3056 setp->states |= ICL_SETF_ACTIVE;
3061 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
3062 /* this doesn't require anything beyond clearing the ACTIVE flag */
3063 setp->states &= ~ICL_SETF_ACTIVE;
3067 case ICL_OP_SS_FREE: /* deassert design for log */
3069 * if we are already in this state, do nothing; otherwise
3070 * deassert desire for log
3072 if (setp->states & ICL_SETF_ACTIVE)
3075 if (!(setp->states & ICL_SETF_FREED)) {
3076 for (i = 0; i < ICL_LOGSPERSET; i++) {
3077 logp = setp->logs[i];
3079 afs_icl_LogHold(logp);
3080 afs_icl_LogFreeUse(logp);
3081 afs_icl_LogRele(logp);
3084 setp->states |= ICL_SETF_FREED;
3093 ReleaseWriteLock(&setp->lock);