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.

93 lines
3.7 KiB

  1. This short note will potentially explain the states and transitions
  2. available on an FCB complex. For those just tuning in, a fileobject (FO)
  3. refers to an FCB (File Control Block) and an FOBX (File Object
  4. Extension). There is a 1-1 correspondence between FOs and FOBXs. Many
  5. FOs may/will refer to the same FCB which represents a single file
  6. somewhere on some server. A client may have several different opens
  7. (NtCreates) on the same FCB and each of these will create a new file
  8. object. What is interesting is that the rdr may choose to send fewer
  9. SMBcreates than it receives NtCreates in effect sharing a server-open
  10. (SVROPEN) among several FOBXs.
  11. Another interesting tidbit is that the rdr doesn't necessarily close its
  12. SRVOPENs when the user opens close hoping that it can reuse the open and
  13. the data without any contact with the server. We say that an FCB is
  14. client-side-open (CSO) if there are user opens openstanding on the FCB.
  15. It is server-side-open is there are existing SRVOPENs on the FCB. From
  16. all of this, the following table explains what can happen on a user open
  17. (assuming the netroot is good):
  18. Create? CS-Open? SS-Open? Action
  19. -----------------------------------------
  20. Yes Open Open ERROR
  21. Open Closed IMPOSSIBLE
  22. Closed Open CloseAllSrvOpens();NewOpen()
  23. Closed Closed NewOpen()
  24. No Open Open NotSharable()-->NewOpen()
  25. Open Closed IMPOSSIBLE
  26. Closed Open NotSharable()-->NewOpen()
  27. Closed Closed NewOpen()
  28. Thus, it actually boils down to a pretty simple scheme:
  29. (Create && CS-Open) ==> return ERROR;
  30. (Create && SS-Open && !CS-Open) ==> CloseAllSrvOpens();
  31. (NotShareable()) ==> return NewOpen();
  32. return SharableOpen();
  33. A careful review here shows us what must happen on cleanup:
  34. specifically, we must do whatever it takes to cleanup the clientside as
  35. appropriate. Further, if the open is the last user open and
  36. DELETE-ON-CLOSE or TRUNCATE-ON-CLOSE are operative, then we must drive
  37. the FCB into the CLOSED/CLOSED state; otherwise, we may elect to leave
  38. SRVOPENs open even if there are no current opens. Since the subrdr is
  39. the best judge of whether closing or keeping is appropriate, we call
  40. down on the transition (SRXSrvOpenTransitioningToClosed). When the
  41. subrdr gets this call, it may elect to (a) close the current SRVOPEN,
  42. (b) close SRVOPENs with no associated user opens, (c) do nothing and
  43. rely on the RDBSS to call down for real closes at the correct time.
  44. If the subrdr chooses to allow the SRVOPEN to remain, the RDBSS will
  45. take some steps close ones that remain according to some criteria that
  46. (a) haven't been worked out yet and (b) need to be very flexible.
  47. Probably this will be another calldown (SRXClosedSrvOpenTimeOut). The
  48. same is true of the FCB itself....after some reasonbale period, it and
  49. the cached data (if any) that it represents should be finalized.
  50. Another pair of calldowns (i.e. SRXFcbTransitioningToClosed and
  51. SRXClosedFcbTimeOut).
  52. So, the following sums it up for cleanup:
  53. (Delete||Truncate)&&LastCSOpenPerFcb => CloseAllSrvOpens();
  54. ELSE LastCSOpenPerSrvOpen => SRXSrvOpenTransitioningToClosed();
  55. ELSE (we'll do it on a timer)
  56. Notice that if the subrdr wants to do something aggressive like close
  57. the srvopen and finalize, then it will have to take out the appropriate
  58. locks itself. The RDBSS isn't going to take the locks just so the subrdr
  59. can say "no, thx". Currently, we uninitialize the cachemap as well and
  60. count on the winding down logic of CM/MM to keep the map open for some
  61. time....we will consider later forcing the CM to stay open (for example,
  62. by putting our own reference on the fileobject).
  63.