Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. read.c
  5. Abstract:
  6. This module implements the mini redirector call down routines pertaining to read
  7. of file system objects.
  8. Author:
  9. Balan Sethu Raman [SethuR] 7-March-1995
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. //
  15. // The local debug trace level
  16. //
  17. #define Dbg (DEBUG_TRACE_READ)
  18. //
  19. // External declartions
  20. //
  21. NTSTATUS
  22. MRxProxyReadContinuation(
  23. MRXPROXY_ASYNCENGINE_ARGUMENT_SIGNATURE
  24. );
  25. NTSTATUS
  26. MRxProxyRead(
  27. IN PRX_CONTEXT RxContext
  28. )
  29. /*++
  30. Routine Description:
  31. This routine handles network read requests.
  32. Arguments:
  33. RxContext - the RDBSS context
  34. Return Value:
  35. RXSTATUS - The return status for the operation
  36. --*/
  37. {
  38. NTSTATUS Status = STATUS_SUCCESS;
  39. //RxCaptureFcb; RxCaptureFobx;
  40. //PMRXPROXY_ASYNCENGINE_CONTEXT AsyncEngineContext;
  41. PAGED_CODE();
  42. RxDbgTrace(+1, Dbg, ("MRxProxyRead\n", 0 ));
  43. //in outerwrapper ASSERT( NodeType(capFobx->pSrvOpen) == RDBSS_NTC_SRVOPEN );
  44. Status = MRxProxyAsyncEngineOuterWrapper(
  45. RxContext,
  46. MRXPROXY_ASYNCENG_CTX_FROM_READ,
  47. MRxProxyReadContinuation,
  48. "MRxProxyRead",
  49. FALSE, //loudprocessing
  50. FALSE
  51. );
  52. RxDbgTrace(-1, Dbg, ("MRxProxyRead exit with status=%08lx\n", Status ));
  53. return(Status);
  54. } // MRxProxyRead
  55. NTSTATUS
  56. MRxProxyReadContinuation(
  57. MRXPROXY_ASYNCENGINE_ARGUMENT_SIGNATURE
  58. )
  59. /*++
  60. Routine Description:
  61. This is the start routine for read.
  62. Arguments:
  63. Return Value:
  64. RXSTATUS - The return status for the operation
  65. --*/
  66. {
  67. NTSTATUS Status; //this is initialized to proxybufstatus on a reenter
  68. PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
  69. ULONG ContinueEntryCount;
  70. RxCaptureFcb; RxCaptureFobx;
  71. PMRX_SRV_OPEN SrvOpen = capFobx->pSrvOpen;
  72. BOOLEAN SynchronousIo =
  73. !BooleanFlagOn(RxContext->Flags,RX_CONTEXT_FLAG_ASYNC_OPERATION);
  74. PAGED_CODE(); RxDbgTrace(+1, Dbg, ("MRxProxyReadContinuation\n", 0 ));
  75. ASSERT_ASYNCENG_CONTEXT(AsyncEngineContext);
  76. AsyncEngineContext->ContinueEntryCount++;
  77. ContinueEntryCount = AsyncEngineContext->ContinueEntryCount;
  78. for (;;) {
  79. //
  80. // Case on the current state
  81. //
  82. switch (AsyncEngineContext->OpSpecificState) {
  83. case MRxProxyAsyncEngOEInnerIoStates_Initial:
  84. AsyncEngineContext->OpSpecificState = MRxProxyAsyncEngOEInnerIoStates_ReadyToSend;
  85. //
  86. // If not a synchronous read, then continue here when resumed
  87. //
  88. //CODE.IMPROVEMENT don't use presense of continuation as the async marker...use a flag
  89. if (!SynchronousIo) {
  90. SetFlag(AsyncEngineContext->Flags,MRXPROXY_ASYNCENG_CTX_FLAG_ASYNC_OPERATION);
  91. AsyncEngineContext->Continuation = MRxProxyReadContinuation;
  92. }
  93. //lack of break is intentional
  94. case MRxProxyAsyncEngOEInnerIoStates_ReadyToSend:
  95. AsyncEngineContext->OpSpecificState = MRxProxyAsyncEngOEInnerIoStates_OperationOutstanding;
  96. if (FALSE && FlagOn(LowIoContext->ParamsFor.ReadWrite.Flags,LOWIO_READWRITEFLAG_PAGING_IO)) {
  97. RxLog(("PagingRead: rx/off/len %lx/%lx/%lx",
  98. RxContext,
  99. (ULONG)(LowIoContext->ParamsFor.ReadWrite.ByteOffset),
  100. LowIoContext->ParamsFor.ReadWrite.ByteCount
  101. ));
  102. }
  103. Status = MRxProxyBuildAsynchronousRequest(
  104. RxContext, // IN PVOID Context
  105. MRxProxyAsyncEngineCalldownIrpCompletion // IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL,
  106. );
  107. if (Status != STATUS_SUCCESS) {
  108. goto FINALLY;
  109. }
  110. Status = MRxProxySubmitAsyncEngRequest(
  111. MRXPROXY_ASYNCENGINE_ARGUMENTS,
  112. MRXPROXY_ASYNCENG_AECTXTYPE_READ
  113. );
  114. //
  115. // If the status is PENDING, then we're done for now. We must
  116. // wait until we're re-entered when the receive happens.
  117. //
  118. if (Status==(STATUS_PENDING)) {
  119. ASSERT(!SynchronousIo);
  120. goto FINALLY;
  121. }
  122. AsyncEngineContext->Status = Status;
  123. //lack of break is intentional
  124. case MRxProxyAsyncEngOEInnerIoStates_OperationOutstanding:
  125. AsyncEngineContext->OpSpecificState = MRxProxyAsyncEngOEInnerIoStates_ReadyToSend;
  126. Status = AsyncEngineContext->Status;
  127. RxContext->InformationToReturn += AsyncEngineContext->Information;
  128. goto FINALLY;
  129. break;
  130. }
  131. }
  132. FINALLY:
  133. //CODE.IMPROVEMENT read_start and write_start and locks_start should be combined.....we use this
  134. //macro until then to keep the async stuff identical
  135. if ( Status != (STATUS_PENDING) ) {
  136. MRxProxyAsyncEngAsyncCompletionIfNecessary(AsyncEngineContext,RxContext);
  137. }
  138. RxDbgTrace(-1, Dbg, ("MRxProxyReadContinuation exit w %08lx\n", Status ));
  139. return Status;
  140. } // ProxyPseExchangeStart_Read
  141.