|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 05/10] granter: Split GranterTryPut to its own function
This allows ring consumers to test for still-pending grants and
eventually defer grant revocation.
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
src/xenvbd/granter.c | 37 +++++++++++++++++++++++++++++--------
src/xenvbd/granter.h | 7 +++++++
2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/src/xenvbd/granter.c b/src/xenvbd/granter.c
index bacd245..8271771 100644
--- a/src/xenvbd/granter.c
+++ b/src/xenvbd/granter.c
@@ -346,31 +346,52 @@ fail1:
return status;
}
+_Check_return_
+NTSTATUS
+GranterTryPut(
+ _Inout_ PXENVBD_GRANTER Granter,
+ _In_ PVOID Handle
+ )
+{
+ PXENBUS_GNTTAB_ENTRY Entry = Handle;
+ NTSTATUS status;
+
+ ASSERT3P(Granter->Cache, !=, NULL);
+
+ status = XENBUS_GNTTAB(TryRevokeForeignAccess,
+ &Granter->GnttabInterface,
+ Granter->Cache,
+ FALSE,
+ Entry);
+ if (!NT_SUCCESS(status))
+ goto fail1;
+
+ InterlockedDecrement(&Granter->Current);
+
+ return STATUS_SUCCESS;
+
+fail1:
+ return status;
+}
+
VOID
GranterPut(
_Inout_ PXENVBD_GRANTER Granter,
_In_ PVOID Handle
)
{
- PXENBUS_GNTTAB_ENTRY Entry = Handle;
NTSTATUS status;
if (Granter->Connected == FALSE)
return;
for (;;) {
- status = XENBUS_GNTTAB(TryRevokeForeignAccess,
- &Granter->GnttabInterface,
- Granter->Cache,
- FALSE,
- Entry);
+ status = GranterTryPut(Granter, Handle);
if (NT_SUCCESS(status))
break;
YieldProcessor();
}
-
- InterlockedDecrement(&Granter->Current);
}
ULONG
diff --git a/src/xenvbd/granter.h b/src/xenvbd/granter.h
index e8d0899..e609a8a 100644
--- a/src/xenvbd/granter.h
+++ b/src/xenvbd/granter.h
@@ -84,6 +84,13 @@ GranterGet(
_Outptr_ PVOID *Handle
);
+_Check_return_
+extern NTSTATUS
+GranterTryPut(
+ _Inout_ PXENVBD_GRANTER Granter,
+ _In_ PVOID Handle
+ );
+
extern VOID
GranterPut(
_Inout_ PXENVBD_GRANTER Granter,
--
2.56.0.windows.4
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |