From: Michael Meffie Date: Thu, 7 Jun 2012 16:58:54 +0000 (-0400) Subject: libafs: use afs_ResetVCache in flush volume data X-Git-Tag: openafs-stable-1_8_0pre1~2215 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=36c6c46bd081e0278611c3bb6ae25dd765f10648 libafs: use afs_ResetVCache in flush volume data Remove some code duplication by using afs_ResetVCache in the flush volume data pioctl. Adds a flag to ResetVCache to avoid unneeded calls to purge dnlc when reseting all the vcaches in a volume. Adds freeing of vcache link data in the flush volume data pioctl. Change-Id: Ib94e6b4d28078a03d2ffd217998bbc345c4968e4 Reviewed-on: http://gerrit.openafs.org/7538 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afs/afs_disconnected.c b/src/afs/afs_disconnected.c index c1499b1..4f4ce80 100644 --- a/src/afs/afs_disconnected.c +++ b/src/afs/afs_disconnected.c @@ -1234,7 +1234,7 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) } else if (afs_ConflictPolicy == SERVER_WINS) { /* DV mismatch, apply collision resolution policy. */ /* Discard this files chunks and remove from current dir. */ - afs_ResetVCache(tvc, acred); + afs_ResetVCache(tvc, acred, 0); tvc->f.truncPos = AFS_NOTRUNC; } else { /* printf("afs_ResyncDisconFiles: no resolution policy selected.\n"); */ @@ -1327,7 +1327,7 @@ afs_DisconDiscardAllShadows(int squash, afs_ucred_t *acred) ObtainWriteLock(&tvc->lock, 706); if (squash) - afs_ResetVCache(tvc, acred); + afs_ResetVCache(tvc, acred, 0); afs_DeleteShadowDir(tvc); @@ -1356,7 +1356,7 @@ afs_DisconDiscardAll(afs_ucred_t *acred) ReleaseWriteLock(&afs_disconDirtyLock); ObtainWriteLock(&tvc->lock, 718); - afs_ResetVCache(tvc, acred); + afs_ResetVCache(tvc, acred, 0); tvc->f.truncPos = AFS_NOTRUNC; ReleaseWriteLock(&tvc->lock); ObtainWriteLock(&afs_disconDirtyLock, 719); diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index e1e66b6..6283a59 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -2147,7 +2147,7 @@ DECL_PIOCTL(PFlush) afs_BozonLock(&avc->pvnLock, avc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif ObtainWriteLock(&avc->lock, 225); - afs_ResetVCache(avc, *acred); + afs_ResetVCache(avc, *acred, 0); ReleaseWriteLock(&avc->lock); #ifdef AFS_BOZONLOCK_ENV afs_BozonUnlock(&avc->pvnLock, avc); @@ -3516,14 +3516,7 @@ DECL_PIOCTL(PFlushVolumeData) afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif ObtainWriteLock(&tvc->lock, 232); - - ObtainWriteLock(&afs_xcbhash, 458); - afs_DequeueCallback(tvc); - tvc->f.states &= ~(CStatd | CDirty); - ReleaseWriteLock(&afs_xcbhash); - if (tvc->f.fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)) - osi_dnlc_purgedp(tvc); - afs_TryToSmush(tvc, *acred, 1); + afs_ResetVCache(tvc, *acred, 1); ReleaseWriteLock(&tvc->lock); #ifdef AFS_BOZONLOCK_ENV afs_BozonUnlock(&tvc->pvnLock, tvc); diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index aaa4eb9..adb7337 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1117,7 +1117,7 @@ extern int afs_RemoteLookup(struct VenusFid *afid, struct AFSCallBack *CallBackp, struct server **serverp, struct AFSVolSync *tsyncp); -extern void afs_ResetVCache(struct vcache *, afs_ucred_t *); +extern void afs_ResetVCache(struct vcache *, afs_ucred_t *, afs_int32 skipdnlc); extern afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid); extern void afs_vcacheInit(int astatSize); diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 1904848..59762fb 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -2603,11 +2603,14 @@ afs_PutVCache(struct vcache *avc) * * \param avc Pointer to the cache entry to reset * \param acred + * \param skipdnlc skip the dnlc purge for this vnode * * \note avc must be write locked on entry + * + * \note The caller should purge the dnlc when skipdnlc is set. */ void -afs_ResetVCache(struct vcache *avc, afs_ucred_t *acred) +afs_ResetVCache(struct vcache *avc, afs_ucred_t *acred, afs_int32 skipdnlc) { ObtainWriteLock(&afs_xcbhash, 456); afs_DequeueCallback(avc); @@ -2615,7 +2618,9 @@ afs_ResetVCache(struct vcache *avc, afs_ucred_t *acred) ReleaseWriteLock(&afs_xcbhash); /* now find the disk cache entries */ afs_TryToSmush(avc, acred, 1); - osi_dnlc_purgedp(avc); + if (!skipdnlc) { + osi_dnlc_purgedp(avc); + } if (avc->linkData && !(avc->f.states & CCore)) { afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1); avc->linkData = NULL;