ReactOS  0.4.15-dev-1018-g0695ecb
lock.c File Reference
#include "classp.h"
#include "debug.h"
Include dependency graph for lock.c:

Go to the source code of this file.

Classes

struct  _REMOVE_TRACKING_BLOCK
 

Typedefs

typedef struct _REMOVE_TRACKING_BLOCK REMOVE_TRACKING_BLOCK
 
typedef struct _REMOVE_TRACKING_BLOCKPREMOVE_TRACKING_BLOCK
 

Functions

ULONG NTAPI ClassAcquireRemoveLockEx (_In_ PDEVICE_OBJECT DeviceObject, _In_ PVOID Tag, _In_ PCSTR File, _In_ ULONG Line)
 
VOID NTAPI ClassReleaseRemoveLock (_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
 
VOID NTAPI ClassCompleteRequest (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
 
RTL_GENERIC_COMPARE_RESULTS NTAPI RemoveTrackingCompareRoutine (PRTL_GENERIC_TABLE Table, PVOID FirstStruct, PVOID SecondStruct)
 
PVOID NTAPI RemoveTrackingAllocateRoutine (PRTL_GENERIC_TABLE Table, CLONG ByteSize)
 
VOID NTAPI RemoveTrackingFreeRoutine (PRTL_GENERIC_TABLE Table, PVOID Buffer)
 
VOID ClasspInitializeRemoveTracking (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClasspUninitializeRemoveTracking (_In_ PDEVICE_OBJECT DeviceObject)
 

Variables

LONG LockHighWatermark = 0
 
LONG LockLowWatermark = 0
 
LONG MaxLockedMinutes = 5
 

Typedef Documentation

◆ PREMOVE_TRACKING_BLOCK

◆ REMOVE_TRACKING_BLOCK

Function Documentation

◆ ClassAcquireRemoveLockEx()

ULONG NTAPI ClassAcquireRemoveLockEx ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PVOID  Tag,
_In_ PCSTR  File,
_In_ ULONG  Line 
)

Definition at line 115 of file lock.c.

123  :28104)
124 #endif
125 {
127  BOOLEAN rundownAcquired;
128  PEX_RUNDOWN_REF_CACHE_AWARE removeLockRundown = NULL;
129 
130  //
131  // Grab the remove lock
132  //
133 
134  #if DBG
135 
136  LONG lockValue;
137 
138  lockValue = InterlockedIncrement(&commonExtension->RemoveLock);
139 
140 
141  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_LOCK, "ClassAcquireRemoveLock: "
142  "Acquired for Object %p & irp %p - count is %d\n",
143  DeviceObject, Tag, lockValue));
144 
145  NT_ASSERTMSG("ClassAcquireRemoveLock - lock value was negative : ",
146  (lockValue > 0));
147 
148  NT_ASSERTMSG("RemoveLock increased to meet LockHighWatermark",
149  ((LockHighWatermark == 0) ||
150  (lockValue != LockHighWatermark)));
151 
152  if (commonExtension->IsRemoved != REMOVE_COMPLETE) {
153  PRTL_GENERIC_TABLE removeTrackingList = NULL;
154  REMOVE_TRACKING_BLOCK trackingBlock;
155  PREMOVE_TRACKING_BLOCK insertedTrackingBlock = NULL;
156  BOOLEAN newElement = FALSE;
157 
158  KIRQL oldIrql;
159 
160  trackingBlock.Tag = Tag;
161 
162  trackingBlock.File = File;
163  trackingBlock.Line = Line;
164 
165  KeQueryTickCount((&trackingBlock.TimeLocked));
166 
167  KeAcquireSpinLock(&commonExtension->RemoveTrackingSpinlock,
168  &oldIrql);
169 
170  removeTrackingList = commonExtension->RemoveTrackingList;
171 
172  if (removeTrackingList != NULL) {
173  insertedTrackingBlock = RtlInsertElementGenericTable(removeTrackingList,
174  &trackingBlock,
175  sizeof(REMOVE_TRACKING_BLOCK),
176  &newElement);
177  }
178 
179  if (insertedTrackingBlock != NULL) {
180  if (!newElement) {
181  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassAcquireRemoveLock: "
182  "already tracking Tag %p\n", Tag));
183  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassAcquireRemoveLock: "
184  "acquired in file %s on line %d\n",
185  insertedTrackingBlock->File, insertedTrackingBlock->Line));
186 // NT_ASSERT(FALSE);
187 
188  }
189  } else {
190  commonExtension->RemoveTrackingUntrackedCount++;
191 
192  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_LOCK, ">>>>>ClassAcquireRemoveLock: "
193  "Cannot track Tag %p - currently %d untracked requsts\n",
194  Tag, commonExtension->RemoveTrackingUntrackedCount));
195  }
196 
197  KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, oldIrql);
198  }
199  #else
200 
204 
205  #endif
206 
207  removeLockRundown = (PEX_RUNDOWN_REF_CACHE_AWARE)
208  ((PCHAR)commonExtension->PrivateCommonData + sizeof(CLASS_PRIVATE_COMMON_DATA));
209  rundownAcquired = ExAcquireRundownProtectionCacheAware(removeLockRundown);
210  if (!rundownAcquired) {
211  InterlockedIncrement((volatile LONG*) &(commonExtension->PrivateCommonData->RemoveLockFailAcquire));
212  TracePrint((TRACE_LEVEL_VERBOSE,
213  TRACE_FLAG_LOCK,
214  "ClassAcquireRemoveLockEx: RemoveLockRundown acquisition failed"
215  "RemoveLockFailAcquire = %d\n",
216  commonExtension->PrivateCommonData->RemoveLockFailAcquire));
217  }
218 
219  return (commonExtension->IsRemoved);
220 }
signed char * PCHAR
Definition: retypes.h:7
#define NT_ASSERTMSG
Definition: rtlfuncs.h:3313
#define REMOVE_COMPLETE
Definition: classpnp.h:98
struct _EX_RUNDOWN_REF_CACHE_AWARE * PEX_RUNDOWN_REF_CACHE_AWARE
Definition: extypes.h:186
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG LockHighWatermark
Definition: lock.c:33
struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA
Definition: classpnp.h:285
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
long LONG
Definition: pedump.c:60
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
LARGE_INTEGER TimeLocked
Definition: lock.c:42
Definition: ncftp.h:79
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define InterlockedIncrement
Definition: armddk.h:53
PCLASS_PRIVATE_COMMON_DATA PrivateCommonData
Definition: classpnp.h:633
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
Definition: File.h:15
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_reads_bytes_(BufferSize) PVOID Buffer, _In_ CLONG BufferSize, _Out_opt_ PBOOLEAN NewElement)
struct Line Line

