[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Create/Destroy BlkifRing caches on Connect/Disconnect


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Wed, 30 Mar 2022 15:02:11 +0100
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Wed, 30 Mar 2022 14:04:26 +0000
  • Ironport-data: A9a23:UvbglqIRTqKYjUzVFE+RtZUlxSXFcZb7ZxGr2PjKsXjdYENSgWZWy jBMWW3UOv+PNjHxLtx2a4/j/U0A7MTRmINmHVFlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA148IMsdoUg7wbRh2dUw2YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 Pds8szuERg0Ao/VpO8XeRZSCTpHHYQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBM70MYVZoXRh0THxBvc6W5HTBa7N4Le02R9u2ZETR66OO KL1bxJFQj+cbCxrGGswN8kwsvya13fzLxNH/Qf9Sa0fvDGIkV0ZPKLWGMXUfJmSW4BZk1iVo krC/n/lGVcKOdqH0z2H/3mwwOjVkkvGtJk6TePisKQw2RvKmzJVWEZ+uUaHTeeRqG/5C4wHN FEo2DMSpqIY+0axVeDddkjtyJKbhSI0V91VGuw8zQiCzKvI/gqUblQ5oi59hM8O75FvG2Fzv rOdt5awXGE07uXJIZ6I3u3MxQ5eLxT5OoPricUsaQIeq+fur4go5v4kZoYySfXl5jEZ9NyZ/ txrkMTcr+hL5SLo///ilbwiv95KjsKTJuLSzl+KNl9JFisjOOaYi3WAsDA3F8poIoeDVUWmt 3MZgcWY5+1mJcjTyHzQEL9URunzv6rt3NjgbbhHRcNJG9OFoSPLQGytyGsmeBcB3jgsJ1cFn 3M/SSsOvcQObRNGnId8Yp6rCtRC8EQTPY+NaxwgVfIXOsIZXFbepElGPBfMt0iwwBlEufxuY v+zLJfzZUv2/Iw6lVJasc9GiuR1rs3/rEuOLa3GI+OPjOPGPSXPGO5fWLZMB8hghJ65TMzu2 443H6O3J993C7ClCsUL2eb/9Ww3EEU=
  • Ironport-hdrordr: A9a23:gd3LWap06gMV6k8I6kNXAA8aV5oteYIsimQD101hICG8cqSj+P xG+85rsiMc6QxhIU3I9urgBEDtex7hHNtOkOss1NSZLW3bUQmTTL2KhLGKq1aLJ8S9zJ856U 4JSdkZNDSaNzZHZKjBjDVQa+xQo+W6zA==
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Move cache creation to Connect after XENBUS_CACHE(Acquire) and cache
destruction to Disconnect before XENBUS_CACHE(Release)

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/ring.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 4482c31..ca84051 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1898,23 +1898,14 @@ BlkifRingCreate(
 
     KeInitializeThreadedDpc(&(*BlkifRing)->Dpc, BlkifRingDpc, *BlkifRing);
 
-    status = BlkifRingCacheCreate(*BlkifRing);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
     status = ThreadCreate(RingWatchdog,
                           *BlkifRing,
                           &(*BlkifRing)->WatchdogThread);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail4;
 
     return STATUS_SUCCESS;
 
-fail5:
-    Error("fail5\n");
-
-    BlkifRingCacheDestroy(*BlkifRing);
-
 fail4:
     Error("fail4\n");
 
@@ -1952,8 +1943,6 @@ BlkifRingDestroy(
     ThreadJoin(BlkifRing->WatchdogThread);
     BlkifRing->WatchdogThread = NULL;
 
-    BlkifRingCacheDestroy(BlkifRing);
-
     RtlZeroMemory(&BlkifRing->Dpc, sizeof(KDPC));
 
     ASSERT(IsListEmpty(&BlkifRing->PreparedQueue));
@@ -2003,11 +1992,15 @@ BlkifRingConnect(
     }
     KeSetImportanceDpc(&BlkifRing->Dpc, MediumHighImportance);
 
+    status = BlkifRingCacheCreate(BlkifRing);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
     BlkifRing->Mdl = __AllocatePages(1 << Ring->Order);
 
     status = STATUS_NO_MEMORY;
     if (BlkifRing->Mdl == NULL)
-        goto fail1;
+        goto fail2;
 
     BlkifRing->Shared = MmGetSystemAddressForMdlSafe(BlkifRing->Mdl,
                                                      NormalPagePriority);
@@ -2026,7 +2019,7 @@ BlkifRingConnect(
                             FALSE,
                             &BlkifRing->Grants[Index]);
         if (!NT_SUCCESS(status))
-            goto fail2;
+            goto fail3;
     }
 
     BlkifRing->Channel = XENBUS_EVTCHN(Open,
@@ -2038,7 +2031,7 @@ BlkifRingConnect(
                                        TRUE);
     status = STATUS_NO_MEMORY;
     if (BlkifRing->Channel == NULL)
-        goto fail3;
+        goto fail4;
 
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
@@ -2051,7 +2044,7 @@ BlkifRingConnect(
                                  __MODULE__"|RING[%u]",
                                  BlkifRing->Index);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;
 
     status = XENBUS_DEBUG(Register,
                           &Ring->DebugInterface,
@@ -2060,25 +2053,25 @@ BlkifRingConnect(
                           BlkifRing,
                           &BlkifRing->DebugCallback);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     BlkifRing->Connected = TRUE;
     Trace("<==== %u\n", BlkifRing->Index);
 
     return STATUS_SUCCESS;
 
+fail6:
+    Error("fail6\n");
 fail5:
     Error("fail5\n");
-fail4:
-    Error("fail4\n");
     XENBUS_EVTCHN(Close,
                   &Ring->EvtchnInterface,
                   BlkifRing->Channel);
     BlkifRing->Channel = NULL;
+fail4:
+    Error("fail4\n");
 fail3:
     Error("fail3\n");
-fail2:
-    Error("fail2\n");
     for (Index = 0; Index < (1ul << Ring->Order); ++Index) {
         if (BlkifRing->Grants[Index] == NULL)
             continue;
@@ -2092,6 +2085,9 @@ fail2:
     __FreePages(BlkifRing->Mdl);
     BlkifRing->Shared = NULL;
     BlkifRing->Mdl = NULL;
+fail2:
+    Error("fail2\n");
+    BlkifRingCacheDestroy(BlkifRing);
 fail1:
     Error("fail1 %08x\n", status);
     return status;
@@ -2311,6 +2307,8 @@ BlkifRingDisconnect(
     BlkifRing->Shared = NULL;
     BlkifRing->Mdl = NULL;
 
+    BlkifRingCacheDestroy(BlkifRing);
+
     BlkifRing->Events = 0;
     BlkifRing->Dpcs = 0;
     BlkifRing->RequestsPosted = 0;
-- 
2.32.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.