Index: trunk/include/VBox/vd-cache-plugin.h
===================================================================
--- trunk/include/VBox/vd-cache-plugin.h	(revision 44408)
+++ trunk/include/VBox/vd-cache-plugin.h	(revision 44412)
@@ -132,158 +132,5 @@
 
     /**
-     * Read data from a cache image. The area read never crosses a block
-     * boundary.
-     *
-     * @returns VBox status code.
-     * @returns VERR_VD_BLOCK_FREE if this image contains no data for this block.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   uOffset         Offset to start reading from.
-     * @param   pvBuf           Where to store the read bits.
-     * @param   cbRead          Number of bytes to read.
-     * @param   pcbActuallyRead Pointer to returned number of bytes read.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, void *pvBuf,
-                                        size_t cbRead, size_t *pcbActuallyRead));
-
-    /**
-     * Write data to a cache image. The area written never crosses a block
-     * boundary.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   uOffset         Offset to start writing to.
-     * @param   pvBuf           Where to retrieve the written bits.
-     * @param   cbWrite         Number of bytes to write.
-     * @param   pcbWriteProcess Pointer to returned number of bytes that could
-     *                          be processed.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset,
-                                         const void *pvBuf, size_t cbWrite,
-                                         size_t *pcbWriteProcess));
-
-    /**
-     * Flush data to disk.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData));
-
-    /**
-     * Get the version of a cache image.
-     *
-     * @returns version of cache image.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData));
-
-    /**
-     * Get the capacity of a cache image.
-     *
-     * @returns size of cache image in bytes.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData));
-
-    /**
-     * Get the file size of a cache image.
-     *
-     * @returns size of cache image in bytes.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData));
-
-    /**
-     * Get the image flags of a cache image.
-     *
-     * @returns image flags of cache image.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData));
-
-    /**
-     * Get the open flags of a cache image.
-     *
-     * @returns open flags of cache image.
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData));
-
-    /**
-     * Set the open flags of a cache image. May cause the image to be locked
-     * in a different mode or be reopened (which can fail).
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   uOpenFlags      New open flags for this image.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags));
-
-    /**
-     * Get comment of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pszComment      Where to store the comment.
-     * @param   cbComment       Size of the comment buffer.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment));
-
-    /**
-     * Set comment of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pszComment      Where to get the comment from. NULL resets comment.
-     *                          The comment is silently truncated if the image format
-     *                          limit is exceeded.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment));
-
-    /**
-     * Get UUID of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pUuid           Where to store the image UUID.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid));
-
-    /**
-     * Set UUID of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pUuid           Where to get the image UUID from.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid));
-
-    /**
-     * Get last modification UUID of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pUuid           Where to store the image modification UUID.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid));
-
-    /**
-     * Set last modification UUID of a cache image.
-     *
-     * @returns VBox status code.
-     * @param   pBackendData    Opaque state data for this image.
-     * @param   pUuid           Where to get the image modification UUID from.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid));
-
-    /**
-     * Dump information about a cache image.
-     *
-     * @param   pBackendData    Opaque state data for this image.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData));
-
-    /**
-     * Start an asynchronous read request.
+     * Start a read request.
      *
      * @returns VBox status code.
@@ -294,9 +141,9 @@
      * @param   pcbActuallyRead Pointer to returned number of bytes read.
      */
-    DECLR3CALLBACKMEMBER(int, pfnAsyncRead, (void *pBackendData, uint64_t uOffset, size_t cbRead,
-                                             PVDIOCTX pIoCtx, size_t *pcbActuallyRead));
-
-    /**
-     * Start an asynchronous write request.
+    DECLR3CALLBACKMEMBER(int, pfnRead, (void *pBackendData, uint64_t uOffset, size_t cbRead,
+                                        PVDIOCTX pIoCtx, size_t *pcbActuallyRead));
+
+    /**
+     * Start a write request.
      *
      * @returns VBox status code.
@@ -312,6 +159,6 @@
      *                          amount of (previously read) padding data.
      */
