Changeset 63992 in vbox for trunk/src/VBox/Devices/Storage/VSCSI/VSCSIIoReq.cpp
- Timestamp:
- Sep 25, 2016 5:58:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VSCSI/VSCSIIoReq.cpp
r62506 r63992 26 26 #include "VSCSIInternal.h" 27 27 28 int vscsiIoReqInit(PVSCSILUNINT pVScsiLun) 29 { 30 return vscsiLunReqAllocSizeSet(pVScsiLun, sizeof(VSCSIIOREQINT)); 31 } 32 28 33 int vscsiIoReqFlushEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq) 29 34 { … … 31 36 PVSCSIIOREQINT pVScsiIoReq = NULL; 32 37 33 pVScsiIoReq = (PVSCSIIOREQINT)RTMemAllocZ(sizeof(VSCSIIOREQINT));34 if ( !pVScsiIoReq)35 return VERR_NO_MEMORY;36 37 pVScsiIoReq->pVScsiReq = pVScsiReq;38 pVScsiIoReq->pVScsiLun = pVScsiLun;39 pVScsiIoReq->enmTxDir = VSCSIIOREQTXDIR_FLUSH; 40 41 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 42 43 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq);44 if (RT_FAILURE(rc))45 {46 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding);47 RTMemFree(pVScsiIoReq);38 rc = vscsiLunReqAlloc(pVScsiLun, (uint64_t)pVScsiReq, &pVScsiIoReq); 39 if (RT_SUCCESS(rc)) 40 { 41 pVScsiIoReq->pVScsiReq = pVScsiReq; 42 pVScsiIoReq->pVScsiLun = pVScsiLun; 43 pVScsiIoReq->enmTxDir = VSCSIIOREQTXDIR_FLUSH; 44 45 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 46 47 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq); 48 if (RT_FAILURE(rc)) 49 { 50 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding); 51 RTMemFree(pVScsiIoReq); 52 } 48 53 } 49 54 … … 62 67 pVScsiLun, pVScsiReq, enmTxDir, uOffset, cbTransfer)); 63 68 64 pVScsiIoReq = (PVSCSIIOREQINT)RTMemAllocZ(sizeof(VSCSIIOREQINT));65 if ( !pVScsiIoReq)66 return VERR_NO_MEMORY;67 68 pVScsiIoReq->pVScsiReq = pVScsiReq;69 pVScsiIoReq->pVScsiLun = pVScsiLun;70 pVScsiIoReq->enmTxDir = enmTxDir;71 pVScsiIoReq->u.Io.uOffset = uOffset;72 pVScsiIoReq->u.Io.cbTransfer = cbTransfer;73 pVScsiIoReq->u.Io.paSeg = pVScsiReq->SgBuf.paSegs;74 pVScsiIoReq->u.Io.cSeg = pVScsiReq->SgBuf.cSegs; 75 76 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 77 78 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq);79 if (RT_FAILURE(rc))80 {81 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding);82 RTMemFree(pVScsiIoReq);69 rc = vscsiLunReqAlloc(pVScsiLun, (uint64_t)pVScsiReq, &pVScsiIoReq); 70 if (RT_SUCCESS(rc)) 71 { 72 pVScsiIoReq->pVScsiReq = pVScsiReq; 73 pVScsiIoReq->pVScsiLun = pVScsiLun; 74 pVScsiIoReq->enmTxDir = enmTxDir; 75 pVScsiIoReq->u.Io.uOffset = uOffset; 76 pVScsiIoReq->u.Io.cbTransfer = cbTransfer; 77 pVScsiIoReq->u.Io.paSeg = pVScsiReq->SgBuf.paSegs; 78 pVScsiIoReq->u.Io.cSeg = pVScsiReq->SgBuf.cSegs; 79 80 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 81 82 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq); 83 if (RT_FAILURE(rc)) 84 { 85 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding); 86 vscsiLunReqFree(pVScsiLun, pVScsiIoReq); 87 } 83 88 } 84 89 … … 96 101 pVScsiLun, pVScsiReq, paRanges, cRanges)); 97 102 98 pVScsiIoReq = (PVSCSIIOREQINT)RTMemAllocZ(sizeof(VSCSIIOREQINT));99 if ( !pVScsiIoReq)100 return VERR_NO_MEMORY;101 102 pVScsiIoReq->pVScsiReq = pVScsiReq;103 pVScsiIoReq->pVScsiLun = pVScsiLun;104 pVScsiIoReq->enmTxDir = VSCSIIOREQTXDIR_UNMAP;105 pVScsiIoReq->u.Unmap.paRanges = paRanges;106 pVScsiIoReq->u.Unmap.cRanges = cRanges; 107 108 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 109 110 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq);111 if (RT_FAILURE(rc))112 {113 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding);114 RTMemFree(pVScsiIoReq);103 rc = vscsiLunReqAlloc(pVScsiLun, (uint64_t)pVScsiReq, &pVScsiIoReq); 104 if (RT_SUCCESS(rc)) 105 { 106 pVScsiIoReq->pVScsiReq = pVScsiReq; 107 pVScsiIoReq->pVScsiLun = pVScsiLun; 108 pVScsiIoReq->enmTxDir = VSCSIIOREQTXDIR_UNMAP; 109 pVScsiIoReq->u.Unmap.paRanges = paRanges; 110 pVScsiIoReq->u.Unmap.cRanges = cRanges; 111 112 ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding); 113 114 rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq); 115 if (RT_FAILURE(rc)) 116 { 117 ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding); 118 vscsiLunReqFree(pVScsiLun, pVScsiIoReq); 119 } 115 120 } 116 121 … … 163 168 164 169 /* Free the I/O request */ 165 RTMemFree(pVScsiIoReq);170 vscsiLunReqFree(pVScsiLun, pVScsiIoReq); 166 171 167 172 /* Notify completion of the SCSI request. */
Note:
See TracChangeset
for help on using the changeset viewer.