Fix vcache/vnode mismatch in lookup for DARWIN
[openafs.git] / src / afs / VNOPS / afs_vnop_lookup.c
index c14b4a5..ee95ac5 100644 (file)
@@ -205,7 +205,7 @@ EvalMountData(char type, char *data, afs_uint32 states, afs_uint32 cellnum,
      * Don't know why we do this. Would have still found it in above call - jpm.
      */
     if (!tvp && (prefetch == 2) && len < AFS_SMALLOCSIZ - 10) {
-       buf = (char *)osi_AllocSmallSpace(len + 10);
+       buf = osi_AllocSmallSpace(len + 10);
 
        strcpy(buf, volnamep);
        afs_strcat(buf, ".readonly");
@@ -300,8 +300,7 @@ EvalMountPoint(struct vcache *avc, struct vcache *advc,
        auniq = 1;
 
     if (avc->mvid == 0)
-       avc->mvid =
-           (struct VenusFid *)osi_AllocSmallSpace(sizeof(struct VenusFid));
+       avc->mvid = osi_AllocSmallSpace(sizeof(struct VenusFid));
     avc->mvid->Cell = (*avolpp)->cell;
     avc->mvid->Fid.Volume = (*avolpp)->volume;
     avc->mvid->Fid.Vnode = avnoid;
@@ -554,7 +553,7 @@ Check_AtSys(struct vcache *avc, const char *aname,
 
     if (AFS_EQ_ATSYS(aname)) {
        state->offset = 0;
-       state->name = (char *)osi_AllocLargeSpace(MAXSYSNAME);
+       state->name = osi_AllocLargeSpace(MAXSYSNAME);
        state->allocked = 1;
        state->index =
            afs_getsysname(areq, avc, state->name, &num, sysnamelist);
@@ -586,7 +585,7 @@ Next_AtSys(struct vcache *avc, struct vrequest *areq,
 
        if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname - 4))) {
            state->offset = (tname - 4) - state->name;
-           tname = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+           tname = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
            strncpy(tname, state->name, state->offset);
            state->name = tname;
            state->allocked = 1;
@@ -630,6 +629,10 @@ afs_CheckBulkStatus(struct afs_conn *tc, int nFids, AFSBulkStats *statParm,
     int code;
 
     if (statParm->AFSBulkStats_len != nFids || cbParm->AFSCBs_len != nFids) {
+       afs_warn("afs: BulkFetchStatus length %u/%u, expected %u\n",
+                (unsigned)statParm->AFSBulkStats_len,
+                (unsigned)cbParm->AFSCBs_len, nFids);
+       afs_BadFetchStatus(tc);
        return VBUSY;
     }
     for (i = 0; i < nFids; i++) {
@@ -736,11 +739,9 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
      * one for fids and callbacks, and one for stat info.  Well set
      * up our pointers to the memory from there, too.
      */
-    statsp = (AFSFetchStatus *) 
-           osi_Alloc(AFSCBMAX * sizeof(AFSFetchStatus));
-    fidsp = (AFSFid *) osi_AllocLargeSpace(nentries * sizeof(AFSFid));
-    cbsp = (AFSCallBack *) 
-           osi_Alloc(AFSCBMAX * sizeof(AFSCallBack));
+    statsp = osi_Alloc(AFSCBMAX * sizeof(AFSFetchStatus));
+    fidsp = osi_AllocLargeSpace(nentries * sizeof(AFSFid));
+    cbsp = osi_Alloc(AFSCBMAX * sizeof(AFSCallBack));
 
     /* next, we must iterate over the directory, starting from the specified
      * cookie offset (dirCookie), and counting out nentries file entries.
@@ -860,7 +861,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
                    else
                        tvcp->f.m.Type = VREG;
                    /* finalize to a best guess */
-                   afs_darwin_finalizevnode(tvcp, VTOAFS(adp), NULL, 0, 1);
+                   afs_darwin_finalizevnode(tvcp, AFSTOV(adp), NULL, 0, 1);
                    /* re-acquire usecount that finalizevnode disposed of */
                    vnode_ref(AFSTOV(tvcp));
 #endif
@@ -1169,8 +1170,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
        /* now copy ".." entry back out of volume structure, if necessary */
        if (tvcp->mvstat == 2 && (dotdot.Fid.Volume != 0)) {
            if (!tvcp->mvid)
-               tvcp->mvid = (struct VenusFid *)
-                   osi_AllocSmallSpace(sizeof(struct VenusFid));
+               tvcp->mvid = osi_AllocSmallSpace(sizeof(struct VenusFid));
            *tvcp->mvid = dotdot;
        }
 
@@ -1342,7 +1342,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 
 /* was: (AFS_DEC_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_NCR_ENV) */
 #ifdef AFS_DARWIN80_ENV
-int AFSDOBULK = 1;
+int AFSDOBULK = 0;
 #else
 static int AFSDOBULK = 1;
 #endif
@@ -1381,7 +1381,6 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     int pass = 0, hit = 0;
     int force_eval = afs_fakestat_enable ? 0 : 1;
     long dirCookie;
-    extern afs_int32 afs_mariner;      /*Writing activity to log? */
     afs_hyper_t versionNo;
     int no_read_access = 0;
     struct sysname_info sysState;      /* used only for @sys checking */
@@ -1431,11 +1430,8 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     if (code)
        goto done;
 
-    *avcp = NULL;              /* Since some callers don't initialize it */
-
     /* come back to here if we encounter a non-existent object in a read-only
      * volume's directory */
-
   redo:
     *avcp = NULL;              /* Since some callers don't initialize it */
     bulkcode = 0;
@@ -1861,7 +1857,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
                    if (tvolp) {
                        ObtainWriteLock(&tvc->lock, 134);
                        if (tvc->mvid == NULL) {
-                           tvc->mvid = (struct VenusFid *)
+                           tvc->mvid =
                                osi_AllocSmallSpace(sizeof(struct VenusFid));
                        }
                        /* setup backpointer */
@@ -1928,7 +1924,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
             * volume) rather than the vc of the mount point itself.  We can
             * still find the mount point's vc in the vcache by its fid. */
 #endif /* UKERNEL */
-           if (!hit && force_eval) {
+           if (!hit && (force_eval || tvc->mvstat != 1)) {
                osi_dnlc_enter(adp, aname, tvc, &versionNo);
            } else {
 #ifdef AFS_LINUX20_ENV