VirtualBox

Changeset 44233 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jan 4, 2013 8:39:56 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83076
Message:

Storage: Preparations for the sync/async I/O unification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vd-ifs-internal.h

    r38469 r44233  
    210210
    211211    /**
    212      * Synchronous write callback.
    213      *
    214      * @return  VBox status code.
    215      * @param   pvUser          The opaque data passed on container creation.
    216      * @param   pStorage        The storage handle to use.
    217      * @param   uOffset         The offset to start from.
    218      * @param   pvBuffer        Pointer to the bits need to be written.
    219      * @param   cbBuffer        How many bytes to write.
    220      * @param   pcbWritten      Where to store how many bytes were actually written.
    221      *
    222      * @notes Do not use in code called from the async read/write entry points in the backends.
    223      *        This should be only used during open/close of images and for the support functions
    224      *        which are not called while a VM is running (pfnCompact).
    225      */
    226     DECLR3CALLBACKMEMBER(int, pfnWriteSync, (void *pvUser, PVDIOSTORAGE pStorage, uint64_t uOffset,
    227                                              const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten));
    228 
    229     /**
    230      * Synchronous read callback.
    231      *
    232      * @return  VBox status code.
    233      * @param   pvUser          The opaque data passed on container creation.
    234      * @param   pStorage        The storage handle to use.
    235      * @param   uOffset         The offset to start from.
    236      * @param   pvBuffer        Where to store the read bits.
    237      * @param   cbBuffer        How many bytes to read.
    238      * @param   pcbRead         Where to store how many bytes were actually read.
    239      *
    240      * @notes See pfnWriteSync()
    241      */
    242     DECLR3CALLBACKMEMBER(int, pfnReadSync, (void *pvUser, PVDIOSTORAGE pStorage, uint64_t uOffset,
    243                                             void *pvBuffer, size_t cbBuffer, size_t *pcbRead));
    244 
    245     /**
    246      * Flush data to the storage backend.
    247      *
    248      * @return  VBox status code.
    249      * @param   pvUser          The opaque data passed on container creation.
    250      * @param   pStorage        The storage handle to flush.
    251      *
    252      * @notes See pfnWriteSync()
    253      */
    254     DECLR3CALLBACKMEMBER(int, pfnFlushSync, (void *pvUser, PVDIOSTORAGE pStorage));
    255 
    256     /**
    257      * Initiate an asynchronous read request for user data.
     212     * Initiate a read request for user data.
    258213     *
    259214     * @return  VBox status code.
     
    261216     * @param   pStorage       The storage handle.
    262217     * @param   uOffset        The offset to start reading from.
    263      * @param   pIoCtx         I/O context passed in VDAsyncRead/Write.
     218     * @param   pIoCtx         I/O context passed in the read/write callback.
    264219     * @param   cbRead         How many bytes to read.
    265220     */
    266     DECLR3CALLBACKMEMBER(int, pfnReadUserAsync, (void *pvUser, PVDIOSTORAGE pStorage,
    267                                                  uint64_t uOffset, PVDIOCTX pIoCtx,
    268                                                  size_t cbRead));
    269 
    270     /**
    271      * Initiate an asynchronous write request for user data.
     221    DECLR3CALLBACKMEMBER(int, pfnReadUser, (void *pvUser, PVDIOSTORAGE pStorage,
     222                                            uint64_t uOffset, PVDIOCTX pIoCtx,
     223                                            size_t cbRead));
     224
     225    /**
     226     * Initiate a write request for user data.
    272227     *
    273228     * @return  VBox status code.
     
    275230     * @param   pStorage       The storage handle.
    276231     * @param   uOffset        The offset to start writing to.
    277      * @param   pIoCtx         I/O context passed in VDAsyncRead/Write
     232     * @param   pIoCtx         I/O context passed in the read/write callback.
    278233     * @param   cbWrite        How many bytes to write.
    279234     * @param   pfnCompleted   Completion callback.
    280235     * @param   pvCompleteUser Opaque user data passed in the completion callback.
    281236     */
    282     DECLR3CALLBACKMEMBER(int, pfnWriteUserAsync, (void *pvUser, PVDIOSTORAGE pStorage,
    283                                                   uint64_t uOffset, PVDIOCTX pIoCtx,
    284                                                   size_t cbWrite,
    285                                                   PFNVDXFERCOMPLETED pfnComplete,
    286                                                   void *pvCompleteUser));
    287 
    288     /**
    289      * Reads metadata asynchronously from storage.
     237    DECLR3CALLBACKMEMBER(int, pfnWriteUser, (void *pvUser, PVDIOSTORAGE pStorage,
     238                                             uint64_t uOffset, PVDIOCTX pIoCtx,
     239                                             size_t cbWrite,
     240                                             PFNVDXFERCOMPLETED pfnComplete,
     241                                             void *pvCompleteUser));
     242
     243    /**
     244     * Reads metadata from storage.
    290245     * The current I/O context will be halted.
    291246     *
     
    300255     * @param   pfnCompleted   Completion callback.
    301256     * @param   pvCompleteUser Opaque user data passed in the completion callback.
    302      */
    303     DECLR3CALLBACKMEMBER(int, pfnReadMetaAsync, (void *pvUser, PVDIOSTORAGE pStorage,
    304                                                  uint64_t uOffset, void *pvBuffer,
    305                                                  size_t cbBuffer, PVDIOCTX pIoCtx,
    306                                                  PPVDMETAXFER ppMetaXfer,
    307                                                  PFNVDXFERCOMPLETED pfnComplete,
    308                                                  void *pvCompleteUser));
    309 
    310     /**
    311      * Writes metadata asynchronously to storage.
     257     *
     258     * @notes If pIoCtx is NULL the metadata read is handled synchronously
     259     *        i.e. the call returns only if the data is available in the given
     260     *        buffer. ppMetaXfer, pfnCompleted and pvCompleteUser are ignored in that case.
     261     *        Use the synchronous version only when opening/closing the image
     262     *        or when doing certain operations like resizing, compacting or repairing
     263     *        the disk.
     264     */
     265    DECLR3CALLBACKMEMBER(int, pfnReadMeta, (void *pvUser, PVDIOSTORAGE pStorage,
     266                                            uint64_t uOffset, void *pvBuffer,
     267                                            size_t cbBuffer, PVDIOCTX pIoCtx,
     268                                            PPVDMETAXFER ppMetaXfer,
     269                                            PFNVDXFERCOMPLETED pfnComplete,
     270                                            void *pvCompleteUser));
     271
     272    /**
     273     * Writes metadata to storage.
    312274     *
    313275     * @returns VBox status code.
     
    320282     * @param   pfnCompleted   Completion callback.
    321283     * @param   pvCompleteUser Opaque user data passed in the completion callback.
    322      */
    323     DECLR3CALLBACKMEMBER(int, pfnWriteMetaAsync, (void *pvUser, PVDIOSTORAGE pStorage,
    324                                                   uint64_t uOffset, void *pvBuffer,
    325                                                   size_t cbBuffer, PVDIOCTX pIoCtx,
    326                                                   PFNVDXFERCOMPLETED pfnComplete,
    327                                                   void *pvCompleteUser));
     284     *
     285     * @notes See pfnReadMeta().
     286     */
     287    DECLR3CALLBACKMEMBER(int, pfnWriteMeta, (void *pvUser, PVDIOSTORAGE pStorage,
     288                                             uint64_t uOffset, const void *pvBuffer,
     289                                             size_t cbBuffer, PVDIOCTX pIoCtx,
     290                                             PFNVDXFERCOMPLETED pfnComplete,
     291                                             void *pvCompleteUser));
    328292
    329293    /**
     
    338302
    339303    /**
    340      * Initiates an async flush request.
     304     * Initiates a flush request.
    341305     *
    342306     * @return  VBox status code.
     
    346310     * @param   pfnCompleted   Completion callback.
    347311     * @param   pvCompleteUser Opaque user data passed in the completion callback.
    348      */
    349     DECLR3CALLBACKMEMBER(int, pfnFlushAsync, (void *pvUser, PVDIOSTORAGE pStorage,
    350                                               PVDIOCTX pIoCtx,
    351                                               PFNVDXFERCOMPLETED pfnComplete,
    352                                               void *pvCompleteUser));
     312     *
     313     * @notes See pfnReadMeta().
     314     */
     315    DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pvUser, PVDIOSTORAGE pStorage,
     316                                         PVDIOCTX pIoCtx,
     317                                         PFNVDXFERCOMPLETED pfnComplete,
     318                                         void *pvCompleteUser));
    353319
    354320    /**
     
    484450
    485451DECLINLINE(int) vdIfIoIntFileWriteSync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    486                                        uint64_t uOffset, const void *pvBuffer, size_t cbBuffer,
    487                                        size_t *pcbWritten)
    488 {
    489     return pIfIoInt->pfnWriteSync(pIfIoInt->Core.pvUser, pStorage, uOffset,
    490                                   pvBuffer, cbBuffer, pcbWritten);
     452                                       uint64_t uOffset, const void *pvBuffer, size_t cbBuffer)
     453{
     454    return pIfIoInt->pfnWriteMeta(pIfIoInt->Core.pvUser, pStorage,
     455                                  uOffset, pvBuffer, cbBuffer, NULL,
     456                                  NULL, NULL);
    491457}
    492458
    493459DECLINLINE(int) vdIfIoIntFileReadSync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    494                                       uint64_t uOffset, void *pvBuffer, size_t cbBuffer,
    495                                       size_t *pcbRead)
    496 {
    497     return pIfIoInt->pfnReadSync(pIfIoInt->Core.pvUser, pStorage, uOffset,
    498                                  pvBuffer, cbBuffer, pcbRead);
     460                                      uint64_t uOffset, void *pvBuffer, size_t cbBuffer)
     461{
     462    return pIfIoInt->pfnReadMeta(pIfIoInt->Core.pvUser, pStorage,
     463                                 uOffset, pvBuffer, cbBuffer, NULL,
     464                                 NULL, NULL, NULL);
    499465}
    500466
    501467DECLINLINE(int) vdIfIoIntFileFlushSync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage)
    502468{
    503     return pIfIoInt->pfnFlushSync(pIfIoInt->Core.pvUser, pStorage);
    504 }
    505 
    506 DECLINLINE(int) vdIfIoIntFileReadUserAsync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    507                                            uint64_t uOffset, PVDIOCTX pIoCtx, size_t cbRead)
    508 {
    509     return pIfIoInt->pfnReadUserAsync(pIfIoInt->Core.pvUser, pStorage,
    510                                       uOffset, pIoCtx, cbRead);
    511 }
    512 
    513 DECLINLINE(int) vdIfIoIntFileWriteUserAsync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    514                                             uint64_t uOffset, PVDIOCTX pIoCtx, size_t cbWrite,
    515                                             PFNVDXFERCOMPLETED pfnComplete,
    516                                             void *pvCompleteUser)
    517 {
    518     return pIfIoInt->pfnWriteUserAsync(pIfIoInt->Core.pvUser, pStorage,
    519                                        uOffset, pIoCtx, cbWrite, pfnComplete,
    520                                        pvCompleteUser);
    521 }
    522 
    523 DECLINLINE(int) vdIfIoIntFileReadMetaAsync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    524                                            uint64_t uOffset, void *pvBuffer,
    525                                            size_t cbBuffer, PVDIOCTX pIoCtx,
    526                                            PPVDMETAXFER ppMetaXfer,
    527                                            PFNVDXFERCOMPLETED pfnComplete,
    528                                            void *pvCompleteUser)
    529 {
    530     return pIfIoInt->pfnReadMetaAsync(pIfIoInt->Core.pvUser, pStorage,
    531                                       uOffset, pvBuffer, cbBuffer, pIoCtx,
    532                                       ppMetaXfer, pfnComplete, pvCompleteUser);
    533 }
    534 
    535 DECLINLINE(int) vdIfIoIntFileWriteMetaAsync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    536                                             uint64_t uOffset, void *pvBuffer,
    537                                             size_t cbBuffer, PVDIOCTX pIoCtx,
    538                                             PFNVDXFERCOMPLETED pfnComplete,
    539                                             void *pvCompleteUser)
    540 {
    541     return pIfIoInt->pfnWriteMetaAsync(pIfIoInt->Core.pvUser, pStorage,
    542                                        uOffset, pvBuffer, cbBuffer, pIoCtx,
    543                                        pfnComplete, pvCompleteUser);
     469    return pIfIoInt->pfnFlush(pIfIoInt->Core.pvUser, pStorage, NULL, NULL, NULL);
     470}
     471
     472DECLINLINE(int) vdIfIoIntFileReadUser(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
     473                                      uint64_t uOffset, PVDIOCTX pIoCtx, size_t cbRead)
     474{
     475    return pIfIoInt->pfnReadUser(pIfIoInt->Core.pvUser, pStorage,
     476                                 uOffset, pIoCtx, cbRead);
     477}
     478
     479DECLINLINE(int) vdIfIoIntFileWriteUser(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
     480                                       uint64_t uOffset, PVDIOCTX pIoCtx, size_t cbWrite,
     481                                       PFNVDXFERCOMPLETED pfnComplete,
     482                                       void *pvCompleteUser)
     483{
     484    return pIfIoInt->pfnWriteUser(pIfIoInt->Core.pvUser, pStorage,
     485                                  uOffset, pIoCtx, cbWrite, pfnComplete,
     486                                  pvCompleteUser);
     487}
     488
     489DECLINLINE(int) vdIfIoIntFileReadMeta(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
     490                                      uint64_t uOffset, void *pvBuffer,
     491                                      size_t cbBuffer, PVDIOCTX pIoCtx,
     492                                      PPVDMETAXFER ppMetaXfer,
     493                                      PFNVDXFERCOMPLETED pfnComplete,
     494                                      void *pvCompleteUser)
     495{
     496    return pIfIoInt->pfnReadMeta(pIfIoInt->Core.pvUser, pStorage,
     497                                 uOffset, pvBuffer, cbBuffer, pIoCtx,
     498                                 ppMetaXfer, pfnComplete, pvCompleteUser);
     499}
     500
     501DECLINLINE(int) vdIfIoIntFileWriteMeta(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
     502                                       uint64_t uOffset, void *pvBuffer,
     503                                       size_t cbBuffer, PVDIOCTX pIoCtx,
     504                                       PFNVDXFERCOMPLETED pfnComplete,
     505                                       void *pvCompleteUser)
     506{
     507    return pIfIoInt->pfnWriteMeta(pIfIoInt->Core.pvUser, pStorage,
     508                                  uOffset, pvBuffer, cbBuffer, pIoCtx,
     509                                  pfnComplete, pvCompleteUser);
    544510}
    545511
     
    549515}
    550516
    551 DECLINLINE(int) vdIfIoIntFileFlushAsync(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
    552                                         PVDIOCTX pIoCtx, PFNVDXFERCOMPLETED pfnComplete,
    553                                         void *pvCompleteUser)
    554 {
    555     return pIfIoInt->pfnFlushAsync(pIfIoInt->Core.pvUser, pStorage, pIoCtx, pfnComplete,
    556                                    pvCompleteUser);
     517DECLINLINE(int) vdIfIoIntFileFlush(PVDINTERFACEIOINT pIfIoInt, PVDIOSTORAGE pStorage,
     518                                   PVDIOCTX pIoCtx, PFNVDXFERCOMPLETED pfnComplete,
     519                                   void *pvCompleteUser)
     520{
     521    return pIfIoInt->pfnFlush(pIfIoInt->Core.pvUser, pStorage, pIoCtx, pfnComplete,
     522                              pvCompleteUser);
    557523}
    558524
Note: See TracChangeset for help on using the changeset viewer.

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