VirtualBox

Changeset 66058 in vbox


Ignore:
Timestamp:
Mar 13, 2017 11:53:11 AM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/VSCSI: Add possiblity for the LUN to attach opaque data to a VSCSI request for additional book keeping

Location:
trunk/src/VBox/Devices/Storage/VSCSI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIDevice.cpp

    r65111 r66058  
    185185                                       rcReq, pVScsiReq->cbXfer);
    186186
     187    if (pVScsiReq->pvLun)
     188    {
     189        if (vscsiDeviceLunIsPresent(pVScsiDevice, pVScsiReq->iLun))
     190        {
     191            PVSCSILUNINT pVScsiLun = pVScsiDevice->papVScsiLun[pVScsiReq->iLun];
     192            pVScsiLun->pVScsiLunDesc->pfnVScsiLunReqFree(pVScsiLun, pVScsiReq, pVScsiReq->pvLun);
     193        }
     194        else
     195            AssertLogRelMsgFailed(("vscsiDeviceReqComplete: LUN %u for VSCSI request %#p is not present but there is LUN specific data allocated\n",
     196                                   pVScsiReq->iLun, pVScsiReq));
     197
     198        pVScsiReq->pvLun = NULL;
     199    }
     200
    187201    RTMemCacheFree(pVScsiDevice->hCacheReq, pVScsiReq);
    188202}
     
    396410    pVScsiReq->pvVScsiReqUser = pvVScsiReqUser;
    397411    pVScsiReq->cbXfer         = 0;
     412    pVScsiReq->pvLun          = NULL;
    398413    RTSgBufInit(&pVScsiReq->SgBuf, paSGList, cSGListEntries);
    399414
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIInternal.h

    r65111 r66058  
    121121    /** Transfer size determined from the CDB. */
    122122    size_t               cbXfer;
     123    /** Pointer to the opaque data which may be allocated by the LUN
     124     * the request is for. */
     125    void                *pvLun;
    123126} VSCSIREQINT;
    124127
     
    265268
    266269    /**
     270     * Frees additional allocated resources for the given request if it was allocated before.
     271     *
     272     * @returns void.
     273     * @param   pVScsiLun    The SCSI LUN instance.
     274     * @param   pVScsiReq    The SCSI request.
     275     * @param   pvScsiReqLun The opaque data allocated previously.
     276     */
     277    DECLR3CALLBACKMEMBER(void, pfnVScsiLunReqFree, (PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
     278                                                    void *pvScsiReqLun));
     279
     280    /**
    267281     * Informs about a medium being inserted - optional.
    268282     *
     
    424438
    425439/**
     440 * Enqueue a new data transfer request - extended variant.
     441 *
     442 * @returns VBox status code.
     443 * @param   pVScsiLun   The LUN instance which issued the request.
     444 * @param   pVScsiReq   The virtual SCSI request associated with the transfer.
     445 * @param   enmTxDir    Transfer direction.
     446 * @param   uOffset     Start offset of the transfer.
     447 * @param   paSegs      Pointer to the array holding the memory buffer segments.
     448 * @param   cSegs       Number of segments in the array.
     449 * @param   cbTransfer  Number of bytes to transfer.
     450 */
     451int vscsiIoReqTransferEnqueueEx(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
     452                                VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
     453                                PCRTSGSEG paSegs, unsigned cSegs, size_t cbTransfer);
     454
     455/**
    426456 * Enqueue a new unmap request.
    427457 *
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIIoReq.cpp

    r63994 r66058  
    9292
    9393
     94int vscsiIoReqTransferEnqueueEx(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
     95                                VSCSIIOREQTXDIR enmTxDir, uint64_t uOffset,
     96                                PCRTSGSEG paSegs, unsigned cSegs, size_t cbTransfer)
     97{
     98    int rc = VINF_SUCCESS;
     99    PVSCSIIOREQINT pVScsiIoReq = NULL;
     100
     101    LogFlowFunc(("pVScsiLun=%#p pVScsiReq=%#p enmTxDir=%u uOffset=%llu cbTransfer=%u\n",
     102                 pVScsiLun, pVScsiReq, enmTxDir, uOffset, cbTransfer));
     103
     104    rc = vscsiLunReqAlloc(pVScsiLun, (uintptr_t)pVScsiReq, &pVScsiIoReq);
     105    if (RT_SUCCESS(rc))
     106    {
     107        pVScsiIoReq->pVScsiReq       = pVScsiReq;
     108        pVScsiIoReq->pVScsiLun       = pVScsiLun;
     109        pVScsiIoReq->enmTxDir        = enmTxDir;
     110        pVScsiIoReq->u.Io.uOffset    = uOffset;
     111        pVScsiIoReq->u.Io.cbTransfer = cbTransfer;
     112        pVScsiIoReq->u.Io.paSeg      = paSegs;
     113        pVScsiIoReq->u.Io.cSeg       = cSegs;
     114
     115        ASMAtomicIncU32(&pVScsiLun->IoReq.cReqOutstanding);
     116
     117        rc = vscsiLunReqTransferEnqueue(pVScsiLun, pVScsiIoReq);
     118        if (RT_FAILURE(rc))
     119        {
     120            ASMAtomicDecU32(&pVScsiLun->IoReq.cReqOutstanding);
     121            vscsiLunReqFree(pVScsiLun, pVScsiIoReq);
     122        }
     123    }
     124
     125    return rc;
     126}
     127
     128
    94129int vscsiIoReqUnmapEnqueue(PVSCSILUNINT pVScsiLun, PVSCSIREQINT pVScsiReq,
    95130                           PRTRANGE paRanges, unsigned cRanges)
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunMmc.cpp

    r65648 r66058  
    13381338    /** pfnVScsiLunReqProcess */
    13391339    vscsiLunMmcReqProcess,
     1340    /** pfnVScsiLunReqFree */
     1341    NULL,
    13401342    /** pfnVScsiLunMediumInserted */
    13411343    vscsiLunMmcMediumInserted,
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunSbc.cpp

    r65648 r66058  
    616616    /** pfnVScsiLunReqProcess */
    617617    vscsiLunSbcReqProcess,
     618    /** pfnVScsiLunReqFree */
     619    NULL,
    618620    /** pfnVScsiLunMediumInserted */
    619621    NULL,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette