AFSVolSync volSync;
AFSFid tfid;
struct rx_call *callp;
+ struct rx_connection *rxconnp;
osi_queueData_t *qdp;
cm_buf_t *bufp;
long wbytes;
if (code)
continue;
- lock_ObtainMutex(&connp->mx);
- callp = rx_NewCall(connp->callp);
- lock_ReleaseMutex(&connp->mx);
+ rxconnp = cm_GetRxConn(connp);
+ callp = rx_NewCall(rxconnp);
+ rx_PutConnection(rxconnp);
- osi_Log3(afsd_logp, "CALL StoreData vp %x, off 0x%x, size 0x%x",
+ osi_Log3(afsd_logp, "CALL StoreData scp 0x%x, off 0x%x, size 0x%x",
(long) scp, biod.offset.LowPart, nbytes);
code = StartRXAFS_StoreData(callp, &tfid, &inStatus,
bufp = osi_GetQData(qdp);
bufferp = bufp->datap;
wbytes = nbytes;
- if (wbytes > buf_bufferSize)
- wbytes = buf_bufferSize;
+ if (wbytes > cm_data.buf_blockSize)
+ wbytes = cm_data.buf_blockSize;
/* write out wbytes of data from bufferp */
temp = rx_Write(callp, bufferp, wbytes);
osi_Log1(afsd_logp, "EndRXAFS_StoreData failed (%lX)",code);
}
code = rx_EndCall(callp, code);
- osi_Log0(afsd_logp, "CALL StoreData DONE");
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
+ if (code)
+ osi_Log1(afsd_logp, "CALL StoreData FAILURE, code 0x%x", code);
+ else
+ osi_Log0(afsd_logp, "CALL StoreData SUCCESS");
+
/* now, clean up our state */
lock_ObtainMutex(&scp->mx);
long truncPos;
cm_conn_t *connp;
struct rx_call *callp;
+ struct rx_connection *rxconnp;
/* Serialize StoreData RPC's; for rationale see cm_scache.c */
(void) cm_SyncOp(scp, NULL, userp, reqp, 0,
if (code)
continue;
- lock_ObtainMutex(&connp->mx);
- callp = rx_NewCall(connp->callp);
- lock_ReleaseMutex(&connp->mx);
+ rxconnp = cm_GetRxConn(connp);
+ callp = rx_NewCall(rxconnp);
+ rx_PutConnection(rxconnp);
code = StartRXAFS_StoreData(callp, &tfid, &inStatus,
0, 0, truncPos);
long cm_BufRead(cm_buf_t *bufp, long nbytes, long *bytesReadp, cm_user_t *userp)
{
- *bytesReadp = buf_bufferSize;
+ *bytesReadp = cm_data.buf_blockSize;
/* now return a code that means that I/O is done */
return 0;
cm_BufUnstabilize
};
-int cm_InitDCache(long chunkSize, long nbuffers)
+long cm_ValidateDCache(void)
+{
+ return buf_ValidateBuffers();
+}
+
+long cm_ShutdownDCache(void)
+{
+ return 0;
+}
+
+int cm_InitDCache(int newFile, long chunkSize, long nbuffers)
{
lock_InitializeMutex(&cm_bufGetMutex, "buf_Get mutex");
- if (nbuffers)
- buf_nbuffers = nbuffers;
- return buf_Init(&cm_bufOps);
+ return buf_Init(newFile, &cm_bufOps, nbuffers);
}
/* check to see if we have an up-to-date buffer. The buffer must have
if (stop)
break;
- toffset.LowPart = buf_bufferSize;
+ toffset.LowPart = cm_data.buf_blockSize;
toffset.HighPart = 0;
tbase = LargeIntegerAdd(toffset, tbase);
- length -= buf_bufferSize;
+ length -= cm_data.buf_blockSize;
}
/* if we get here, either everything is fine or stop stopped us at a
/* reserve a chunk's worth of buffers */
lock_ReleaseMutex(&scp->mx);
- buf_ReserveBuffers(cm_chunkSize / buf_bufferSize);
+ buf_ReserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
lock_ObtainMutex(&scp->mx);
bufp = NULL;
- for (temp = 0; temp < inSize; temp += buf_bufferSize, bufp = NULL) {
+ for (temp = 0; temp < inSize; temp += cm_data.buf_blockSize, bufp = NULL) {
thyper.HighPart = 0;
thyper.LowPart = temp;
tbase = LargeIntegerAdd(*inOffsetp, thyper);
if (code) {
lock_ReleaseMutex(&bufp->mx);
buf_Release(bufp);
- buf_UnreserveBuffers(cm_chunkSize / buf_bufferSize);
+ buf_UnreserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
return code;
}
osi_QAddH((osi_queue_t **) &biop->bufListp,
(osi_queue_t **) &biop->bufListEndp,
&qdp->q);
- biop->length = buf_bufferSize;
+ biop->length = cm_data.buf_blockSize;
firstModOffset = bufp->offset;
biop->offset = firstModOffset;
| CM_SCACHESYNC_NOWAIT;
/* start by looking backwards until scanStart */
- thyper.HighPart = 0; /* hyper version of buf_bufferSize */
- thyper.LowPart = buf_bufferSize;
+ thyper.HighPart = 0; /* hyper version of cm_data.buf_blockSize */
+ thyper.LowPart = cm_data.buf_blockSize;
tbase = LargeIntegerSubtract(firstModOffset, thyper);
while(LargeIntegerGreaterThanOrEqualTo(tbase, scanStart)) {
/* see if we can find the buffer */
break;
/* try to lock it, and quit if we can't (simplifies locking) */
+ lock_ReleaseMutex(&scp->mx);
code = lock_TryMutex(&bufp->mx);
+ lock_ObtainMutex(&scp->mx);
if (code == 0) {
buf_Release(bufp);
break;
/* update biod info describing the transfer */
biop->offset = LargeIntegerSubtract(biop->offset, thyper);
- biop->length += buf_bufferSize;
+ biop->length += cm_data.buf_blockSize;
/* update loop pointer */
tbase = LargeIntegerSubtract(tbase, thyper);
} /* while loop looking for pages preceding the one we found */
/* now, find later dirty, contiguous pages, and add them to the list */
- thyper.HighPart = 0; /* hyper version of buf_bufferSize */
- thyper.LowPart = buf_bufferSize;
+ thyper.HighPart = 0; /* hyper version of cm_data.buf_blockSize */
+ thyper.LowPart = cm_data.buf_blockSize;
tbase = LargeIntegerAdd(firstModOffset, thyper);
while(LargeIntegerLessThan(tbase, scanEnd)) {
/* see if we can find the buffer */
break;
/* try to lock it, and quit if we can't (simplifies locking) */
+ lock_ReleaseMutex(&scp->mx);
code = lock_TryMutex(&bufp->mx);
+ lock_ObtainMutex(&scp->mx);
if (code == 0) {
buf_Release(bufp);
break;
&qdp->q);
/* update biod info describing the transfer */
- biop->length += buf_bufferSize;
+ biop->length += cm_data.buf_blockSize;
/* update loop pointer */
tbase = LargeIntegerAdd(tbase, thyper);
* sequence at a time.
*/
+ // lock_ObtainMutex(&cm_bufGetMutex);
/* first hold all buffers, since we can't hold any locks in buf_Get */
while (1) {
/* stop at chunk boundary */
- if (collected >= cm_chunkSize) break;
+ if (collected >= cm_chunkSize)
+ break;
/* see if the next page would be past EOF */
- if (LargeIntegerGreaterThanOrEqualTo(pageBase, fileSize)) break;
-
- lock_ObtainMutex(&cm_bufGetMutex);
+ if (LargeIntegerGreaterThanOrEqualTo(pageBase, fileSize))
+ break;
code = buf_Get(scp, &pageBase, &tbp);
if (code) {
lock_ReleaseMutex(&cm_bufGetMutex);
lock_ObtainMutex(&scp->mx);
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
return code;
}
buf_Release(tbp);
- lock_ReleaseMutex(&cm_bufGetMutex);
-
toffset.HighPart = 0;
- toffset.LowPart = buf_bufferSize;
+ toffset.LowPart = cm_data.buf_blockSize;
pageBase = LargeIntegerAdd(toffset, pageBase);
- collected += buf_bufferSize;
+ collected += cm_data.buf_blockSize;
}
/* reserve a chunk's worth of buffers if possible */
- reserving = buf_TryReserveBuffers(cm_chunkSize / buf_bufferSize);
+ reserving = buf_TryReserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
+
+ // lock_ReleaseMutex(&cm_bufGetMutex);
pageBase = *offsetp;
collected = pageBase.LowPart & (cm_chunkSize - 1);
if (!reserving)
break;
- collected += buf_bufferSize;
+ collected += cm_data.buf_blockSize;
toffset.HighPart = 0;
- toffset.LowPart = buf_bufferSize;
+ toffset.LowPart = cm_data.buf_blockSize;
pageBase = LargeIntegerAdd(toffset, pageBase);
}
* we still do the I/O to whatever we've already managed to collect.
*/
isFirst = 0;
- collected += buf_bufferSize;
+ collected += cm_data.buf_blockSize;
}
/* now, we've held in biop->bufListp all the buffer's we're really
* caller requires to make any progress. Give up now.
*/
if (code && isFirst) {
- buf_UnreserveBuffers(cm_chunkSize / buf_bufferSize);
+ buf_UnreserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
return code;
}
/* Give back reserved buffers */
if (biop->reserved)
- buf_UnreserveBuffers(cm_chunkSize / buf_bufferSize);
+ buf_UnreserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
flags = CM_SCACHESYNC_NEEDCALLBACK;
if (isStore)
osi_queueData_t *qdp; /* q element we're scanning */
AFSFid tfid;
struct rx_call *callp;
+ struct rx_connection *rxconnp;
cm_bulkIO_t biod; /* bulk IO descriptor */
cm_conn_t *connp;
int getroot;
// handle it differently, since it's local rather than on any
// server
- getroot = (scp==cm_rootSCachep);
+ getroot = (scp==cm_data.rootSCachep);
if (getroot)
- osi_Log1(afsd_logp,"GetBuffer returns cm_rootSCachep=%x",cm_rootSCachep);
+ osi_Log1(afsd_logp,"GetBuffer returns cm_data.rootSCachep=%x",cm_data.rootSCachep);
#endif
cm_AFSFidFromFid(&tfid, &scp->fid);
&& LargeIntegerGreaterThanOrEqualTo(bufp->offset,
scp->serverLength)) {
if (bufp->dataVersion == -1)
- memset(bufp->datap, 0, buf_bufferSize);
+ memset(bufp->datap, 0, cm_data.buf_blockSize);
bufp->dataVersion = scp->dataVersion;
}
lock_ReleaseMutex(&scp->mx);
afsStatus.FileType = 0x2;
afsStatus.LinkCount = scp->linkCount;
afsStatus.Length = cm_fakeDirSize;
- afsStatus.DataVersion = scp->dataVersion;
+ afsStatus.DataVersion = cm_data.fakeDirVersion;
afsStatus.Author = 0x1;
afsStatus.Owner = 0x0;
afsStatus.CallerAccess = 0x9;
afsStatus.ParentVnode = 0x1;
afsStatus.ParentUnique = 0x1;
afsStatus.ResidencyMask = 0;
- afsStatus.ClientModTime = FakeFreelanceModTime;
- afsStatus.ServerModTime = FakeFreelanceModTime;
+ afsStatus.ClientModTime = (afs_uint32)FakeFreelanceModTime;
+ afsStatus.ServerModTime = (afs_uint32)FakeFreelanceModTime;
afsStatus.Group = 0;
afsStatus.SyncCounter = 0;
afsStatus.dataVersionHigh = 0;
+ afsStatus.lockCount = 0;
+ afsStatus.Length_hi = 0;
+ afsStatus.errorCode = 0;
// once we're done setting up the status info,
// we just fill the buffer pages with fakedata
while (qdp) {
tbufp = osi_GetQData(qdp);
bufferp=tbufp->datap;
- memset(bufferp, 0, buf_bufferSize);
+ memset(bufferp, 0, cm_data.buf_blockSize);
t2 = cm_fakeDirSize - t1;
- if (t2>buf_bufferSize) t2=buf_bufferSize;
+ if (t2>cm_data.buf_blockSize) t2=cm_data.buf_blockSize;
if (t2 > 0) {
memcpy(bufferp, cm_FakeRootDir+t1, t2);
} else {
code = cm_Conn(&scp->fid, up, reqp, &connp);
if (code)
continue;
-
- lock_ObtainMutex(&connp->mx);
- callp = rx_NewCall(connp->callp);
- lock_ReleaseMutex(&connp->mx);
+
+ rxconnp = cm_GetRxConn(connp);
+ callp = rx_NewCall(rxconnp);
+ rx_PutConnection(rxconnp);
osi_Log3(afsd_logp, "CALL FetchData vp %x, off 0x%x, size 0x%x",
(long) scp, biod.offset.LowPart, biod.length);
osi_assert(bufferp != NULL);
/* read rbytes of data */
- rbytes = (nbytes > buf_bufferSize? buf_bufferSize : nbytes);
+ rbytes = (nbytes > cm_data.buf_blockSize? cm_data.buf_blockSize : nbytes);
temp = rx_Read(callp, bufferp, rbytes);
if (temp < rbytes) {
code = (callp->error < 0) ? callp->error : -1;
/* bytes fetched */
rbytes = bufferp - tbufp->datap;
/* bytes left to zero */
- rbytes = buf_bufferSize - rbytes;
+ rbytes = cm_data.buf_blockSize - rbytes;
while(qdp) {
if (rbytes != 0)
memset(bufferp, 0, rbytes);
tbufp = osi_GetQData(qdp);
bufferp = tbufp->datap;
/* bytes to clear in this page */
- rbytes = buf_bufferSize;
+ rbytes = cm_data.buf_blockSize;
}
}
code = cm_MapRPCError(code, reqp);
lock_ObtainMutex(&scp->mx);
+
+ cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_FETCHSTATUS);
+
/* we know that no one else has changed the buffer, since we still have
* the fetching flag on the buffers, and we have the scp locked again.
* Copy in the version # into the buffer if we got code 0 back from the
#ifdef DISKCACHE95
/* write buffer out to disk cache */
- diskcache_Update(tbufp->dcp, tbufp->datap, buf_bufferSize,
+ diskcache_Update(tbufp->dcp, tbufp->datap, cm_data.buf_blockSize,
tbufp->dataVersion);
#endif /* DISKCACHE95 */
}