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

[PATCH 1/2] Move BlkifRing CacheCreate/Destroy to inline functions


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Wed, 30 Mar 2022 15:02:10 +0100
  • Authentication-results: esa5.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:02:24 +0000
  • Ironport-data: A9a23:a7Y6NaCbK+NejhVW/0Tjw5YqxClBgxIJ4kV8jS/XYbTApDslhmEPy mBKDW6Ab/eJMTP3ft0nYYXi8xtX657UnIdhQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMZiaA4E/raNANlFEkvU2ybuOU5NXsZ2YgHWeIdA970Ug5w7Vi2tYy6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhbk 9IVuKy3Yj1xEfXHgd0iaBJ5HCtxaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguwkM8Ttepgau21g5TrYEewnUdbIRKCiCdpwgmlh1pAeQqi2i 8wxUid1RSrnPjZzFw0MUpgXobz0oCjdWmgNwL6SjfVuuDWCpOBr65DyMdyQYsLPSchLk0Kwo mPd43+/EhwcLMaYyzeO7jSrnOCnoM/gcNtMTvvirKcs2QDNgDxIYPELabelidPijRaza9V0E RQ7oiE3lJcJ/22kRNaoCnVUv0W4lhIbXtNRFcgz5weM1rfY7m6lO4QUctJSQId47ZFrHFTGw nfMxoq0XmI37NV5XFrHrt+pQSWO1T/5xIPoTQsNVkM77tbqu+nfZTqfH484QMZZYjAYcAwcI gxmTgBj393/buZRjs1XGGwrZRr2/PAlqSZvu23qspqNtF8RWWJfW6Sm6ELA8dFLJ5uDQ1+Ks RAswpbCvL1eV8jXzHbVHI3h+Y1FAd7falUwZnY1QvEcG8mFoSb/Lei8HhkgTKuWDir0UWCwO xKC0e+gzJRSIGGrfcdKj3GZUKwXIVzbPY29DJj8N4MWCrAoLVPv1Hw+NCa4gjG2+GBxwP5XB HtuWZv1ZV4AF79dxSa7L89El+dDKtYWnjiIG/gWDn2PjNKjWZJiYepcaALVNLFgtstpYmz9q r5iCidD8D0HOMWWX8Ud2dV7wYwiRZTjOa3Llg==
  • Ironport-hdrordr: A9a23:Yi6mEqoPF8GEfDH5ahho02UaV5oheYIsimQD101hICG8cqSj+P xG+85rsCMc6QxhP03I9urgBEDtex7hHP1OkOss1NWZPDUO0VHAROoJ0WKL+UyFJ8SUzIBgPM lbH5SWcOeAbmRHsQ==
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

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

diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 1ea1250..4482c31 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1709,63 +1709,26 @@ RingWatchdog(
     return STATUS_SUCCESS;
 }
 
