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
11 * afs_init.c - initialize AFS client.
16 #include <afsconfig.h>
17 #include "afs/param.h"
21 #include "afs/sysincludes.h" /* Standard vendor system headers */
22 #include "afsincludes.h" /* Afs-based standard headers */
23 #include "afs/afs_stats.h" /* afs statistics */
24 #include "rx/rxstat.h"
25 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
26 #include <linux/cred.h>
29 #define FSINT_COMMON_XG
30 #include "afs/afscbint.h"
32 /* Exported variables */
33 struct osi_dev cacheDev; /*Cache device */
34 afs_int32 cacheInfoModTime; /*Last time cache info modified */
35 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_NBSD_ENV)
36 struct mount *afs_cacheVfsp = 0;
37 #elif defined(AFS_LINUX20_ENV)
38 struct super_block *afs_cacheSBp = 0;
40 struct vfs *afs_cacheVfsp = 0;
42 afs_rwlock_t afs_puttofileLock; /* not used */
43 char *afs_sysname = 0; /* So that superuser may change the
44 * local value of @sys */
45 char *afs_sysnamelist[MAXNUMSYSNAMES]; /* For support of a list of sysname */
46 int afs_sysnamecount = 0;
47 int afs_sysnamegen = 0;
48 struct volume *Initialafs_freeVolList;
49 int afs_memvolumes = 0;
50 #if defined(AFS_XBSD_ENV)
51 static struct vnode *volumeVnode;
53 afs_rwlock_t afs_discon_lock;
54 extern afs_rwlock_t afs_disconDirtyLock;
55 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
56 const struct cred *cache_creds;
59 /* This is the kernel side of the dynamic vcache setting */
60 #ifdef AFS_MAXVCOUNT_ENV
61 int afsd_dynamic_vcaches = 0; /* Enable dynamic-vcache support */
65 * Initialization order is important. Must first call afs_CacheInit,
66 * then cache file and volume file initialization routines. Next, the
67 * individual cache entry initialization routines are called.
77 * astatSize : The number of stat cache (vnode) entries to
79 * afiles : The number of disk files to allocate to the cache
80 * ablocks : The max number of 1 Kbyte blocks that all of
81 * the files in the cache may occupy.
82 * aDentries : Number of dcache entries to allocate.
83 * aVolumes : Number of volume cache entries to allocate.
84 * achunk : Power of 2 to make the chunks.
85 * aflags : Flags passed in.
86 * inodes : max inodes to pin down in inode[]
87 * users : what should size of per-user access cache be?
90 * This routine should only be called at initialization time, since
91 * it reclaims no resources and doesn't sufficiently synchronize
92 * with other processes.
95 struct cm_initparams cm_initParams;
96 static int afs_cacheinit_flag = 0;
98 afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
99 afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk,
100 afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers,
101 afs_int32 dynamic_vcaches)
106 AFS_STATCNT(afs_CacheInit);
108 * Jot down the epoch time, namely when this incarnation of the
109 * Cache Manager started.
111 afs_stats_cmperf.epoch = pag_epoch = osi_Time();
113 afs_stats_cmperf.sysName_ID = SYS_NAME_ID;
115 afs_stats_cmperf.sysName_ID = SYS_NAME_ID_UNDEFINED;
116 #endif /* SYS_NAME_ID */
118 #ifdef AFS_MAXVCOUNT_ENV
119 afsd_dynamic_vcaches = dynamic_vcaches;
120 afs_warn("%s dynamically allocated vcaches\n",
121 ( afsd_dynamic_vcaches ? "enabling" : "disabling" ));
124 afs_warn("Starting AFS cache scan...");
125 if (afs_cacheinit_flag)
127 afs_cacheinit_flag = 1;
128 cacheInfoModTime = 0;
130 LOCK_INIT(&afs_ftf, "afs_ftf");
131 AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
132 AFS_RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
133 AFS_RWLOCK_INIT(&afs_disconDirtyLock, "afs_disconDirtyLock");
134 QInit(&afs_disconDirty);
135 QInit(&afs_disconShadow);
139 * create volume list structure
143 else if (aVolumes > 32767)
146 tv = afs_osi_Alloc(aVolumes * sizeof(struct volume));
147 osi_Assert(tv != NULL);
148 for (i = 0; i < aVolumes - 1; i++)
149 tv[i].next = &tv[i + 1];
150 tv[aVolumes - 1].next = NULL;
151 afs_freeVolList = Initialafs_freeVolList = tv;
152 afs_memvolumes = aVolumes;
154 afs_cacheFiles = afiles;
155 afs_cacheStats = astatSize;
156 afs_vcacheInit(astatSize);
157 afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
158 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
160 * Save current credentials for later access to disk cache files.
161 * If selinux, apparmor or other security modules are enabled,
162 * they might deny access to cache files if the userspace process
163 * is restricted. Save the credentials used at cache initialisation
164 * for later use when opening cache files.
166 cache_creds = get_current_cred();
168 #ifdef AFS_64BIT_CLIENT
169 #ifdef AFS_VM_RDWR_ENV
170 afs_vmMappingEnd = AFS_CHUNKBASE(0x7fffffff);
171 #endif /* AFS_VM_RDWR_ENV */
172 #endif /* AFS_64BIT_CLIENT */
174 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV)
176 static void afs_procsize_init(void);
182 /* Save the initialization parameters for later pioctl queries. */
183 cm_initParams.cmi_version = CMI_VERSION;
184 cm_initParams.cmi_nChunkFiles = afiles;
185 cm_initParams.cmi_nStatCaches = astatSize;
186 cm_initParams.cmi_nDataCaches = aDentries;
187 cm_initParams.cmi_nVolumeCaches = aVolumes;
188 cm_initParams.cmi_firstChunkSize = AFS_FIRSTCSIZE;
189 cm_initParams.cmi_otherChunkSize = AFS_OTHERCSIZE;
190 cm_initParams.cmi_cacheSize = afs_cacheBlocks;
191 cm_initParams.cmi_setTime = afs_setTime;
192 cm_initParams.cmi_memCache = (aflags & AFSCALL_INIT_MEMCACHE) ? 1 : 0;
200 * afs_ComputeCacheParams
203 * Set some cache parameters.
210 afs_ComputeCacheParms(void)
213 afs_int32 afs_maxCacheDirty;
216 * Don't allow more than 2/3 of the files in the cache to be dirty.
218 afs_maxCacheDirty = (2 * afs_cacheFiles) / 3;
221 * Also, don't allow more than 2/3 of the total space get filled
222 * with dirty chunks. Compute the total number of chunks required
223 * to fill the cache, make sure we don't set out limit above 2/3 of
224 * that. If the cache size is greater than 1G, avoid overflow at
225 * the expense of precision on the chunk size.
227 if (afs_cacheBlocks & 0xffe00000) {
228 i = afs_cacheBlocks / (AFS_FIRSTCSIZE >> 10);
230 i = (afs_cacheBlocks << 10) / AFS_FIRSTCSIZE;
233 if (afs_maxCacheDirty > i)
234 afs_maxCacheDirty = i;
235 if (afs_maxCacheDirty < 1)
236 afs_maxCacheDirty = 1;
237 afs_stats_cmperf.cacheMaxDirtyChunks = afs_maxCacheDirty;
238 } /*afs_ComputeCacheParms */
242 * afs_LookupInodeByPath
244 * Look up inode given a file name.
245 * Optionally return the vnode too.
246 * If the vnode is not returned, we rele it.
249 afs_LookupInodeByPath(char *filename, afs_ufs_dcache_id_t *inode,
254 #if defined(AFS_LINUX22_ENV)
256 code = gop_lookupname(filename, AFS_UIOSYS, 0, &dp);
259 osi_get_fh(dp, inode);
262 struct vnode *filevp;
263 code = gop_lookupname(filename, AFS_UIOSYS, 0, &filevp);
266 #ifdef AFS_CACHE_VNODE_PATH
267 *inode = afs_strdup(filename);
269 *inode = afs_vnodeToInumber(filevp);
282 afs_InitCellInfo(char *afile)
284 afs_dcache_id_t inode;
287 code = afs_LookupInodeByPath(afile, &inode.ufs, NULL);
288 return afs_cellname_init(&inode, code);
295 * Set up the volume info storage file.
298 * afile : the file to be declared to be the volume info storage
299 * file for AFS. It must be already truncated to 0 length.
302 * This function is called only during initialization.
304 * WARNING: Data will be written to this file over time by AFS.
308 afs_InitVolumeInfo(char *afile)
311 struct osi_file *tfile;
313 AFS_STATCNT(afs_InitVolumeInfo);
314 #if defined(AFS_XBSD_ENV)
316 * On Open/Free/NetBSD, we can get into big trouble if we don't hold the volume file
317 * vnode. SetupVolume holds afs_xvolume lock exclusive.
318 * SetupVolume->GetVolSlot->UFSGetVolSlot->{GetVolCache or WriteVolCache}
319 * ->osi_UFSOpen->VFS_VGET()->ffs_vget->getnewvnode->vgone on some vnode.
320 * If it's AFS, then ->vclean->afs_nbsd_reclaim->FlushVCache->QueueVCB->
321 * GetVolume->FindVolume-> waits on afs_xvolume lock !
323 * In general, anything that's called with afs_xvolume locked must not
324 * end up calling getnewvnode(). The only cases I've found so far
325 * are things which try to get the volumeInode, and since we keep
328 code = afs_LookupInodeByPath(afile, &volumeInode.ufs, &volumeVnode);
330 code = afs_LookupInodeByPath(afile, &volumeInode.ufs, NULL);
334 tfile = afs_CFileOpen(&volumeInode);
335 afs_CFileTruncate(tfile, 0);
336 afs_CFileClose(tfile);
344 * Set up the given file as the AFS cache info file.
347 * afile : Name of the file assumed to be the cache info file
348 * for the Cache Manager; it will be used as such.
349 * Side Effects: This sets afs_fragsize, which is used in the cache usage
350 * calculations such as in afs_adjustsize()
353 * This function is called only during initialization. The given
354 * file should NOT be truncated to 0 lenght; its contents descrebe
355 * what data is really in the cache.
357 * WARNING: data will be written to this file over time by AFS.
359 * NOTE: Starting to use separate osi_InitCacheInfo() routines to clean up
364 afs_InitCacheInfo(char *afile)
367 struct osi_stat tstat;
368 struct osi_file *tfile;
369 struct afs_fheader theader;
370 #ifndef AFS_LINUX22_ENV
371 struct vnode *filevp;
375 AFS_STATCNT(afs_InitCacheInfo);
376 if (cacheDiskType != AFS_FCACHE_TYPE_UFS)
377 osi_Panic("afs_InitCacheInfo --- called for non-ufs cache!");
378 #ifdef AFS_LINUX22_ENV
379 code = osi_InitCacheInfo(afile);
383 code = gop_lookupname(afile, AFS_UIOSYS, 0, &filevp);
387 #if defined(AFS_SUN5_ENV)
389 #elif defined(AFS_HPUX102_ENV)
391 #elif defined(AFS_SGI_ENV) || defined(AFS_HPUX100_ENV) || defined(AFS_NBSD40_ENV)
393 #elif defined(AFS_DARWIN80_ENV)
399 #if defined(AFS_SGI_ENV)
401 VFS_STATVFS(filevp->v_vfsp, &st, NULL, code);
404 if (!VFS_STATFS(filevp->v_vfsp, &st, NULL))
405 #endif /* AFS_SGI65_ENV */
406 #elif defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV)
407 if (!VFS_STATVFS(filevp->v_vfsp, &st))
408 #elif defined(AFS_AIX41_ENV)
409 if (!VFS_STATFS(filevp->v_vfsp, &st, &afs_osi_cred))
410 #elif defined(AFS_LINUX20_ENV)
415 VFS_STATFS(filevp->v_vfsp, &st);
418 #elif defined(AFS_DARWIN80_ENV)
419 afs_cacheVfsp = vnode_mount(filevp);
420 if (afs_cacheVfsp && ((st = *(vfs_statfs(afs_cacheVfsp))),1))
421 #elif defined(AFS_FBSD80_ENV)
422 if (!VFS_STATFS(filevp->v_mount, &st))
423 #elif defined(AFS_NBSD50_ENV)
424 if (!VFS_STATVFS(filevp->v_vfsp, &st))
425 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
426 if (!VFS_STATFS(filevp->v_mount, &st, osi_curproc()))
428 if (!VFS_STATFS(filevp->v_vfsp, &st))
430 #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV)
431 if (strcmp("zfs", st.f_basetype) == 0) {
433 * Files in ZFS can take up to around the next
434 * recordsize boundary after being truncated. recordsize
435 * is reported in statvfs by f_bsize, so use that
438 afs_fsfragsize = st.f_bsize - 1;
440 afs_fsfragsize = st.f_frsize - 1;
443 afs_fsfragsize = st.f_bsize - 1;
446 #if defined(AFS_LINUX20_ENV)
447 cacheInode.ufs = filevp->i_ino;
448 afs_cacheSBp = filevp->i_sb;
449 #elif defined(AFS_XBSD_ENV)
450 cacheInode.ufs = VTOI(filevp)->i_number;
451 cacheDev.mp = filevp->v_mount;
452 cacheDev.held_vnode = filevp;
453 vref(filevp); /* Make sure mount point stays busy. XXX */
454 #if !defined(AFS_OBSD_ENV)
455 afs_cacheVfsp = filevp->v_vfsp;
458 #if defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
459 afs_InitDualFSCacheOps(filevp);
461 #ifndef AFS_CACHE_VNODE_PATH
462 #ifndef AFS_DARWIN80_ENV
463 afs_cacheVfsp = filevp->v_vfsp;
465 cacheInode.ufs = afs_vnodeToInumber(filevp);
467 afs_LookupInodeByPath(afile, &cacheInode.ufs, NULL);
469 cacheDev.dev = afs_vnodeToDev(filevp);
470 #endif /* AFS_LINUX20_ENV */
472 #endif /* AFS_LINUX22_ENV */
473 if (afs_fsfragsize < AFS_MIN_FRAGSIZE) {
474 afs_fsfragsize = AFS_MIN_FRAGSIZE;
476 tfile = osi_UFSOpen(&cacheInode);
477 afs_osi_Stat(tfile, &tstat);
478 cacheInfoModTime = tstat.mtime;
479 code = afs_osi_Read(tfile, -1, &theader, sizeof(theader));
481 if (code == sizeof(theader)) {
482 /* read the header correctly */
483 if (theader.magic == AFS_FHMAGIC
484 && theader.firstCSize == AFS_FIRSTCSIZE
485 && theader.otherCSize == AFS_OTHERCSIZE
486 && theader.dataSize == sizeof(struct fcache)
487 && theader.version == AFS_CI_VERSION)
491 /* write out a good file label */
492 theader.magic = AFS_FHMAGIC;
493 theader.firstCSize = AFS_FIRSTCSIZE;
494 theader.otherCSize = AFS_OTHERCSIZE;
495 theader.dataSize = sizeof(struct fcache);
496 theader.version = AFS_CI_VERSION;
497 afs_osi_Write(tfile, 0, &theader, sizeof(theader));
499 * Truncate the rest of the file, since it may be arbitrarily
502 osi_UFSTruncate(tfile, sizeof(struct afs_fheader));
504 /* Leave the file open now, since reopening the file makes public pool
505 * vnode systems (like OSF/Alpha) much harder to handle, That's because
506 * they can do a vnode recycle operation any time we open a file, which
507 * we'd do on any afs_GetDSlot call, etc.
509 afs_cacheInodep = (struct osi_file *)tfile;
513 int afs_resourceinit_flag = 0;
515 afs_ResourceInit(int preallocs)
518 static struct rx_securityClass *secobj;
520 AFS_STATCNT(afs_ResourceInit);
521 AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
522 AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
523 AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
524 AFS_RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
525 AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
526 AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
527 LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
528 #ifndef AFS_PRIVATE_OSI_ALLOCSPACES
529 LOCK_INIT(&osi_fsplock, "osi_fsplock");
530 LOCK_INIT(&osi_flplock, "osi_flplock");
532 AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
535 afs_InitCBQueue(1); /* initialize callback queues */
537 if (afs_resourceinit_flag == 0) {
538 afs_resourceinit_flag = 1;
539 for (i = 0; i < NFENTRIES; i++)
541 for (i = 0; i < MAXNUMSYSNAMES; i++) {
542 afs_sysnamelist[i] = afs_osi_Alloc(MAXSYSNAME);
543 osi_Assert(afs_sysnamelist[i] != NULL);
545 afs_sysname = afs_sysnamelist[0];
546 strcpy(afs_sysname, SYS_NAME);
547 afs_sysnamecount = 1;
551 secobj = rxnull_NewServerSecurityObject();
553 rx_NewService(0, 1, "afs", &secobj, 1, RXAFSCB_ExecuteRequest);
555 rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", &secobj, 1,
556 RXSTATS_ExecuteRequest);
558 afs_osi_Wakeup(&afs_server); /* wakeup anyone waiting for it */
561 } /*afs_ResourceInit */
563 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV)
566 * AIX dynamic sizeof(struct proc)
568 * AIX keeps its proc structures in an array. The size of struct proc
569 * varies from release to release of the OS. In order to maintain
570 * binary compatibility with releases later than what we build on, we
571 * need to determine the size of struct proc at run time.
573 * We need this in order to walk the proc[] array to do PAG garbage
576 * We also need this in order to support 'klog -setpag', since the
577 * kernel code needs to locate the proc structure for the parent process
578 * of the current process.
580 * To compute sizeof(struct proc), we need the addresses of two proc
581 * structures and their corresponding pids. Given the pids, we can use
582 * the PROCMASK() macro to compute their corresponding indices in the
583 * proc[] array. By dividing the distance between the pointers by the
584 * number of proc structures, we can compute the size of a single proc
587 * We know the base address of the proc table from v.vb_proc:
589 * <sys/sysconfig.h> declares sysconfig() and SYS_GETPARMS;
590 * (we don't use this, but I note it here for completeness)
592 * <sys/var.h> declares struct var and external variable v;
596 * v.ve_proc &proc[x] (current highwater mark for
597 * proc[] array usage)
599 * The first proc pointer is v.vb_proc, which is the proc structure for
600 * process 0. Process 0's pointer to its first child is the other proc
601 * pointer. If process 0 has no children, we simply give up and do not
602 * support features that require knowing the size of struct proc.
606 afs_procsize_init(void)
608 afs_proc_t *p0; /* pointer to process 0 */
609 afs_proc_t *pN; /* pointer to process 0's first child */
617 p0 = (afs_proc_t *)v.vb_proc;
619 afs_gcpags = AFS_GCPAGS_EPROC0;
634 afs_gcpags = AFS_GCPAGS_EPROCN;
638 if (pN->p_pid == p0->p_pid) {
639 afs_gcpags = AFS_GCPAGS_EEQPID;
643 pN_index = PROCMASK(pN->p_pid);
644 pN_offset = ((char *)pN - (char *)p0);
645 procsize = pN_offset / pN_index;
648 * check that the computation was exact
651 if (pN_index * procsize != pN_offset) {
652 afs_gcpags = AFS_GCPAGS_EINEXACT;
657 * check that the proc table size is a multiple of procsize.
660 if ((((char *)v.ve_proc - (char *)v.vb_proc) % procsize) != 0) {
661 afs_gcpags = AFS_GCPAGS_EPROCEND;
667 afs_gcpags_procsize = procsize;
675 * Clean up and shut down the AFS cache.
681 * Nothing interesting.
686 AFS_STATCNT(shutdown_cache);
687 afs_WriteThroughDSlots();
688 if (1/*afs_cold_shutdown*/) {
689 afs_cacheinit_flag = 0;
694 afs_cacheFiles = afs_cacheBlocks = 0;
697 #if defined(AFS_XBSD_ENV)
698 /* memcache never sets this, so don't panic on shutdown */
699 if (volumeVnode != NULL) {
700 vrele(volumeVnode); /* let it go, finally. */
703 if (cacheDev.held_vnode) {
704 vrele(cacheDev.held_vnode);
705 cacheDev.held_vnode = NULL;
708 #ifdef AFS_CACHE_VNODE_PATH
709 if (cacheDiskType != AFS_FCACHE_TYPE_MEM) {
710 afs_osi_FreeStr(cacheInode.ufs);
711 afs_osi_FreeStr(volumeInode.ufs);
714 afs_reset_inode(&cacheInode);
715 afs_reset_inode(&volumeInode);
716 cacheInfoModTime = 0;
718 afs_fsfragsize = 1023;
719 memset(&cacheDev, 0, sizeof(struct osi_dev));
722 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
723 put_cred(cache_creds);
725 } /*shutdown_cache */
729 shutdown_vnodeops(void)
731 AFS_STATCNT(shutdown_vnodeops);
732 if (afs_cold_shutdown) {
733 #ifndef AFS_SUN5_ENV /* XXX */
736 #ifndef AFS_LINUX20_ENV
745 shutdown_server(void)
748 struct afs_cbr *tcbrp, *tbrp;
751 for (i = 0; i < NSERVERS; i++) {
752 struct server *ts, *next;
757 for (sa = ts->addr; sa; sa = sa->next_sa) {
759 /* afs_ReleaseConns has been updated to
760 * defer rx_DestroyConnection to Rx
761 * shutdown, as most recently was done
763 afs_ReleaseConns(sa->conns);
766 for (tcbrp = ts->cbrs; tcbrp; tcbrp = tbrp) {
768 * Free all server's callback structs
773 afs_osi_Free(ts, sizeof(struct server));
778 for (i = 0; i < NSERVERS; i++) {
779 struct srvAddr *sa, *next;
781 sa = afs_srvAddrs[i];
784 afs_osi_Free(sa, sizeof(struct srvAddr));
791 shutdown_volume(void)
796 for (i = 0; i < NVOLS; i++) {
797 for (tv = afs_volumes[i]; tv; tv = tv->next) {
799 afs_osi_Free(tv->name, strlen(tv->name) + 1);
812 AFS_STATCNT(shutdown_AFS);
813 if (afs_cold_shutdown) {
814 afs_resourceinit_flag = 0;
819 * Free FreeVolList allocations
821 afs_osi_Free(Initialafs_freeVolList,
822 afs_memvolumes * sizeof(struct volume));
823 afs_freeVolList = Initialafs_freeVolList = 0;
825 /* XXX HACK for MEM systems XXX
827 * For -memcache cache managers when we run out of free in memory volumes
828 * we simply malloc more; we won't be able to free those additional volumes.
832 * Free Users table allocation
835 struct unixuser *tu, *ntu;
836 for (i = 0; i < NUSERS; i++) {
837 for (tu = afs_users[i]; tu; tu = ntu) {
840 afs_FreeTokens(&tu->tokens);
842 EXP_RELE(tu->exporter);
843 afs_osi_Free(tu, sizeof(struct unixuser));
849 for (i = 0; i < NFENTRIES; i++)
851 /* Reinitialize local globals to defaults */
852 for (i = 0; i < MAXNUMSYSNAMES; i++)
853 afs_osi_Free(afs_sysnamelist[i], MAXSYSNAME);
855 afs_sysnamecount = 0;
857 afs_setTimeHost = NULL;
859 afs_waitForever = afs_waitForeverCount = 0;
861 afs_server = (struct rx_service *)0;
862 AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
863 memset(&afs_rootFid, 0, sizeof(struct VenusFid));
864 AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
865 AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
866 AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
867 LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");