Index: trunk/src/VBox/Storage/VD.cpp
===================================================================
--- trunk/src/VBox/Storage/VD.cpp	(revision 90819)
+++ trunk/src/VBox/Storage/VD.cpp	(revision 90820)
@@ -8139,5 +8139,4 @@
     int rc2 = vdThreadStartWrite(pDisk);
     AssertRC(rc2);
-    bool fLockWrite = true;
 
     PVDCACHE pCache = pDisk->pCache;
@@ -8170,9 +8169,6 @@
     Assert(!RT_VALID_PTR(pDisk->pLast));
 
-    if (RT_UNLIKELY(fLockWrite))
-    {
-        rc2 = vdThreadFinishWrite(pDisk);
-        AssertRC(rc2);
-    }
+    rc2 = vdThreadFinishWrite(pDisk);
+    AssertRC(rc2);
 
     LogFlowFunc(("returns %Rrc\n", rc));
@@ -8183,44 +8179,33 @@
 VBOXDDU_DECL(int) VDFilterRemoveAll(PVDISK pDisk)
 {
-    int rc = VINF_SUCCESS;
-    int rc2;
-    bool fLockWrite = false;
-
     LogFlowFunc(("pDisk=%#p\n", pDisk));
-    do
-    {
-        /* sanity check */
-        AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
-        AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
-
-        /* Lock the entire operation. */
-        rc2 = vdThreadStartWrite(pDisk);
-        AssertRC(rc2);
-        fLockWrite = true;
-
-        PVDFILTER pFilter, pFilterNext;
-        RTListForEachSafe(&pDisk->ListFilterChainWrite, pFilter, pFilterNext, VDFILTER, ListNodeChainWrite)
-        {
-            RTListNodeRemove(&pFilter->ListNodeChainWrite);
-            vdFilterRelease(pFilter);
-        }
-
-        RTListForEachSafe(&pDisk->ListFilterChainRead, pFilter, pFilterNext, VDFILTER, ListNodeChainRead)
-        {
-            RTListNodeRemove(&pFilter->ListNodeChainRead);
-            vdFilterRelease(pFilter);
-        }
-        Assert(RTListIsEmpty(&pDisk->ListFilterChainRead));
-        Assert(RTListIsEmpty(&pDisk->ListFilterChainWrite));
-    } while (0);
-
-    if (RT_UNLIKELY(fLockWrite))
-    {
-        rc2 = vdThreadFinishWrite(pDisk);
-        AssertRC(rc2);
-    }
-
-    LogFlowFunc(("returns %Rrc\n", rc));
-    return rc;
+    /* sanity check */
+    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
+    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
+
+    /* Lock the entire operation. */
+    int rc2 = vdThreadStartWrite(pDisk);
+    AssertRC(rc2);
+
+    PVDFILTER pFilter, pFilterNext;
+    RTListForEachSafe(&pDisk->ListFilterChainWrite, pFilter, pFilterNext, VDFILTER, ListNodeChainWrite)
+    {
+        RTListNodeRemove(&pFilter->ListNodeChainWrite);
+        vdFilterRelease(pFilter);
+    }
+
+    RTListForEachSafe(&pDisk->ListFilterChainRead, pFilter, pFilterNext, VDFILTER, ListNodeChainRead)
+    {
+        RTListNodeRemove(&pFilter->ListNodeChainRead);
+        vdFilterRelease(pFilter);
+    }
+    Assert(RTListIsEmpty(&pDisk->ListFilterChainRead));
+    Assert(RTListIsEmpty(&pDisk->ListFilterChainWrite));
+
+    rc2 = vdThreadFinishWrite(pDisk);
+    AssertRC(rc2);
+
+    LogFlowFunc(("returns %Rrc\n", VINF_SUCCESS));
+    return VINF_SUCCESS;
 }
 
@@ -8292,5 +8277,4 @@
     int rc = VINF_SUCCESS;
     int rc2;
-    bool fLockWrite = false;
 
     LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbWrite=%zu\n",
@@ -8308,5 +8292,4 @@
         rc2 = vdThreadStartWrite(pDisk);
         AssertRC(rc2);
-        fLockWrite = true;
 
         AssertMsgBreakStmt(   uOffset < pDisk->cbSize
@@ -8338,9 +8321,6 @@
     } while (0);
 
-    if (RT_UNLIKELY(fLockWrite))
-    {
-        rc2 = vdThreadFinishWrite(pDisk);
-        AssertRC(rc2);
-    }
+    rc2 = vdThreadFinishWrite(pDisk);
+    AssertRC(rc2);
 
     LogFlowFunc(("returns %Rrc\n", rc));
@@ -8353,16 +8333,14 @@
     int rc = VINF_SUCCESS;
     int rc2;
-    bool fLockWrite = false;
 
     LogFlowFunc(("pDisk=%#p\n", pDisk));
+    /* sanity check */
+    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
+    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
+
     do
     {
-        /* sanity check */
-        AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
-        AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
-
         rc2 = vdThreadStartWrite(pDisk);
         AssertRC(rc2);
-        fLockWrite = true;
 
         PVDIMAGE pImage = pDisk->pLast;
@@ -8387,9 +8365,6 @@
     } while (0);
 
-    if (RT_UNLIKELY(fLockWrite))
-    {
-        rc2 = vdThreadFinishWrite(pDisk);
-        AssertRC(rc2);
-    }
+    rc2 = vdThreadFinishWrite(pDisk);
+    AssertRC(rc2);
 
     LogFlowFunc(("returns %Rrc\n", rc));