-    DECLR3CALLBACKMEMBER(int, pfnAsyncWrite, (void *pBackendData, uint64_t uOffset, size_t cbWrite,
-                                              PVDIOCTX pIoCtx, size_t *pcbWriteProcess));
+    DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pBackendData, uint64_t uOffset, size_t cbWrite,
+                                         PVDIOCTX pIoCtx, size_t *pcbWriteProcess));
 
     /**
@@ -322,5 +169,138 @@
      * @param   pIoCtx          I/O context associated with this request.
      */
-    DECLR3CALLBACKMEMBER(int, pfnAsyncFlush, (void *pBackendData, PVDIOCTX pIoCtx));
+    DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pBackendData, PVDIOCTX pIoCtx));
+
+    /**
+     * Discards the given amount of bytes from the cache.
+     *
+     * @returns VBox status code.
+     * @retval  VERR_VD_DISCARD_ALIGNMENT_NOT_MET if the range doesn't meet the required alignment
+     *          for the discard.
+     * @param   pBackendData         Opaque state data for this image.
+     * @param   pIoCtx               I/O context associated with this request.
+     * @param   uOffset              The offset of the first byte to discard.
+     * @param   cbDiscard            How many bytes to discard.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnDiscard, (void *pBackendData, PVDIOCTX pIoCtx,
+                                           uint64_t uOffset, size_t cbDiscard,
+                                           size_t *pcbPreAllocated,
+                                           size_t *pcbPostAllocated,
+                                           size_t *pcbActuallyDiscarded,
+                                           void   **ppbmAllocationBitmap,
+                                           unsigned fDiscard));
+
+    /**
+     * Get the version of a cache image.
+     *
+     * @returns version of cache image.
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(unsigned, pfnGetVersion, (void *pBackendData));
+
+    /**
+     * Get the capacity of a cache image.
+     *
+     * @returns size of cache image in bytes.
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize, (void *pBackendData));
+
+    /**
+     * Get the file size of a cache image.
+     *
+     * @returns size of cache image in bytes.
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(uint64_t, pfnGetFileSize, (void *pBackendData));
+
+    /**
+     * Get the image flags of a cache image.
+     *
+     * @returns image flags of cache image.
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(unsigned, pfnGetImageFlags, (void *pBackendData));
+
+    /**
+     * Get the open flags of a cache image.
+     *
+     * @returns open flags of cache image.
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(unsigned, pfnGetOpenFlags, (void *pBackendData));
+
+    /**
+     * Set the open flags of a cache image. May cause the image to be locked
+     * in a different mode or be reopened (which can fail).
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   uOpenFlags      New open flags for this image.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetOpenFlags, (void *pBackendData, unsigned uOpenFlags));
+
+    /**
+     * Get comment of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pszComment      Where to store the comment.
+     * @param   cbComment       Size of the comment buffer.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnGetComment, (void *pBackendData, char *pszComment, size_t cbComment));
+
+    /**
+     * Set comment of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pszComment      Where to get the comment from. NULL resets comment.
+     *                          The comment is silently truncated if the image format
+     *                          limit is exceeded.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetComment, (void *pBackendData, const char *pszComment));
+
+    /**
+     * Get UUID of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pUuid           Where to store the image UUID.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnGetUuid, (void *pBackendData, PRTUUID pUuid));
+
+    /**
+     * Set UUID of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pUuid           Where to get the image UUID from.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetUuid, (void *pBackendData, PCRTUUID pUuid));
+
+    /**
+     * Get last modification UUID of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pUuid           Where to store the image modification UUID.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnGetModificationUuid, (void *pBackendData, PRTUUID pUuid));
+
+    /**
+     * Set last modification UUID of a cache image.
+     *
+     * @returns VBox status code.
+     * @param   pBackendData    Opaque state data for this image.
+     * @param   pUuid           Where to get the image modification UUID from.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetModificationUuid, (void *pBackendData, PCRTUUID pUuid));
+
+    /**
+     * Dump information about a cache image.
+     *
+     * @param   pBackendData    Opaque state data for this image.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnDump, (void *pBackendData));
 
     /** Returns a human readable hard disk location string given a
