Author: ion
Date: Thu Aug 17 03:31:39 2006
New Revision: 23591
URL:
http://svn.reactos.org/svn/reactos?rev=23591&view=rev
Log:
- Add NCB lock macros.
- Implement CmpDereferenceNcbWithLock, CmpFreeDelayItem.
Modified:
branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h
branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h Thu Aug 17 03:31:39 2006
@@ -80,3 +80,20 @@
(k)->ConvKey).Lock); \
}
+//
+// Exclusively acquires an NCB
+//
+#define CmpAcquireNcbLockExclusive(n) \
+{ \
+ ExAcquirePushLockExclusive(GET_HASH_ENTRY(CmpNameCacheTable, \
+ (n)->ConvKey).Lock); \
+}
+
+//
+// Releases an exlusively or shared acquired NCB
+//
+#define CmpReleaseNcbLock(k) \
+{ \
+ ExReleasePushLock(GET_HASH_ENTRY(CmpNameCacheTable, \
+ (k)->ConvKey).Lock); \
+}
Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c Thu Aug 17 03:31:39 2006
@@ -290,6 +290,79 @@
}
VOID
+CmpDereferenceNcbWithLock(IN PCM_NAME_CONTROL_BLOCK Ncb)
+{
+ PCM_NAME_HASH Current, Next;
+
+ /* Lock the NCB */
+ CmpAcquireNcbLockExclusive(Ncb);
+
+ /* Decrease the reference count */
+ if (!(--Ncb->RefCount))
+ {
+ /* Find the NCB in the table */
+ Next = GET_HASH_ENTRY(CmpNameCacheTable, Ncb->ConvKey).Entry;
+ while (TRUE)
+ {
+ /* Check the current entry */
+ Current = Next;
+ ASSERT(Current != NULL);
+ if (Current == &Ncb->NameHash) break;
+
+ /* Get to the next one */
+ Next = Current->NextHash;
+ }
+
+ /* Found it, now unlink it and free it */
+ Current->NextHash = Next->NextHash;
+ ExFreePool(Ncb);
+ }
+
+ /* Release the lock */
+ CmpReleaseNcbLock(Ncb);
+}
+
+VOID
+NTAPI
+CmpFreeDelayItem(PVOID Entry)
+{
+ PCM_DELAYED_CLOSE_ENTRY AllocEntry = (PCM_DELAYED_CLOSE_ENTRY)Entry;
+ PCM_DELAYED_CLOSE_ENTRY *AllocTable;
+ PCM_ALLOC_PAGE AllocPage;
+ ULONG i;
+ PAGED_CODE();
+
+ /* Lock the table */
+ KeAcquireGuardedMutex(&CmpDelayAllocBucketLock);
+
+ /* Add the entry at the end */
+ InsertTailList(&CmpFreeDelayItemsListHead, &AllocEntry->DelayedLRUList);
+
+ /* Get the alloc page */
+ AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
+ ASSERT(AllocPage->FreeCount != CM_DELAYS_PER_PAGE);
+
+ /* Increase the number of free items */
+ if (++AllocPage->FreeCount == CM_DELAYS_PER_PAGE)
+ {
+ /* Page is totally free now, loop each entry */
+ AllocTable = (PCM_DELAYED_CLOSE_ENTRY*)&AllocPage->AllocPage;
+ for (i = CM_DELAYS_PER_PAGE; i; i--)
+ {
+ /* Get the entry and unlink it */
+ AllocEntry = AllocTable[i];
+ RemoveEntryList(&AllocEntry->DelayedLRUList);
+ }
+
+ /* Now free the page */
+ ExFreePool(AllocPage);
+ }
+
+ /* Release the lock */
+ KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
+}
+
+VOID
NTAPI
CmpRemoveFromDelayedClose(IN PCM_KEY_CONTROL_BLOCK Kcb)
{