Change the meaning of the -fakestat switch to only enable fakestat
[openafs.git] / src / afs / VNOPS / afs_vnop_lookup.c
index 6bde5de..74960ee 100644 (file)
@@ -260,11 +260,9 @@ void afs_InitFakeStat(struct afs_fakestat_state *state)
  *
  * The actual implementation of afs_EvalFakeStat and afs_TryEvalFakeStat,
  * which is called by those wrapper functions.
- *
- * Only issues RPCs if canblock is non-zero.
  */
-int afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
-       struct vrequest *areq, int canblock)
+static int afs_EvalFakeStat_int(struct vcache **avcp,
+       struct afs_fakestat_state *state, struct vrequest *areq, int canblock)
 {
     struct vcache *tvc, *root_vp;
     struct volume *tvolp = NULL;
@@ -281,10 +279,29 @@ int afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
     if (tvc->mvstat != 1)
        return 0;
 
-    /* Is the call to VerifyVCache really necessary? */
     code = afs_VerifyVCache(tvc, areq);
     if (code)
        goto done;
+
+    if (afs_fakestat_enable == 2 && !canblock) {
+       ObtainSharedLock(&tvc->lock, 680);
+       if (!tvc->linkData) {
+           UpgradeSToWLock(&tvc->lock, 681);
+           code = afs_HandleLink(tvc, areq);
+           if (code) {
+               ReleaseWriteLock(&tvc->lock);
+               goto done;
+           }
+           ConvertWToRLock(&tvc->lock);
+       } else {
+           ConvertSToRLock(&tvc->lock);
+       }
+
+       if (!afs_strchr(tvc->linkData, ':'))
+           canblock = 1;
+       ReleaseReadLock(&tvc->lock);
+    }
+
     if (canblock) {
        ObtainWriteLock(&tvc->lock, 599);
        code = EvalMountPoint(tvc, NULL, &tvolp, areq);