From 7d4f3a4710fb8c9fbde4294c2458ecf32658300b Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Thu, 3 Apr 2014 16:37:51 -0400 Subject: [PATCH] afs: only reset access caches for the matching cell MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When an AFS user's tokens change (unlog, aklog) or expire, afs_ResetAccessCache() is called to reset all the access caches for that uid/PAG. However, a user/PAG may have tokens for multiple cells, and they may expire or be set/reset at different times. Therefore, it is incorrect to assume that all access caches for a uid/PAG should be discarded when only one cell's tokens have changed. Modify afs_ResetAccessCache() to acccept a new argument 'cell', and only reset the access caches for a uid/PAG if the vcache resides in the specified cell. If the caller really wants to reset all a user's access caches, specify cell=-1. For cache managers that are running with multiple PAGs and multiple cells, this should improve performance because 1) it avoids scanning access caches chains for vcaches that are not part of the current cell and 2) it avoids deleting access caches that may still good, thus preventing unnecessary FetchStatus calls. Change-Id: Id4c138dab45fd48265a4029880a5d57947e67a52 Reviewed-on: http://gerrit.openafs.org/11070 Tested-by: BuildBot Reviewed-by: D Brashear --- src/afs/afs_prototypes.h | 2 +- src/afs/afs_user.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 6a1db164b..6e5187944 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1004,7 +1004,7 @@ extern void afs_ComputePAGStats(void); extern void afs_PutUser(struct unixuser *au, afs_int32 locktype); extern void afs_GCUserData(int aforce); extern void afs_CheckTokenCache(void); -extern void afs_ResetAccessCache(afs_int32 uid, int alock); +extern void afs_ResetAccessCache(afs_int32 uid, afs_int32 cell, int alock); extern void afs_ResetUserConns(struct unixuser *auser); extern void afs_SetPrimary(struct unixuser *au, int aflag); extern void afs_MarkUserExpired(afs_int32 pag); diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index 0b63550c0..7f7468c1c 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -50,7 +50,7 @@ struct unixuser *afs_users[NUSERS]; #ifndef AFS_PAG_MANAGER /* Forward declarations */ -void afs_ResetAccessCache(afs_int32 uid, int alock); +void afs_ResetAccessCache(afs_int32 uid, afs_int32 cell, int alock); #endif /* !AFS_PAG_MANAGER */ @@ -218,8 +218,13 @@ done: } /*afs_CheckTokenCache */ +/* Remove any access caches associated with this uid+cell + * by scanning the entire vcache table. Specify cell=-1 + * to remove all access caches associated with this uid + * regardless of cell. + */ void -afs_ResetAccessCache(afs_int32 uid, int alock) +afs_ResetAccessCache(afs_int32 uid, afs_int32 cell, int alock) { int i; struct vcache *tvc; @@ -232,8 +237,11 @@ afs_ResetAccessCache(afs_int32 uid, int alock) for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { /* really should do this under cache write lock, but that. * is hard to under locking hierarchy */ - if (tvc->Access && (ac = afs_FindAxs(tvc->Access, uid))) { - afs_RemoveAxs(&tvc->Access, ac); + if (tvc->Access && (cell == -1 || tvc->f.fid.Cell == cell)) { + ac = afs_FindAxs(tvc->Access, uid); + if (ac) { + afs_RemoveAxs(&tvc->Access, ac); + } } } } @@ -272,7 +280,7 @@ afs_ResetUserConns(struct unixuser *auser) ReleaseWriteLock(&afs_xconn); ReleaseReadLock(&afs_xsrvAddr); - afs_ResetAccessCache(auser->uid, 1); + afs_ResetAccessCache(auser->uid, auser->cell, 1); auser->states &= ~UNeedsReset; } /*afs_ResetUserConns */ #endif /* !AFS_PAG_MANAGER */ -- 2.39.5