From: Derrick Brashear Date: Tue, 29 Dec 2009 16:29:09 +0000 (-0500) Subject: clean up axscache at shutdown X-Git-Tag: openafs-devel-1_5_69~65 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=0fce88e07934899eb2dfcff87ec289e0d4f683eb clean up axscache at shutdown modify allocations in axscache code to be able to be tracked. at shutdown, clean up allocations. Change-Id: I1fbde0fe49cf0cdeea451dac58718a90f1c87e66 Reviewed-on: http://gerrit.openafs.org/1037 Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs_axscache.c b/src/afs/afs_axscache.c index ea3a4aa..d71f847 100644 --- a/src/afs/afs_axscache.c +++ b/src/afs/afs_axscache.c @@ -16,8 +16,11 @@ #include "afs/afs_stats.h" /* statistics */ #include "afs/stds.h" static struct axscache *afs_axsfreelist = NULL; + +#define NAXSs (1000 / sizeof(struct axscache)) static struct xfreelist { struct xfreelist *next; + struct axscache data[NAXSs]; } *xfreemallocs = 0; static int afs_xaxscnt = 0; afs_rwlock_t afs_xaxs; @@ -52,24 +55,25 @@ afs_SlowFindAxs(struct axscache **cachep, afs_int32 id) } -#define NAXSs (1000 / sizeof(struct axscache)) struct axscache * axs_Alloc(void) { - register struct axscache *i, *j, *xsp; - struct axscache *h; + struct axscache *i, *j; + struct xfreelist *h, *xsp; int k; ObtainWriteLock(&afs_xaxs, 174); - if ((h = afs_axsfreelist)) { - afs_axsfreelist = h->next; + if ((i = afs_axsfreelist)) { + afs_axsfreelist = i->next; + ReleaseWriteLock(&afs_xaxs); + return i; } else { - h = i = j = - (struct axscache *)afs_osi_Alloc(NAXSs * sizeof(struct axscache)); + h = afs_osi_Alloc(sizeof(struct xfreelist)); afs_xaxscnt++; - xsp = (struct axscache *)xfreemallocs; - xfreemallocs = (struct xfreelist *)h; - xfreemallocs->next = (struct xfreelist *)xsp; + xsp = xfreemallocs; + xfreemallocs = h; + xfreemallocs->next = xsp; + i = j = h->data; for (k = 0; k < NAXSs - 1; k++, i++) { i->uid = -2; i->axess = 0; @@ -78,10 +82,10 @@ axs_Alloc(void) i->uid = -2; i->axess = 0; i->next = NULL; - afs_axsfreelist = h->next; + afs_axsfreelist = (h->data)->next; } ReleaseWriteLock(&afs_xaxs); - return (h); + return (h->data); } @@ -165,8 +169,7 @@ afs_FreeAllAxs(struct axscache **headp) /* doesn't appear to be used at all */ -#if 0 -static void +void shutdown_xscache(void) { struct xfreelist *xp, *nxp; @@ -175,10 +178,9 @@ shutdown_xscache(void) xp = xfreemallocs; while (xp) { nxp = xp->next; - afs_osi_Free((char *)xp, NAXSs * sizeof(struct axscache)); + afs_osi_Free(xp, sizeof(struct xfreelist)); xp = nxp; } afs_axsfreelist = NULL; xfreemallocs = NULL; } -#endif diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index a19ac02..25f34fe 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -1331,6 +1331,7 @@ afs_shutdown(void) shutdown_osifile(); shutdown_vnodeops(); shutdown_memcache(); + shutdown_xscache(); #if (!defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)) shutdown_exporter(); shutdown_nfsclnt(); diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 70c08d9..1c1f315 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -22,6 +22,7 @@ extern struct axscache *afs_SlowFindAxs(struct axscache **cachep, extern struct axscache *axs_Alloc(void); extern void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp); extern void afs_FreeAllAxs(struct axscache **headp); +extern void shutdown_xscache(void); /* afs_buffer.c */ extern void DInit(int abuffers);