Windows: Add cm_req_t parameter to buf_Get* functions
[openafs.git] / src / WINNT / afsd / rawops.c
index 228f3cf..c06af5e 100644 (file)
@@ -82,7 +82,7 @@ long ReadData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
             }
             lock_ReleaseWrite(&scp->rw);
 
-            code = buf_Get(scp, &thyper, &bufferp);
+            code = buf_Get(scp, &thyper, &req, &bufferp);
 
             lock_ObtainWrite(&scp->rw);
             if (code) goto done;
@@ -243,7 +243,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
             }  
             lock_ReleaseWrite(&scp->rw);
 
-            code = buf_Get(scp, &thyper, &bufferp);
+            code = buf_Get(scp, &thyper, &req, &bufferp);
 
             lock_ObtainMutex(&bufferp->mx);
             lock_ObtainWrite(&scp->rw);
@@ -284,7 +284,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
                      (count >= buf_bufferSize ||
                        LargeIntegerGreaterThanOrEqualTo(LargeIntegerAdd(offset, ConvertLongToLargeInteger(count)), minLength))) {
                     if (count < buf_bufferSize
-                         && bufferp->dataVersion == -1)
+                         && bufferp->dataVersion == CM_BUF_VERSION_BAD)
                         memset(bufferp->datap, 0,
                                 buf_bufferSize);
                     bufferp->dataVersion = scp->dataVersion;
@@ -342,10 +342,11 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
 
     if (code == 0 && doWriteBack) {
         lock_ObtainWrite(&scp->rw);
-        cm_SyncOp(scp, NULL, userp, &req, 0, CM_SCACHESYNC_ASYNCSTORE);
+        code = cm_SyncOp(scp, NULL, userp, &req, 0, CM_SCACHESYNC_ASYNCSTORE);
         lock_ReleaseWrite(&scp->rw);
-        cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart,
-                            writeBackOffset.HighPart, cm_chunkSize, 0, userp);
+        if (code == 0)
+            cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart,
+                               writeBackOffset.HighPart, cm_chunkSize, 0, userp);
     }   
 
     /* cm_SyncOpDone is called when cm_BkgStore completes */