VirtualBox

Ignore:
Timestamp:
Mar 29, 2010 8:52:56 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59468
Message:

VBoxHDD: First part of the async I/O support

  • The async I/O interface is not presented to the backend directly anymore but goes through a new interface in VBoxHDD doing the request management
  • Implemented everything to make the old coe work again
  • Async I/O completely disabled for now because it is not working atm (the old code for VMDK was removed)
File:
1 edited

Legend:

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

    r27232 r27808  
    4343{
    4444    /** Base image name. */
    45     const char      *pszFilename;
     45    const char       *pszFilename;
    4646#ifndef VBOX_WITH_NEW_IO_CODE
    4747    /** File descriptor. */
    48     RTFILE          File;
     48    RTFILE            File;
    4949#else
    50     /** Opaque storage handle. */
    51     void           *pvStorage;
     50    /** Storage handle. */
     51    PVDIOSTORAGE      pStorage;
     52    /** I/O interface. */
     53    PVDINTERFACE      pInterfaceIO;
     54    /** Async I/O interface callbacks. */
     55    PVDINTERFACEIO    pInterfaceIOCallbacks;
    5256#endif
    5357
     
    5963    /** Opaque data for error callback. */
    6064    PVDINTERFACEERROR pInterfaceErrorCallbacks;
    61 #ifdef VBOX_WITH_NEW_IO_CODE
    62     /** Async I/O interface. */
    63     PVDINTERFACE        pInterfaceAsyncIO;
    64     /** Async I/O interface callbacks. */
    65     PVDINTERFACEASYNCIO pInterfaceAsyncIOCallbacks;
    66 #endif
    6765
    6866    /** Open flags passed by VBoxHD layer. */
    69     unsigned        uOpenFlags;
     67    unsigned          uOpenFlags;
    7068    /** Image flags defined during creation or determined during open. */
    71     unsigned        uImageFlags;
     69    unsigned          uImageFlags;
    7270    /** Total size of the image. */
    73     uint64_t        cbSize;
     71    uint64_t          cbSize;
    7472    /** Physical geometry of this image. */
    75     PDMMEDIAGEOMETRY PCHSGeometry;
     73    PDMMEDIAGEOMETRY  PCHSGeometry;
    7674    /** Logical geometry of this image. */
    77     PDMMEDIAGEOMETRY LCHSGeometry;
     75    PDMMEDIAGEOMETRY  LCHSGeometry;
    7876
    7977} RAWIMAGE, *PRAWIMAGE;
     
    132130    rc = RTFileOpen(&pImage->File, pImage->pszFilename, fOpen);
    133131#else
    134 
    135132    unsigned uOpenFlags = fReadonly ? VD_INTERFACEASYNCIO_OPEN_FLAGS_READONLY : 0;
    136133
     
    138135        uOpenFlags |= VD_INTERFACEASYNCIO_OPEN_FLAGS_CREATE;
    139136
    140     rc = pImage->pInterfaceAsyncIOCallbacks->pfnOpen(pImage->pInterfaceAsyncIO->pvUser,
    141                                                      pImage->pszFilename,
    142                                                      uOpenFlags,
    143                                                      NULL,
    144                                                      pImage->pVDIfsDisk,
    145                                                      &pImage->pvStorage);
     137    rc = pImage->pInterfaceIOCallbacks->pfnOpen(pImage->pInterfaceIO->pvUser,
     138                                                pImage->pszFilename,
     139                                                uOpenFlags,
     140                                                &pImage->pStorage);
    146141#endif
    147142
     
    159154    pImage->File = NIL_RTFILE;
    160155#else
    161     if (pImage->pvStorage)
    162         rc = pImage->pInterfaceAsyncIOCallbacks->pfnClose(pImage->pInterfaceAsyncIO->pvUser,
    163                                                           pImage->pvStorage);
    164 
    165     pImage->pvStorage = NULL;
     156    if (pImage->pStorage)
     157        rc = pImage->pInterfaceIOCallbacks->pfnClose(pImage->pInterfaceIO->pvUser,
     158                                                     pImage->pStorage);
     159
     160    pImage->pStorage = NULL;
    166161#endif
    167162
     
    176171    rc = RTFileFlush(pImage->File);
    177172#else
    178     if (pImage->pvStorage)
    179         rc = pImage->pInterfaceAsyncIOCallbacks->pfnFlushSync(pImage->pInterfaceAsyncIO->pvUser,
    180                                                               pImage->pvStorage);
     173    rc = pImage->pInterfaceIOCallbacks->pfnFlushSync(pImage->pInterfaceIO->pvUser,
     174                                                     pImage->pStorage);
    181175#endif
    182176
     
    191185    rc = RTFileGetSize(pImage->File, pcbSize);
    192186#else
    193     if (pImage->pvStorage)
    194         rc = pImage->pInterfaceAsyncIOCallbacks->pfnGetSize(pImage->pInterfaceAsyncIO->pvUser,
    195                                                             pImage->pvStorage,
    196                                                             pcbSize);
     187    rc = pImage->pInterfaceIOCallbacks->pfnGetSize(pImage->pInterfaceIO->pvUser,
     188                                                   pImage->pStorage,
     189                                                   pcbSize);
    197190#endif
    198191
     
    208201    rc = RTFileSetSize(pImage->File, cbSize);
    209202#else
    210     if (pImage->pvStorage)
    211         rc = pImage->pInterfaceAsyncIOCallbacks->pfnSetSize(pImage->pInterfaceAsyncIO->pvUser,
    212                                                             pImage->pvStorage,
    213                                                             cbSize);
     203    rc = pImage->pInterfaceIOCallbacks->pfnSetSize(pImage->pInterfaceIO->pvUser,
     204                                                   pImage->pStorage,
     205                                                   cbSize);
    214206#endif
    215207
     
    225217    rc = RTFileWriteAt(pImage->File, off, pcvBuf, cbWrite, pcbWritten);
    226218#else
    227     if (pImage->pvStorage)
    228         rc = pImage->pInterfaceAsyncIOCallbacks->pfnWriteSync(pImage->pInterfaceAsyncIO->pvUser,
    229                                                               pImage->pvStorage,
    230                                                               off, cbWrite, pcvBuf,
    231                                                               pcbWritten);
     219    rc = pImage->pInterfaceIOCallbacks->pfnWriteSync(pImage->pInterfaceIO->pvUser,
     220                                                     pImage->pStorage,
     221                                                     off, cbWrite, pcvBuf,
     222                                                     pcbWritten);
    232223#endif
    233224
     
    242233    rc = RTFileReadAt(pImage->File, off, pvBuf, cbRead, pcbRead);
    243234#else
    244     if (pImage->pvStorage)
    245         rc = pImage->pInterfaceAsyncIOCallbacks->pfnReadSync(pImage->pInterfaceAsyncIO->pvUser,
    246                                                              pImage->pvStorage,
    247                                                              off, cbRead, pvBuf,
    248                                                              pcbRead);
     235    rc = pImage->pInterfaceIOCallbacks->pfnReadSync(pImage->pInterfaceIO->pvUser,
     236                                                    pImage->pStorage,
     237                                                    off, cbRead, pvBuf,
     238                                                    pcbRead);
    249239#endif
    250240
     
    257247    return pImage->File != NIL_RTFILE;
    258248#else
    259     return pImage->pvStorage != NULL;
     249    return pImage->pStorage != NULL;
    260250#endif
    261251}
     
    278268
    279269#ifdef VBOX_WITH_NEW_IO_CODE
    280     /* Try to get async I/O interface. */
    281     pImage->pInterfaceAsyncIO = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ASYNCIO);
    282     AssertPtr(pImage->pInterfaceAsyncIO);
    283     pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO);
    284     AssertPtr(pImage->pInterfaceAsyncIOCallbacks);
     270    /* Try to get I/O interface. */
     271    pImage->pInterfaceIO = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_IO);
     272    AssertPtr(pImage->pInterfaceIO);
     273    pImage->pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);
     274    AssertPtr(pImage->pInterfaceIOCallbacks);
    285275#endif
    286276
     
    345335#ifdef VBOX_WITH_NEW_IO_CODE
    346336    /* Try to get async I/O interface. */
    347     pImage->pInterfaceAsyncIO = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ASYNCIO);
    348     AssertPtr(pImage->pInterfaceAsyncIO);
    349     pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO);
    350     AssertPtr(pImage->pInterfaceAsyncIOCallbacks);
     337    pImage->pInterfaceIO = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_IO);
     338    AssertPtr(pImage->pInterfaceIO);
     339    pImage->pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);
     340    AssertPtr(pImage->pInterfaceIOCallbacks);
    351341#endif
    352342
     
    518508    pImage->File = NIL_RTFILE;
    519509#else
    520     pImage->pvStorage = NULL;
     510    pImage->pStorage = NULL;
    521511#endif
    522512    pImage->pVDIfsDisk = pVDIfsDisk;
     
    587577    pImage->File = NIL_RTFILE;
    588578#else
    589     pImage->pvStorage = NULL;
     579    pImage->pStorage = NULL;
    590580#endif
    591581    pImage->pVDIfsDisk = pVDIfsDisk;
     
    12141204
    12151205static int rawAsyncRead(void *pvBackendData, uint64_t uOffset, size_t cbRead,
    1216                         PPDMDATASEG paSeg, unsigned cSeg, void *pvUser)
     1206                        PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
    12171207{
    12181208    int rc = VERR_NOT_IMPLEMENTED;
     
    12221212
    12231213static int rawAsyncWrite(void *pvBackendData, uint64_t uOffset, size_t cbWrite,
    1224                          PPDMDATASEG paSeg, unsigned cSeg, void *pvUser)
     1214                         PVDIOCTX pIoCtx,
     1215                         size_t *pcbWriteProcess, size_t *pcbPreRead,
     1216                         size_t *pcbPostRead, unsigned fWrite)
     1217{
     1218    int rc = VERR_NOT_IMPLEMENTED;
     1219    LogFlowFunc(("returns %Rrc\n", rc));
     1220    return rc;
     1221}
     1222
     1223static int rawAsyncFlush(void *pvBackendData, PVDIOCTX pIoCtx)
    12251224{
    12261225    int rc = VERR_NOT_IMPLEMENTED;
     
    13171316    /* pfnAsyncWrite */
    13181317    rawAsyncWrite,
     1318    /* pfnAsyncFlush */
     1319    rawAsyncFlush,
    13191320    /* pfnComposeLocation */
    13201321    genericFileComposeLocation,
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