sys: IRP_MJ_CREATE refactoring

This commit is contained in:
Bill Zissimopoulos 2016-01-12 13:50:41 -08:00
parent 26e2bf506b
commit cd28edf6a9
2 changed files with 11 additions and 12 deletions

View File

@ -348,6 +348,7 @@ NTSTATUS FspFsvolCreatePrepare(
return Result; return Result;
} }
/* no longer post a Close if the IRP gets cancelled */
FspIopRequestContext(Request, RequestFileObject) = 0; FspIopRequestContext(Request, RequestFileObject) = 0;
/* see what the MM thinks about all this */ /* see what the MM thinks about all this */
@ -357,8 +358,8 @@ NTSTATUS FspFsvolCreatePrepare(
{ {
FspFileContextPgioUnlock(FsContext); FspFileContextPgioUnlock(FsContext);
FspFileContextClose(FsContext, FileObject);
FspFsvolCreatePostClose(FsContext, (UINT_PTR)FileObject->FsContext2); FspFsvolCreatePostClose(FsContext, (UINT_PTR)FileObject->FsContext2);
FspFileContextClose(FsContext, FileObject);
return STATUS_USER_MAPPED_FILE; return STATUS_USER_MAPPED_FILE;
} }
@ -505,12 +506,11 @@ VOID FspFsvolCreateComplete(
if (!MmFlushImageSection(&FsContext->NonPaged->SectionObjectPointers, if (!MmFlushImageSection(&FsContext->NonPaged->SectionObjectPointers,
MmFlushForWrite)) MmFlushForWrite))
{ {
Result = DeleteOnClose ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION;
FspFileContextClose(FsContext, FileObject);
FspFsvolCreatePostClose(FsContext, FspFsvolCreatePostClose(FsContext,
Response->Rsp.Create.Opened.UserContext2); Response->Rsp.Create.Opened.UserContext2);
FspFileContextClose(FsContext, FileObject);
Result = DeleteOnClose ? STATUS_CANNOT_DELETE : STATUS_SHARING_VIOLATION;
FSP_RETURN(); FSP_RETURN();
} }
} }
@ -531,16 +531,17 @@ VOID FspFsvolCreateComplete(
FspIrpRequest(Irp) = 0; FspIrpRequest(Irp) = 0;
FspIopDeleteRequest(Request); 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, FspIopCreateRequestFunnel(Irp,
FsvolDeviceExtension->VolumeParams.FileNameRequired ? &FsContext->FileName : 0, 0, FsvolDeviceExtension->VolumeParams.FileNameRequired ? &FsContext->FileName : 0, 0,
FspFsvolCreateOverwriteRequestFini, TRUE, FspFsvolCreateOverwriteRequestFini, TRUE,
&Request); &Request);
/* associate the FsContext with the Create2 request */ /* associate the FsContext and FileObject with the Overwrite request */
FspIopRequestContext(Request, RequestFsContext) = FsContext; FspIopRequestContext(Request, RequestFsContext) = FsContext;
FspIopRequestContext(Request, RequestFileObject) = FileObject;
/* populate the Create2 request */ /* populate the Overwrite request */
Request->Kind = FspFsctlTransactOverwriteKind; Request->Kind = FspFsctlTransactOverwriteKind;
Request->Req.Overwrite.UserContext = FsContext->UserContext; Request->Req.Overwrite.UserContext = FsContext->UserContext;
Request->Req.Overwrite.UserContext2 = (UINT_PTR)FileObject->FsContext2; Request->Req.Overwrite.UserContext2 = (UINT_PTR)FileObject->FsContext2;
@ -548,10 +549,11 @@ VOID FspFsvolCreateComplete(
Request->Req.Overwrite.Supersede = FILE_SUPERSEDED == Response->IoStatus.Information; 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, * 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 the volume device Ioq is stopped or if the IRP is canceled.
*/ */
if (FspIoqPostIrpBestEffort(FsvolDeviceExtension->Ioq, Irp, &Result)) if (FspIoqPostIrpBestEffort(FsvolDeviceExtension->Ioq, Irp, &Result))
Result = STATUS_PENDING; Result = STATUS_PENDING;
} }
@ -588,9 +590,6 @@ VOID FspFsvolCreateComplete(
FspFileContextPgioUnlock(FsContext); FspFileContextPgioUnlock(FsContext);
/* disassociate the FsContext from the Overwrite request */
FspIopRequestContext(Request, RequestFsContext) = 0;
/* SUCCESS! */ /* SUCCESS! */
Irp->IoStatus.Information = Request->Req.Overwrite.Supersede ? FILE_SUPERSEDED : FILE_OVERWRITTEN; Irp->IoStatus.Information = Request->Req.Overwrite.Supersede ? FILE_SUPERSEDED : FILE_OVERWRITTEN;
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;

View File

@ -513,8 +513,8 @@ typedef struct
FSP_FILE_CONTEXT_NONPAGED *NonPaged; FSP_FILE_CONTEXT_NONPAGED *NonPaged;
/* interlocked access */ /* interlocked access */
LONG RefCount; LONG RefCount;
LONG OpenCount;
/* locked access */ /* locked access */
LONG OpenCount;
SHARE_ACCESS ShareAccess; SHARE_ACCESS ShareAccess;
/* read-only after creation (and insertion in the GenericTable) */ /* read-only after creation (and insertion in the GenericTable) */
PDEVICE_OBJECT FsvolDeviceObject; PDEVICE_OBJECT FsvolDeviceObject;