Lines Matching defs:pReq

272  * @param   pReq              The request to free.
274 static void rtAioMgrReqFree(PRTAIOMGRINT pThis, PRTAIOMGRREQ pReq)
276 if (pReq->cbBounceBuffer)
278 AssertPtr(pReq->pvBounceBuffer);
279 RTMemPageFree(pReq->pvBounceBuffer, pReq->cbBounceBuffer);
280 pReq->pvBounceBuffer = NULL;
281 pReq->cbBounceBuffer = 0;
283 pReq->fFlags = 0;
284 RTAioMgrFileRelease(pReq->pFile);
285 RTMemCacheFree(pThis->hMemCacheReqs, pReq);
288 static void rtAioMgrReqCompleteRc(PRTAIOMGRINT pThis, PRTAIOMGRREQ pReq,
294 pFile = pReq->pFile;
306 pFile->pfnReqCompleted(pFile, rcReq, pReq->pvUser);
307 rtAioMgrReqFree(pThis, pReq);
317 if (RT_UNLIKELY( cbTransfered < pReq->DataSeg.cbSeg
318 || ( pReq->cbBounceBuffer
319 && cbTransfered < pReq->cbBounceBuffer)))
327 if (pReq->cbBounceBuffer)
329 AssertPtr(pReq->pvBounceBuffer);
330 offStart = (pReq->off & ~((RTFOFF)512-1)) + cbTransfered;
331 cbToTransfer = pReq->cbBounceBuffer - cbTransfered;
332 pbBuf = (uint8_t *)pReq->pvBounceBuffer + cbTransfered;
336 Assert(!pReq->pvBounceBuffer);
337 offStart = pReq->off + cbTransfered;
338 cbToTransfer = pReq->DataSeg.cbSeg - cbTransfered;
339 pbBuf = (uint8_t *)pReq->DataSeg.pvSeg + cbTransfered;
342 if ( pReq->enmType == RTAIOMGRREQTYPE_PREFETCH
343 || pReq->enmType == RTAIOMGRREQTYPE_READ)
345 rc = RTFileAioReqPrepareRead(pReq->hReqIo, pFile->hFile, offStart,
346 pbBuf, cbToTransfer, pReq);
350 AssertMsg(pReq->enmType == RTAIOMGRREQTYPE_WRITE,
352 rc = RTFileAioReqPrepareWrite(pReq->hReqIo, pFile->hFile, offStart,
353 pbBuf, cbToTransfer, pReq);
357 rc = rtAioMgrReqsEnqueue(pThis, pFile, &pReq->hReqIo, 1);
361 else if (pReq->enmType == RTAIOMGRREQTYPE_PREFETCH)
363 Assert(pReq->cbBounceBuffer);
364 pReq->enmType = RTAIOMGRREQTYPE_WRITE;
366 memcpy(((uint8_t *)pReq->pvBounceBuffer) + pReq->offBounceBuffer,
367 pReq->DataSeg.pvSeg,
368 pReq->DataSeg.cbSeg);
371 RTFOFF offStart = pReq->off & ~(RTFOFF)(512-1);
372 size_t cbToTransfer = RT_ALIGN_Z(pReq->DataSeg.cbSeg + (pReq->off - offStart), 512);
374 rc = RTFileAioReqPrepareWrite(pReq->hReqIo, pFile->hFile,
375 offStart, pReq->pvBounceBuffer, cbToTransfer, pReq);
377 rc = rtAioMgrReqsEnqueue(pThis, pFile, &pReq->hReqIo, 1);
383 if (RT_SUCCESS(rc) && pReq->cbBounceBuffer)
385 if (pReq->enmType == RTAIOMGRREQTYPE_READ)
386 memcpy(pReq->DataSeg.pvSeg,
387 ((uint8_t *)pReq->pvBounceBuffer) + pReq->offBounceBuffer,
388 pReq->DataSeg.cbSeg);
392 pFile->pfnReqCompleted(pFile, rcReq, pReq->pvUser);
393 rtAioMgrReqFree(pThis, pReq);
405 PRTAIOMGRREQ pReq = (PRTAIOMGRREQ)RTFileAioReqGetUser(hReq);
407 rtAioMgrReqCompleteRc(pThis, pReq, rcReq, cbTransfered);
431 PRTAIOMGRREQ pReq = (PRTAIOMGRREQ)RTFileAioReqGetUser(pahReqs[i]);
433 Assert(pReq->hReqIo == pahReqs[i]);
434 RTListAppend(&pFile->AioMgr.ListWaitingReqs, &pReq->NodeWaitingList);
448 PRTAIOMGRREQ pReq = (PRTAIOMGRREQ)RTFileAioReqGetUser(pahReqs[i]);
458 rtAioMgrReqCompleteRc(pThis, pReq, rcReq, 0);
491 * @param pReq The request to prepare.
493 static int rtAioMgrReqPrepareNonBuffered(PRTAIOMGRFILEINT pFile, PRTAIOMGRREQ pReq)
496 RTFOFF offStart = pReq->off & ~(RTFOFF)(512-1);
497 size_t cbToTransfer = RT_ALIGN_Z(pReq->DataSeg.cbSeg + (pReq->off - offStart), 512);
498 void *pvBuf = pReq->DataSeg.pvSeg;
499 bool fAlignedReq = cbToTransfer == pReq->DataSeg.cbSeg
500 && offStart == pReq->off;
511 pReq->cbBounceBuffer = cbToTransfer;
513 AssertMsg(pReq->off >= offStart, ("Overflow in calculation off=%llu offStart=%llu\n",
514 pReq->off, offStart));
515 pReq->offBounceBuffer = pReq->off - offStart;
522 pReq->pvBounceBuffer = RTMemPageAlloc(cbToTransfer);
523 if (RT_LIKELY(pReq->pvBounceBuffer))
525 pvBuf = pReq->pvBounceBuffer;
527 if (pReq->enmType == RTAIOMGRREQTYPE_WRITE)
529 if ( RT_UNLIKELY(cbToTransfer != pReq->DataSeg.cbSeg)
530 || RT_UNLIKELY(offStart != pReq->off))
533 pReq->enmType = RTAIOMGRREQTYPE_WRITE;
536 memcpy(pvBuf, pReq->DataSeg.pvSeg, pReq->DataSeg.cbSeg);
543 pReq->cbBounceBuffer = 0;
547 if (pReq->enmType == RTAIOMGRREQTYPE_WRITE)
549 rc = RTFileAioReqPrepareWrite(pReq->hReqIo, pFile->hFile,
550 offStart, pvBuf, cbToTransfer, pReq);
553 rc = RTFileAioReqPrepareRead(pReq->hReqIo, pFile->hFile,
554 offStart, pvBuf, cbToTransfer, pReq);
556 pReq->fFlags |= RTAIOMGRREQ_FLAGS_PREPARED;
566 * @param pReq The request to prepare.
569 static int rtAioMgrPrepareReq(PRTAIOMGRREQ pReq, PRTFILEAIOREQ phReqIo)
572 PRTAIOMGRFILEINT pFile = pReq->pFile;
574 switch (pReq->enmType)
578 rc = RTFileAioReqPrepareFlush(pReq->hReqIo, pFile->hFile, pReq);
584 rc = rtAioMgrReqPrepareNonBuffered(pFile, pReq);
588 AssertMsgFailed(("Invalid transfer type %d\n", pReq->enmType));
592 *phReqIo = pReq->hReqIo;
1015 static void rtAioMgrFileQueueReq(PRTAIOMGRFILEINT pThis, PRTAIOMGRREQ pReq)
1018 RTQueueAtomicInsert(&pThis->QueueReqs, &pReq->WorkItem);
1057 PRTAIOMGRREQ pReq = rtAioMgrReqAlloc(pAioMgr);
1058 if (RT_LIKELY(pReq))
1061 size_t cbSeg = RTSgBufSegArrayCreate(pSgBuf, &pReq->DataSeg, &cSeg, cbIo);
1065 pReq->enmType = enmType;
1066 pReq->pFile = pFile;
1067 pReq->pvUser = pvUser;
1068 pReq->off = off;
1069 rtAioMgrFileQueueReq(pFile, pReq);
1075 rtAioMgrReqFree(pAioMgr, pReq);
1095 PRTAIOMGRREQ pReq = (PRTAIOMGRREQ)pvObj;
1097 memset(pReq, 0, sizeof(RTAIOMGRREQ));
1098 return RTFileAioReqCreate(&pReq->hReqIo);
1110 PRTAIOMGRREQ pReq = (PRTAIOMGRREQ)pvObj;
1111 int rc = RTFileAioReqDestroy(pReq->hReqIo);
1303 PRTAIOMGRREQ pReq = rtAioMgrReqAlloc(pAioMgr);
1304 if (RT_UNLIKELY(!pReq))
1307 pReq->pFile = pFile;
1308 pReq->enmType = RTAIOMGRREQTYPE_FLUSH;
1309 pReq->pvUser = pvUser;
1310 rtAioMgrFileQueueReq(pFile, pReq);