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.

185 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. Flush.c
  5. Abstract:
  6. This module implements the File Flush buffers routine for Rx called by the
  7. dispatch driver.
  8. In a future version of the wrapper, it may be that flush will be routed thru lowio.
  9. Author:
  10. Joe Linn [JoeLinn] 15-dec-1994
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. //
  16. // The local debug trace level
  17. //
  18. #define Dbg (DEBUG_TRACE_FLUSH)
  19. #ifdef ALLOC_PRAGMA
  20. #pragma alloc_text(PAGE, RxCommonFlushBuffers)
  21. #endif
  22. NTSTATUS
  23. RxCommonFlushBuffers ( RXCOMMON_SIGNATURE )
  24. /*++
  25. Routine Description:
  26. This is the common routine for flushing file buffers.
  27. Arguments:
  28. Irp - Supplies the Irp to process
  29. Return Value:
  30. RXSTATUS - The return status for the operation
  31. --*/
  32. {
  33. NTSTATUS Status;
  34. RxCaptureRequestPacket;
  35. RxCaptureFcb; RxCaptureFobx; RxCaptureParamBlock; RxCaptureFileObject;
  36. NODE_TYPE_CODE TypeOfOpen = NodeType(capFcb);
  37. PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
  38. BOOLEAN FcbAcquired = FALSE;
  39. PAGED_CODE();
  40. RxDbgTrace(+1, Dbg, ("RxCommonFlush...IrpC %08lx, Fobx %08lx, Fcb %08lx\n",
  41. RxContext, capFobx, capFcb));
  42. RxLog(("%s %lx %lx %lx\n","slF",RxContext,capFcb,capFobx));
  43. RxWmiLog(LOG,
  44. RxCommonFlushBuffers,
  45. LOGPTR(RxContext)
  46. LOGPTR(capFcb)
  47. LOGPTR(capFobx));
  48. //
  49. // CcFlushCache is always synchronous, so if we can't wait enqueue
  50. // the irp to the Fsp.
  51. if ( !FlagOn(RxContext->Flags, RX_CONTEXT_FLAG_WAIT) ) {
  52. Status = RxFsdPostRequest( RxContext );
  53. RxDbgTrace(-1, Dbg, ("RxCommonFlushBuffers -> %08lx\n", Status ));
  54. return Status;
  55. }
  56. Status = STATUS_SUCCESS;
  57. try {
  58. //
  59. // Case on the type of open that we are trying to flush
  60. //
  61. switch (TypeOfOpen) {
  62. case RDBSS_NTC_STORAGE_TYPE_FILE:
  63. RxDbgTrace(0, Dbg, ("Flush User File Open\n", 0));
  64. Status = RxAcquireExclusiveFcb( RxContext, capFcb );
  65. if (Status != STATUS_SUCCESS) break;
  66. FcbAcquired = TRUE;
  67. //
  68. // If the file is cached then flush its cache
  69. //
  70. Status = RxFlushFcbInSystemCache(capFcb, TRUE);
  71. if (!NT_SUCCESS( Status )) break;
  72. //rdrs don't do this.....only local FSs
  73. ////
  74. //// Check if we should be changing the time or file size
  75. //
  76. //RxAdjustFileTimesAndSize(RXCOMMON_ARGUMENTS);
  77. // if we make this lowio.........
  78. ////
  79. //// Initialize LowIO_CONTEXT block in the RxContext and Calldown
  80. //
  81. //RxInitializeLowIoContext(LowIoContext,LOWIO_OP_FLUSH);
  82. //
  83. //Status = RxLowIoFlushShell(RxContext);
  84. MINIRDR_CALL(Status,RxContext,capFcb->MRxDispatch,MRxFlush,(RxContext));
  85. break;
  86. case RDBSS_NTC_SPOOLFILE:
  87. RxDbgTrace(0, Dbg, ("Flush Sppol File\n", 0));
  88. Status = RxAcquireExclusiveFcb( RxContext, capFcb );
  89. if (Status != STATUS_SUCCESS) break;
  90. FcbAcquired = TRUE;
  91. // should this be low io???
  92. ////
  93. //// Initialize LowIO_CONTEXT block in the RxContext and Calldown
  94. //
  95. //RxInitializeLowIoContext(LowIoContext,LOWIO_OP_FLUSH);
  96. //
  97. //Status = RxLowIoFlushShell(RxContext);
  98. MINIRDR_CALL(Status,RxContext,capFcb->MRxDispatch,MRxFlush,(RxContext));
  99. break;
  100. default:
  101. Status = STATUS_INVALID_DEVICE_REQUEST;
  102. }
  103. } finally {
  104. DebugUnwind( RxCommonFlushBuffers );
  105. if (FcbAcquired) { RxReleaseFcb( RxContext, capFcb ); }
  106. //
  107. // If this is a normal termination then pass the request on
  108. // to the target device object.
  109. //
  110. if (!AbnormalTermination()) {
  111. NOTHING;
  112. }
  113. }
  114. RxDbgTrace(-1, Dbg, ("RxCommonFlushBuffers -> %08lx\n", Status));
  115. return Status;
  116. }
  117.