VirtualBox

Changeset 44252 in vbox for trunk/src/VBox/Storage/ISCSI.cpp


Ignore:
Timestamp:
Jan 8, 2013 1:23:54 PM (12 years ago)
Author:
vboxsync
Message:

Storage/Backends: async/sync I/O unification, remove separate entries for sync and async I/O callbacks, remove unused code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/ISCSI.cpp

    r44242 r44252  
    46044604}
    46054605
    4606 /** @copydoc VBOXHDDBACKEND::pfnRead */
    4607 static int iscsiRead(void *pBackendData, uint64_t uOffset, void *pvBuf,
    4608                      size_t cbToRead, size_t *pcbActuallyRead)
     4606static int iscsiReadSync(void *pBackendData, uint64_t uOffset, void *pvBuf,
     4607                         size_t cbToRead, size_t *pcbActuallyRead)
    46094608{
    46104609    /** @todo reinstate logging of the target everywhere - dropped temporarily */
     
    47064705}
    47074706
    4708 /** @copydoc VBOXHDDBACKEND::pfnWrite */
    4709 static int iscsiWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf,
    4710                      size_t cbToWrite, size_t *pcbWriteProcess,
    4711                      size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite)
     4707static int iscsiWriteSync(void *pBackendData, uint64_t uOffset, const void *pvBuf,
     4708                          size_t cbToWrite, size_t *pcbWriteProcess,
     4709                          size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite)
    47124710{
    47134711     LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n", pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess, pcbPreRead, pcbPostRead));
     
    48104808}
    48114809
    4812 /** @copydoc VBOXHDDBACKEND::pfnFlush */
    4813 static int iscsiFlush(void *pBackendData)
     4810static int iscsiFlushSync(void *pBackendData)
    48144811{
    48154812    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    48534850}
    48544851
    4855 /** @copydoc VBOXHDDBACKEND::pfnGetVersion */
    4856 static unsigned iscsiGetVersion(void *pBackendData)
    4857 {
    4858     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
    4859     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4860 
    4861     Assert(pImage);
    4862     NOREF(pImage);
    4863 
    4864     return 0;
    4865 }
    4866 
    4867 /** @copydoc VBOXHDDBACKEND::pfnGetSize */
    4868 static uint64_t iscsiGetSize(void *pBackendData)
    4869 {
    4870     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
    4871     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4872 
    4873     Assert(pImage);
    4874 
    4875     if (pImage)
    4876         return pImage->cbSize;
    4877     else
    4878         return 0;
    4879 }
    4880 
    4881 /** @copydoc VBOXHDDBACKEND::pfnGetFileSize */
    4882 static uint64_t iscsiGetFileSize(void *pBackendData)
    4883 {
    4884     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
    4885     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4886 
    4887     Assert(pImage);
    4888     NOREF(pImage);
    4889 
    4890     if (pImage)
    4891         return pImage->cbSize;
    4892     else
    4893         return 0;
    4894 }
    4895 
    4896 /** @copydoc VBOXHDDBACKEND::pfnGetPCHSGeometry */
    4897 static int iscsiGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
    4898 {
    4899     LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry));
    4900     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4901     int rc;
    4902 
    4903     Assert(pImage);
    4904 
    4905     if (pImage)
    4906         rc = VERR_VD_GEOMETRY_NOT_SET;
    4907     else
    4908         rc = VERR_VD_NOT_OPENED;
    4909 
    4910     LogFlowFunc(("returns %Rrc (PCHS=%u/%u/%u)\n", rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
    4911     return rc;
    4912 }
    4913 
    4914 /** @copydoc VBOXHDDBACKEND::pfnSetPCHSGeometry */
    4915 static int iscsiSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
    4916 {
    4917     LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
    4918     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4919     int rc;
    4920 
    4921     Assert(pImage);
    4922 
    4923     if (pImage)
    4924     {
    4925         if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    4926         {
    4927             rc = VERR_VD_IMAGE_READ_ONLY;
    4928             goto out;
    4929         }
    4930         rc = VERR_VD_GEOMETRY_NOT_SET;
    4931     }
    4932     else
    4933         rc = VERR_VD_NOT_OPENED;
    4934 
    4935 out:
    4936     LogFlowFunc(("returns %Rrc\n", rc));
    4937     return rc;
    4938 }
    4939 
    4940 /** @copydoc VBOXHDDBACKEND::pfnGetLCHSGeometry */
    4941 static int iscsiGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
    4942 {
    4943     LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry));
    4944     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4945     int rc;
    4946 
    4947     Assert(pImage);
    4948 
    4949     if (pImage)
    4950         rc = VERR_VD_GEOMETRY_NOT_SET;
    4951     else
    4952         rc = VERR_VD_NOT_OPENED;
    4953 
    4954     LogFlowFunc(("returns %Rrc (LCHS=%u/%u/%u)\n", rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
    4955     return rc;
    4956 }
    4957 
    4958 /** @copydoc VBOXHDDBACKEND::pfnSetLCHSGeometry */
    4959 static int iscsiSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
    4960 {
    4961     LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n", pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
    4962     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4963     int rc;
    4964 
    4965     Assert(pImage);
    4966 
    4967     if (pImage)
    4968     {
    4969         if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    4970         {
    4971             rc = VERR_VD_IMAGE_READ_ONLY;
    4972             goto out;
    4973         }
    4974         rc = VERR_VD_GEOMETRY_NOT_SET;
    4975     }
    4976     else
    4977         rc = VERR_VD_NOT_OPENED;
    4978 
    4979 out:
    4980     LogFlowFunc(("returns %Rrc\n", rc));
    4981     return rc;
    4982 }
    4983 
    4984 /** @copydoc VBOXHDDBACKEND::pfnGetImageFlags */
    4985 static unsigned iscsiGetImageFlags(void *pBackendData)
    4986 {
    4987     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
    4988     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    4989     unsigned uImageFlags;
    4990 
    4991     Assert(pImage);
    4992     NOREF(pImage);
    4993 
    4994     uImageFlags = VD_IMAGE_FLAGS_FIXED;
    4995 
    4996     LogFlowFunc(("returns %#x\n", uImageFlags));
    4997     return uImageFlags;
    4998 }
    4999 
    5000 /** @copydoc VBOXHDDBACKEND::pfnGetOpenFlags */
    5001 static unsigned iscsiGetOpenFlags(void *pBackendData)
    5002 {
    5003     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
    5004     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5005     unsigned uOpenFlags;
    5006 
    5007     Assert(pImage);
    5008 
    5009     if (pImage)
    5010         uOpenFlags = pImage->uOpenFlags;
    5011     else
    5012         uOpenFlags = 0;
    5013 
    5014     LogFlowFunc(("returns %#x\n", uOpenFlags));
    5015     return uOpenFlags;
    5016 }
    5017 
    5018 /** @copydoc VBOXHDDBACKEND::pfnSetOpenFlags */
    5019 static int iscsiSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
    5020 {
    5021     LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags));
    5022     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5023     int rc;
    5024 
    5025     /* Image must be opened and the new flags must be valid. */
    5026     if (!pImage || (uOpenFlags & ~(  VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO
    5027                                    | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE
    5028                                    | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS)))
    5029     {
    5030         rc = VERR_INVALID_PARAMETER;
    5031         goto out;
    5032     }
    5033 
    5034     /* Implement this operation via reopening the image if we actually need
    5035      * to do something. A read/write -> readonly transition doesn't need a
    5036      * reopen. In the other direction we don't have the necessary information
    5037      * as the "disk is readonly" flag is thrown away. Can be optimized too,
    5038      * but it's not worth the effort at the moment. */
    5039     if (   !(uOpenFlags & VD_OPEN_FLAGS_READONLY)
    5040         && (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5041     {
    5042         iscsiFreeImage(pImage, false);
    5043         rc = iscsiOpenImage(pImage, uOpenFlags);
    5044     }
    5045     else
    5046     {
    5047         pImage->uOpenFlags = uOpenFlags;
    5048         rc = VINF_SUCCESS;
    5049     }
    5050 out:
    5051     LogFlowFunc(("returns %Rrc\n", rc));
    5052     return rc;
    5053 }
    5054 
    5055 /** @copydoc VBOXHDDBACKEND::pfnGetComment */
    5056 static int iscsiGetComment(void *pBackendData, char *pszComment,
    5057                           size_t cbComment)
    5058 {
    5059     LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment));
    5060     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5061     int rc;
    5062 
    5063     Assert(pImage);
    5064 
    5065     if (pImage)
    5066         rc = VERR_NOT_SUPPORTED;
    5067     else
    5068         rc = VERR_VD_NOT_OPENED;
    5069 
    5070     LogFlowFunc(("returns %Rrc comment='%s'\n", rc, pszComment));
    5071     return rc;
    5072 }
    5073 
    5074 /** @copydoc VBOXHDDBACKEND::pfnSetComment */
    5075 static int iscsiSetComment(void *pBackendData, const char *pszComment)
    5076 {
    5077     LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
    5078     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5079     int rc;
    5080 
    5081     Assert(pImage);
    5082 
    5083     if (pImage)
    5084     {
    5085         if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5086             rc = VERR_NOT_SUPPORTED;
    5087         else
    5088             rc = VERR_VD_IMAGE_READ_ONLY;
    5089     }
    5090     else
    5091         rc = VERR_VD_NOT_OPENED;
    5092 
    5093     LogFlowFunc(("returns %Rrc\n", rc));
    5094     return rc;
    5095 }
    5096 
    5097 /** @copydoc VBOXHDDBACKEND::pfnGetUuid */
    5098 static int iscsiGetUuid(void *pBackendData, PRTUUID pUuid)
    5099 {
    5100     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
    5101     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5102     int rc;
    5103 
    5104     Assert(pImage);
    5105 
    5106     if (pImage)
    5107         rc = VERR_NOT_SUPPORTED;
    5108     else
    5109         rc = VERR_VD_NOT_OPENED;
    5110 
    5111     LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
    5112     return rc;
    5113 }
    5114 
    5115 /** @copydoc VBOXHDDBACKEND::pfnSetUuid */
    5116 static int iscsiSetUuid(void *pBackendData, PCRTUUID pUuid)
    5117 {
    5118     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
    5119     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5120     int rc;
    5121 
    5122     LogFlowFunc(("%RTuuid\n", pUuid));
    5123     Assert(pImage);
    5124 
    5125     if (pImage)
    5126     {
    5127         if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5128             rc = VERR_NOT_SUPPORTED;
    5129         else
    5130             rc = VERR_VD_IMAGE_READ_ONLY;
    5131     }
    5132     else
    5133         rc = VERR_VD_NOT_OPENED;
    5134 
    5135     LogFlowFunc(("returns %Rrc\n", rc));
    5136     return rc;
    5137 }
    5138 
    5139 /** @copydoc VBOXHDDBACKEND::pfnGetModificationUuid */
    5140 static int iscsiGetModificationUuid(void *pBackendData, PRTUUID pUuid)
    5141 {
    5142     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
    5143     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5144     int rc;
    5145 
    5146     Assert(pImage);
    5147 
    5148     if (pImage)
    5149         rc = VERR_NOT_SUPPORTED;
    5150     else
    5151         rc = VERR_VD_NOT_OPENED;
    5152 
    5153     LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
    5154     return rc;
    5155 }
    5156 
    5157 /** @copydoc VBOXHDDBACKEND::pfnSetModificationUuid */
    5158 static int iscsiSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
    5159 {
    5160     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
    5161     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5162     int rc;
    5163 
    5164     LogFlowFunc(("%RTuuid\n", pUuid));
    5165     Assert(pImage);
    5166 
    5167     if (pImage)
    5168     {
    5169         if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5170             rc = VERR_NOT_SUPPORTED;
    5171         else
    5172             rc = VERR_VD_IMAGE_READ_ONLY;
    5173     }
    5174     else
    5175         rc = VERR_VD_NOT_OPENED;
    5176 
    5177     LogFlowFunc(("returns %Rrc\n", rc));
    5178     return rc;
    5179 }
    5180 
    5181 /** @copydoc VBOXHDDBACKEND::pfnGetParentUuid */
    5182 static int iscsiGetParentUuid(void *pBackendData, PRTUUID pUuid)
    5183 {
    5184     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
    5185     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5186     int rc;
    5187 
    5188     Assert(pImage);
    5189 
    5190     if (pImage)
    5191         rc = VERR_NOT_SUPPORTED;
    5192     else
    5193         rc = VERR_VD_NOT_OPENED;
    5194 
    5195     LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
    5196     return rc;
    5197 }
    5198 
    5199 /** @copydoc VBOXHDDBACKEND::pfnSetParentUuid */
    5200 static int iscsiSetParentUuid(void *pBackendData, PCRTUUID pUuid)
    5201 {
    5202     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
    5203     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5204     int rc;
    5205 
    5206     LogFlowFunc(("%RTuuid\n", pUuid));
    5207     Assert(pImage);
    5208 
    5209     if (pImage)
    5210     {
    5211         if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5212             rc = VERR_NOT_SUPPORTED;
    5213         else
    5214             rc = VERR_VD_IMAGE_READ_ONLY;
    5215     }
    5216     else
    5217         rc = VERR_VD_NOT_OPENED;
    5218 
    5219     LogFlowFunc(("returns %Rrc\n", rc));
    5220     return rc;
    5221 }
    5222 
    5223 /** @copydoc VBOXHDDBACKEND::pfnGetParentModificationUuid */
    5224 static int iscsiGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
    5225 {
    5226     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
    5227     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5228     int rc;
    5229 
    5230     Assert(pImage);
    5231 
    5232     if (pImage)
    5233         rc = VERR_NOT_SUPPORTED;
    5234     else
    5235         rc = VERR_VD_NOT_OPENED;
    5236 
    5237     LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
    5238     return rc;
    5239 }
    5240 
    5241 /** @copydoc VBOXHDDBACKEND::pfnSetParentModificationUuid */
    5242 static int iscsiSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
    5243 {
    5244     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
    5245     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5246     int rc;
    5247 
    5248     LogFlowFunc(("%RTuuid\n", pUuid));
    5249     Assert(pImage);
    5250 
    5251     if (pImage)
    5252     {
    5253         if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    5254             rc = VERR_NOT_SUPPORTED;
    5255         else
    5256             rc = VERR_VD_IMAGE_READ_ONLY;
    5257     }
    5258     else
    5259         rc = VERR_VD_NOT_OPENED;
    5260 
    5261     LogFlowFunc(("returns %Rrc\n", rc));
    5262     return rc;
    5263 }
    5264 
    5265 /** @copydoc VBOXHDDBACKEND::pfnDump */
    5266 static void iscsiDump(void *pBackendData)
    5267 {
    5268     PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
    5269 
    5270     Assert(pImage);
    5271     if (pImage)
    5272     {
    5273         /** @todo put something useful here */
    5274         vdIfErrorMessage(pImage->pIfError, "Header: cVolume=%u\n", pImage->cVolume);
    5275     }
    5276 }
    5277 
    5278 /** @copydoc VBOXHDDBACKEND::pfnAsyncRead */
    5279 static int iscsiAsyncRead(void *pBackendData, uint64_t uOffset, size_t cbToRead,
    5280                           PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
     4852/** @copydoc VBOXHDDBACKEND::pfnRead */
     4853static int iscsiRead(void *pBackendData, uint64_t uOffset, size_t cbToRead,
     4854                     PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
    52814855{
    52824856    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     
    53064880        Assert(cbSegs == cbToRead);
    53074881
    5308         return iscsiRead(pBackendData, uOffset, Segment.pvSeg, cbToRead, pcbActuallyRead);
     4882        return iscsiReadSync(pBackendData, uOffset, Segment.pvSeg, cbToRead, pcbActuallyRead);
    53094883    }
    53104884
     
    54124986
    54134987/** @copydoc VBOXHDDBACKEND::pfnAsyncWrite */
    5414 static int iscsiAsyncWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
    5415                            PVDIOCTX pIoCtx,
    5416                            size_t *pcbWriteProcess, size_t *pcbPreRead,
    5417                            size_t *pcbPostRead, unsigned fWrite)
     4988static int iscsiWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
     4989                      PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead,
     4990                      size_t *pcbPostRead, unsigned fWrite)
    54184991{
    54194992    LogFlowFunc(("pBackendData=%p uOffset=%llu pIoCtx=%#p cbToWrite=%u pcbWriteProcess=%p pcbPreRead=%p pcbPostRead=%p fWrite=%u\n",
     
    54345007    cbToWrite = RT_MIN(cbToWrite, pImage->cbSendDataLength);
    54355008
    5436     /** @todo: Remove iscsiWrite and integrate properly. */
     5009    /** @todo: Remove iscsiWriteSync and integrate properly. */
    54375010    if (vdIfIoIntIoCtxIsSynchronous(pImage->pIfIo, pIoCtx))
    54385011    {
     
    54455018        Assert(cbSegs == cbToWrite);
    54465019
    5447         return iscsiWrite(pBackendData, uOffset, Segment.pvSeg, cbToWrite,
    5448                           pcbWriteProcess, pcbPreRead, pcbPostRead, fWrite);
     5020        return iscsiWriteSync(pBackendData, uOffset, Segment.pvSeg, cbToWrite,
     5021                              pcbWriteProcess, pcbPreRead, pcbPostRead, fWrite);
    54495022    }
    54505023
     
    55515124}
    55525125
    5553 /** @copydoc VBOXHDDBACKEND::pfnAsyncFlush */
    5554 static int iscsiAsyncFlush(void *pBackendData, PVDIOCTX pIoCtx)
     5126/** @copydoc VBOXHDDBACKEND::pfnFlush */
     5127static int iscsiFlush(void *pBackendData, PVDIOCTX pIoCtx)
    55555128{
    55565129    LogFlowFunc(("pBackendData=%p pIoCtx=%#p\n", pBackendData, pIoCtx));
     
    55585131    int rc = VINF_SUCCESS;
    55595132
    5560     /** @todo: Remove iscsiFlush and integrate properly. */
     5133    /** @todo: Remove iscsiFlushSync and integrate properly. */
    55615134    if (vdIfIoIntIoCtxIsSynchronous(pImage->pIfIo, pIoCtx))
    5562         return iscsiFlush(pBackendData);
     5135        return iscsiFlushSync(pBackendData);
    55635136
    55645137    PSCSIREQASYNC pReqAsync = (PSCSIREQASYNC)RTMemAllocZ(sizeof(SCSIREQASYNC));
     
    56165189    LogFlowFunc(("returns rc=%Rrc\n", rc));
    56175190    return rc;
     5191}
     5192
     5193/** @copydoc VBOXHDDBACKEND::pfnGetVersion */
     5194static unsigned iscsiGetVersion(void *pBackendData)
     5195{
     5196    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5197    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5198
     5199    Assert(pImage);
     5200    NOREF(pImage);
     5201
     5202    return 0;
     5203}
     5204
     5205/** @copydoc VBOXHDDBACKEND::pfnGetSize */
     5206static uint64_t iscsiGetSize(void *pBackendData)
     5207{
     5208    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5209    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5210
     5211    Assert(pImage);
     5212
     5213    if (pImage)
     5214        return pImage->cbSize;
     5215    else
     5216        return 0;
     5217}
     5218
     5219/** @copydoc VBOXHDDBACKEND::pfnGetFileSize */
     5220static uint64_t iscsiGetFileSize(void *pBackendData)
     5221{
     5222    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5223    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5224
     5225    Assert(pImage);
     5226    NOREF(pImage);
     5227
     5228    if (pImage)
     5229        return pImage->cbSize;
     5230    else
     5231        return 0;
     5232}
     5233
     5234/** @copydoc VBOXHDDBACKEND::pfnGetPCHSGeometry */
     5235static int iscsiGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
     5236{
     5237    LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry));
     5238    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5239    int rc;
     5240
     5241    Assert(pImage);
     5242
     5243    if (pImage)
     5244        rc = VERR_VD_GEOMETRY_NOT_SET;
     5245    else
     5246        rc = VERR_VD_NOT_OPENED;
     5247
     5248    LogFlowFunc(("returns %Rrc (PCHS=%u/%u/%u)\n", rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
     5249    return rc;
     5250}
     5251
     5252/** @copydoc VBOXHDDBACKEND::pfnSetPCHSGeometry */
     5253static int iscsiSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
     5254{
     5255    LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
     5256    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5257    int rc;
     5258
     5259    Assert(pImage);
     5260
     5261    if (pImage)
     5262    {
     5263        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
     5264        {
     5265            rc = VERR_VD_IMAGE_READ_ONLY;
     5266            goto out;
     5267        }
     5268        rc = VERR_VD_GEOMETRY_NOT_SET;
     5269    }
     5270    else
     5271        rc = VERR_VD_NOT_OPENED;
     5272
     5273out:
     5274    LogFlowFunc(("returns %Rrc\n", rc));
     5275    return rc;
     5276}
     5277
     5278/** @copydoc VBOXHDDBACKEND::pfnGetLCHSGeometry */
     5279static int iscsiGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
     5280{
     5281    LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry));
     5282    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5283    int rc;
     5284
     5285    Assert(pImage);
     5286
     5287    if (pImage)
     5288        rc = VERR_VD_GEOMETRY_NOT_SET;
     5289    else
     5290        rc = VERR_VD_NOT_OPENED;
     5291
     5292    LogFlowFunc(("returns %Rrc (LCHS=%u/%u/%u)\n", rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
     5293    return rc;
     5294}
     5295
     5296/** @copydoc VBOXHDDBACKEND::pfnSetLCHSGeometry */
     5297static int iscsiSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
     5298{
     5299    LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n", pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
     5300    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5301    int rc;
     5302
     5303    Assert(pImage);
     5304
     5305    if (pImage)
     5306    {
     5307        if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
     5308        {
     5309            rc = VERR_VD_IMAGE_READ_ONLY;
     5310            goto out;
     5311        }
     5312        rc = VERR_VD_GEOMETRY_NOT_SET;
     5313    }
     5314    else
     5315        rc = VERR_VD_NOT_OPENED;
     5316
     5317out:
     5318    LogFlowFunc(("returns %Rrc\n", rc));
     5319    return rc;
     5320}
     5321
     5322/** @copydoc VBOXHDDBACKEND::pfnGetImageFlags */
     5323static unsigned iscsiGetImageFlags(void *pBackendData)
     5324{
     5325    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5326    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5327    unsigned uImageFlags;
     5328
     5329    Assert(pImage);
     5330    NOREF(pImage);
     5331
     5332    uImageFlags = VD_IMAGE_FLAGS_FIXED;
     5333
     5334    LogFlowFunc(("returns %#x\n", uImageFlags));
     5335    return uImageFlags;
     5336}
     5337
     5338/** @copydoc VBOXHDDBACKEND::pfnGetOpenFlags */
     5339static unsigned iscsiGetOpenFlags(void *pBackendData)
     5340{
     5341    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     5342    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5343    unsigned uOpenFlags;
     5344
     5345    Assert(pImage);
     5346
     5347    if (pImage)
     5348        uOpenFlags = pImage->uOpenFlags;
     5349    else
     5350        uOpenFlags = 0;
     5351
     5352    LogFlowFunc(("returns %#x\n", uOpenFlags));
     5353    return uOpenFlags;
     5354}
     5355
     5356/** @copydoc VBOXHDDBACKEND::pfnSetOpenFlags */
     5357static int iscsiSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
     5358{
     5359    LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags));
     5360    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5361    int rc;
     5362
     5363    /* Image must be opened and the new flags must be valid. */
     5364    if (!pImage || (uOpenFlags & ~(  VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO
     5365                                   | VD_OPEN_FLAGS_ASYNC_IO | VD_OPEN_FLAGS_SHAREABLE
     5366                                   | VD_OPEN_FLAGS_SEQUENTIAL | VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS)))
     5367    {
     5368        rc = VERR_INVALID_PARAMETER;
     5369        goto out;
     5370    }
     5371
     5372    /* Implement this operation via reopening the image if we actually need
     5373     * to do something. A read/write -> readonly transition doesn't need a
     5374     * reopen. In the other direction we don't have the necessary information
     5375     * as the "disk is readonly" flag is thrown away. Can be optimized too,
     5376     * but it's not worth the effort at the moment. */
     5377    if (   !(uOpenFlags & VD_OPEN_FLAGS_READONLY)
     5378        && (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5379    {
     5380        iscsiFreeImage(pImage, false);
     5381        rc = iscsiOpenImage(pImage, uOpenFlags);
     5382    }
     5383    else
     5384    {
     5385        pImage->uOpenFlags = uOpenFlags;
     5386        rc = VINF_SUCCESS;
     5387    }
     5388out:
     5389    LogFlowFunc(("returns %Rrc\n", rc));
     5390    return rc;
     5391}
     5392
     5393/** @copydoc VBOXHDDBACKEND::pfnGetComment */
     5394static int iscsiGetComment(void *pBackendData, char *pszComment,
     5395                          size_t cbComment)
     5396{
     5397    LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment));
     5398    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5399    int rc;
     5400
     5401    Assert(pImage);
     5402
     5403    if (pImage)
     5404        rc = VERR_NOT_SUPPORTED;
     5405    else
     5406        rc = VERR_VD_NOT_OPENED;
     5407
     5408    LogFlowFunc(("returns %Rrc comment='%s'\n", rc, pszComment));
     5409    return rc;
     5410}
     5411
     5412/** @copydoc VBOXHDDBACKEND::pfnSetComment */
     5413static int iscsiSetComment(void *pBackendData, const char *pszComment)
     5414{
     5415    LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
     5416    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5417    int rc;
     5418
     5419    Assert(pImage);
     5420
     5421    if (pImage)
     5422    {
     5423        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5424            rc = VERR_NOT_SUPPORTED;
     5425        else
     5426            rc = VERR_VD_IMAGE_READ_ONLY;
     5427    }
     5428    else
     5429        rc = VERR_VD_NOT_OPENED;
     5430
     5431    LogFlowFunc(("returns %Rrc\n", rc));
     5432    return rc;
     5433}
     5434
     5435/** @copydoc VBOXHDDBACKEND::pfnGetUuid */
     5436static int iscsiGetUuid(void *pBackendData, PRTUUID pUuid)
     5437{
     5438    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     5439    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5440    int rc;
     5441
     5442    Assert(pImage);
     5443
     5444    if (pImage)
     5445        rc = VERR_NOT_SUPPORTED;
     5446    else
     5447        rc = VERR_VD_NOT_OPENED;
     5448
     5449    LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
     5450    return rc;
     5451}
     5452
     5453/** @copydoc VBOXHDDBACKEND::pfnSetUuid */
     5454static int iscsiSetUuid(void *pBackendData, PCRTUUID pUuid)
     5455{
     5456    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     5457    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5458    int rc;
     5459
     5460    LogFlowFunc(("%RTuuid\n", pUuid));
     5461    Assert(pImage);
     5462
     5463    if (pImage)
     5464    {
     5465        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5466            rc = VERR_NOT_SUPPORTED;
     5467        else
     5468            rc = VERR_VD_IMAGE_READ_ONLY;
     5469    }
     5470    else
     5471        rc = VERR_VD_NOT_OPENED;
     5472
     5473    LogFlowFunc(("returns %Rrc\n", rc));
     5474    return rc;
     5475}
     5476
     5477/** @copydoc VBOXHDDBACKEND::pfnGetModificationUuid */
     5478static int iscsiGetModificationUuid(void *pBackendData, PRTUUID pUuid)
     5479{
     5480    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     5481    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5482    int rc;
     5483
     5484    Assert(pImage);
     5485
     5486    if (pImage)
     5487        rc = VERR_NOT_SUPPORTED;
     5488    else
     5489        rc = VERR_VD_NOT_OPENED;
     5490
     5491    LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
     5492    return rc;
     5493}
     5494
     5495/** @copydoc VBOXHDDBACKEND::pfnSetModificationUuid */
     5496static int iscsiSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
     5497{
     5498    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     5499    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5500    int rc;
     5501
     5502    LogFlowFunc(("%RTuuid\n", pUuid));
     5503    Assert(pImage);
     5504
     5505    if (pImage)
     5506    {
     5507        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5508            rc = VERR_NOT_SUPPORTED;
     5509        else
     5510            rc = VERR_VD_IMAGE_READ_ONLY;
     5511    }
     5512    else
     5513        rc = VERR_VD_NOT_OPENED;
     5514
     5515    LogFlowFunc(("returns %Rrc\n", rc));
     5516    return rc;
     5517}
     5518
     5519/** @copydoc VBOXHDDBACKEND::pfnGetParentUuid */
     5520static int iscsiGetParentUuid(void *pBackendData, PRTUUID pUuid)
     5521{
     5522    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     5523    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5524    int rc;
     5525
     5526    Assert(pImage);
     5527
     5528    if (pImage)
     5529        rc = VERR_NOT_SUPPORTED;
     5530    else
     5531        rc = VERR_VD_NOT_OPENED;
     5532
     5533    LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
     5534    return rc;
     5535}
     5536
     5537/** @copydoc VBOXHDDBACKEND::pfnSetParentUuid */
     5538static int iscsiSetParentUuid(void *pBackendData, PCRTUUID pUuid)
     5539{
     5540    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     5541    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5542    int rc;
     5543
     5544    LogFlowFunc(("%RTuuid\n", pUuid));
     5545    Assert(pImage);
     5546
     5547    if (pImage)
     5548    {
     5549        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5550            rc = VERR_NOT_SUPPORTED;
     5551        else
     5552            rc = VERR_VD_IMAGE_READ_ONLY;
     5553    }
     5554    else
     5555        rc = VERR_VD_NOT_OPENED;
     5556
     5557    LogFlowFunc(("returns %Rrc\n", rc));
     5558    return rc;
     5559}
     5560
     5561/** @copydoc VBOXHDDBACKEND::pfnGetParentModificationUuid */
     5562static int iscsiGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
     5563{
     5564    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     5565    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5566    int rc;
     5567
     5568    Assert(pImage);
     5569
     5570    if (pImage)
     5571        rc = VERR_NOT_SUPPORTED;
     5572    else
     5573        rc = VERR_VD_NOT_OPENED;
     5574
     5575    LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
     5576    return rc;
     5577}
     5578
     5579/** @copydoc VBOXHDDBACKEND::pfnSetParentModificationUuid */
     5580static int iscsiSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
     5581{
     5582    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     5583    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5584    int rc;
     5585
     5586    LogFlowFunc(("%RTuuid\n", pUuid));
     5587    Assert(pImage);
     5588
     5589    if (pImage)
     5590    {
     5591        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     5592            rc = VERR_NOT_SUPPORTED;
     5593        else
     5594            rc = VERR_VD_IMAGE_READ_ONLY;
     5595    }
     5596    else
     5597        rc = VERR_VD_NOT_OPENED;
     5598
     5599    LogFlowFunc(("returns %Rrc\n", rc));
     5600    return rc;
     5601}
     5602
     5603/** @copydoc VBOXHDDBACKEND::pfnDump */
     5604static void iscsiDump(void *pBackendData)
     5605{
     5606    PISCSIIMAGE pImage = (PISCSIIMAGE)pBackendData;
     5607
     5608    Assert(pImage);
     5609    if (pImage)
     5610    {
     5611        /** @todo put something useful here */
     5612        vdIfErrorMessage(pImage->pIfError, "Header: cVolume=%u\n", pImage->cVolume);
     5613    }
    56185614}
    56195615
     
    57055701    /* pfnFlush */
    57065702    iscsiFlush,
     5703    /* pfnDiscard */
     5704    NULL,
    57075705    /* pfnGetVersion */
    57085706    iscsiGetVersion,
     
    57575755    /* pfnSetParentFilename */
    57585756    NULL,
    5759     /* pfnAsyncRead */
    5760     iscsiAsyncRead,
    5761     /* pfnAsyncWrite */
    5762     iscsiAsyncWrite,
    5763     /* pfnAsyncFlush */
    5764     iscsiAsyncFlush,
    57655757    /* pfnComposeLocation */
    57665758    iscsiComposeLocation,
     
    57715763    /* pfnResize */
    57725764    NULL,
    5773     /* pfnDiscard */
    5774     NULL,
    5775     /* pfnAsyncDiscard */
    5776     NULL,
    57775765    /* pfnRepair */
    57785766    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