~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/Storage/VD.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2618
2618
                if (   rc == VINF_VD_ASYNC_IO_FINISHED
2619
2619
                    && ASMAtomicCmpXchgBool(&pIoCtxParent->fComplete, true, false))
2620
2620
                {
 
2621
                    RTCritSectLeave(&pDisk->CritSect);
2621
2622
                    LogFlowFunc(("Parent I/O context completed pIoCtxParent=%#p rcReq=%Rrc\n", pIoCtxParent, pIoCtxParent->rcReq));
2622
2623
                    pIoCtxParent->Type.Root.pfnComplete(pIoCtxParent->Type.Root.pvUser1,
2623
2624
                                                        pIoCtxParent->Type.Root.pvUser2,
2624
2625
                                                        pIoCtxParent->rcReq);
2625
2626
                    vdThreadFinishWrite(pDisk);
2626
2627
                    vdIoCtxFree(pDisk, pIoCtxParent);
 
2628
                    RTCritSectEnter(&pDisk->CritSect);
2627
2629
                }
2628
2630
 
2629
2631
                /* Process any pending writes if the current request didn't caused another growing. */
2664
2666
                        if (   rc == VINF_VD_ASYNC_IO_FINISHED
2665
2667
                            && ASMAtomicCmpXchgBool(&pIoCtxWait->fComplete, true, false))
2666
2668
                        {
 
2669
                            RTCritSectLeave(&pDisk->CritSect);
2667
2670
                            LogFlowFunc(("Waiting I/O context completed pIoCtxWait=%#p\n", pIoCtxWait));
2668
2671
                            vdThreadFinishWrite(pDisk);
2669
2672
                            pIoCtxWait->Type.Root.pfnComplete(pIoCtxWait->Type.Root.pvUser1,
2670
2673
                                                              pIoCtxWait->Type.Root.pvUser2,
2671
2674
                                                              pIoCtxWait->rcReq);
2672
2675
                            vdIoCtxFree(pDisk, pIoCtxWait);
 
2676
                            RTCritSectEnter(&pDisk->CritSect);
2673
2677
                        }
2674
2678
                    } while (!RTListIsEmpty(&ListTmp));
2675
2679
                }
2692
2696
                }
2693
2697
 
2694
2698
                LogFlowFunc(("I/O context completed pIoCtx=%#p rcReq=%Rrc\n", pIoCtx, pIoCtx->rcReq));
 
2699
                RTCritSectLeave(&pDisk->CritSect);
2695
2700
                pIoCtx->Type.Root.pfnComplete(pIoCtx->Type.Root.pvUser1,
2696
2701
                                              pIoCtx->Type.Root.pvUser2,
2697
2702
                                              pIoCtx->rcReq);
 
2703
                RTCritSectEnter(&pDisk->CritSect);
2698
2704
            }
2699
2705
 
2700
2706
            vdIoCtxFree(pDisk, pIoCtx);
2718
2724
    LogFlowFunc(("pIoStorage=%#p pIoCtx=%#p pfnComplete=%#p pvUser=%#p cbTransfer=%zu rcReq=%Rrc\n",
2719
2725
                 pIoStorage, pIoCtx, pfnComplete, pvUser, cbTransfer, rcReq));
2720
2726
 
 
2727
    RTCritSectEnter(&pDisk->CritSect);
2721
2728
    Assert(pIoCtx->cbTransferLeft >= cbTransfer);
2722
2729
    ASMAtomicSubU32(&pIoCtx->cbTransferLeft, cbTransfer);
2723
2730
    ASMAtomicDecU32(&pIoCtx->cDataTransfersPending);
2724
2731
 
2725
2732
    if (pfnComplete)
2726
 
    {
2727
 
        RTCritSectEnter(&pDisk->CritSect);
2728
2733
        rc = pfnComplete(pIoStorage->pVDIo->pBackendData, pIoCtx, pvUser, rcReq);
2729
 
        RTCritSectLeave(&pDisk->CritSect);
2730
 
    }
2731
2734
 
2732
2735
    if (RT_SUCCESS(rc))
2733
2736
        rc = vdIoCtxContinue(pIoCtx, rcReq);
2734
2737
    else if (rc == VERR_VD_ASYNC_IO_IN_PROGRESS)
2735
2738
        rc = VINF_SUCCESS;
2736
2739
 
 
2740
    RTCritSectLeave(&pDisk->CritSect);
 
2741
 
2737
2742
    return rc;
2738
2743
}
2739
2744
 
2774
2779
    }
2775
2780
    else
2776
2781
        RTListMove(&ListIoCtxWaiting, &pMetaXfer->ListIoCtxWaiting);
2777
 
    RTCritSectLeave(&pDisk->CritSect);
2778
2782
 
2779
2783
    /* Go through the waiting list and continue the I/O contexts. */
2780
2784
    while (!RTListIsEmpty(&ListIoCtxWaiting))
2789
2793
        ASMAtomicDecU32(&pIoCtx->cMetaTransfersPending);
2790
2794
 
2791
2795
        if (pfnComplete)
2792
 
        {
2793
 
            RTCritSectEnter(&pDisk->CritSect);
2794
2796
            rc = pfnComplete(pIoStorage->pVDIo->pBackendData, pIoCtx, pvUser, rcReq);
2795
 
            RTCritSectLeave(&pDisk->CritSect);
2796
 
        }
2797
2797
 
2798
2798
        LogFlow(("Completion callback for I/O context %#p returned %Rrc\n", pIoCtx, rc));
2799
2799
 
2809
2809
    /* Remove if not used anymore. */
2810
2810
    if (RT_SUCCESS(rcReq) && !fFlush)
2811
2811
    {
2812
 
        RTCritSectEnter(&pDisk->CritSect);
2813
2812
        pMetaXfer->cRefs--;
2814
2813
        if (!pMetaXfer->cRefs && RTListIsEmpty(&pMetaXfer->ListIoCtxWaiting))
2815
2814
        {
2819
2818
            Assert(fRemoved);
2820
2819
            RTMemFree(pMetaXfer);
2821
2820
        }
2822
 
        RTCritSectLeave(&pDisk->CritSect);
2823
2821
    }
2824
2822
    else if (fFlush)
2825
2823
        RTMemFree(pMetaXfer);
2826
2824
 
 
2825
    RTCritSectLeave(&pDisk->CritSect);
 
2826
 
2827
2827
    return VINF_SUCCESS;
2828
2828
}
2829
2829
 
3498
3498
    if (!pIoCtx->cbTransferLeft)
3499
3499
        pIoCtx->pfnIoCtxTransfer = NULL;
3500
3500
 
 
3501
    vdIoCtxContinue(pIoCtx, rcReq);
 
3502
 
3501
3503
    rc = RTCritSectLeave(&pDisk->CritSect);
3502
3504
    AssertRC(rc);
3503
 
 
3504
 
    vdIoCtxContinue(pIoCtx, rcReq);
3505
3505
}
3506
3506
 
3507
3507
/**