afs: Create afs_SetDataVersion
[openafs.git] / src / afs / VNOPS / afs_vnop_create.c
index 313187d..30eaa7b 100644 (file)
@@ -62,8 +62,9 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 
     AFS_STATCNT(afs_create);
 
-    OutFidStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
-    OutDirStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+    OutFidStatus = osi_AllocSmallSpace(sizeof(struct AFSFetchStatus));
+    OutDirStatus = osi_AllocSmallSpace(sizeof(struct AFSFetchStatus));
+    memset(&InStatus, 0, sizeof(InStatus));
 
     if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
@@ -257,8 +258,12 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
                    }
                }
                *avcp = tvc;
-           } else
-               code = ENOENT;  /* shouldn't get here */
+
+           } else {
+               /* Directory entry already exists, but we cannot fetch the
+                * fid it points to. */
+               code = EIO;
+           }
            /* make sure vrefCount bumped only if code == 0 */
            goto done;
        }
@@ -351,11 +356,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 
        if (code) {
            if (code < 0) {
-               ObtainWriteLock(&afs_xcbhash, 488);
-               afs_DequeueCallback(adp);
-               adp->f.states &= ~CStatd;
-               ReleaseWriteLock(&afs_xcbhash);
-               osi_dnlc_purgedp(adp);
+               afs_StaleVCache(adp);
            }
            ReleaseWriteLock(&adp->lock);
            if (tdc) {
@@ -446,11 +447,9 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
                    afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp);
                }
            } else {
-               afs_DequeueCallback(tvc);
-               tvc->f.states &= ~(CStatd | CUnique);
-               tvc->callback = 0;
-               if (tvc->f.fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
-                   osi_dnlc_purgedp(tvc);
+               afs_StaleVCacheFlags(tvc,
+                                    AFS_STALEVC_CBLOCKED | AFS_STALEVC_CLEARCB,
+                                    CUnique);
            }
            ReleaseWriteLock(&afs_xcbhash);
            if (AFS_IS_DISCON_RW) {
@@ -465,8 +464,11 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            ReleaseWriteLock(&tvc->lock);
            *avcp = tvc;
            code = 0;
-       } else
-           code = ENOENT;
+
+       } else {
+           /* Cannot create a new vcache. */
+           code = EIO;
+       }
     } else {
        /* otherwise cache entry already exists, someone else must
         * have created it.  Comments used to say:  "don't need write
@@ -552,7 +554,7 @@ afs_LocalHero(struct vcache *avc, struct dcache *adc,
     /* The bulk status code used the length as a sequence number.  */
     /* Don't update the vcache entry unless the stats are current. */
     if (avc->f.states & CStatd) {
-       hset(avc->f.m.DataVersion, avers);
+       afs_SetDataVersion(avc, &avers);
 #ifdef AFS_64BIT_CLIENT
        FillInt64(avc->f.m.Length, astat->Length_hi, astat->Length);
 #else /* AFS_64BIT_CLIENT */