[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 1/2] Move BlkifRing CacheCreate/Destroy to inline functions
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |