mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
afs: Make FlushReclaimedVcaches() Darwin specific
Currently, the ReclaimedVCList is only fed on Darwin. As a result, the logic present in afs_FlushReclaimedVcaches() is never used on all other platforms and should be wrapped in #ifdef AFS_DARWIN_ENV. While here, also reorganize this function in an effort to make it more readable. No functional change is incurred by this commit. Change-Id: I1097a2b07fcb48dec2b31385477c34e974144b51 Reviewed-on: https://gerrit.openafs.org/15027 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
parent
f98e84458c
commit
a06cafd6d6
@ -63,7 +63,6 @@ afs_rwlock_t afs_xvreclaim; /*Lock: entries reclaimed, not on free list */
|
|||||||
afs_lock_t afs_xvcb; /*Lock: fids on which there are callbacks */
|
afs_lock_t afs_xvcb; /*Lock: fids on which there are callbacks */
|
||||||
#if !defined(AFS_LINUX_ENV)
|
#if !defined(AFS_LINUX_ENV)
|
||||||
static struct vcache *freeVCList; /*Free list for stat cache entries */
|
static struct vcache *freeVCList; /*Free list for stat cache entries */
|
||||||
struct vcache *ReclaimedVCList; /*Reclaimed list for stat entries */
|
|
||||||
static struct vcache *Initial_freeVCList; /*Initial list for above */
|
static struct vcache *Initial_freeVCList; /*Initial list for above */
|
||||||
#endif
|
#endif
|
||||||
struct afs_q VLRU; /*vcache LRU */
|
struct afs_q VLRU; /*vcache LRU */
|
||||||
@ -75,6 +74,9 @@ static struct afs_cbr *afs_cbrHashT[CBRSIZE];
|
|||||||
afs_int32 afs_bulkStatsLost;
|
afs_int32 afs_bulkStatsLost;
|
||||||
int afs_norefpanic = 0;
|
int afs_norefpanic = 0;
|
||||||
|
|
||||||
|
#if defined(AFS_DARWIN_ENV)
|
||||||
|
struct vcache *ReclaimedVCList; /*Reclaimed list for stat entries */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Disk backed vcache definitions
|
/* Disk backed vcache definitions
|
||||||
* Both protected by xvcache */
|
* Both protected by xvcache */
|
||||||
@ -672,40 +674,48 @@ afs_RemoveVCB(struct VenusFid *afid)
|
|||||||
ReleaseWriteLock(&afs_xvcb);
|
ReleaseWriteLock(&afs_xvcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush reclaimed/unlinked vcaches.
|
||||||
|
*
|
||||||
|
* In order to avoid deadlocks, Darwin doesn't block on the afs_xvcache lock
|
||||||
|
* when trying to flush a given vcache. Instead, if afs_xvcache can't be
|
||||||
|
* acquired, the entry in question is appended to the list of vcaches
|
||||||
|
* (ReclaimedVCList) to be flushed by this function later, which is called
|
||||||
|
* periodically in the background or when a new vcache is created.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
afs_FlushReclaimedVcaches(void)
|
afs_FlushReclaimedVcaches(void)
|
||||||
{
|
{
|
||||||
#if !defined(AFS_LINUX_ENV)
|
#if defined(AFS_DARWIN_ENV)
|
||||||
struct vcache *tvc;
|
struct vcache *tvc;
|
||||||
int code, fv_slept;
|
int code, fv_slept, states;
|
||||||
struct vcache *tmpReclaimedVCList = NULL;
|
struct vcache *tmpReclaimedVCList = NULL;
|
||||||
|
|
||||||
|
states = CVInit;
|
||||||
|
# ifdef AFS_DARWIN80_ENV
|
||||||
|
states |= CDeadVnode;
|
||||||
|
# endif
|
||||||
|
|
||||||
ObtainWriteLock(&afs_xvreclaim, 76);
|
ObtainWriteLock(&afs_xvreclaim, 76);
|
||||||
|
|
||||||
while (ReclaimedVCList) {
|
while (ReclaimedVCList) {
|
||||||
tvc = ReclaimedVCList; /* take from free list */
|
tvc = ReclaimedVCList; /* take from free list */
|
||||||
ReclaimedVCList = tvc->nextfree;
|
ReclaimedVCList = tvc->nextfree;
|
||||||
tvc->nextfree = NULL;
|
tvc->nextfree = NULL;
|
||||||
|
|
||||||
code = afs_FlushVCache(tvc, &fv_slept);
|
code = afs_FlushVCache(tvc, &fv_slept);
|
||||||
if (code) {
|
if (code) {
|
||||||
/* Ok, so, if we got code != 0, uh, wtf do we do? */
|
/*
|
||||||
/* Probably, build a temporary list and then put all back when we
|
* Since we must not leak vcaches that couldn't be flushed, add them
|
||||||
get to the end of the list */
|
* to a temporary list and put all back when we get to the end of
|
||||||
/* This is actually really crappy, but we need to not leak these.
|
* the list. This approach is not ideal and we probably need a way
|
||||||
We probably need a way to be smarter about this. */
|
* to be smarter about this.
|
||||||
|
*/
|
||||||
tvc->nextfree = tmpReclaimedVCList;
|
tvc->nextfree = tmpReclaimedVCList;
|
||||||
tmpReclaimedVCList = tvc;
|
tmpReclaimedVCList = tvc;
|
||||||
/* printf("Reclaim list flush %lx failed: %d\n", (unsigned long) tvc, code); */
|
|
||||||
}
|
}
|
||||||
if (tvc->f.states & (CVInit
|
if ((tvc->f.states & states) != 0) {
|
||||||
# ifdef AFS_DARWIN80_ENV
|
tvc->f.states &= ~states;
|
||||||
| CDeadVnode
|
|
||||||
# endif
|
|
||||||
)) {
|
|
||||||
tvc->f.states &= ~(CVInit
|
|
||||||
# ifdef AFS_DARWIN80_ENV
|
|
||||||
| CDeadVnode
|
|
||||||
# endif
|
|
||||||
);
|
|
||||||
afs_osi_Wakeup(&tvc->f.states);
|
afs_osi_Wakeup(&tvc->f.states);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user