[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 4/5] Remove PDO set/is-missing logic from XENDISK
It's all completely unnecessary for a filter driver Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/xendisk/fdo.c | 55 +++------------------------------------------ src/xendisk/pdo.c | 67 ++++++++----------------------------------------------- src/xendisk/pdo.h | 16 ------------- 3 files changed, 12 insertions(+), 126 deletions(-) diff --git a/src/xendisk/fdo.c b/src/xendisk/fdo.c index 27db284..09f785f 100644 --- a/src/xendisk/fdo.c +++ b/src/xendisk/fdo.c @@ -265,28 +265,15 @@ __FdoEnumerate( PLIST_ENTRY Next = ListEntry->Flink; PXENDISK_DX Dx = CONTAINING_RECORD(ListEntry, XENDISK_DX, ListEntry); PXENDISK_PDO Pdo = Dx->Pdo; - BOOLEAN Missing; - Missing = TRUE; for (Index = 0; Index < Count; Index++) { if (PdoGetPhysicalDeviceObject(Pdo) == PhysicalDeviceObject[Index]) { - Missing = FALSE; #pragma prefast(suppress:6387) // PhysicalDeviceObject[Index] could be NULL - ObDereferenceObject(PhysicalDeviceObject[Index]); PhysicalDeviceObject[Index] = NULL; // avoid duplication break; } } - if (Missing && !PdoIsMissing(Pdo)) { - if (PdoGetDevicePnpState(Pdo) == Present) { - PdoSetDevicePnpState(Pdo, Deleted); - PdoDestroy(Pdo); - } else { - PdoSetMissing(Pdo, "device disappeared"); - } - } - ListEntry = Next; } @@ -296,7 +283,6 @@ __FdoEnumerate( if (PhysicalDeviceObject[Index] != NULL) { (VOID) PdoCreate(Fdo, PhysicalDeviceObject[Index]); - ObDereferenceObject(PhysicalDeviceObject[Index]); } } @@ -831,7 +817,6 @@ FdoQueryDeviceRelations( { KEVENT Event; PIO_STACK_LOCATION StackLocation; - ULONG Size; PDEVICE_RELATIONS Relations; PLIST_ENTRY ListEntry; ULONG Count; @@ -875,59 +860,28 @@ FdoQueryDeviceRelations( if (Relations->Count != 0) __FdoEnumerate(Fdo, Relations); - ExFreePool(Relations); - __FdoAcquireMutex(Fdo); Count = 0; for (ListEntry = Fdo->Dx->ListEntry.Flink; ListEntry != &Fdo->Dx->ListEntry; - ListEntry = ListEntry->Flink) - { - PXENDISK_DX Dx = CONTAINING_RECORD(ListEntry, XENDISK_DX, ListEntry); - PXENDISK_PDO Pdo = Dx->Pdo; - - if (PdoIsMissing(Pdo)) - continue; - - Count++; - } - - Size = sizeof(DEVICE_RELATIONS) + (sizeof (PDEVICE_OBJECT) * Count); - - Relations = ExAllocatePoolWithTag(PagedPool, Size, 'TLIF'); - - status = STATUS_NO_MEMORY; - if (Relations == NULL) - goto fail3; - - RtlZeroMemory(Relations, Size); - - for (ListEntry = Fdo->Dx->ListEntry.Flink; - ListEntry != &Fdo->Dx->ListEntry; ListEntry = ListEntry->Flink) { PXENDISK_DX Dx = CONTAINING_RECORD(ListEntry, XENDISK_DX, ListEntry); PXENDISK_PDO Pdo = Dx->Pdo; ASSERT3U(Dx->Type, ==, PHYSICAL_DEVICE_OBJECT); - if (PdoIsMissing(Pdo)) - continue; - if (PdoGetDevicePnpState(Pdo) == Present) PdoSetDevicePnpState(Pdo, Enumerated); - ObReferenceObject(PdoGetPhysicalDeviceObject(Pdo)); - Relations->Objects[Relations->Count++] = PdoGetPhysicalDeviceObject(Pdo); + Count++; } - ASSERT3U(Relations->Count, ==, Count); - Trace("%d PDO(s)\n", Relations->Count); - __FdoReleaseMutex(Fdo); - Irp->IoStatus.Information = (ULONG_PTR)Relations; + Trace("%d PDO(s)\n", Relations->Count); + status = STATUS_SUCCESS; done: @@ -938,9 +892,6 @@ done: return status; -fail3: - __FdoReleaseMutex(Fdo); - fail2: IoReleaseRemoveLock(&Fdo->Dx->RemoveLock, Irp); diff --git a/src/xendisk/pdo.c b/src/xendisk/pdo.c index cdf4af6..dffb294 100644 --- a/src/xendisk/pdo.c +++ b/src/xendisk/pdo.c @@ -61,8 +61,6 @@ struct _XENDISK_PDO { PIRP DevicePowerIrp; PXENDISK_FDO Fdo; - BOOLEAN Missing; - const CHAR *Reason; ULONG SectorSize; }; @@ -188,41 +186,6 @@ PdoGetPhysicalDeviceObject( } static FORCEINLINE VOID -__PdoSetMissing( - IN PXENDISK_PDO Pdo, - IN const CHAR *Reason - ) -{ - Pdo->Reason = Reason; - Pdo->Missing = TRUE; -} - -VOID -PdoSetMissing( - IN PXENDISK_PDO Pdo, - IN const CHAR *Reason - ) -{ - __PdoSetMissing(Pdo, Reason); -} - -static FORCEINLINE BOOLEAN -__PdoIsMissing( - IN PXENDISK_PDO Pdo - ) -{ - return Pdo->Missing; -} - -BOOLEAN -PdoIsMissing( - IN PXENDISK_PDO Pdo - ) -{ - return __PdoIsMissing(Pdo); -} - -static FORCEINLINE VOID __PdoLink( IN PXENDISK_PDO Pdo, IN PXENDISK_FDO Fdo @@ -1122,23 +1085,18 @@ PdoRemoveDevice( PowerState); done: - if (__PdoIsMissing(Pdo)) { - __PdoSetDevicePnpState(Pdo, Deleted); - IoReleaseRemoveLockAndWait(&Pdo->Dx->RemoveLock, Irp); - } else { - __PdoSetDevicePnpState(Pdo, Enumerated); - IoReleaseRemoveLock(&Pdo->Dx->RemoveLock, Irp); - } + FdoAcquireMutex(Fdo); + __PdoSetDevicePnpState(Pdo, Deleted); + FdoReleaseMutex(Fdo); + + IoReleaseRemoveLockAndWait(&Pdo->Dx->RemoveLock, Irp); status = PdoForwardIrpSynchronously(Pdo, Irp); IoCompleteRequest(Irp, IO_NO_INCREMENT); - if (__PdoIsMissing(Pdo)) { - FdoAcquireMutex(Fdo); - PdoDestroy(Pdo); - FdoReleaseMutex(Fdo); - } else if (__PdoGetDevicePnpState(Pdo) == Enumerated) - __PdoSetMissing(Pdo, "Device removed"); + FdoAcquireMutex(Fdo); + PdoDestroy(Pdo); + FdoReleaseMutex(Fdo); return status; @@ -1158,7 +1116,6 @@ PdoEject( PXENDISK_FDO Fdo = __PdoGetFdo(Pdo); NTSTATUS status; - __PdoSetMissing(Pdo, "Ejected"); __PdoSetDevicePnpState(Pdo, Deleted); status = PdoForwardIrpSynchronously(Pdo, Irp); @@ -2074,15 +2031,9 @@ PdoDestroy( ASSERT3U(__PdoGetDevicePnpState(Pdo), ==, Deleted); - ASSERT(__PdoIsMissing(Pdo)); - Pdo->Missing = FALSE; - __PdoUnlink(Pdo); - Verbose("%p (%s)\n", - FilterDeviceObject, - Pdo->Reason); - Pdo->Reason = NULL; + Verbose("%p\n", FilterDeviceObject); Dx->Pdo = NULL; diff --git a/src/xendisk/pdo.h b/src/xendisk/pdo.h index 7866b83..566d60f 100644 --- a/src/xendisk/pdo.h +++ b/src/xendisk/pdo.h @@ -54,22 +54,6 @@ PdoGetPhysicalDeviceObject( IN PXENDISK_PDO Pdo ); -extern BOOLEAN -PdoIsMissing( - IN PXENDISK_PDO Pdo - ); - -extern VOID -PdoSetMissing( - IN PXENDISK_PDO Pdo, - IN const CHAR *Reason - ); - -extern BOOLEAN -PdoIsMasked( - IN PXENDISK_PDO Pdo - ); - extern NTSTATUS PdoCreate( IN PXENDISK_FDO Fdo, -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |