Bug fixes from Alex:

- CDFS should enter a critical region before acquiring a resource.
- "Fix" resource assert during installation by adding some padding at the end of the VFAT FCB header -- corruption happens at pad 51.
- Once we detect corruption at pad 51, skip the FCB instead of attempting to flush it.
- Fix a serious bug in our detection of incorrect resource usage while APCs are not disabled.
- Fix a serious bug which caused shared resources not to wake up waiters when it was released, and which cause it to wake up waiters when there were still active locks held.
 
New ERESOURCE implementation by Aleksey (thanks to Alex for providing the information required)
- Remove ERESOURCE_XP concept, and fix the three incorrect and different definitions of the ERESOURCE structure.
- Fix the ERESOURCE implementation to use the new Vista ERESOURCE type. Two main changes:
   * The count is now a 32-bit count called ActiveEntries. ActiveCount is now simply a flip-flop bit (0/1) for backward compatibility (we set to 0 when active entries is 0, and 1 when active entries is > 0)
   * Instead of caching two owners, we only cache one owner, in the OwnerEntry field.
- Optimize some search algorithms slightly (just better code).
- Remove duplicated code for ExReleaseResourceLite and call ExReleaseResourceForThreadLite instead. Alex says this is ok.

svn path=/trunk/; revision=33111
This commit is contained in:
Aleksey Bragin 2008-04-22 20:44:34 +00:00
parent 64a5765676
commit e74ec0acfc
6 changed files with 417 additions and 549 deletions

View file

@ -277,11 +277,13 @@ CdfsCreate(PDEVICE_OBJECT DeviceObject,
DeviceExt = DeviceObject->DeviceExtension;
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&DeviceExt->DirResource,
TRUE);
Status = CdfsCreateFile(DeviceObject,
Irp);
ExReleaseResourceLite(&DeviceExt->DirResource);
KeLeaveCriticalRegion();
ByeBye:
Irp->IoStatus.Status = Status;

View file

@ -52,6 +52,7 @@ NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb)
ListEntry = ListEntry->Flink;
if (!vfatFCBIsDirectory(Fcb))
{
if (Fcb->PadPad51) continue; // Corrupt FCB
ExAcquireResourceExclusiveLite(&Fcb->MainResource, TRUE);
Status = VfatFlushFile(DeviceExt, Fcb);
ExReleaseResourceLite (&Fcb->MainResource);

View file

@ -322,6 +322,21 @@ typedef struct _VFATFCB
{
/* FCB header required by ROS/NT */
FSRTL_COMMON_FCB_HEADER RFCB;
ULONG PadPad;
ULONG PadPad2;
ULONG PadPad3;
ULONG PadPad4;
ULONG PadPad5;
ULONG PadPad50;
ULONG PadPad51;
ULONG PadPad52;
ULONG PadPad53;
ULONG PadPad54;
ULONG PadPad55;
ULONG PadPad56;
ULONG PadPad6;
ULONG PadPad7;
ULONG PadPad8;
SECTION_OBJECT_POINTERS SectionObjectPointers;
ERESOURCE MainResource;
ERESOURCE PagingIoResource;

View file

@ -3279,22 +3279,25 @@ typedef struct _OWNER_ENTRY {
#define RESOURCE_HASH_TABLE_SIZE 64
typedef struct _ERESOURCE {
LIST_ENTRY SystemResourcesList;
POWNER_ENTRY OwnerTable;
SHORT ActiveCount;
USHORT Flag;
volatile PKSEMAPHORE SharedWaiters;
volatile PKEVENT ExclusiveWaiters;
OWNER_ENTRY OwnerThreads[2];
ULONG ContentionCount;
USHORT NumberOfSharedWaiters;
USHORT NumberOfExclusiveWaiters;
_ANONYMOUS_UNION union {
PVOID Address;
ULONG_PTR CreatorBackTraceIndex;
} DUMMYUNIONNAME;
KSPIN_LOCK SpinLock;
typedef struct _ERESOURCE
{
LIST_ENTRY SystemResourcesList;
POWNER_ENTRY OwnerTable;
SHORT ActiveCount;
USHORT Flag;
volatile PKSEMAPHORE SharedWaiters;
volatile PKEVENT ExclusiveWaiters;
OWNER_ENTRY OwnerEntry;
ULONG ActiveEntries;
ULONG ContentionCount;
ULONG NumberOfSharedWaiters;
ULONG NumberOfExclusiveWaiters;
union
{
PVOID Address;
ULONG_PTR CreatorBackTraceIndex;
};
KSPIN_LOCK SpinLock;
} ERESOURCE, *PERESOURCE;
typedef struct _DEVOBJ_EXTENSION

View file

@ -376,29 +376,6 @@ typedef BOOLEAN
IN PVOID Context
);
//
// Compatibility with Windows XP Drivers using ERESOURCE
//
typedef struct _ERESOURCE_XP
{
LIST_ENTRY SystemResourcesList;
POWNER_ENTRY OwnerTable;
SHORT ActiveCount;
USHORT Flag;
PKSEMAPHORE SharedWaiters;
PKEVENT ExclusiveWaiters;
OWNER_ENTRY OwnerThreads[2];
ULONG ContentionCount;
USHORT NumberOfSharedWaiters;
USHORT NumberOfExclusiveWaiters;
union
{
PVOID Address;
ULONG_PTR CreatorBackTraceIndex;
};
KSPIN_LOCK SpinLock;
} ERESOURCE_XP, *PERESOURCE_XP;
//
// Executive Work Queue Structures
//

File diff suppressed because it is too large Load diff