Leaked source code of windows server 2003
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.

162 lines
3.4 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 (
  24. IN PRX_CONTEXT RxContext,
  25. IN PIRP Irp
  26. )
  27. /*++
  28. Routine Description:
  29. This is the common routine for flushing file buffers.
  30. Arguments:
  31. Irp - Supplies the Irp to process
  32. Return Value:
  33. RXSTATUS - The return status for the operation
  34. --*/
  35. {
  36. NTSTATUS Status;
  37. PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
  38. PFCB Fcb;
  39. PFOBX Fobx;
  40. NODE_TYPE_CODE TypeOfOpen;
  41. PLOWIO_CONTEXT LowIoContext = &RxContext->LowIoContext;
  42. BOOLEAN FcbAcquired = FALSE;
  43. PAGED_CODE();
  44. TypeOfOpen = RxDecodeFileObject( IrpSp->FileObject, &Fcb, &Fobx );
  45. RxDbgTrace( +1, Dbg, ("RxCommonFlush...IrpC %08lx, Fobx %08lx, Fcb %08lx\n",
  46. RxContext, Fobx, Fcb ));
  47. RxLog(( "%s %lx %lx %lx\n","slF", RxContext, Fcb, Fobx ));
  48. RxWmiLog( LOG,
  49. RxCommonFlushBuffers,
  50. LOGPTR( RxContext )
  51. LOGPTR( Fcb )
  52. LOGPTR( Fobx ) );
  53. //
  54. // CcFlushCache is always synchronous, so if we can't wait enqueue
  55. // the irp to the Fsp.
  56. //
  57. if (!FlagOn( RxContext->Flags, RX_CONTEXT_FLAG_WAIT )) {
  58. Status = RxFsdPostRequest( RxContext );
  59. RxDbgTrace( -1, Dbg, ("RxCommonFlushBuffers -> %08lx\n", Status ));
  60. return Status;
  61. }
  62. Status = STATUS_SUCCESS;
  63. try {
  64. //
  65. // Case on the type of open that we are trying to flush
  66. //
  67. switch (TypeOfOpen) {
  68. case RDBSS_NTC_STORAGE_TYPE_FILE:
  69. RxDbgTrace( 0, Dbg, ("Flush User File Open\n", 0) );
  70. Status = RxAcquireExclusiveFcb( RxContext, Fcb );
  71. if (Status != STATUS_SUCCESS) break;
  72. FcbAcquired = TRUE;
  73. //
  74. // If the file is cached then flush its cache
  75. //
  76. Status = RxFlushFcbInSystemCache( Fcb, TRUE );
  77. if (!NT_SUCCESS( Status )) break;
  78. MINIRDR_CALL( Status, RxContext, Fcb->MRxDispatch, MRxFlush, (RxContext) );
  79. break;
  80. case RDBSS_NTC_SPOOLFILE:
  81. RxDbgTrace(0, Dbg, ("Flush Sppol File\n", 0));
  82. Status = RxAcquireExclusiveFcb( RxContext, Fcb );
  83. if (Status != STATUS_SUCCESS) break;
  84. FcbAcquired = TRUE;
  85. MINIRDR_CALL( Status, RxContext, Fcb->MRxDispatch, MRxFlush, (RxContext) );
  86. break;
  87. default:
  88. Status = STATUS_INVALID_DEVICE_REQUEST;
  89. }
  90. } finally {
  91. DebugUnwind( RxCommonFlushBuffers );
  92. if (FcbAcquired) {
  93. RxReleaseFcb( RxContext, Fcb );
  94. }
  95. }
  96. RxDbgTrace(-1, Dbg, ("RxCommonFlushBuffers -> %08lx\n", Status));
  97. return Status;
  98. }
  99.