From e50c9ff649230ef18ea592c13b64b7359781164f Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Thu, 10 Nov 2016 15:03:58 -0800 Subject: [PATCH] sys: IRP_MJ_CREATE: oplock support --- src/sys/create.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sys/create.c b/src/sys/create.c index 9198fec9..d366f8fe 100644 --- a/src/sys/create.c +++ b/src/sys/create.c @@ -1040,10 +1040,15 @@ static NTSTATUS FspFsvolCreateSharingViolationWork( KEVENT Event; NTSTATUS Result; - KeInitializeEvent(&Event, NotificationEvent, FALSE); - FspFileNodeAcquireShared(FileNode, Main); + Result = FspCheckOplockEx(FspFileNodeAddrOfOplock(FileNode), Irp, + OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY, 0, 0, 0); + if (!NT_SUCCESS(Result)) + goto exit; + + KeInitializeEvent(&Event, NotificationEvent, FALSE); + if (FsRtlCurrentBatchOplock(FspFileNodeAddrOfOplock(FileNode))) { Result = FspCheckOplock(FspFileNodeAddrOfOplock(FileNode), Irp, @@ -1053,10 +1058,11 @@ static NTSTATUS FspFsvolCreateSharingViolationWork( KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, 0); if (STATUS_SUCCESS == Irp->IoStatus.Status) OpbatchBreakUnderway = TRUE; + + KeResetEvent(&Event); } } - KeResetEvent(&Event); Result = FspOplockBreakH(FspFileNodeAddrOfOplock(FileNode), Irp, 0, &Event, FspFsvolCreateSharingViolationOplockComplete, 0); if (STATUS_PENDING == Result) @@ -1066,6 +1072,7 @@ static NTSTATUS FspFsvolCreateSharingViolationWork( StatusSharingViolation = FALSE; } +exit: FspFileNodeRelease(FileNode, Main); FspFileNodeClose(FileNode, IrpSp->FileObject, FALSE, TRUE);