From c99797eadc80efa24972a85d1c37e03393c888ca Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 17 Nov 2012 21:32:44 -0500 Subject: [PATCH] Windows: buf_CleanLocked validate cm_scache_t If the cm_scache_t object is not passed in by the caller ensure that the cm_scache_t has a valid callback. If the cm_scache_t has the CM_SCACHEFLAG_DELETED flag set, clear the dirty flag on the cm_buf_t and do not bother contacting the file server. Change-Id: If85be550b59765f64aadea4e1882af9430cebcb4 Reviewed-on: http://gerrit.openafs.org/8473 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_buf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 1b8ccecc7..bed02b045 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -816,6 +816,23 @@ afs_uint32 buf_CleanLocked(cm_scache_t *scp, cm_buf_t *bp, cm_req_t *reqp, reqp) == 0) { release_scp = 1; + + lock_ObtainWrite(&scp->rw); + code = cm_SyncOp(scp, NULL, bp->userp ? bp->userp : cm_rootUserp, reqp, 0, + CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); + if (code == 0) { + cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS); + } + lock_ReleaseWrite(&scp->rw); + } + + if (scp && (scp->flags & CM_SCACHEFLAG_DELETED)) { + _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY); + _InterlockedOr(&bp->flags, CM_BUF_ERROR); + bp->dirty_length = 0; + bp->error = code; + bp->dataVersion = CM_BUF_VERSION_BAD; + bp->dirtyCounter++; } while ((bp->flags & CM_BUF_DIRTY) == CM_BUF_DIRTY) { -- 2.39.5