Changeset 41549 in vbox for trunk/src/VBox/Runtime/common/dvm
- Timestamp:
- Jun 1, 2012 5:29:05 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78314
- Location:
- trunk/src/VBox/Runtime/common/dvm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dvm/dvm.cpp
r40293 r41549 469 469 { 470 470 int rc = VINF_SUCCESS; 471 bool fAllocated = false;472 471 PRTDVMINTERNAL pThis = hVolMgr; 473 472 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); … … 478 477 VERR_INVALID_PARAMETER); 479 478 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) 496 490 { 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) 501 504 { 502 fVolFound = true; 503 if (pVol->pfnQueryBlockStatus) 505 bool fIntersect = pThis->pDvmFmtOps->pfnVolumeIsRangeIntersecting(pVol->hVolFmt, off, 506 cb, &offVol, 507 &cbIntersect); 508 if (fIntersect) 504 509 { 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; 511 532 } 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) 513 538 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; 519 542 } 520 543 } 521 544 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 } 533 547 534 548 return rc; -
trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp
r40949 r41549 343 343 } 344 344 345 static 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 345 359 DECLCALLBACK(uint32_t) rtDvmFmtBsdLblGetValidVolumes(RTDVMFMT hVolMgrFmt) 346 360 { … … 513 527 /* pfnClose */ 514 528 rtDvmFmtBsdLblClose, 529 /* pfnQueryRangeUse */ 530 rtDvmFmtBsdLblQueryRangeUse, 515 531 /* pfnGetValidVolumes */ 516 532 rtDvmFmtBsdLblGetValidVolumes, -
trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp
r40949 r41549 342 342 } 343 343 344 static 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 344 358 static DECLCALLBACK(uint32_t) rtDvmFmtGptGetValidVolumes(RTDVMFMT hVolMgrFmt) 345 359 { … … 531 545 /* pfnClose */ 532 546 rtDvmFmtGptClose, 547 /* pfnQueryRangeUse */ 548 rtDvmFmtGptQueryRangeUse, 533 549 /* pfnGetValidVolumes */ 534 550 rtDvmFmtGptGetValidVolumes, -
trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp
r40298 r41549 212 212 } 213 213 214 static 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 214 229 static DECLCALLBACK(uint32_t) rtDvmFmtMbrGetValidVolumes(RTDVMFMT hVolMgrFmt) 215 230 { … … 399 414 /* pfnClose */ 400 415 rtDvmFmtMbrClose, 416 /* pfnQueryRangeUse */ 417 rtDvmFmtMbrQueryRangeUse, 401 418 /* pfnGetValidVolumes */ 402 419 rtDvmFmtMbrGetValidVolumes, -
trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp
r41094 r41549 93 93 94 94 Assert(pSgBuf->cSegs == 1); 95 Assert(off < 0);96 95 NOREF(fBlocking); 97 96 … … 149 148 150 149 Assert(pSgBuf->cSegs == 1); 151 Assert(off < 0);152 150 NOREF(fBlocking); 153 151
Note:
See TracChangeset
for help on using the changeset viewer.