mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-24 09:23:37 -05:00
sys: device: replace device Resource with GenericTableFastMutex
This commit is contained in:
parent
5e3fae6a8c
commit
1bb0b6be10
@ -24,6 +24,8 @@ static VOID FspFsvolDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
|||||||
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject);
|
||||||
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
static IO_TIMER_ROUTINE FspFsvolDeviceTimerRoutine;
|
||||||
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
static WORKER_THREAD_ROUTINE FspFsvolDeviceExpirationRoutine;
|
||||||
|
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject);
|
||||||
|
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
||||||
@ -46,6 +48,8 @@ VOID FspDeviceDeleteAll(VOID);
|
|||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInitComplete)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInitComplete)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceLockContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceUnlockContext)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceLookupContext)
|
#pragma alloc_text(PAGE, FspFsvolDeviceLookupContext)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInsertContext)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInsertContext)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceDeleteContext)
|
#pragma alloc_text(PAGE, FspFsvolDeviceDeleteContext)
|
||||||
@ -277,10 +281,8 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
|||||||
ExInitializeWorkItem(&FsvolDeviceExtension->ExpirationWorkItem,
|
ExInitializeWorkItem(&FsvolDeviceExtension->ExpirationWorkItem,
|
||||||
FspFsvolDeviceExpirationRoutine, DeviceObject);
|
FspFsvolDeviceExpirationRoutine, DeviceObject);
|
||||||
|
|
||||||
/* initialize our resource */
|
|
||||||
ExInitializeResourceLite(&FsvolDeviceExtension->Resource);
|
|
||||||
|
|
||||||
/* initialize our generic table */
|
/* initialize our generic table */
|
||||||
|
ExInitializeFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
||||||
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
||||||
|
|
||||||
@ -338,9 +340,6 @@ static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject)
|
|||||||
/* free the spare VPB if we still have it */
|
/* free the spare VPB if we still have it */
|
||||||
if (0 != FsvolDeviceExtension->SwapVpb)
|
if (0 != FsvolDeviceExtension->SwapVpb)
|
||||||
FspFreeExternal(FsvolDeviceExtension->SwapVpb);
|
FspFreeExternal(FsvolDeviceExtension->SwapVpb);
|
||||||
|
|
||||||
/* delete our resource */
|
|
||||||
ExDeleteResourceLite(&FsvolDeviceExtension->Resource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID FspFsvolDeviceTimerRoutine(PDEVICE_OBJECT DeviceObject, PVOID Context)
|
static VOID FspFsvolDeviceTimerRoutine(PDEVICE_OBJECT DeviceObject, PVOID Context)
|
||||||
@ -394,13 +393,23 @@ static VOID FspFsvolDeviceExpirationRoutine(PVOID Context)
|
|||||||
FspDeviceRelease(DeviceObject);
|
FspDeviceRelease(DeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject)
|
||||||
|
{
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject)
|
||||||
|
{
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
||||||
|
}
|
||||||
|
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
||||||
{
|
{
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Resource));
|
|
||||||
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result;
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result;
|
||||||
|
|
||||||
Result = RtlLookupElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
Result = RtlLookupElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
@ -414,10 +423,9 @@ PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier
|
|||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Resource));
|
|
||||||
ASSERT(0 != ElementStorage);
|
|
||||||
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result, Element = { 0 };
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Result, Element = { 0 };
|
||||||
|
|
||||||
|
ASSERT(0 != ElementStorage);
|
||||||
Element.Identifier = Identifier;
|
Element.Identifier = Identifier;
|
||||||
Element.Context = Context;
|
Element.Context = Context;
|
||||||
|
|
||||||
@ -437,8 +445,6 @@ VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
|||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Resource));
|
|
||||||
|
|
||||||
BOOLEAN Deleted;
|
BOOLEAN Deleted;
|
||||||
|
|
||||||
Deleted = RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
Deleted = RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
|
@ -375,9 +375,9 @@ typedef struct
|
|||||||
KSPIN_LOCK ExpirationLock;
|
KSPIN_LOCK ExpirationLock;
|
||||||
WORK_QUEUE_ITEM ExpirationWorkItem;
|
WORK_QUEUE_ITEM ExpirationWorkItem;
|
||||||
BOOLEAN ExpirationInProgress;
|
BOOLEAN ExpirationInProgress;
|
||||||
|
FAST_MUTEX GenericTableFastMutex;
|
||||||
RTL_AVL_TABLE GenericTable;
|
RTL_AVL_TABLE GenericTable;
|
||||||
PVOID GenericTableElementStorage;
|
PVOID GenericTableElementStorage;
|
||||||
ERESOURCE Resource;
|
|
||||||
} FSP_FSVOL_DEVICE_EXTENSION;
|
} FSP_FSVOL_DEVICE_EXTENSION;
|
||||||
static inline
|
static inline
|
||||||
FSP_DEVICE_EXTENSION *FspDeviceExtension(PDEVICE_OBJECT DeviceObject)
|
FSP_DEVICE_EXTENSION *FspDeviceExtension(PDEVICE_OBJECT DeviceObject)
|
||||||
@ -401,6 +401,8 @@ VOID FspDeviceInitComplete(PDEVICE_OBJECT DeviceObject);
|
|||||||
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceDelete(PDEVICE_OBJECT DeviceObject);
|
||||||
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
BOOLEAN FspDeviceRetain(PDEVICE_OBJECT DeviceObject);
|
||||||
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
VOID FspDeviceRelease(PDEVICE_OBJECT DeviceObject);
|
||||||
|
VOID FspFsvolDeviceLockContext(PDEVICE_OBJECT DeviceObject);
|
||||||
|
VOID FspFsvolDeviceUnlockContext(PDEVICE_OBJECT DeviceObject);
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier);
|
||||||
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *ElementStorage, PBOOLEAN PInserted);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user