◆ ClassCompleteRequest()

VOID NTAPI ClassCompleteRequest ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_ CCHAR  PriorityBoost 
)

Definition at line 401 of file lock.c.

406 {
407  #if DBG
409 
410  PRTL_GENERIC_TABLE removeTrackingList = NULL;
411  REMOVE_TRACKING_BLOCK searchDataBlock;
412  PREMOVE_TRACKING_BLOCK foundTrackingBlock;
413 
414  KIRQL oldIrql;
415 
416  KeAcquireSpinLock(&commonExtension->RemoveTrackingSpinlock, &oldIrql);
417 
418  removeTrackingList = commonExtension->RemoveTrackingList;
419 
420  if (removeTrackingList != NULL)
421  {
422  searchDataBlock.Tag = Irp;
423 
424  foundTrackingBlock = RtlLookupElementGenericTable(removeTrackingList, &searchDataBlock);
425 
426  if(foundTrackingBlock != NULL) {
427 
428  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassCompleteRequest: "
429  "Irp %p completed while still holding the remove lock\n", Irp));
430  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassCompleteRequest: "
431  "Lock acquired in file %s on line %d\n",
432  foundTrackingBlock->File, foundTrackingBlock->Line));
433  NT_ASSERT(FALSE);
434  }
435  }
436 
437  KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, oldIrql);
438  #endif
439 
440 
442 
444  return;
445 } // end ClassCompleteRequest()
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
_In_ CCHAR PriorityBoost
Definition: iofuncs.h:763
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _IRQL_requires_max_(), _Success_(), ClassCheckVerifyComplete(), ClassCreateClose(), ClassDeviceControl(), ClassDeviceControlDispatch(), ClassDeviceGetLBProvisioningResources(), ClassDeviceHwFirmwareActivateProcess(), ClassDeviceHwFirmwareDownloadProcess(), ClassDeviceHwFirmwareGetInfoProcess(), ClassDispatchPnp(), ClassDispatchPower(), ClassInternalIoControl(), ClassIoCompleteAssociated(), ClassMinimalPowerHandler(), ClasspAccessAlignmentProperty(), ClasspCompleteOffloadRequest(), ClasspDeviceGetLBAStatus(), ClasspDeviceLBProvisioningProperty(), ClasspDeviceMediaTypeProperty(), ClasspDeviceSeekPenaltyProperty(), ClasspDeviceTrimProcess(), ClasspDeviceTrimProperty(), ClasspDuidQueryProperty(), ClasspMcnControl(), ClasspPersistentReserve(), ClasspPowerDownCompletion(), ClasspPowerHandler(), ClasspPowerUpCompletion(), ClasspPriorityHint(), ClasspStartIo(), ClasspStorageEventNotification(), ClasspWriteCacheProperty(), ClassReadWrite(), ClassShutdownFlush(), ClassSystemControl(), ClassWmiCompleteRequest(), DiskDeviceControl(), DiskFlushComplete(), DiskIoctlVerifyThread(), DiskShutdownFlush(), ScsiFlopDeviceControl(), and TransferPktComplete().