-static NTSTATUS
-BlkifRingCreate(
-    IN  PXENVBD_RING        Ring,
-    IN  ULONG               Index,
-    OUT PXENVBD_BLKIF_RING* BlkifRing
+static FORCEINLINE NTSTATUS
+BlkifRingCacheCreate(
+    IN  PXENVBD_BLKIF_RING  BlkifRing
     )
 {
+    PXENVBD_RING            Ring;
     PXENVBD_FRONTEND        Frontend;
-    ULONG                   Length;
-    PCHAR                   Path;
     CHAR                    Name[MAX_NAME_LEN];
     NTSTATUS                status;
 
+    Ring = BlkifRing->Ring;
     Frontend = Ring->Frontend;
 
-    Length = (ULONG)strlen(FrontendGetFrontendPath(Frontend)) +
-        (ULONG)strlen("/queue-xxx");
-
-    Path = __RingAllocate(Length + 1);
-
-    status = STATUS_NO_MEMORY;
-    if (Path == NULL)
-        goto fail1;
-
-    status = RtlStringCchPrintfA(Path,
-                                 Length,
-                                 "%s/queue-%u",
-                                 FrontendGetFrontendPath(Frontend),
-                                 Index);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    *BlkifRing = __RingAllocate(sizeof(XENVBD_BLKIF_RING));
-
-    status = STATUS_NO_MEMORY;
-    if (*BlkifRing == NULL)
-        goto fail3;
-
-    (*BlkifRing)->Ring = Ring;
-    (*BlkifRing)->Index = Index;
-    (*BlkifRing)->Path = Path;
-    Path = NULL;
-
-    InitializeListHead(&(*BlkifRing)->SrbQueue);
-    InitializeListHead(&(*BlkifRing)->ShutdownQueue);
-    InitializeListHead(&(*BlkifRing)->SubmittedList);
-    InitializeListHead(&(*BlkifRing)->PreparedQueue);
-
-    KeInitializeThreadedDpc(&(*BlkifRing)->Dpc, BlkifRingDpc, *BlkifRing);
-
     status = RtlStringCbPrintfA(Name,
                                 sizeof(Name),
                                 "vbd_%u_queue_%u_request",
                                 FrontendGetTargetId(Frontend),
-                                Index);
+                                BlkifRing->Index);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail1;
 
     status = XENBUS_CACHE(Create,
                           &Ring->CacheInterface,
@@ -1777,18 +1740,18 @@ BlkifRingCreate(
                           BlkifRingRequestDtor,
                           BlkifRingAcquireLock,
                           BlkifRingReleaseLock,
-                          *BlkifRing,
-                          &(*BlkifRing)->RequestCache);
+                          BlkifRing,
+                          &BlkifRing->RequestCache);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail2;
 
     status = RtlStringCbPrintfA(Name,
                                 sizeof(Name),
                                 "vbd_%u_queue_%u_segment",
                                 FrontendGetTargetId(Frontend),
-                                Index);
+                                BlkifRing->Index);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail3;
 
     status = XENBUS_CACHE(Create,
                           &Ring->CacheInterface,
@@ -1800,18 +1763,18 @@ BlkifRingCreate(
                           BlkifRingSegmentDtor,
                           BlkifRingAcquireLock,
                           BlkifRingReleaseLock,
-                          *BlkifRing,
-                          &(*BlkifRing)->SegmentCache);
+                          BlkifRing,
+                          &BlkifRing->SegmentCache);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail4;
 
     status = RtlStringCbPrintfA(Name,
                                 sizeof(Name),
                                 "vbd_%u_queue_%u_indirect",
                                 FrontendGetTargetId(Frontend),
-                                Index);
+                                BlkifRing->Index);
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail5;
 
     status = XENBUS_CACHE(Create,
                           &Ring->CacheInterface,
@@ -1823,43 +1786,135 @@ BlkifRingCreate(
                           BlkifRingIndirectDtor,
                           BlkifRingAcquireLock,
                           BlkifRingReleaseLock,
-                          *BlkifRing,
-                          &(*BlkifRing)->IndirectCache);
-    if (!NT_SUCCESS(status))
-        goto fail9;
-
-    status = ThreadCreate(RingWatchdog,
-                          *BlkifRing,
-                          &(*BlkifRing)->WatchdogThread);
+                          BlkifRing,
+                          &BlkifRing->IndirectCache);
     if (!NT_SUCCESS(status))
-        goto fail10;
+        goto fail6;
 
     return STATUS_SUCCESS;
 
