Oplocks: FltInitializeOplock is NOT allocating memory

Hi,

OS: Windows Server 2008 R2 (64-bit)

I am trying to add support for Oplocks in my filter driver (layered fs) by calling
FltInitializeOplock during FSCTL_REQUEST_OPLOCK_XXX cases. But this function is NOT returning any memory allocated (this function doesn’t return any error code). All most all of WLK Oplock test cases are failing and probably due to this.

Appreciate if any pointers can be given. I have spend enough time checking the variables that i am passing seems to be straightforward. (In the following code fcb contains
variable declared as OPLOCK Oplock;

if (!fcb->Oplock) {

FltInitializeOplock(&fcb->Oplock);
}

ASSERT( fcb->Oplock != NULL);

Function declaration from msdn:

VOID FltInitializeOplock(
Out POPLOCK Oplock
);

I have found that in some cases if FsRtlOplockFsctrl() intializes the Oplock by allocating memroy.
Which seems strange considering this variable is a input parameter in this function.

Hello.

You should call FltInitializeOplock when your fcb is created.

Oplock package will allocate memory for the OPLOCK structure when it will be
required, usually on FSCTRL_REQUEST_OPLOCK, at this point you should call
FltOplockFsctrl.

Best regards,
Alexey Barabash

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Friday, March 08, 2013 2:17 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Oplocks: FltInitializeOplock is NOT allocating memory

Hi,

OS: Windows Server 2008 R2 (64-bit)

I am trying to add support for Oplocks in my filter driver (layered fs) by
calling FltInitializeOplock during FSCTL_REQUEST_OPLOCK_XXX cases. But this
function is NOT returning any memory allocated (this function doesn’t return
any error code). All most all of WLK Oplock test cases are failing and
probably due to this.

Appreciate if any pointers can be given. I have spend enough time checking
the variables that i am passing seems to be straightforward. (In the
following code fcb contains variable declared as OPLOCK Oplock;

if (!fcb->Oplock) {

FltInitializeOplock(&fcb->Oplock);
}

ASSERT( fcb->Oplock != NULL);

Function declaration from msdn:

VOID FltInitializeOplock(
Out POPLOCK Oplock
);


NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Hi Alexey,

I do have FltInitializeOplock during FCB creation. And this extra check in FSCTL is to make sure that
was allocated. If FltOplockFsctrl() allocates the memory instead of FltIntiailzieOplock that might explain the behavior. I will investigate further why test cases are failing from test suite even though I am merely calling FltOPlockFsctrl (ruling memory allocation problem)