◆ ClasspInitializeRemoveTracking()

VOID ClasspInitializeRemoveTracking ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 500 of file lock.c.

503 {
505 
506  #if DBG
507  KeInitializeSpinLock(&commonExtension->RemoveTrackingSpinlock);
508 
509  commonExtension->RemoveTrackingList = ExAllocatePoolWithTag(NonPagedPoolNx, sizeof(RTL_GENERIC_TABLE), CLASS_TAG_LOCK_TRACKING);
510 
511  if (commonExtension->RemoveTrackingList != NULL)
512  {
517  NULL);
518  }
519  #else
520 
522 
523  commonExtension->RemoveTrackingSpinlock = (ULONG_PTR) -1;
524  commonExtension->RemoveTrackingList = NULL;
525  #endif
526 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
VOID NTAPI RemoveTrackingFreeRoutine(PRTL_GENERIC_TABLE Table, PVOID Buffer)
Definition: lock.c:489
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
RTL_GENERIC_COMPARE_RESULTS NTAPI RemoveTrackingCompareRoutine(PRTL_GENERIC_TABLE Table, PVOID FirstStruct, PVOID SecondStruct)
Definition: lock.c:450
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define ULONG_PTR
Definition: config.h:101
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603
#define CLASS_TAG_LOCK_TRACKING
Definition: classpnp.h:88
PVOID NTAPI RemoveTrackingAllocateRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
Definition: lock.c:477

◆ ClasspUninitializeRemoveTracking()

VOID ClasspUninitializeRemoveTracking ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 529 of file lock.c.

532 {
533  #if DBG
535  PRTL_GENERIC_TABLE removeTrackingList = commonExtension->RemoveTrackingList;
536 
537  ASSERTMSG("Removing the device while still holding remove locks",
538  commonExtension->RemoveTrackingUntrackedCount == 0 &&
539  removeTrackingList != NULL ? RtlNumberGenericTableElements(removeTrackingList) == 0 : TRUE);
540 
541  if (removeTrackingList != NULL)
542  {
543  KIRQL oldIrql;
544  KeAcquireSpinLock(&commonExtension->RemoveTrackingSpinlock, &oldIrql);
545 
546  FREE_POOL(removeTrackingList);
547  commonExtension->RemoveTrackingList = NULL;
548 
549  KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, oldIrql);
550  }
551 
552  #else
553 
555  #endif
556 }
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(_In_ PRTL_GENERIC_TABLE Table)
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define FREE_POOL(_PoolPtr)
Definition: classpnp.h:63
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603

◆ ClassReleaseRemoveLock()

VOID NTAPI ClassReleaseRemoveLock ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_opt_ PIRP  Tag 
)

Definition at line 251 of file lock.c.

