儲存庫 vbox 的更動 40292
- 時間撮記:
- 2012-2-29 上午11:29:35 (13 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Runtime/common/vfs/vfsmemory.cpp
r40127 r40292 172 172 if (!pExtent || pExtent->off < off) 173 173 { 174 pExtent = RTListGetFirst(&pThis->ExtentHead, RTVFSMEMEXTENT, Entry); 174 /* Consider the last entry first (for writes). */ 175 pExtent = RTListGetLast(&pThis->ExtentHead, RTVFSMEMEXTENT, Entry); 175 176 if (!pExtent) 176 177 { … … 178 179 return NULL; 179 180 } 181 if (off - pExtent->off < pExtent->cb) 182 { 183 *pfHit = true; 184 pThis->pCurExt = pExtent; 185 return pExtent; 186 } 187 188 /* Otherwise, start from the head. */ 189 pExtent = RTListGetFirst(&pThis->ExtentHead, RTVFSMEMEXTENT, Entry); 180 190 } 181 191 … … 188 198 { 189 199 *pfHit = false; 190 return p Extent;200 return pNext; 191 201 } 192 202 … … 201 211 202 212 /** 203 * Locates the extent covering the specified offset, or the n one beforeit.213 * Locates the extent covering the specified offset, or the one after it. 204 214 * 205 215 * @returns The closest extent. NULL if off is 0 and there are no extent … … 285 295 for (;;) 286 296 { 287 PRTVFSMEMEXTENT pNext; 288 size_t cbThisRead; 289 Assert(!pExtent || pExtent->off <= offUnsigned); 297 size_t cbThisRead; 290 298 291 299 /* 292 * Do we hit an extent covering the thecurrent file surface?300 * Do we hit an extent covering the current file surface? 293 301 */ 294 302 if (fHit) 295 303 { 304 /* Yes, copy the data. */ 305 Assert(offUnsigned - pExtent->off < pExtent->cb); 296 306 size_t const offExtent = (size_t)(offUnsigned - pExtent->off); 297 307 cbThisRead = pExtent->cb - offExtent; … … 307 317 pbDst += cbThisRead; 308 318 309 pNext = RTListGetNext(&pThis->ExtentHead, pExtent, RTVFSMEMEXTENT, Entry); 319 /* Advance, looping immediately if not sparse. */ 320 PRTVFSMEMEXTENT pNext = RTListGetNext(&pThis->ExtentHead, pExtent, RTVFSMEMEXTENT, Entry); 310 321 if ( pNext 311 322 && pNext->off == pExtent->off + pExtent->cb) … … 314 325 continue; 315 326 } 327 328 Assert(!pNext || pNext->off > pExtent->off); 329 pExtent = pNext; 316 330 fHit = false; 317 331 } 332 else 333 Assert(!pExtent || pExtent->off > offUnsigned); 318 334 319 335 /* 320 * No extent of this portion (sparse file) .336 * No extent of this portion (sparse file) - Read zeros. 321 337 */ 322 else if (pExtent) 323 pNext = RTListGetNext(&pThis->ExtentHead, pExtent, RTVFSMEMEXTENT, Entry); 324 else 325 pNext = NULL; 326 Assert(!pNext || pNext->off > pExtent->off); 327 328 if ( !pNext 329 || offUnsigned + cbLeftToRead <= pNext->off) 338 if ( !pExtent 339 || offUnsigned + cbLeftToRead <= pExtent->off) 330 340 cbThisRead = cbLeftToRead; 331 341 else 332 cbThisRead = (size_t)(p Next->off - offUnsigned);342 cbThisRead = (size_t)(pExtent->off - offUnsigned); 333 343 334 344 RT_BZERO(pbDst, cbThisRead); … … 341 351 342 352 /* Go on and read content from the next extent. */ 343 fHit = true; 344 pExtent = pNext; 353 fHit = true; 345 354 } 346 355 } … … 359 368 * @param cbToWrite The number of bytes we're interested in writing 360 369 * starting at @a offUnsigned. 361 * @param pPrev The extention before @a offUnsigned. NULL if 362 * none. 370 * @param pNext The extention after @a offUnsigned. NULL if 371 * none, i.e. we're allocating space at the end of 372 * the file. 363 373 */ 364 374 static PRTVFSMEMEXTENT rtVfsMemFile_AllocExtent(PRTVFSMEMFILE pThis, uint64_t offUnsigned, size_t cbToWrite, 365 PRTVFSMEMEXTENT p Prev)375 PRTVFSMEMEXTENT pNext) 366 376 { 367 377 /* … … 395 405 uint32_t cbExtent = pThis->cbExtent; 396 406 407 PRTVFSMEMEXTENT pPrev = pNext 408 ? RTListGetPrev(&pThis->ExtentHead, pNext, RTVFSMEMEXTENT, Entry) 409 : RTListGetLast(&pThis->ExtentHead, RTVFSMEMEXTENT, Entry); 397 410 uint64_t const offPrev = pPrev ? pPrev->off + pPrev->cb : 0; 398 411 if (offExtent < offPrev) 399 412 offExtent = offPrev; 400 413 401 PRTVFSMEMEXTENT pNext = pPrev402 ? RTListGetNext(&pThis->ExtentHead, pPrev, RTVFSMEMEXTENT, Entry)403 : RTListGetFirst(&pThis->ExtentHead, RTVFSMEMEXTENT, Entry);404 414 if (pNext) 405 415 { … … 462 472 if (!fHit) 463 473 { 464 Assert(!pExtent || offUnsigned < pExtent->off);474 Assert(!pExtent || pExtent->off > offUnsigned); 465 475 466 476 /* Skip leading zeros if there is a whole bunch of them. */ … … 493 503 } 494 504 } 505 Assert(offUnsigned - pExtent->off < pExtent->cb); 495 506 496 507 /*
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器