]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-merge-status-20070204
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 5 Feb 2007 11:07:44 +0000 (11:07 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 5 Feb 2007 11:07:44 +0000 (11:07 +0000)
For each StoreData operation the dataVersion on the object is incremented.
To prevent all of the cached buffers from being considered out of date,
if the dataVersion has been incremented by exactly one, then update the
dataVersion of the buffers that match the FID and the previous dataVersion

src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_scache.c
src/WINNT/afsd/cm_scache.h
src/WINNT/afsd/cm_vnodeops.c

index dbcd5b79baefc05f51c252df6f0dd7411ac7d601..7c3b55421eb4574a240cfbe5ad967a13eb380b28 100644 (file)
@@ -295,7 +295,7 @@ long cm_BufWrite(void *vscp, osi_hyper_t *offsetp, long length, long flags,
         if (LargeIntegerGreaterThanOrEqualTo(t, scp->length))
             scp->mask &= ~CM_SCACHEMASK_LENGTH;
 
-        cm_MergeStatus(scp, &outStatus, &volSync, userp, 0);
+        cm_MergeStatus(scp, &outStatus, &volSync, userp, CM_MERGEFLAG_STOREDATA);
     } else {
         if (code == CM_ERROR_SPACE)
             scp->flags |= CM_SCACHEFLAG_OUTOFSPACE;
@@ -418,7 +418,7 @@ long cm_StoreMini(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 
         if (LargeIntegerGreaterThanOrEqualTo(t, scp->length))
             scp->mask &= ~CM_SCACHEMASK_LENGTH;
-        cm_MergeStatus(scp, &outStatus, &volSync, userp, 0);
+        cm_MergeStatus(scp, &outStatus, &volSync, userp, CM_MERGEFLAG_STOREDATA);
     }
 
     return code;
index 7f40f166c829c3f4b99963fdacb5395585eec172..ba49c492950b9b55af9c508adeac4cd8d55f61a2 100644 (file)
@@ -1366,6 +1366,7 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
         if (!(scp->flags & CM_SCACHEFLAG_RO))
             return;
     }       
+
     scp->serverModTime = statusp->ServerModTime;
 
     if (!(scp->mask & CM_SCACHEMASK_CLIENTMODTIME)) {
@@ -1380,7 +1381,6 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
     scp->serverLength.HighPart = statusp->Length_hi;
 
     scp->linkCount = statusp->LinkCount;
-    scp->dataVersion = statusp->DataVersion;
     scp->owner = statusp->Owner;
     scp->group = statusp->Group;
     scp->unixModeBits = statusp->UnixModeBits & 07777;
@@ -1411,6 +1411,23 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
     if (userp != NULL) {
         cm_AddACLCache(scp, userp, statusp->CallerAccess);
     }
+
+    if ((flags & CM_MERGEFLAG_STOREDATA) &&
+       statusp->DataVersion - scp->dataVersion == 1) {
+       afs_uint32 i;
+       cm_buf_t *bp;
+
+       for (i = 0; i < cm_data.buf_hashSize; i++)
+       {
+           for(bp = cm_data.buf_hashTablepp[i]; bp; bp=bp->hashp) {
+               if (cm_FidCmp(&scp->fid, &bp->fid) == 0 && 
+                   bp->dataVersion == scp->dataVersion)
+                   bp->dataVersion = statusp->DataVersion;
+           }
+       }
+
+    }
+    scp->dataVersion = statusp->DataVersion;
 }
 
 /* note that our stat cache info is incorrect, so force us eventually
index fa791f040991a5a1f731d66053c064757308f4bb..cb14dfe554352265122b6367ab4f8559fa95ac65 100644 (file)
@@ -288,6 +288,7 @@ typedef struct cm_scache {
                                                 * used to see if we're merging
                                                 * in old info.
                                                  */
+#define CM_MERGEFLAG_STOREDATA         2       /* Merge due to storedata op */
 
 /* hash define.  Must not include the cell, since the callback revocation code
  * doesn't necessarily know the cell in the case of a multihomed server
index ec74fb1bcfb180deefbc71c19eadc94a059bfca8..496cba450e7107503efa22bf25d9113f6f1fa9b2 100644 (file)
@@ -1403,13 +1403,13 @@ long cm_Unlink(cm_scache_t *dscp, char *namep, cm_user_t *userp, cm_req_t *reqp)
     cm_SyncOpDone(dscp, NULL, sflags);
     if (code == 0) 
         cm_MergeStatus(dscp, &newDirStatus, &volSync, userp, 0);
-       else if (code == CM_ERROR_NOSUCHFILE) {
-               /* windows would not have allowed the request to delete the file 
-                * if it did not believe the file existed.  therefore, we must 
-                * have an inconsistent view of the world.
-                */
-               dscp->cbServerp = NULL;
-       }
+    else if (code == CM_ERROR_NOSUCHFILE) {
+       /* windows would not have allowed the request to delete the file 
+        * if it did not believe the file existed.  therefore, we must 
+        * have an inconsistent view of the world.
+        */
+       dscp->cbServerp = NULL;
+    }
     lock_ReleaseMutex(&dscp->mx);
 
     return code;
@@ -2311,7 +2311,7 @@ long cm_SetAttr(cm_scache_t *scp, cm_attr_t *attrp, cm_user_t *userp,
     cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_STORESTATUS);
     if (code == 0)
         cm_MergeStatus(scp, &afsOutStatus, &volSync, userp,
-                        CM_MERGEFLAG_FORCE);
+                        CM_MERGEFLAG_FORCE|CM_MERGEFLAG_STOREDATA);
        
     /* if we're changing the mode bits, discard the ACL cache, 
      * since we changed the mode bits.