From cd28edf6a9a604569b01059aa607a3628db5c44c Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Tue, 12 Jan 2016 13:50:41 -0800 Subject: [PATCH] sys: IRP_MJ_CREATE refactoring --- src/sys/create.c | 21 ++++++++++----------- src/sys/driver.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/sys/create.c b/src/sys/create.c index 23c15f7d..1c0ce99c 100644 --- a/src/sys/create.c +++ b/src/sys/create.c @@ -348,6 +348,7 @@ NTSTATUS FspFsvolCreatePrepare( return Result; } + /* no longer post a Close if the IRP gets cancelled */ FspIopRequestContext(Request, RequestFileObject) = 0; /* see what the MM thinks about all this */ @@ -357,8 +358,8 @@ NTSTATUS FspFsvolCreatePrepare( { FspFileContextPgioUnlock(FsContext); - FspFileContextClose(FsContext, FileObject); FspFsvolCreatePostClose(FsContext, (UINT_PTR)FileObject->FsContext2); + FspFileContextClose(FsContext, FileObject); return STATUS_USER_MAPPED_FILE; } @@ -505,12 +506,11 @@ VOID FspFsvolCreateComplete( if (!MmFlushImageSection(&FsContext->NonPaged->SectionObjectPointers, MmFlushForWrite)) { - Result = DeleteOnClose ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION; - - FspFileContextClose(FsContext, FileObject); FspFsvolCreatePostClose(FsContext, Response->Rsp.Create.Opened.UserContext2); + FspFileContextClose(FsContext, FileObject); + Result = DeleteOnClose ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION; FSP_RETURN(); } } @@ -531,16 +531,17 @@ VOID FspFsvolCreateComplete( FspIrpRequest(Irp) = 0; FspIopDeleteRequest(Request); - /* create the Create2 request; MustSucceed because we must either overwrite or close */ + /* create the Overwrite request; MustSucceed because we must either overwrite or close */ FspIopCreateRequestFunnel(Irp, FsvolDeviceExtension->VolumeParams.FileNameRequired ? &FsContext->FileName : 0, 0, FspFsvolCreateOverwriteRequestFini, TRUE, &Request); - /* associate the FsContext with the Create2 request */ + /* associate the FsContext and FileObject with the Overwrite request */ FspIopRequestContext(Request, RequestFsContext) = FsContext; + FspIopRequestContext(Request, RequestFileObject) = FileObject; - /* populate the Create2 request */ + /* populate the Overwrite request */ Request->Kind = FspFsctlTransactOverwriteKind; Request->Req.Overwrite.UserContext = FsContext->UserContext; Request->Req.Overwrite.UserContext2 = (UINT_PTR)FileObject->FsContext2; @@ -548,10 +549,11 @@ VOID FspFsvolCreateComplete( Request->Req.Overwrite.Supersede = FILE_SUPERSEDED == Response->IoStatus.Information; /* + * Post it as BestEffort. + * * Note that it is still possible for this request to not be delivered, * if the volume device Ioq is stopped or if the IRP is canceled. */ - if (FspIoqPostIrpBestEffort(FsvolDeviceExtension->Ioq, Irp, &Result)) Result = STATUS_PENDING; } @@ -588,9 +590,6 @@ VOID FspFsvolCreateComplete( FspFileContextPgioUnlock(FsContext); - /* disassociate the FsContext from the Overwrite request */ - FspIopRequestContext(Request, RequestFsContext) = 0; - /* SUCCESS! */ Irp->IoStatus.Information = Request->Req.Overwrite.Supersede ? FILE_SUPERSEDED : FILE_OVERWRITTEN; Result = STATUS_SUCCESS; diff --git a/src/sys/driver.h b/src/sys/driver.h index 821da3c1..1da1db3e 100644 --- a/src/sys/driver.h +++ b/src/sys/driver.h @@ -513,8 +513,8 @@ typedef struct FSP_FILE_CONTEXT_NONPAGED *NonPaged; /* interlocked access */ LONG RefCount; - LONG OpenCount; /* locked access */ + LONG OpenCount; SHARE_ACCESS ShareAccess; /* read-only after creation (and insertion in the GenericTable) */ PDEVICE_OBJECT FsvolDeviceObject;