[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 5/7] Tidy up GranterDebugCallback
From: Owen Smith <owen.smith@xxxxxxxxxx> Dont chain debug callback from FrontendDebugCallback, register a debug callback internally to the Granter Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/xenvbd/frontend.c | 6 +-- src/xenvbd/granter.c | 146 +++++++++++++++++++++++++++++++++----------------- src/xenvbd/granter.h | 46 +++++++--------- 3 files changed, 117 insertions(+), 81 deletions(-) diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c index bffe3d7..33dfd18 100644 --- a/src/xenvbd/frontend.c +++ b/src/xenvbd/frontend.c @@ -1067,7 +1067,7 @@ FrontendConnect( XenbusState BackendState; // Alloc Ring, Create Evtchn, Gnttab map - Status = GranterConnect(Frontend->Granter, Frontend->BackendDomain); + Status = GranterConnect(Frontend->Granter); if (!NT_SUCCESS(Status)) goto fail1; @@ -1089,7 +1089,7 @@ FrontendConnect( if (!NT_SUCCESS(Status)) goto abort; - Status = GranterStoreWrite(Frontend->Granter, Transaction, Frontend->FrontendPath); + Status = GranterStoreWrite(Frontend->Granter, Transaction); if (!NT_SUCCESS(Status)) goto abort; @@ -1495,8 +1495,6 @@ FrontendDebugCallback( Frontend->DiskInfo.SectorSize, Frontend->DiskInfo.PhysSectorSize, Frontend->DiskInfo.DiskInfo); - - GranterDebugCallback(Frontend->Granter, &Frontend->DebugInterface); } __checkReturn diff --git a/src/xenvbd/granter.c b/src/xenvbd/granter.c index ff7a575..89040ac 100644 --- a/src/xenvbd/granter.c +++ b/src/xenvbd/granter.c @@ -29,25 +29,32 @@ * SUCH DAMAGE. */ +#include <ntddk.h> +#include <ntstrsafe.h> + +#include <debug_interface.h> +#include <gnttab_interface.h> + +#include "granter.h" #include "frontend.h" #include "target.h" #include "adapter.h" + #include "util.h" #include "debug.h" -#include "thread.h" -#include <gnttab_interface.h> -#include <ntstrsafe.h> +#include "assert.h" struct _XENVBD_GRANTER { PXENVBD_FRONTEND Frontend; BOOLEAN Connected; BOOLEAN Enabled; + XENBUS_DEBUG_INTERFACE DebugInterface; XENBUS_GNTTAB_INTERFACE GnttabInterface; + PXENBUS_DEBUG_CALLBACK DebugCallback; PXENBUS_GNTTAB_CACHE Cache; KSPIN_LOCK Lock; - USHORT BackendDomain; LONG Current; LONG Maximum; }; @@ -55,7 +62,7 @@ struct _XENVBD_GRANTER { static FORCEINLINE PVOID __GranterAllocate( - IN ULONG Length + IN ULONG Length ) { return __AllocatePoolWithTag(NonPagedPool, Length, GRANTER_POOL_TAG); @@ -63,7 +70,7 @@ __GranterAllocate( static FORCEINLINE VOID __GranterFree( - IN PVOID Buffer + IN PVOID Buffer ) { if (Buffer) @@ -72,11 +79,11 @@ __GranterFree( NTSTATUS GranterCreate( - IN PXENVBD_FRONTEND Frontend, - OUT PXENVBD_GRANTER* Granter + IN PXENVBD_FRONTEND Frontend, + OUT PXENVBD_GRANTER *Granter ) { - NTSTATUS status; + NTSTATUS status; status = STATUS_NO_MEMORY; *Granter = __GranterAllocate(sizeof(XENVBD_GRANTER)); @@ -94,7 +101,7 @@ fail1: VOID GranterDestroy( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ) { Granter->Frontend = NULL; @@ -108,10 +115,10 @@ GranterDestroy( static VOID __drv_requiresIRQL(DISPATCH_LEVEL) GranterAcquireLock( - IN PVOID Argument + IN PVOID Argument ) { - PXENVBD_GRANTER Granter = Argument; + PXENVBD_GRANTER Granter = Argument; ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL); @@ -121,10 +128,10 @@ GranterAcquireLock( static VOID __drv_requiresIRQL(DISPATCH_LEVEL) GranterReleaseLock( - IN PVOID Argument + IN PVOID Argument ) { - PXENVBD_GRANTER Granter = Argument; + PXENVBD_GRANTER Granter = Argument; ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL); @@ -132,34 +139,60 @@ GranterReleaseLock( KeReleaseSpinLockFromDpcLevel(&Granter->Lock); } +static DECLSPEC_NOINLINE VOID +GranterDebugCallback( + IN PVOID Argument, + IN BOOLEAN Crashing + ) +{ + PXENVBD_GRANTER Granter = Argument; + + UNREFERENCED_PARAMETER(Crashing); + + XENBUS_DEBUG(Printf, + &Granter->DebugInterface, + "%s %s\n", + Granter->Connected ? "CONNECTED" : "DISCONNECTED", + Granter->Enabled ? "ENABLED" : "DISABLED"); + XENBUS_DEBUG(Printf, + &Granter->DebugInterface, + "%d / %d\n", + Granter->Current, + Granter->Maximum); + + Granter->Maximum = Granter->Current; +} + #define MAXNAMELEN 32 NTSTATUS GranterConnect( - IN PXENVBD_GRANTER Granter, - IN USHORT BackendDomain + IN PXENVBD_GRANTER Granter ) { - PXENVBD_ADAPTER Adapter = TargetGetAdapter(FrontendGetTarget(Granter->Frontend)); - CHAR Name[MAXNAMELEN]; - NTSTATUS status; + PXENVBD_ADAPTER Adapter = TargetGetAdapter(FrontendGetTarget(Granter->Frontend)); + CHAR Name[MAXNAMELEN]; + NTSTATUS status; ASSERT(Granter->Connected == FALSE); AdapterGetGnttabInterface(Adapter, &Granter->GnttabInterface); + AdapterGetDebugInterface(Adapter, &Granter->DebugInterface); status = XENBUS_GNTTAB(Acquire, &Granter->GnttabInterface); if (!NT_SUCCESS(status)) goto fail1; - Granter->BackendDomain = BackendDomain; + status = XENBUS_DEBUG(Acquire, &Granter->DebugInterface); + if (!NT_SUCCESS(status)) + goto fail2; status = RtlStringCbPrintfA(Name, sizeof (Name), "disk_%u", FrontendGetTargetId(Granter->Frontend)); if (!NT_SUCCESS(status)) - goto fail2; + goto fail3; status = XENBUS_GNTTAB(CreateCache, &Granter->GnttabInterface, @@ -170,37 +203,58 @@ GranterConnect( Granter, &Granter->Cache); if (!NT_SUCCESS(status)) - goto fail3; + goto fail4; + + status = XENBUS_DEBUG(Register, + &Granter->DebugInterface, + __MODULE__"|GRANTER", + GranterDebugCallback, + Granter, + &Granter->DebugCallback); + if (!NT_SUCCESS(status)) + goto fail5; Granter->Connected = TRUE; return STATUS_SUCCESS; +fail5: + Error("fail5\n"); + XENBUS_GNTTAB(DestroyCache, + &Granter->GnttabInterface, + Granter->Cache); + Granter->Cache = NULL; +fail4: + Error("fail4\n"); fail3: + Error("fail3\n"); + XENBUS_DEBUG(Release, &Granter->DebugInterface); fail2: - Granter->BackendDomain = 0; + Error("fail2\n"); XENBUS_GNTTAB(Release, &Granter->GnttabInterface); - RtlZeroMemory(&Granter->GnttabInterface, sizeof(XENBUS_GNTTAB_INTERFACE)); fail1: + Error("fail1 %08x\n", status); + + RtlZeroMemory(&Granter->DebugInterface, sizeof(XENBUS_DEBUG_INTERFACE)); + RtlZeroMemory(&Granter->GnttabInterface, sizeof(XENBUS_GNTTAB_INTERFACE)); + return status; } NTSTATUS GranterStoreWrite( - IN PXENVBD_GRANTER Granter, - IN PXENBUS_STORE_TRANSACTION Transaction, - IN PCHAR FrontendPath + IN PXENVBD_GRANTER Granter, + IN PVOID Transaction ) { UNREFERENCED_PARAMETER(Granter); UNREFERENCED_PARAMETER(Transaction); - UNREFERENCED_PARAMETER(FrontendPath); return STATUS_SUCCESS; } VOID GranterEnable( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ) { ASSERT(Granter->Enabled == FALSE); @@ -210,7 +264,7 @@ GranterEnable( VOID GranterDisable( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ) { ASSERT(Granter->Enabled == TRUE); @@ -220,7 +274,7 @@ GranterDisable( VOID GranterDisconnect( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ) { ASSERT(Granter->Connected == TRUE); @@ -228,35 +282,25 @@ GranterDisconnect( ASSERT3S(Granter->Current, ==, 0); Granter->Maximum = 0; + XENBUS_DEBUG(Deregister, + &Granter->DebugInterface, + Granter->DebugCallback); + Granter->DebugCallback = NULL; + XENBUS_GNTTAB(DestroyCache, &Granter->GnttabInterface, Granter->Cache); Granter->Cache = NULL; + XENBUS_DEBUG(Release, &Granter->DebugInterface); XENBUS_GNTTAB(Release, &Granter->GnttabInterface); + + RtlZeroMemory(&Granter->DebugInterface, sizeof(XENBUS_DEBUG_INTERFACE)); RtlZeroMemory(&Granter->GnttabInterface, sizeof(XENBUS_GNTTAB_INTERFACE)); - Granter->BackendDomain = 0; Granter->Connected = FALSE; } -VOID -GranterDebugCallback( - IN PXENVBD_GRANTER Granter, - IN PXENBUS_DEBUG_INTERFACE Debug - ) -{ - XENBUS_DEBUG(Printf, Debug, - "GRANTER: %s %s\n", - Granter->Connected ? "CONNECTED" : "DISCONNECTED", - Granter->Enabled ? "ENABLED" : "DISABLED"); - XENBUS_DEBUG(Printf, Debug, - "GRANTER: %d / %d\n", - Granter->Current, - Granter->Maximum); - Granter->Maximum = Granter->Current; -} - NTSTATUS GranterGet( IN PXENVBD_GRANTER Granter, @@ -277,7 +321,7 @@ GranterGet( &Granter->GnttabInterface, Granter->Cache, FALSE, - Granter->BackendDomain, + (USHORT)FrontendGetBackendDomain(Granter->Frontend), Pfn, ReadOnly, &Entry); @@ -292,7 +336,9 @@ GranterGet( return STATUS_SUCCESS; fail2: + Error("fail2\n"); fail1: + Error("fail1 %08x\n", status); return status; } diff --git a/src/xenvbd/granter.h b/src/xenvbd/granter.h index de7701c..b840c13 100644 --- a/src/xenvbd/granter.h +++ b/src/xenvbd/granter.h @@ -32,75 +32,67 @@ #ifndef _XENVBD_GRANTER_H #define _XENVBD_GRANTER_H +#include <ntddk.h> + typedef struct _XENVBD_GRANTER XENVBD_GRANTER, *PXENVBD_GRANTER; -#include <debug_interface.h> -#include <store_interface.h> #include "frontend.h" extern NTSTATUS GranterCreate( - IN PXENVBD_FRONTEND Frontend, - OUT PXENVBD_GRANTER* Granter + IN PXENVBD_FRONTEND Frontend, + OUT PXENVBD_GRANTER *Granter ); extern VOID GranterDestroy( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ); extern NTSTATUS GranterConnect( - IN PXENVBD_GRANTER Granter, - IN USHORT BackendDomain + IN PXENVBD_GRANTER Granter ); extern NTSTATUS GranterStoreWrite( - IN PXENVBD_GRANTER Granter, - IN PXENBUS_STORE_TRANSACTION Transaction, - IN PCHAR FrontendPath + IN PXENVBD_GRANTER Granter, + IN PVOID Transaction ); extern VOID GranterEnable( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ); extern VOID GranterDisable( - IN PXENVBD_GRANTER Granter + IN PXENVBD_GRANTER Granter ); extern VOID GranterDisconnect( - IN PXENVBD_GRANTER Granter - ); - -extern VOID -GranterDebugCallback( - IN PXENVBD_GRANTER Granter, - IN PXENBUS_DEBUG_INTERFACE Debug + IN PXENVBD_GRANTER Granter ); extern NTSTATUS GranterGet( - IN PXENVBD_GRANTER Granter, - IN PFN_NUMBER Pfn, - IN BOOLEAN ReadOnly, - OUT PVOID *Handle + IN PXENVBD_GRANTER Granter, + IN PFN_NUMBER Pfn, + IN BOOLEAN ReadOnly, + OUT PVOID *Handle ); extern VOID GranterPut( - IN PXENVBD_GRANTER Granter, - IN PVOID Handle + IN PXENVBD_GRANTER Granter, + IN PVOID Handle ); extern ULONG GranterReference( - IN PXENVBD_GRANTER Granter, - IN PVOID Handle + IN PXENVBD_GRANTER Granter, + IN PVOID Handle ); #endif // _XENVBD_GRANTER_H -- 2.8.3 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |