2.1.4.13 Algorithm to Recompute the State of a Shared Oplock

The inputs for this algorithm are:

  • ThisOplock: The Oplock on whose state is being recomputed.

Pseudocode for the algorithm is as follows:

  • If ThisOplock.IIOplocks, ThisOplock.ROplocks, ThisOplock.RHOplocks, and ThisOplock.RHBreakQueue are all empty:

    • Set ThisOplock.State to NO_OPLOCK.

  • Else If ThisOplock.ROplocks is not empty and either ThisOplock.RHOplocks or ThisOplock.RHBreakQueue are not empty:

    • Set ThisOplock.State to (READ_CACHING|HANDLE_CACHING|MIXED_R_AND_RH).

  • Else If ThisOplock.ROplocks is empty and ThisOplock.RHOplocks is not empty:

    • Set ThisOplock.State to (READ_CACHING|HANDLE_CACHING).

  • Else If ThisOplock.ROplocks is not empty and ThisOplock.IIOplocks is not empty:

    • Set ThisOplock.State to (READ_CACHING|LEVEL_TWO_OPLOCK).

  • Else If ThisOplock.ROplocks is not empty and ThisOplock.IIOplocks is empty:

    • Set ThisOplock.State to READ_CACHING.

  • Else If ThisOplock.ROplocks is empty and ThisOplock.IIOplocks is not empty:

    • Set ThisOplock.State to LEVEL_TWO_OPLOCK.

  • Else

    • //   ThisOplock.ROplocks is empty
      //   ThisOplock.RHOplocks is empty
      //   ThisOplock.RHBreakQueue MUST be non-empty

    • If RHOpContext.BreakingToRead is TRUE for every RHOpContext on ThisOplock.RHBreakQueue:

      • Set ThisOplock.State to (READ_CACHING|HANDLE_CACHING|BREAK_TO_READ_CACHING).

    • Else If RHOpContext.BreakingToRead is FALSE for every RHOpContext on ThisOplock.RHBreakQueue:

      • Set ThisOplock.State to (READ_CACHING|HANDLE_CACHING|BREAK_TO_NO_CACHING).

    • Else:

      • Set ThisOplock.State to (READ_CACHING|HANDLE_CACHING).

    • EndIf

  • EndIf