From 9689219fba92964bf83d08aa809ba3a5398c1621 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Feb 2007 11:08:32 +0000 Subject: [PATCH] DEVEL15-windows-merge-status-20070204 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 (cherry picked from commit 4e8bc6d5016f8e6d46a21331009c414d94e90d10) --- src/WINNT/afsd/cm_dcache.c | 4 ++-- src/WINNT/afsd/cm_scache.c | 19 ++++++++++++++++++- src/WINNT/afsd/cm_scache.h | 1 + src/WINNT/afsd/cm_vnodeops.c | 16 ++++++++-------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index f1aa3daca..f0ca4e270 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -297,7 +297,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; @@ -420,7 +420,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; diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 67f2fed03..09a5c83e8 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -1368,6 +1368,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)) { @@ -1382,7 +1383,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; @@ -1413,6 +1413,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 diff --git a/src/WINNT/afsd/cm_scache.h b/src/WINNT/afsd/cm_scache.h index e96a38bd3..2592637dd 100644 --- a/src/WINNT/afsd/cm_scache.h +++ b/src/WINNT/afsd/cm_scache.h @@ -292,6 +292,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 diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index a30cc5e59..97619330b 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -1405,13 +1405,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; @@ -2313,7 +2313,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. -- 2.39.5