diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index d14e3ce8c6..ceba954014 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -1345,7 +1345,7 @@ void buf_CleanWait(cm_scache_t * scp, cm_buf_t *bp, afs_uint32 locked) * * The buffer must be locked before calling this routine. */ -void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length, cm_user_t *userp) +void buf_SetDirty(cm_buf_t *bp, cm_req_t *reqp, afs_uint32 offset, afs_uint32 length, cm_user_t *userp) { osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic"); osi_assertx(bp->refCount > 0, "cm_buf_t refcount 0"); diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index 391b51deb2..3d5fffc7f2 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -179,7 +179,7 @@ extern afs_uint32 buf_CleanAsync(cm_scache_t *, cm_buf_t *, cm_req_t *, afs_uint extern void buf_CleanWait(cm_scache_t *, cm_buf_t *, afs_uint32 locked); -extern void buf_SetDirty(cm_buf_t *, afs_uint32 offset, afs_uint32 length, cm_user_t *); +extern void buf_SetDirty(cm_buf_t *, cm_req_t *, afs_uint32 offset, afs_uint32 length, cm_user_t *); extern long buf_CleanAndReset(void); diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c index 31cdaa0c3b..627f9a08ce 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -144,7 +144,7 @@ void cm_BkgDaemon(void * parm) #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_BkgDaemon (before) scp 0x%x ref %d",rp->scp, rp->scp->refCount); #endif - code = (*rp->procp)(rp->scp, rp->p1, rp->p2, rp->p3, rp->p4, rp->userp); + code = (*rp->procp)(rp->scp, rp->p1, rp->p2, rp->p3, rp->p4, rp->userp, &rp->req); #ifdef DEBUG_REFCOUNT osi_Log2(afsd_logp,"cm_BkgDaemon (after) scp 0x%x ref %d",rp->scp, rp->scp->refCount); #endif @@ -192,7 +192,7 @@ void cm_BkgDaemon(void * parm) } void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, - cm_user_t *userp) + cm_user_t *userp, cm_req_t *reqp) { cm_bkgRequest_t *rp; @@ -208,6 +208,7 @@ void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, af rp->p2 = p2; rp->p3 = p3; rp->p4 = p4; + rp->req = *reqp; lock_ObtainWrite(&cm_daemonLock); cm_bkgQueueCount++; diff --git a/src/WINNT/afsd/cm_daemon.h b/src/WINNT/afsd/cm_daemon.h index 7d5a0232f8..087260191a 100644 --- a/src/WINNT/afsd/cm_daemon.h +++ b/src/WINNT/afsd/cm_daemon.h @@ -25,7 +25,7 @@ void cm_DaemonShutdown(void); void cm_InitDaemon(int nDaemons); typedef afs_int32 (cm_bkgProc_t)(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, - afs_uint32 p4, struct cm_user *up); + afs_uint32 p4, struct cm_user *up, cm_req_t *reqp); typedef struct cm_bkgRequest { osi_queue_t q; @@ -35,11 +35,12 @@ typedef struct cm_bkgRequest { afs_uint32 p2; afs_uint32 p3; afs_uint32 p4; - struct cm_user *userp; + cm_user_t *userp; + cm_req_t req; } cm_bkgRequest_t; extern void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, - afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp); + afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp, cm_req_t *reqp); #define CM_MAX_DAEMONS 64 diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index b0ca7da510..71fea626f8 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -726,20 +726,18 @@ cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, osi_hyper_t *lengt afs_int32 cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, - cm_user_t *userp) + cm_user_t *userp, cm_req_t *reqp) { osi_hyper_t toffset; long length; - cm_req_t req; long code = 0; if (scp->flags & CM_SCACHEFLAG_DELETED) { osi_Log4(afsd_logp, "Skipping BKG store - Deleted scp 0x%p, offset 0x%x:%08x, length 0x%x", scp, p2, p1, p3); } else { - cm_InitReq(&req); - /* Retries will be performed by the BkgDaemon thread if appropriate */ - req.flags |= CM_REQ_NORETRY; + afs_uint32 req_flags = reqp->flags; + reqp->flags |= CM_REQ_NORETRY; toffset.LowPart = p1; toffset.HighPart = p2; @@ -747,9 +745,11 @@ cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_u osi_Log4(afsd_logp, "Starting BKG store scp 0x%p, offset 0x%x:%08x, length 0x%x", scp, p2, p1, p3); - code = cm_BufWrite(scp, &toffset, length, /* flags */ 0, userp, &req); + code = cm_BufWrite(scp, &toffset, length, /* flags */ 0, userp, reqp); osi_Log4(afsd_logp, "Finished BKG store scp 0x%p, offset 0x%x:%08x, code 0x%x", scp, p2, p1, code); + + reqp->flags = req_flags; } /* @@ -771,6 +771,7 @@ cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_u cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_ASYNCSTORE); lock_ReleaseWrite(&scp->rw); } + return code; } @@ -793,7 +794,7 @@ void cm_ClearPrefetchFlag(long code, cm_scache_t *scp, osi_hyper_t *base, osi_hy * because there is no harm done. */ afs_int32 cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, - cm_user_t *userp) + cm_user_t *userp, cm_req_t *reqp) { osi_hyper_t length; osi_hyper_t base; @@ -804,12 +805,11 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af afs_int32 code; int rxheld = 0; cm_buf_t *bp = NULL; - cm_req_t req; - - cm_InitReq(&req); + afs_uint32 req_flags; /* Retries will be performed by the BkgDaemon thread if appropriate */ - req.flags |= CM_REQ_NORETRY; + req_flags = reqp->flags; + reqp->flags |= CM_REQ_NORETRY; fetched.LowPart = 0; fetched.HighPart = 0; @@ -833,7 +833,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af rxheld = 0; } - code = buf_Get(scp, &offset, &req, &bp); + code = buf_Get(scp, &offset, reqp, &bp); if (code) break; @@ -854,7 +854,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af rxheld = 1; } - code = cm_GetBuffer(scp, bp, NULL, userp, &req); + code = cm_GetBuffer(scp, bp, NULL, userp, reqp); if (code == 0) fetched = LargeIntegerAdd(fetched, tblocksize); buf_Release(bp); @@ -889,6 +889,8 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af osi_Log4(afsd_logp, "Ending BKG prefetch scp 0x%p code 0x%x fetched 0x%x:%x", scp, code, fetched.HighPart, fetched.LowPart); + + reqp->flags = req_flags; return code; } @@ -977,7 +979,7 @@ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 coun cm_QueueBKGRequest(scp, cm_BkgPrefetch, realBase.LowPart, realBase.HighPart, readLength.LowPart, readLength.HighPart, - userp); + userp, reqp); } /* scp must be locked; temporarily unlocked during processing. @@ -1246,6 +1248,7 @@ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp, tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize); biop->scp = scp; /* do not hold; held by caller */ + biop->reqp = reqp; biop->offset = *offsetp; /* null out the list of buffers */ biop->bufListp = biop->bufListEndp = NULL; diff --git a/src/WINNT/afsd/cm_dcache.h b/src/WINNT/afsd/cm_dcache.h index 8537f79682..be5b723cb0 100644 --- a/src/WINNT/afsd/cm_dcache.h +++ b/src/WINNT/afsd/cm_dcache.h @@ -13,6 +13,7 @@ /* bulk I/O descriptor */ typedef struct cm_bulkIO { struct cm_scache *scp; /* typically unheld vnode ptr */ + struct cm_req *reqp; /* the request ptr */ osi_hyper_t offset; /* offset of buffers */ long length; /* # of bytes to be transferred */ int reserved; /* did we reserve multiple buffers? */ @@ -47,10 +48,10 @@ extern long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize, cm_bulkIO_t *biop, cm_user_t *userp, cm_req_t *reqp); extern afs_int32 cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, - struct cm_user *userp); + struct cm_user *userp, cm_req_t *reqp); extern afs_int32 cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, - struct cm_user *userp); + struct cm_user *userp, cm_req_t *reqp); extern void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 count, diff --git a/src/WINNT/afsd/rawops.c b/src/WINNT/afsd/rawops.c index 56d29fc98b..ecc6f24750 100644 --- a/src/WINNT/afsd/rawops.c +++ b/src/WINNT/afsd/rawops.c @@ -326,7 +326,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op, /* now copy the data */ memcpy(bufferp->datap + bufIndex, op, nbytes); - buf_SetDirty(bufferp, bufIndex, nbytes, userp); + buf_SetDirty(bufferp, &req, bufIndex, nbytes, userp); /* adjust counters, pointers, etc. */ op += nbytes; @@ -350,7 +350,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op, lock_ReleaseWrite(&scp->rw); if (code == 0) cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart, - writeBackOffset.HighPart, cm_chunkSize, 0, userp); + writeBackOffset.HighPart, cm_chunkSize, 0, userp, &req); } /* cm_SyncOpDone is called when cm_BkgStore completes */ diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index 25016aed56..bf2c50968c 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -7459,7 +7459,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, afs_uint32 count, char /* now copy the data */ memcpy(bufferp->datap + bufIndex, op, nbytes); - buf_SetDirty(bufferp, bufIndex, nbytes, userp); + buf_SetDirty(bufferp, &req, bufIndex, nbytes, userp); /* adjust counters, pointers, etc. */ op += nbytes; @@ -7509,7 +7509,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, afs_uint32 count, char lock_ReleaseWrite(&scp->rw); cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart, writeBackOffset.HighPart, - smb_AsyncStoreSize, 0, userp); + smb_AsyncStoreSize, 0, userp, &req); /* cm_SyncOpDone is called at the completion of cm_BkgStore */ } } else { diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 3e388f9aed..2832f28c76 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -8270,7 +8270,7 @@ long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) if (prefetch) cm_QueueBKGRequest(scp, cm_BkgPrefetch, 0, 0, scp->length.LowPart, scp->length.HighPart, - userp); + userp, &req); osi_Log2(smb_logp, "SMB NT CreateX opening fid %d path %S", fidp->fid, @@ -9024,7 +9024,7 @@ long smb_ReceiveNTTranCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *out if (prefetch) cm_QueueBKGRequest(scp, cm_BkgPrefetch, 0, 0, scp->length.LowPart, scp->length.HighPart, - userp); + userp, &req); osi_Log1(smb_logp, "SMB NTTranCreate opening fid %d", fidp->fid);