Changeset 23744 in vbox
- Timestamp:
- Oct 13, 2009 10:48:21 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 53469
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletionFileCache.cpp
r23712 r23744 1311 1311 else 1312 1312 { 1313 AssertMsg(!(pEntry->fFlags & PDMACFILECACHE_ENTRY_IO_IN_PROGRESS),1314 ("Entry is not dirty but in progress\n"));1315 1316 /* Write as much as we can into the entry and update the file.*/1317 while (cbToWrite)1313 /* 1314 * Check if a read is in progress for this entry. 1315 * We have to defer processing in that case. 1316 */ 1317 if (pEntry->fFlags & PDMACFILECACHE_ENTRY_IO_IN_PROGRESS) 1318 1318 { 1319 size_t cbCopy = RT_MIN(cbSegLeft, cbToWrite); 1320 1321 memcpy(pEntry->pbData + OffDiff, pbSegBuf, cbCopy); 1322 1323 ADVANCE_SEGMENT_BUFFER(cbCopy); 1324 1325 cbToWrite-= cbCopy; 1326 off += cbCopy; 1327 OffDiff += cbCopy; 1328 ASMAtomicSubS32(&pTask->cbTransferLeft, cbCopy); 1319 RTSemRWRequestWrite(pEndpointCache->SemRWEntries, RT_INDEFINITE_WAIT); 1320 1321 /* Check again. The completion callback might have raced us. */ 1322 if (pEntry->fFlags & PDMACFILECACHE_ENTRY_IO_IN_PROGRESS) 1323 { 1324 1325 while (cbToWrite) 1326 { 1327 PPDMACFILETASKSEG pSeg = (PPDMACFILETASKSEG)RTMemAllocZ(sizeof(PDMACFILETASKSEG)); 1328 1329 pSeg->pTask = pTask; 1330 pSeg->uBufOffset = OffDiff; 1331 pSeg->cbTransfer = RT_MIN(cbToWrite, cbSegLeft); 1332 pSeg->pvBuf = pbSegBuf; 1333 pSeg->fWrite = true; 1334 1335 ADVANCE_SEGMENT_BUFFER(pSeg->cbTransfer); 1336 1337 pSeg->pNext = pEntry->pHead; 1338 pEntry->pHead = pSeg; 1339 1340 off += pSeg->cbTransfer; 1341 OffDiff += pSeg->cbTransfer; 1342 cbToWrite -= pSeg->cbTransfer; 1343 } 1344 1345 RTSemRWReleaseWrite(pEndpointCache->SemRWEntries); 1346 } 1347 else 1348 { 1349 RTSemRWReleaseWrite(pEndpointCache->SemRWEntries); 1350 1351 /* Write as much as we can into the entry and update the file. */ 1352 while (cbToWrite) 1353 { 1354 size_t cbCopy = RT_MIN(cbSegLeft, cbToWrite); 1355 1356 memcpy(pEntry->pbData + OffDiff, pbSegBuf, cbCopy); 1357 1358 ADVANCE_SEGMENT_BUFFER(cbCopy); 1359 1360 cbToWrite-= cbCopy; 1361 off += cbCopy; 1362 OffDiff += cbCopy; 1363 ASMAtomicSubS32(&pTask->cbTransferLeft, cbCopy); 1364 } 1365 1366 pEntry->fFlags |= PDMACFILECACHE_ENTRY_IS_DIRTY; 1367 pdmacFileCacheWriteToEndpoint(pEntry); 1368 } 1329 1369 } 1330 1331 pEntry->fFlags |= PDMACFILECACHE_ENTRY_IS_DIRTY; 1332 pdmacFileCacheWriteToEndpoint(pEntry); 1370 else 1371 { 1372 /* Write as much as we can into the entry and update the file. */ 1373 while (cbToWrite) 1374 { 1375 size_t cbCopy = RT_MIN(cbSegLeft, cbToWrite); 1376 1377 memcpy(pEntry->pbData + OffDiff, pbSegBuf, cbCopy); 1378 1379 ADVANCE_SEGMENT_BUFFER(cbCopy); 1380 1381 cbToWrite-= cbCopy; 1382 off += cbCopy; 1383 OffDiff += cbCopy; 1384 ASMAtomicSubS32(&pTask->cbTransferLeft, cbCopy); 1385 } 1386 1387 pEntry->fFlags |= PDMACFILECACHE_ENTRY_IS_DIRTY; 1388 pdmacFileCacheWriteToEndpoint(pEntry); 1389 } 1333 1390 } 1334 1391
Note:
See TracChangeset
for help on using the changeset viewer.