From 4e8bc6d5016f8e6d46a21331009c414d94e90d10 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 5 Feb 2007 11:07:44 +0000 Subject: [PATCH] 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 --- 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 dbcd5b79b..7c3b55421 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -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; diff --git a/src/WINNT/afsd/cm_scache.c b/src/WINNT/afsd/cm_scache.c index 7f40f166c..ba49c4929 100644 --- a/src/WINNT/afsd/cm_scache.c +++ b/src/WINNT/afsd/cm_scache.c @@ -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 diff --git a/src/WINNT/afsd/cm_scache.h b/src/WINNT/afsd/cm_scache.h index fa791f040..cb14dfe55 100644 --- a/src/WINNT/afsd/cm_scache.h +++ b/src/WINNT/afsd/cm_scache.h @@ -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 diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index ec74fb1bc..496cba450 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -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. -- 2.39.5