257  :28103)
258 #endif
259 {
261  LONG lockValue;
262  LONG oldValue;
263  PEX_RUNDOWN_REF_CACHE_AWARE removeLockRundown = NULL;
264 
265  #if DBG
266  PRTL_GENERIC_TABLE removeTrackingList = NULL;
267  REMOVE_TRACKING_BLOCK searchDataBlock;
268 
269  BOOLEAN found = FALSE;
270 
271  BOOLEAN isRemoved = (commonExtension->IsRemoved == REMOVE_COMPLETE);
272 
273  KIRQL oldIrql;
274 
275  if (isRemoved) {
276  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_LOCK, "ClassReleaseRemoveLock: REMOVE_COMPLETE set; this should never happen"));
277  InterlockedDecrement(&(commonExtension->RemoveLock));
278  return;
279  }
280 
281  KeAcquireSpinLock(&commonExtension->RemoveTrackingSpinlock,
282  &oldIrql);
283 
284  removeTrackingList = commonExtension->RemoveTrackingList;
285 
286  if (removeTrackingList != NULL) {
287  searchDataBlock.Tag = Tag;
288  found = RtlDeleteElementGenericTable(removeTrackingList, &searchDataBlock);
289  }
290 
291  if (!found) {
292  if(commonExtension->RemoveTrackingUntrackedCount == 0) {
293  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassReleaseRemoveLock: "
294  "Couldn't find Tag %p in the lock tracking list\n", Tag));
295  //
296  // This might happen if the device is being removed and the tracking list
297  // has already been freed. Don't assert if that is the case.
298  //
299  NT_ASSERT((removeTrackingList == NULL) && (commonExtension->IsRemoved != NO_REMOVE));
300  } else {
301  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassReleaseRemoveLock: "
302  "Couldn't find Tag %p in the lock tracking list - "
303  "may be one of the %d untracked requests still outstanding\n",
304  Tag, commonExtension->RemoveTrackingUntrackedCount));
305 
306  commonExtension->RemoveTrackingUntrackedCount--;
307  NT_ASSERT(commonExtension->RemoveTrackingUntrackedCount >= 0);
308  }
309  }
310 
311  KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock,
312  oldIrql);
313 
314  lockValue = InterlockedDecrement(&commonExtension->RemoveLock);
315 
316  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_LOCK, "ClassReleaseRemoveLock: "
317  "Released for Object %p & irp %p - count is %d\n",
318  DeviceObject, Tag, lockValue));
319 
320  NT_ASSERT(lockValue >= 0);
321 
322  NT_ASSERTMSG("RemoveLock decreased to meet LockLowWatermark",
323  ((LockLowWatermark == 0) || !(lockValue == LockLowWatermark)));
324 
325  if (lockValue == 0) {
326 
327  NT_ASSERT(commonExtension->IsRemoved);
328 
329  //
330  // The device needs to be removed. Signal the remove event
331  // that it's safe to go ahead.
332  //
333 
334  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_LOCK, "ClassReleaseRemoveLock: "
335  "Release for object %p & irp %p caused lock to go to zero\n",
336  DeviceObject, Tag));
337 
338  }
339 
340  #else
341 
343 
344  #endif
345 
346  //
347  // Decrement the RemoveLockFailAcquire by 1 when RemoveLockFailAcquire is non-zero.
348  // Release the RemoveLockRundown only when RemoveLockFailAcquire is zero.
349  //
350 
351  oldValue = 1;
352  lockValue = commonExtension->PrivateCommonData->RemoveLockFailAcquire;
353  while (lockValue != 0) {
354  oldValue =
356  lockValue - 1,
357  lockValue);
358 
359  if (oldValue == lockValue) {
360  break;
361  }
362 
363  lockValue = oldValue;
364  }
365 
366  if (lockValue == 0) {
367  removeLockRundown = (PEX_RUNDOWN_REF_CACHE_AWARE)
368  ((PCHAR)commonExtension->PrivateCommonData + sizeof(CLASS_PRIVATE_COMMON_DATA));
369  ExReleaseRundownProtectionCacheAware(removeLockRundown);
370  }
371 
372  return;
373 }
signed char * PCHAR
Definition: retypes.h:7
#define NT_ASSERTMSG
Definition: rtlfuncs.h:3313
#define REMOVE_COMPLETE
Definition: classpnp.h:98
struct _EX_RUNDOWN_REF_CACHE_AWARE * PEX_RUNDOWN_REF_CACHE_AWARE
Definition: extypes.h:186
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define InterlockedCompareExchange
Definition: interlocked.h:104
struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA
Definition: classpnp.h:285
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
long LONG
Definition: pedump.c:60
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
LONG LockLowWatermark
Definition: lock.c:34
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NO_REMOVE
Definition: classpnp.h:96
#define InterlockedDecrement
Definition: armddk.h:52
NTKERNELAPI VOID FASTCALL ExReleaseRundownProtectionCacheAware(_Inout_ PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
PCLASS_PRIVATE_COMMON_DATA PrivateCommonData
Definition: classpnp.h:633
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _Function_class_(), _IRQL_requires_max_(), _Success_(), ClassAsynchronousCompletion(), ClassCheckVerifyComplete(), ClassCreateClose(), ClassDeviceControl(), ClassDeviceControlDispatch(), ClassDeviceGetLBProvisioningResources(), ClassDeviceHwFirmwareActivateProcess(), ClassDeviceHwFirmwareDownloadProcess(), ClassDeviceHwFirmwareGetInfoProcess(), ClassDispatchPnp(), ClassDispatchPower(), ClassInternalIoControl(), ClassIoComplete(), ClassIoCompleteAssociated(), ClassMinimalPowerHandler(), ClasspAccessAlignmentProperty(), ClasspCompleteOffloadRequest(), ClasspDeviceGetLBAStatus(), ClasspDeviceLBProvisioningProperty(), ClasspDeviceLockFailurePowerIrpCompletion(), ClasspDeviceMediaTypeProperty(), ClasspDeviceSeekPenaltyProperty(), ClasspDeviceTrimProcess(), ClasspDeviceTrimProperty(), ClasspDuidQueryProperty(), ClasspFailurePredict(), ClasspInitializeGesn(), ClasspMcnControl(), ClasspMediaChangeDetectionCompletion(), ClasspPersistentReserve(), ClasspPowerDownCompletion(), ClasspPowerHandler(), ClasspPowerUpCompletion(), ClasspPrepareMcnIrp(), ClasspPriorityHint(), ClasspStartIo(), ClasspStorageEventNotification(), ClasspWriteCacheProperty(), ClassReadWrite(), ClassReleaseQueueCompletion(), ClassShutdownFlush(), ClassSystemControl(), ClassWmiCompleteRequest(), CleanupTransferPacketToWorkingSetSizeWorker(), DiskDeviceControl(), DiskFlushComplete(), DiskInfoExceptionCheck(), DiskInfoExceptionComplete(), DiskIoctlVerifyThread(), DiskReregWorker(), DiskShutdownFlush(), EnqueueFreeTransferPacket(), ScsiFlopDeviceControl(), and TransferPktComplete().

◆ RemoveTrackingAllocateRoutine()

PVOID NTAPI RemoveTrackingAllocateRoutine ( PRTL_GENERIC_TABLE  Table,
CLONG  ByteSize 
)

Definition at line 477 of file lock.c.

481 {
483 
484  return ExAllocatePoolWithTag(NonPagedPoolNx, ByteSize, CLASS_TAG_LOCK_TRACKING);
485 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CLASS_TAG_LOCK_TRACKING
Definition: classpnp.h:88
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:393

Referenced by ClasspInitializeRemoveTracking().

◆ RemoveTrackingCompareRoutine()

RTL_GENERIC_COMPARE_RESULTS NTAPI RemoveTrackingCompareRoutine ( PRTL_GENERIC_TABLE  Table,
PVOID  FirstStruct,
PVOID  SecondStruct 
)

Definition at line 450 of file lock.c.

455 {
456  PVOID tag1, tag2;
457 
459 
460  tag1 = ((PREMOVE_TRACKING_BLOCK)FirstStruct)->Tag;
461  tag2 = ((PREMOVE_TRACKING_BLOCK)SecondStruct)->Tag;
462 
463  if (tag1 < tag2)
464  {
465  return GenericLessThan;
466  }
467  else if (tag1 > tag2)
468  {
469  return GenericGreaterThan;
470  }
471 
472  return GenericEqual;
473 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
struct _REMOVE_TRACKING_BLOCK * PREMOVE_TRACKING_BLOCK
_IRQL_requires_same_ _In_ PVOID _In_ PVOID SecondStruct
Definition: rtltypes.h:383
_IRQL_requires_same_ _In_ PVOID FirstStruct
Definition: rtltypes.h:383

Referenced by ClasspInitializeRemoveTracking().

◆ RemoveTrackingFreeRoutine()

VOID NTAPI RemoveTrackingFreeRoutine ( PRTL_GENERIC_TABLE  Table,
PVOID  Buffer 
)

Definition at line 489 of file lock.c.

493 {
495 
496  FREE_POOL(Buffer);
497 }
ASMGENDATA Table[]
Definition: genincdata.c:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: bufpool.h:45
#define FREE_POOL(_PoolPtr)
Definition: classpnp.h:63

Referenced by ClasspInitializeRemoveTracking().

Variable Documentation

◆ LockHighWatermark

LONG LockHighWatermark = 0

Definition at line 33 of file lock.c.

Referenced by ClassAcquireRemoveLockEx().

◆ LockLowWatermark

LONG LockLowWatermark = 0

Definition at line 34 of file lock.c.

Referenced by ClassReleaseRemoveLock().

◆ MaxLockedMinutes

LONG MaxLockedMinutes = 5

Definition at line 35 of file lock.c.

Referenced by IoInitializeRemoveLockEx().