VirtualBox

Ignore:
Timestamp:
Jun 1, 2012 5:29:05 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78314
Message:

VFS/Filesystem: Convert the filesystem specific code to the VFS framework and make it work

Location:
trunk/src/VBox/Runtime/common/dvm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dvm/dvm.cpp

    r40293 r41549  
    469469{
    470470    int rc = VINF_SUCCESS;
    471     bool fAllocated = false;
    472471    PRTDVMINTERNAL       pThis = hVolMgr;
    473472    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     
    478477                 VERR_INVALID_PARAMETER);
    479478
    480     while (   cb > 0
    481            && !fAllocated)
    482     {
    483         PRTDVMVOLUMEINTERNAL pVol;
    484         bool fVolFound = false;
    485         uint64_t cbIntersect;
    486         uint64_t offVol;
    487 
    488         /*
    489          * Search through all volumes. It is not possible to
    490          * get all start sectors and sizes of all volumes here
    491          * because volumes can be scattered around the disk for certain formats.
    492          * Linux LVM is one example, extents of logical volumes don't need to be
    493          * contigous on the medium.
    494          */
    495         RTListForEach(&pThis->VolumeList, pVol, RTDVMVOLUMEINTERNAL, VolumeNode)
     479    /* Check whether the range is inuse by the volume manager metadata first. */
     480    rc = pThis->pDvmFmtOps->pfnQueryRangeUse(pThis->hVolMgrFmt, off, cb, pfAllocated);
     481    if (RT_FAILURE(rc))
     482        return rc;
     483
     484    if (!*pfAllocated)
     485    {
     486        bool fAllocated = false;
     487
     488        while (   cb > 0
     489               && !fAllocated)
    496490        {
    497             bool fIntersect = pThis->pDvmFmtOps->pfnVolumeIsRangeIntersecting(pVol->hVolFmt, off,
    498                                                                               cb, &offVol,
    499                                                                               &cbIntersect);
    500             if (fIntersect)
     491            PRTDVMVOLUMEINTERNAL pVol;
     492            bool fVolFound = false;
     493            uint64_t cbIntersect;
     494            uint64_t offVol;
     495
     496            /*
     497             * Search through all volumes. It is not possible to
     498             * get all start sectors and sizes of all volumes here
     499             * because volumes can be scattered around the disk for certain formats.
     500             * Linux LVM is one example, extents of logical volumes don't need to be
     501             * contigous on the medium.
     502             */
     503            RTListForEach(&pThis->VolumeList, pVol, RTDVMVOLUMEINTERNAL, VolumeNode)
    501504            {
    502                 fVolFound = true;
    503                 if (pVol->pfnQueryBlockStatus)
     505                bool fIntersect = pThis->pDvmFmtOps->pfnVolumeIsRangeIntersecting(pVol->hVolFmt, off,
     506                                                                                  cb, &offVol,
     507                                                                                  &cbIntersect);
     508                if (fIntersect)
    504509                {
    505                     bool fVolAllocated = true;
    506 
    507                     rc = pVol->pfnQueryBlockStatus(pVol->pvUser, offVol, cbIntersect,
    508                                                    &fVolAllocated);
    509                     if (RT_FAILURE(rc))
    510                         break;
     510                    fVolFound = true;
     511                    if (pVol->pfnQueryBlockStatus)
     512                    {
     513                        bool fVolAllocated = true;
     514
     515                        rc = pVol->pfnQueryBlockStatus(pVol->pvUser, offVol, cbIntersect,
     516                                                       &fVolAllocated);
     517                        if (RT_FAILURE(rc))
     518                            break;
     519                        else if (fVolAllocated)
     520                        {
     521                            fAllocated = true;
     522                            break;
     523                        }
     524                    }
     525                    else if (!(pThis->fFlags & DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED))
     526                        fAllocated = true;
     527                    /* else, flag is set, continue. */
     528
     529                    cb  -= cbIntersect;
     530                    off += cbIntersect;
     531                    break;
    511532                }
    512                 else if (!(pThis->fFlags & DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED))
     533            }
     534
     535            if (!fVolFound)
     536            {
     537                if (pThis->fFlags & DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED)
    513538                    fAllocated = true;
    514                 /* else, flag is set, continue. */
    515 
    516                 cb  -= cbIntersect;
    517                 off += cbIntersect;
    518                 break;
     539
     540                cb  -= pThis->DvmDisk.cbSector;
     541                off += pThis->DvmDisk.cbSector;
    519542            }
    520543        }
    521544
    522         if (!fVolFound)
    523         {
    524             if (pThis->fFlags & DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED)
    525                 fAllocated = true;
    526 
    527             cb  -= pThis->DvmDisk.cbSector;
    528             off += pThis->DvmDisk.cbSector;
    529         }
    530     }
    531 
    532     *pfAllocated = fAllocated;
     545        *pfAllocated = fAllocated;
     546    }
    533547
    534548    return rc;
  • trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp

    r40949 r41549  
    343343}
    344344
     345static DECLCALLBACK(int) rtDvmFmtBsdLblQueryRangeUse(RTDVMFMT hVolMgrFmt,
     346                                                     uint64_t off, uint64_t cbRange,
     347                                                     bool *pfUsed)
     348{
     349    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
     350
     351    if (off <= RTDVM_BSDLBL_LBA2BYTE(1, pThis->pDisk))
     352        *pfUsed = true;
     353    else
     354        *pfUsed = false;
     355
     356    return VINF_SUCCESS;
     357}
     358
    345359DECLCALLBACK(uint32_t) rtDvmFmtBsdLblGetValidVolumes(RTDVMFMT hVolMgrFmt)
    346360{
     
    513527    /* pfnClose */
    514528    rtDvmFmtBsdLblClose,
     529    /* pfnQueryRangeUse */
     530    rtDvmFmtBsdLblQueryRangeUse,
    515531    /* pfnGetValidVolumes */
    516532    rtDvmFmtBsdLblGetValidVolumes,
  • trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp

    r40949 r41549  
    342342}
    343343
     344static DECLCALLBACK(int) rtDvmFmtGptQueryRangeUse(RTDVMFMT hVolMgrFmt,
     345                                                  uint64_t off, uint64_t cbRange,
     346                                                  bool *pfUsed)
     347{
     348    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
     349
     350    if (off < 33*pThis->pDisk->cbSector)
     351        *pfUsed = true;
     352    else
     353        *pfUsed = false;
     354
     355    return VINF_SUCCESS;
     356}
     357
    344358static DECLCALLBACK(uint32_t) rtDvmFmtGptGetValidVolumes(RTDVMFMT hVolMgrFmt)
    345359{
     
    531545    /* pfnClose */
    532546    rtDvmFmtGptClose,
     547    /* pfnQueryRangeUse */
     548    rtDvmFmtGptQueryRangeUse,
    533549    /* pfnGetValidVolumes */
    534550    rtDvmFmtGptGetValidVolumes,
  • trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp

    r40298 r41549  
    212212}
    213213
     214static DECLCALLBACK(int) rtDvmFmtMbrQueryRangeUse(RTDVMFMT hVolMgrFmt,
     215                                                  uint64_t off, uint64_t cbRange,
     216                                                  bool *pfUsed)
     217{
     218    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
     219
     220    /* MBR uses the first sector only. */
     221    if (off < 512)
     222        *pfUsed = true;
     223    else
     224        *pfUsed = false;
     225
     226    return VINF_SUCCESS;
     227}
     228
    214229static DECLCALLBACK(uint32_t) rtDvmFmtMbrGetValidVolumes(RTDVMFMT hVolMgrFmt)
    215230{
     
    399414    /* pfnClose */
    400415    rtDvmFmtMbrClose,
     416    /* pfnQueryRangeUse */
     417    rtDvmFmtMbrQueryRangeUse,
    401418    /* pfnGetValidVolumes */
    402419    rtDvmFmtMbrGetValidVolumes,
  • trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp

    r41094 r41549  
    9393
    9494    Assert(pSgBuf->cSegs == 1);
    95     Assert(off < 0);
    9695    NOREF(fBlocking);
    9796
     
    149148
    150149    Assert(pSgBuf->cSegs == 1);
    151     Assert(off < 0);
    152150    NOREF(fBlocking);
    153151
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