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 int afsd_dynamic_vcaches = 0; /* Enable dynamic-vcache support */
63 * Initialization order is important. Must first call afs_CacheInit,
64 * then cache file and volume file initialization routines. Next, the
65 * individual cache entry initialization routines are called.
75 * astatSize : The number of stat cache (vnode) entries to
77 * afiles : The number of disk files to allocate to the cache
78 * ablocks : The max number of 1 Kbyte blocks that all of
79 * the files in the cache may occupy.
80 * aDentries : Number of dcache entries to allocate.
81 * aVolumes : Number of volume cache entries to allocate.
82 * achunk : Power of 2 to make the chunks.
83 * aflags : Flags passed in.
84 * inodes : max inodes to pin down in inode[]
85 * users : what should size of per-user access cache be?
88 * This routine should only be called at initialization time, since
89 * it reclaims no resources and doesn't sufficiently synchronize
90 * with other processes.
93 struct cm_initparams cm_initParams;
94 static int afs_cacheinit_flag = 0;
96 afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
97 afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk,
98 afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers,
99 afs_int32 dynamic_vcaches)
104 AFS_STATCNT(afs_CacheInit);
106 * Jot down the epoch time, namely when this incarnation of the
107 * Cache Manager started.
109 afs_stats_cmperf.epoch = pag_epoch = osi_Time();
111 afs_stats_cmperf.sysName_ID = SYS_NAME_ID;
113 afs_stats_cmperf.sysName_ID = SYS_NAME_ID_UNDEFINED;
114 #endif /* SYS_NAME_ID */
116 #ifdef AFS_MAXVCOUNT_ENV
117 afsd_dynamic_vcaches = dynamic_vcaches;
118 afs_warn("%s dynamically allocated vcaches\n",
119 ( afsd_dynamic_vcaches ? "enabling" : "disabling" ));
122 afs_warn("Starting AFS cache scan...");
123 if (afs_cacheinit_flag)
125 afs_cacheinit_flag = 1;
126 cacheInfoModTime = 0;
128 LOCK_INIT(&afs_ftf, "afs_ftf");
129 AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
130 AFS_RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
131 AFS_RWLOCK_INIT(&afs_disconDirtyLock, "afs_disconDirtyLock");
132 QInit(&afs_disconDirty);
133 QInit(&afs_disconShadow);
137 * create volume list structure
141 else if (aVolumes > 32767)
144 tv = afs_osi_Alloc(aVolumes * sizeof(struct volume));
145 osi_Assert(tv != NULL);
146 for (i = 0; i < aVolumes - 1; i++)
147 tv[i].next = &tv[i + 1];
148 tv[aVolumes - 1].next = NULL;
149 afs_freeVolList = Initialafs_freeVolList = tv;
150 afs_memvolumes = aVolumes;
152 afs_cacheFiles = afiles;
153 afs_cacheStats = astatSize;
154 afs_vcacheInit(astatSize);
155 afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
156 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
158 * Save current credentials for later access to disk cache files.
159 * If selinux, apparmor or other security modules are enabled,
160 * they might deny access to cache files if the userspace process
161 * is restricted. Save the credentials used at cache initialisation
162 * for later use when opening cache files.
164 cache_creds = get_current_cred();
166 #ifdef AFS_64BIT_CLIENT
167 #ifdef AFS_VM_RDWR_ENV
168 afs_vmMappingEnd = AFS_CHUNKBASE(0x7fffffff);
169 #endif /* AFS_VM_RDWR_ENV */
170 #endif /* AFS_64BIT_CLIENT */
172 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV)
174 static void afs_procsize_init(void);
180 /* Save the initialization parameters for later pioctl queries. */
181 cm_initParams.cmi_version = CMI_VERSION;
182 cm_initParams.cmi_nChunkFiles = afiles;
183 cm_initParams.cmi_nStatCaches = astatSize;
184 cm_initParams.cmi_nDataCaches = aDentries;
185 cm_initParams.cmi_nVolumeCaches = aVolumes;
186 cm_initParams.cmi_firstChunkSize = AFS_FIRSTCSIZE;
187 cm_initParams.cmi_otherChunkSize = AFS_OTHERCSIZE;
188 cm_initParams.cmi_cacheSize = afs_cacheBlocks;
189 cm_initParams.cmi_setTime = 0;
190 cm_initParams.cmi_memCache = (aflags & AFSCALL_INIT_MEMCACHE) ? 1 : 0;
198 * afs_ComputeCacheParams
201 * Set some cache parameters.
208 afs_ComputeCacheParms(void)
211 afs_int32 afs_maxCacheDirty;
214 * Don't allow more than 2/3 of the files in the cache to be dirty.
216 afs_maxCacheDirty = (2 * afs_cacheFiles) / 3;
219 * Also, don't allow more than 2/3 of the total space get filled
220 * with dirty chunks. Compute the total number of chunks required
221 * to fill the cache, make sure we don't set out limit above 2/3 of
222 * that. If the cache size is greater than 1G, avoid overflow at
223 * the expense of precision on the chunk size.
225 if (afs_cacheBlocks & 0xffe00000) {
226 i = afs_cacheBlocks / (AFS_FIRSTCSIZE >> 10);
228 i = (afs_cacheBlocks << 10) / AFS_FIRSTCSIZE;
231 if (afs_maxCacheDirty > i)
232 afs_maxCacheDirty = i;
233 if (afs_maxCacheDirty < 1)
234 afs_maxCacheDirty = 1;
235 afs_stats_cmperf.cacheMaxDirtyChunks = afs_maxCacheDirty;
236 } /*afs_ComputeCacheParms */
240 * afs_LookupInodeByPath
242 * Look up inode given a file name.
243 * Optionally return the vnode too.
244 * If the vnode is not returned, we rele it.
247 afs_LookupInodeByPath(char *filename, afs_ufs_dcache_id_t *inode,
252 #if defined(AFS_LINUX22_ENV)
254 code = gop_lookupname(filename, AFS_UIOSYS, 0, &dp);
257 osi_get_fh(dp, inode);
260 struct vnode *filevp;
261 code = gop_lookupname(filename, AFS_UIOSYS, 0, &filevp);
264 #ifdef AFS_CACHE_VNODE_PATH
265 *inode = afs_strdup(filename);
267 *inode = afs_vnodeToInumber(filevp);
280 afs_InitCellInfo(char *afile)
282 afs_dcache_id_t inode;
285 code = afs_LookupInodeByPath(afile, &inode.ufs, NULL);
286 return afs_cellname_init(&inode, code);
293 * Set up the volume info storage file.
296 * afile : the file to be declared to be the volume info storage
297 * file for AFS. It must be already truncated to 0 length.
300 * This function is called only during initialization.
302 * WARNING: Data will be written to this file over time by AFS.
306 afs_InitVolumeInfo(char *afile)
309 struct osi_file *tfile;
311 AFS_STATCNT(afs_InitVolumeInfo);
312 #if defined(AFS_XBSD_ENV)
314 * On Open/Free/NetBSD, we can get into big trouble if we don't hold the volume file
315 * vnode. SetupVolume holds afs_xvolume lock exclusive.
316 * SetupVolume->GetVolSlot->UFSGetVolSlot->{GetVolCache or WriteVolCache}
317 * ->osi_UFSOpen->VFS_VGET()->ffs_vget->getnewvnode->vgone on some vnode.
318 * If it's AFS, then ->vclean->afs_nbsd_reclaim->FlushVCache->QueueVCB->
319 * GetVolume->FindVolume-> waits on afs_xvolume lock !
321 * In general, anything that's called with afs_xvolume locked must not
322 * end up calling getnewvnode(). The only cases I've found so far
323 * are things which try to get the volumeInode, and since we keep
326 code = afs_LookupInodeByPath(afile, &volumeInode.ufs, &volumeVnode);
328 code = afs_LookupInodeByPath(afile, &volumeInode.ufs, NULL);
332 tfile = afs_CFileOpen(&volumeInode);
333 afs_CFileTruncate(tfile, 0);
334 afs_CFileClose(tfile);
339 afs_InitFHeader(struct afs_fheader *aheader)
341 memset(aheader, 0, sizeof(*aheader));
342 aheader->magic = AFS_FHMAGIC;
343 aheader->version = AFS_CI_VERSION;
344 aheader->dataSize = sizeof(struct fcache);
345 aheader->firstCSize = AFS_FIRSTCSIZE;
346 aheader->otherCSize = AFS_OTHERCSIZE;
353 * Set up the given file as the AFS cache info file.
356 * afile : Name of the file assumed to be the cache info file
357 * for the Cache Manager; it will be used as such.
358 * Side Effects: This sets afs_fragsize, which is used in the cache usage
359 * calculations such as in afs_adjustsize()
362 * This function is called only during initialization. The given
363 * file should NOT be truncated to 0 length; its contents describe
364 * what data is really in the cache.
366 * WARNING: data will be written to this file over time by AFS.
368 * NOTE: Starting to use separate osi_InitCacheInfo() routines to clean up
373 afs_InitCacheInfo(char *afile)
376 struct osi_stat tstat;
377 struct osi_file *tfile;
378 struct afs_fheader theader;
379 #ifndef AFS_LINUX22_ENV
380 struct vnode *filevp;
384 AFS_STATCNT(afs_InitCacheInfo);
385 if (cacheDiskType != AFS_FCACHE_TYPE_UFS)
386 osi_Panic("afs_InitCacheInfo --- called for non-ufs cache!");
387 #ifdef AFS_LINUX22_ENV
388 code = osi_InitCacheInfo(afile);
392 code = gop_lookupname(afile, AFS_UIOSYS, 0, &filevp);
396 #if defined(AFS_SUN5_ENV)
398 #elif defined(AFS_HPUX102_ENV)
400 #elif defined(AFS_SGI_ENV) || defined(AFS_HPUX100_ENV) || defined(AFS_NBSD40_ENV)
402 #elif defined(AFS_DARWIN80_ENV)
408 #if defined(AFS_SGI_ENV)
410 VFS_STATVFS(filevp->v_vfsp, &st, NULL, code);
413 if (!VFS_STATFS(filevp->v_vfsp, &st, NULL))
414 #endif /* AFS_SGI65_ENV */
415 #elif defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV)
416 if (!VFS_STATVFS(filevp->v_vfsp, &st))
417 #elif defined(AFS_AIX41_ENV)
418 if (!VFS_STATFS(filevp->v_vfsp, &st, &afs_osi_cred))
419 #elif defined(AFS_LINUX20_ENV)
424 VFS_STATFS(filevp->v_vfsp, &st);
427 #elif defined(AFS_DARWIN80_ENV)
428 afs_cacheVfsp = vnode_mount(filevp);
429 if (afs_cacheVfsp && ((st = *(vfs_statfs(afs_cacheVfsp))),1))
430 #elif defined(AFS_FBSD80_ENV)
431 if (!VFS_STATFS(filevp->v_mount, &st))
432 #elif defined(AFS_NBSD50_ENV)
433 if (!VFS_STATVFS(filevp->v_vfsp, &st))
434 #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
435 if (!VFS_STATFS(filevp->v_mount, &st, osi_curproc()))
437 if (!VFS_STATFS(filevp->v_vfsp, &st))
439 #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV)
440 if (strcmp("zfs", st.f_basetype) == 0) {
442 * Files in ZFS can take up to around the next
443 * recordsize boundary after being truncated. recordsize
444 * is reported in statvfs by f_bsize, so use that
447 afs_fsfragsize = st.f_bsize - 1;
449 afs_fsfragsize = st.f_frsize - 1;
452 afs_fsfragsize = st.f_bsize - 1;
455 #if defined(AFS_LINUX20_ENV)
456 cacheInode.ufs = filevp->i_ino;
457 afs_cacheSBp = filevp->i_sb;
458 #elif defined(AFS_XBSD_ENV)
459 cacheInode.ufs = VTOI(filevp)->i_number;
460 cacheDev.mp = filevp->v_mount;
461 cacheDev.held_vnode = filevp;
462 vref(filevp); /* Make sure mount point stays busy. XXX */
463 #if !defined(AFS_OBSD_ENV)
464 afs_cacheVfsp = filevp->v_vfsp;
467 #if defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
468 afs_InitDualFSCacheOps(filevp);
470 #ifndef AFS_CACHE_VNODE_PATH
471 #ifndef AFS_DARWIN80_ENV
472 afs_cacheVfsp = filevp->v_vfsp;
474 cacheInode.ufs = afs_vnodeToInumber(filevp);
476 afs_LookupInodeByPath(afile, &cacheInode.ufs, NULL);
478 cacheDev.dev = afs_vnodeToDev(filevp);
479 #endif /* AFS_LINUX20_ENV */
481 #endif /* AFS_LINUX22_ENV */
482 if (afs_fsfragsize < AFS_MIN_FRAGSIZE) {
483 afs_fsfragsize = AFS_MIN_FRAGSIZE;
485 tfile = osi_UFSOpen(&cacheInode);
489 afs_osi_Stat(tfile, &tstat);
490 cacheInfoModTime = tstat.mtime;
491 code = afs_osi_Read(tfile, -1, &theader, sizeof(theader));
493 if (code == sizeof(theader)) {
494 /* read the header correctly */
495 if (theader.magic == AFS_FHMAGIC
496 && theader.firstCSize == AFS_FIRSTCSIZE
497 && theader.otherCSize == AFS_OTHERCSIZE
498 && theader.dataSize == sizeof(struct fcache)
499 && theader.version == AFS_CI_VERSION)
503 /* write out a good file label */
504 afs_InitFHeader(&theader);
505 afs_osi_Write(tfile, 0, &theader, sizeof(theader));
507 * Truncate the rest of the file, since it may be arbitrarily
510 osi_UFSTruncate(tfile, sizeof(struct afs_fheader));
512 /* Leave the file open now, since reopening the file makes public pool
513 * vnode systems (like OSF/Alpha) much harder to handle, That's because
514 * they can do a vnode recycle operation any time we open a file, which
515 * we'd do on any afs_GetDSlot call, etc.
517 afs_cacheInodep = (struct osi_file *)tfile;
521 int afs_resourceinit_flag = 0;
523 afs_ResourceInit(int preallocs)
526 static struct rx_securityClass *secobj;
528 AFS_STATCNT(afs_ResourceInit);
529 AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
530 AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
531 AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
532 AFS_RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
533 AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
534 AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
535 LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
536 #ifndef AFS_PRIVATE_OSI_ALLOCSPACES
537 LOCK_INIT(&osi_fsplock, "osi_fsplock");
538 LOCK_INIT(&osi_flplock, "osi_flplock");
540 AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
543 afs_InitCBQueue(1); /* initialize callback queues */
545 if (afs_resourceinit_flag == 0) {
546 afs_resourceinit_flag = 1;
547 for (i = 0; i < NFENTRIES; i++)
549 for (i = 0; i < MAXNUMSYSNAMES; i++) {
550 afs_sysnamelist[i] = afs_osi_Alloc(MAXSYSNAME);
551 osi_Assert(afs_sysnamelist[i] != NULL);
553 afs_sysname = afs_sysnamelist[0];
554 strcpy(afs_sysname, SYS_NAME);
555 afs_sysnamecount = 1;
559 secobj = rxnull_NewServerSecurityObject();
561 rx_NewService(0, 1, "afs", &secobj, 1, RXAFSCB_ExecuteRequest);
563 rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", &secobj, 1,
564 RXSTATS_ExecuteRequest);
566 afs_osi_Wakeup(&afs_server); /* wakeup anyone waiting for it */
569 } /*afs_ResourceInit */
571 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV)
574 * AIX dynamic sizeof(struct proc)
576 * AIX keeps its proc structures in an array. The size of struct proc
577 * varies from release to release of the OS. In order to maintain
578 * binary compatibility with releases later than what we build on, we
579 * need to determine the size of struct proc at run time.
581 * We need this in order to walk the proc[] array to do PAG garbage
584 * We also need this in order to support 'klog -setpag', since the
585 * kernel code needs to locate the proc structure for the parent process
586 * of the current process.
588 * To compute sizeof(struct proc), we need the addresses of two proc
589 * structures and their corresponding pids. Given the pids, we can use
590 * the PROCMASK() macro to compute their corresponding indices in the
591 * proc[] array. By dividing the distance between the pointers by the
592 * number of proc structures, we can compute the size of a single proc
595 * We know the base address of the proc table from v.vb_proc:
597 * <sys/sysconfig.h> declares sysconfig() and SYS_GETPARMS;
598 * (we don't use this, but I note it here for completeness)
600 * <sys/var.h> declares struct var and external variable v;
604 * v.ve_proc &proc[x] (current highwater mark for
605 * proc[] array usage)
607 * The first proc pointer is v.vb_proc, which is the proc structure for
608 * process 0. Process 0's pointer to its first child is the other proc
609 * pointer. If process 0 has no children, we simply give up and do not
610 * support features that require knowing the size of struct proc.
614 afs_procsize_init(void)
616 afs_proc_t *p0; /* pointer to process 0 */
617 afs_proc_t *pN; /* pointer to process 0's first child */
625 p0 = (afs_proc_t *)v.vb_proc;
627 afs_gcpags = AFS_GCPAGS_EPROC0;
642 afs_gcpags = AFS_GCPAGS_EPROCN;
646 if (pN->p_pid == p0->p_pid) {
647 afs_gcpags = AFS_GCPAGS_EEQPID;
651 pN_index = PROCMASK(pN->p_pid);
652 pN_offset = ((char *)pN - (char *)p0);
653 procsize = pN_offset / pN_index;
656 * check that the computation was exact
659 if (pN_index * procsize != pN_offset) {
660 afs_gcpags = AFS_GCPAGS_EINEXACT;
665 * check that the proc table size is a multiple of procsize.
668 if ((((char *)v.ve_proc - (char *)v.vb_proc) % procsize) != 0) {
669 afs_gcpags = AFS_GCPAGS_EPROCEND;
675 afs_gcpags_procsize = procsize;
683 * Clean up and shut down the AFS cache.
689 * Nothing interesting.
694 AFS_STATCNT(shutdown_cache);
695 afs_WriteThroughDSlots();
696 if (1/*afs_cold_shutdown*/) {
697 afs_cacheinit_flag = 0;
702 afs_cacheFiles = afs_cacheBlocks = 0;
705 #if defined(AFS_XBSD_ENV)
706 /* memcache never sets this, so don't panic on shutdown */
707 if (volumeVnode != NULL) {
708 vrele(volumeVnode); /* let it go, finally. */
711 if (cacheDev.held_vnode) {
712 vrele(cacheDev.held_vnode);
713 cacheDev.held_vnode = NULL;
716 #ifdef AFS_CACHE_VNODE_PATH
717 if (cacheDiskType != AFS_FCACHE_TYPE_MEM) {
718 afs_osi_FreeStr(cacheInode.ufs);
719 afs_osi_FreeStr(volumeInode.ufs);
722 afs_reset_inode(&cacheInode);
723 afs_reset_inode(&volumeInode);
724 cacheInfoModTime = 0;
726 afs_fsfragsize = 1023;
727 memset(&cacheDev, 0, sizeof(struct osi_dev));
730 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
731 put_cred(cache_creds);
733 } /*shutdown_cache */
737 shutdown_vnodeops(void)
739 AFS_STATCNT(shutdown_vnodeops);
740 if (afs_cold_shutdown) {
741 #ifndef AFS_LINUX20_ENV
750 shutdown_server(void)
753 struct afs_cbr *tcbrp, *tbrp;
756 for (i = 0; i < NSERVERS; i++) {
757 struct server *ts, *next;
762 for (sa = ts->addr; sa; sa = sa->next_sa) {
764 /* afs_ReleaseConns has been updated to
765 * defer rx_DestroyConnection to Rx
766 * shutdown, as most recently was done
768 afs_ReleaseConns(sa->conns);
771 for (tcbrp = ts->cbrs; tcbrp; tcbrp = tbrp) {
773 * Free all server's callback structs
778 afs_osi_Free(ts, sizeof(struct server));
783 for (i = 0; i < NSERVERS; i++) {
784 struct srvAddr *sa, *next;
786 sa = afs_srvAddrs[i];
789 afs_osi_Free(sa, sizeof(struct srvAddr));
796 shutdown_volume(void)
801 for (i = 0; i < NVOLS; i++) {
802 for (tv = afs_volumes[i]; tv; tv = tv->next) {
804 afs_osi_Free(tv->name, strlen(tv->name) + 1);
817 AFS_STATCNT(shutdown_AFS);
818 if (afs_cold_shutdown) {
819 afs_resourceinit_flag = 0;
824 * Free FreeVolList allocations
826 afs_osi_Free(Initialafs_freeVolList,
827 afs_memvolumes * sizeof(struct volume));
828 afs_freeVolList = Initialafs_freeVolList = 0;
830 /* XXX HACK for MEM systems XXX
832 * For -memcache cache managers when we run out of free in memory volumes
833 * we simply malloc more; we won't be able to free those additional volumes.
837 * Free Users table allocation
840 struct unixuser *tu, *ntu;
841 for (i = 0; i < NUSERS; i++) {
842 for (tu = afs_users[i]; tu; tu = ntu) {
845 afs_FreeTokens(&tu->tokens);
847 EXP_RELE(tu->exporter);
848 afs_osi_Free(tu, sizeof(struct unixuser));
854 for (i = 0; i < NFENTRIES; i++)
856 /* Reinitialize local globals to defaults */
857 for (i = 0; i < MAXNUMSYSNAMES; i++)
858 afs_osi_Free(afs_sysnamelist[i], MAXSYSNAME);
860 afs_sysnamecount = 0;
863 afs_waitForever = afs_waitForeverCount = 0;
865 afs_server = (struct rx_service *)0;
866 AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
867 memset(&afs_rootFid, 0, sizeof(struct VenusFid));
868 AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
869 AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
870 AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
871 LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");