Windows: buf_CleanLocked validate cm_scache_t
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 18 Nov 2012 02:32:44 +0000 (21:32 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 23 Nov 2012 15:45:45 +0000 (07:45 -0800)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_buf.c

index 1b8ccec..bed02b0 100644 (file)
@@ -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) {