VirtualBox

Ignore:
Timestamp:
Jan 4, 2016 2:13:22 PM (9 years ago)
Author:
vboxsync
Message:

Storage: Get rid of the block driver and merge the the little extra functionality it had into the VD driver. Enables us to get rid of PDMIBLOCK which is basically a subset of PDMIMEDIA and makes changes to the latter interface tedious because it had to be replicated in the former. (bugref:4114)

File:
1 edited

Legend:

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

    r59152 r59248  
    4444 *
    4545 * @implements  PDMISCSICONNECTOR
    46  * @implements  PDMIBLOCKASYNCPORT
     46 * @implements  PDMIMEDIAASYNCPORT
    4747 * @implements  PDMIMOUNTNOTIFY
    4848 */
     
    5555    PPDMIBASE               pDrvBase;
    5656    /** Pointer to the attached driver's block interface. */
    57     PPDMIBLOCK              pDrvBlock;
     57    PPDMIMEDIA              pDrvMedia;
    5858    /** Pointer to the attached driver's async block interface. */
    59     PPDMIBLOCKASYNC         pDrvBlockAsync;
    60     /** Pointer to the attached driver's block bios interface. */
    61     PPDMIBLOCKBIOS          pDrvBlockBios;
     59    PPDMIMEDIAASYNC         pDrvMediaAsync;
    6260    /** Pointer to the attached driver's mount interface. */
    6361    PPDMIMOUNT              pDrvMount;
     
    6866    /** The scsi connector interface .*/
    6967    PDMISCSICONNECTOR       ISCSIConnector;
    70     /** The block port interface. */
    71     PDMIBLOCKPORT           IPort;
    72     /** The optional block async port interface. */
    73     PDMIBLOCKASYNCPORT      IPortAsync;
     68    /** The media port interface. */
     69    PDMIMEDIAPORT           IPort;
     70    /** The optional media async port interface. */
     71    PDMIMEDIAASYNCPORT      IPortAsync;
    7472    /** The mount notify interface. */
    7573    PDMIMOUNTNOTIFY         IMountNotify;
     
    113111#define PDMISCSICONNECTOR_2_DRVSCSI(pInterface)  ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, ISCSIConnector)) )
    114112/** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */
    115 #define PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )
     113#define PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )
    116114/** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */
    117115#define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface)    ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) )
    118116/** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */
    119 #define PDMIBLOCKPORT_2_DRVSCSI(pInterface)      ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )
     117#define PDMIMEDIAPORT_2_DRVSCSI(pInterface)      ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )
    120118
    121119static bool drvscsiIsRedoPossible(int rc)
     
    142140        case VSCSIIOREQTXDIR_FLUSH:
    143141        {
    144             rc = pThis->pDrvBlock->pfnFlush(pThis->pDrvBlock);
     142            rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
    145143            if (   RT_FAILURE(rc)
    146144                && pThis->cErrors++ < MAX_LOG_REL_ERRORS)
     
    171169                {
    172170                    pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
    173                     rc = pThis->pDrvBlock->pfnRead(pThis->pDrvBlock, uOffset,
     171                    rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, uOffset,
    174172                                                    paSeg->pvSeg, cbProcess);
    175173                    pThis->pLed->Actual.s.fReading = 0;
     
    181179                {
    182180                    pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
    183                     rc = pThis->pDrvBlock->pfnWrite(pThis->pDrvBlock, uOffset,
     181                    rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, uOffset,
    184182                                                    paSeg->pvSeg, cbProcess);
    185183                    pThis->pLed->Actual.s.fWriting = 0;
     
    217215
    218216            pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
    219             rc = pThis->pDrvBlock->pfnDiscard(pThis->pDrvBlock, paRanges, cRanges);
     217            rc = pThis->pDrvMedia->pfnDiscard(pThis->pDrvMedia, paRanges, cRanges);
    220218            pThis->pLed->Actual.s.fWriting = 0;
    221219
     
    243241    PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
    244242
    245     *pcbSize = pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock);
     243    *pcbSize = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia);
    246244
    247245    return VINF_SUCCESS;
     
    253251    PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
    254252
    255     *pcbSectorSize = pThis->pDrvBlock->pfnGetSectorSize(pThis->pDrvBlock);
     253    *pcbSectorSize = pThis->pDrvMedia->pfnGetSectorSize(pThis->pDrvMedia);
    256254
    257255    return VINF_SUCCESS;
     
    269267}
    270268
    271 static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMIBLOCKASYNCPORT pInterface, void *pvUser, int rc)
    272 {
    273     PDRVSCSI pThis = PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface);
     269static DECLCALLBACK(int) drvscsiTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rc)
     270{
     271    PDRVSCSI pThis = PDMIMEDIAASYNCPORT_2_DRVSCSI(pInterface);
    274272    VSCSIIOREQ hVScsiIoReq = (VSCSIIOREQ)pvUser;
    275273    VSCSIIOREQTXDIR enmTxDir = VSCSIIoReqTxDirGet(hVScsiIoReq);
     
    332330    PDRVSCSI pThis = (PDRVSCSI)pvScsiLunUser;
    333331
    334     if (pThis->pDrvBlockAsync)
     332    if (pThis->pDrvMediaAsync)
    335333    {
    336334        /* async I/O path. */
     
    345343            case VSCSIIOREQTXDIR_FLUSH:
    346344            {
    347                 rc = pThis->pDrvBlockAsync->pfnStartFlush(pThis->pDrvBlockAsync, hVScsiIoReq);
     345                rc = pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, hVScsiIoReq);
    348346                if (   RT_FAILURE(rc)
    349347                    && rc != VERR_VD_ASYNC_IO_IN_PROGRESS
     
    362360
    363361                pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
    364                 rc = pThis->pDrvBlockAsync->pfnStartDiscard(pThis->pDrvBlockAsync, paRanges, cRanges, hVScsiIoReq);
     362                rc = pThis->pDrvMediaAsync->pfnStartDiscard(pThis->pDrvMediaAsync, paRanges, cRanges, hVScsiIoReq);
    365363                if (   RT_FAILURE(rc)
    366364                    && rc != VERR_VD_ASYNC_IO_IN_PROGRESS
     
    386384                {
    387385                    pThis->pLed->Asserted.s.fReading = pThis->pLed->Actual.s.fReading = 1;
    388                     rc = pThis->pDrvBlockAsync->pfnStartRead(pThis->pDrvBlockAsync, uOffset,
     386                    rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, uOffset,
    389387                                                             paSeg, cSeg, cbTransfer,
    390388                                                             hVScsiIoReq);
     
    394392                {
    395393                    pThis->pLed->Asserted.s.fWriting = pThis->pLed->Actual.s.fWriting = 1;
    396                     rc = pThis->pDrvBlockAsync->pfnStartWrite(pThis->pDrvBlockAsync, uOffset,
     394                    rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, uOffset,
    397395                                                              paSeg, cSeg, cbTransfer,
    398396                                                              hVScsiIoReq);
     
    464462    *pfFeatures = 0;
    465463
    466     if (   pThis->pDrvBlock->pfnDiscard
    467         || (   pThis->pDrvBlockAsync
    468             && pThis->pDrvBlockAsync->pfnStartDiscard))
     464    if (   pThis->pDrvMedia->pfnDiscard
     465        || (   pThis->pDrvMediaAsync
     466            && pThis->pDrvMediaAsync->pfnStartDiscard))
    469467        *pfFeatures |= VSCSI_LUN_FEATURE_UNMAP;
    470468
     
    682680
    683681    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount);
    684     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->pDrvBlockBios);
    685682    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    686683    PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);
    687     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKPORT, &pThis->IPort);
     684    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pThis->IPort);
    688685    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify);
    689     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKASYNCPORT, &pThis->IPortAsync);
     686    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNCPORT, &pThis->IPortAsync);
    690687    return NULL;
    691688}
    692689
    693 static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIBLOCKPORT pInterface, const char **ppcszController,
     690static DECLCALLBACK(int) drvscsiQueryDeviceLocation(PPDMIMEDIAPORT pInterface, const char **ppcszController,
    694691                                                    uint32_t *piInstance, uint32_t *piLUN)
    695692{
    696     PDRVSCSI pThis = PDMIBLOCKPORT_2_DRVSCSI(pInterface);
     693    PDRVSCSI pThis = PDMIMEDIAPORT_2_DRVSCSI(pInterface);
    697694
    698695    return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController,
     
    711708
    712709    /* Ignore the call if we're called while being attached. */
    713     if (!pThis->pDrvBlock)
     710    if (!pThis->pDrvMedia)
    714711        return;
    715712
     
    742739    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    743740
    744     if (!pThis->pDrvBlockAsync)
     741    if (!pThis->pDrvMediaAsync)
    745742    {
    746743        if (pThis->hQueueRequests != NIL_RTREQQUEUE)
     
    790787    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    791788
    792     if (pThis->pDrvBlockAsync)
     789    if (pThis->pDrvMediaAsync)
    793790    {
    794791        if (pThis->StatIoDepth > 0)
     
    833830    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    834831
    835     if (pThis->pDrvBlockAsync)
     832    if (pThis->pDrvMediaAsync)
    836833    {
    837834        if (pThis->StatIoDepth > 0)
     
    967964     * Query the block and blockbios interfaces.
    968965     */
    969     pThis->pDrvBlock = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCK);
    970     if (!pThis->pDrvBlock)
     966    pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIA);
     967    if (!pThis->pDrvMedia)
    971968    {
    972969        AssertMsgFailed(("Configuration error: No block interface!\n"));
    973970        return VERR_PDM_MISSING_INTERFACE;
    974971    }
    975     pThis->pDrvBlockBios = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKBIOS);
    976     if (!pThis->pDrvBlockBios)
    977     {
    978         AssertMsgFailed(("Configuration error: No block BIOS interface!\n"));
    979         return VERR_PDM_MISSING_INTERFACE;
    980     }
    981972
    982973    pThis->pDrvMount = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMOUNT);
    983974
    984975    /* Try to get the optional async block interface. */
    985     pThis->pDrvBlockAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBLOCKASYNC);
    986 
    987     PDMBLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);
     976    pThis->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIMEDIAASYNC);
     977
     978    PDMMEDIATYPE enmType = pThis->pDrvMedia->pfnGetType(pThis->pDrvMedia);
    988979    VSCSILUNTYPE enmLunType;
    989980    switch (enmType)
    990981    {
    991     case PDMBLOCKTYPE_HARD_DISK:
     982    case PDMMEDIATYPE_HARD_DISK:
    992983        enmLunType = VSCSILUNTYPE_SBC;
    993984        break;
    994     case PDMBLOCKTYPE_CDROM:
    995     case PDMBLOCKTYPE_DVD:
     985    case PDMMEDIATYPE_CDROM:
     986    case PDMMEDIATYPE_DVD:
    996987        enmLunType = VSCSILUNTYPE_MMC;
    997988        break;
     
    1001992                                   enmType);
    1002993    }
    1003     if (    (   enmType == PDMBLOCKTYPE_DVD
    1004              || enmType == PDMBLOCKTYPE_CDROM)
     994    if (    (   enmType == PDMMEDIATYPE_DVD
     995             || enmType == PDMMEDIATYPE_CDROM)
    1005996        &&  !pThis->pDrvMount)
    1006997    {
     
    10281019    if (pThis->pDrvMount)
    10291020    {
    1030         if (pThis->pDrvBlock->pfnGetSize(pThis->pDrvBlock))
     1021        if (pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia))
    10311022        {
    10321023            rc = VINF_SUCCESS; VSCSILunMountNotify(pThis->hVScsiLun);
     
    10611052    pThis->StatIoDepth = 0;
    10621053
    1063     if (!pThis->pDrvBlockAsync)
     1054    if (!pThis->pDrvMediaAsync)
    10641055    {
    10651056        /* Create request queue. */
     
    10761067        LogRel(("SCSI#%d: using async I/O\n", pDrvIns->iInstance));
    10771068
    1078     if (   pThis->pDrvBlock->pfnDiscard
    1079         || (   pThis->pDrvBlockAsync
    1080             && pThis->pDrvBlockAsync->pfnStartDiscard))
     1069    if (   pThis->pDrvMedia->pfnDiscard
     1070        || (   pThis->pDrvMediaAsync
     1071            && pThis->pDrvMediaAsync->pfnStartDiscard))
    10811072        LogRel(("SCSI#%d: Enabled UNMAP support\n", pDrvIns->iInstance));
    10821073
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