From e2fcfb88a234afe1bfe2b0b1046f0a0325580ea6 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Sat, 20 Jul 2002 08:57:17 +0000 Subject: [PATCH] Minor internal cleanup of fakestat's afs_EvalFakeStat and afs_TryEvalFakeStat; no functional change. --- src/afs/VNOPS/afs_vnop_lookup.c | 52 +++++++++++++++++++++------------ src/afs/afs.h | 1 - 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 534f7e9e3..e71338d4c 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -255,27 +255,22 @@ afs_InitFakeStat(state) state->valid = 1; state->did_eval = 0; state->need_release = 0; - state->nonblock = 0; } /* - * afs_EvalFakeStat - * - * Automatically does the equivalent of EvalMountPoint for vcache entries - * which are mount points. Remembers enough state to properly release - * the volume root vcache when afs_PutFakeStat() is called. + * afs_EvalFakeStat_int * - * State variable must be initialized by afs_InitFakeState() beforehand. + * The actual implementation of afs_EvalFakeStat and afs_TryEvalFakeStat, + * which is called by those wrapper functions. * - * Returns 0 when everything succeeds and *avcp points to the vcache entry - * that should be used for the real vnode operation. Returns non-zero if - * something goes wrong and the error code should be returned to the user. + * Only issues RPCs if canblock is non-zero. */ -int -afs_EvalFakeStat(avcp, state, areq) +static int +afs_EvalFakeStat_int(avcp, state, areq, canblock) struct vcache **avcp; struct afs_fakestat_state *state; struct vrequest *areq; + int canblock; { struct vcache *tvc, *root_vp; struct volume *tvolp = NULL; @@ -294,7 +289,7 @@ afs_EvalFakeStat(avcp, state, areq) code = afs_VerifyVCache(tvc, areq); if (code) goto done; - if (!state->nonblock) { + if (canblock) { ObtainWriteLock(&tvc->lock, 599); code = EvalMountPoint(tvc, NULL, &tvolp, areq); ReleaseWriteLock(&tvc->lock); @@ -307,7 +302,7 @@ afs_EvalFakeStat(avcp, state, areq) } } if (tvc->mvid && (tvc->states & CMValid)) { - if (state->nonblock) { + if (!canblock) { afs_int32 retry; do { @@ -324,7 +319,7 @@ afs_EvalFakeStat(avcp, state, areq) root_vp = afs_GetVCache(tvc->mvid, areq, NULL, NULL, WRITE_LOCK); } if (!root_vp) { - code = state->nonblock ? 0 : ENOENT; + code = canblock ? ENOENT : 0; goto done; } if (tvolp) { @@ -342,7 +337,7 @@ afs_EvalFakeStat(avcp, state, areq) *avcp = root_vp; code = 0; } else { - code = state->nonblock ? 0 : ENOENT; + code = canblock ? ENOENT : 0; } done: @@ -351,6 +346,28 @@ done: return code; } +/* + * afs_EvalFakeStat + * + * Automatically does the equivalent of EvalMountPoint for vcache entries + * which are mount points. Remembers enough state to properly release + * the volume root vcache when afs_PutFakeStat() is called. + * + * State variable must be initialized by afs_InitFakeState() beforehand. + * + * Returns 0 when everything succeeds and *avcp points to the vcache entry + * that should be used for the real vnode operation. Returns non-zero if + * something goes wrong and the error code should be returned to the user. + */ +int +afs_EvalFakeStat(avcp, state, areq) + struct vcache **avcp; + struct afs_fakestat_state *state; + struct vrequest *areq; +{ + return afs_EvalFakeStat_int(avcp, state, areq, 1); +} + /* * afs_TryEvalFakeStat * @@ -367,8 +384,7 @@ afs_TryEvalFakeStat(avcp, state, areq) struct afs_fakestat_state *state; struct vrequest *areq; { - state->nonblock = 1; - return afs_EvalFakeStat(avcp, state, areq); + return afs_EvalFakeStat_int(avcp, state, areq, 0); } /* diff --git a/src/afs/afs.h b/src/afs/afs.h index 3deb8352b..e119600b4 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -1188,7 +1188,6 @@ struct afs_fakestat_state { char valid; char did_eval; char need_release; - char nonblock; struct vcache *root_vp; }; -- 2.39.5