-fail10:
-    Error("fail10\n");
+fail6:
+    Error("fail6\n");
+
+fail5:
+    Error("fail5\n");
+
     XENBUS_CACHE(Destroy,
                  &Ring->CacheInterface,
-                 (*BlkifRing)->IndirectCache);
-    (*BlkifRing)->IndirectCache = NULL;
-fail9:
-    Error("fail9\n");
-fail8:
-    Error("fail8\n");
+                 BlkifRing->SegmentCache);
+    BlkifRing->SegmentCache = NULL;
+
+fail4:
+    Error("fail4\n");
+
+fail3:
+    Error("fail3\n");
+
     XENBUS_CACHE(Destroy,
                  &Ring->CacheInterface,
-                 (*BlkifRing)->SegmentCache);
-    (*BlkifRing)->SegmentCache = NULL;
-fail7:
-    Error("fail7\n");
-fail6:
-    Error("fail6\n");
+                 BlkifRing->RequestCache);
+    BlkifRing->RequestCache = NULL;
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 %08x\n", status);
+
+    return status;
+}
+
+static FORCEINLINE VOID
+BlkifRingCacheDestroy(
+    IN  PXENVBD_BLKIF_RING  BlkifRing
+    )
+{
+    PXENVBD_RING            Ring;
+
+    Ring = BlkifRing->Ring;
+
     XENBUS_CACHE(Destroy,
                  &Ring->CacheInterface,
-                 (*BlkifRing)->RequestCache);
-    (*BlkifRing)->RequestCache = NULL;
+                 BlkifRing->IndirectCache);
+    BlkifRing->IndirectCache = NULL;
+
+    XENBUS_CACHE(Destroy,
+                 &Ring->CacheInterface,
+                 BlkifRing->SegmentCache);
+    BlkifRing->SegmentCache = NULL;
+
+    XENBUS_CACHE(Destroy,
+                 &Ring->CacheInterface,
+                 BlkifRing->RequestCache);
+    BlkifRing->RequestCache = NULL;
+}
+
+static NTSTATUS
+BlkifRingCreate(
+    IN  PXENVBD_RING        Ring,
+    IN  ULONG               Index,
+    OUT PXENVBD_BLKIF_RING* BlkifRing
+    )
+{
+    PXENVBD_FRONTEND        Frontend;
+    ULONG                   Length;
+    PCHAR                   Path;
+    NTSTATUS                status;
+
+    Frontend = Ring->Frontend;
+
+    Length = (ULONG)strlen(FrontendGetFrontendPath(Frontend)) +
+        (ULONG)strlen("/queue-xxx");
+
+    Path = __RingAllocate(Length + 1);
+
+    status = STATUS_NO_MEMORY;
+    if (Path == NULL)
+        goto fail1;
+
+    status = RtlStringCchPrintfA(Path,
+                                 Length,
+                                 "%s/queue-%u",
+                                 FrontendGetFrontendPath(Frontend),
+                                 Index);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    *BlkifRing = __RingAllocate(sizeof(XENVBD_BLKIF_RING));
+
+    status = STATUS_NO_MEMORY;
+    if (*BlkifRing == NULL)
+        goto fail3;
+
+    (*BlkifRing)->Ring = Ring;
+    (*BlkifRing)->Index = Index;
+    (*BlkifRing)->Path = Path;
+    Path = NULL;
+
+    InitializeListHead(&(*BlkifRing)->SrbQueue);
+    InitializeListHead(&(*BlkifRing)->ShutdownQueue);
+    InitializeListHead(&(*BlkifRing)->SubmittedList);
+    InitializeListHead(&(*BlkifRing)->PreparedQueue);
+
+    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;
+
+    return STATUS_SUCCESS;
+
 fail5:
     Error("fail5\n");
+
+    BlkifRingCacheDestroy(*BlkifRing);
+
 fail4:
     Error("fail4\n");
 
@@ -1893,26 +1948,11 @@ BlkifRingDestroy(
     IN  PXENVBD_BLKIF_RING  BlkifRing
     )
 {
-    PXENVBD_RING            Ring = BlkifRing->Ring;
-
     ThreadAlert(BlkifRing->WatchdogThread);
     ThreadJoin(BlkifRing->WatchdogThread);
     BlkifRing->WatchdogThread = NULL;
 
-    XENBUS_CACHE(Destroy,
-                 &Ring->CacheInterface,
-                 BlkifRing->IndirectCache);
-    BlkifRing->IndirectCache = NULL;
-
-    XENBUS_CACHE(Destroy,
-                 &Ring->CacheInterface,
-                 BlkifRing->SegmentCache);
-    BlkifRing->SegmentCache = NULL;
-
-    XENBUS_CACHE(Destroy,
-                 &Ring->CacheInterface,
-                 BlkifRing->RequestCache);
-    BlkifRing->RequestCache = NULL;
+    BlkifRingCacheDestroy(BlkifRing);
 
     RtlZeroMemory(&BlkifRing->Dpc, sizeof(KDPC));
 
-- 
2.32.0.windows.1




 


Rackspace

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