home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / vmsnet / internal / 1240 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  9.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!swrinde!network.ucsd.edu!mvb.saic.com!macro32
  2. From: (Jon Pinkley, Westinghouse (216)486-8300 x1335)
  3. Newsgroups: vmsnet.internals
  4. Subject: DDB$L_DDT != UCB$L_DDT
  5. Message-ID: <9209010026.AA08446@relay1.UU.NET>
  6. Date: 31 Aug 92 23:31:05 GMT
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. Lines: 189
  9. X-Gateway-Source-Info: Mailing List
  10.  
  11. Summary: What reasons are there for not changing the
  12.          UCB$L_DDT field of a disk device to point to a
  13.          "cloned" DDT with a different startio vector?
  14.  
  15. If you aren't interested in device driver internals, you may want to
  16. skip the rest of this (long) article.
  17.  
  18.  
  19. On Aug 11th, 1992 I posted some comments about serializing access to a
  20. DRM-600 6 CD-ROM mini-changer.  My plan is to modify the CDDRIVER that
  21. was submitted to DECUS.  This is related to that posting.
  22.  
  23. Following is the background leading up to my question.
  24.  
  25. -----------------
  26.  
  27. Some random comments about CDDRIVER as was distributed on the VAX89B1
  28. DECUS tape.  CDDRIVER is a cache driver that was written by Paul Sorenson
  29. of American Electric Power (AEP).  CDDRIVER is an intercept driver that
  30. is transparent to application I/O requests.  I will refer to this as
  31. CDDRIVER.89b1 or just CDDRIVER.
  32.  
  33. CDDRIVER effectively replaces the startio routine of the disk drive that
  34. is being cached.  It does this by modifying the startio vector in the
  35. target disk's Driver Dispatch Table (DDT) to point to the CDDRIVER
  36. altstartio routine.  Since the address of the original startio routine
  37. must be saved, and because caching requires additional data structures, a
  38. place must be provided to hold this additional context.  Normally, a
  39. driver writer would just provide UCB extensions for this purpose.  We
  40. can't extend the disk device's UCB, so a CDDRIVER (CDA) unit is
  41. associated with each disk being cached, and it's UCB is used as an
  42. extension of the disk's UCB.  The problem to be solved is the following:
  43.  
  44.     Given the address of a disk UCB (in R5), find the address of
  45.     the corresponding CDAx UCB, or determine that no CDAx unit is
  46.     associated with the current device.  Also, if all units for
  47.     the disk driver are being vectored through the replacement
  48.     startio routine, then the original startio routine address
  49.     must be determined, so that IRPs for non-cached drives using
  50.     the same disk device driver can be passed on to the correct
  51.     startio routine.
  52.  
  53. In CDDRIVER.89B1, the DDT startio vector of the disk device driver is
  54. changed to point to the CDDRIVER altstartio routine when the first disk
  55. using the disk driver is cached.  Since there is a single DDT for the
  56. disk driver, all disks using the same driver are also revectored through
  57. CDDRIVER's altstartio routine.  As a result, the replacement startio
  58. routine must check to see if this is a request for a cached disk.  It
  59. does this by scanning all the CDAx units to find one that is associated
  60. with the current io request, i.e.  does the CDA UCB$L_CD_DSKUCB equal the
  61. UCB for the current IRP (what is in R5).  This strategy takes the most
  62. time for disks that are not being cached, because it must verify that
  63. every CDAx unit is NOT associated with the current request.  This is one
  64. reason to limit the number of devices that are being cached.  The current
  65. driver is limited to 8 units.
  66.  
  67. In an effort to reduce the impact on non-cached disks and to allow for a
  68. larger number of cached devices, I started thinking about possible
  69. changes to CDDRIVER.
  70.  
  71. The problem of affecting non-cached devices using the same driver could
  72. be eliminated by cloning the driver's DDT, modifying the startio vector
  73. in the cloned DDT to point to the replacement startio routine, and then
  74. modifying the UCB$L_DDT pointer of the cached disk to point to the cloned
  75. DDT.  Since the original DDT is no longer changed, non-cached devices
  76. will not be affected in any way.
  77.  
  78. Cloning the DDT also eliminates the need for the replacement startio
  79. routine to determine whether the I/O request is from a non-cached drive,
  80. since only cached disks' I/O should ever reach the replacement startio
  81. routine.  This allows us to make some other optimizations, since we don't
  82. have to remember the original startio routine for non-cached disks.
  83.  
  84. To handle a large number of cached devices without a linear increase in
  85. the amount of time to find the associated CDA UCB, one possible method
  86. would be to hash R5 to produce a hash table index for the associated CDA
  87. unit queues.  This should reduce our average search substantially.  The
  88. number of hash queue headers could be controlled by a define in CDDRIVER.
  89. For this to work we have to guarantee that only cached devices will use
  90. the replacement startio routine, otherwise we wouldn't find an associated
  91. CDA unit, and we wouldn't be able to recover the original startio address
  92. (without looking through all the queues for a unit using the same
  93. driver).
  94.  
  95. Another possible optimization would be to have a periodic routine sort
  96. entries in the queues based on number of I/O operations (i.e. a repeating
  97. system TQE would synchronize with the driver, examine the queues and
  98. counts and reorder them).
  99.  
  100. If you really feel lucky, you can avoid the reverse search by breaking
  101. the rules.  If we can find a longword field in the UCB that is not being
  102. used by the disk driver, then we can use this field to store the UCB
  103. address of the associated CDAx UCB.  The two likely candidates for this
  104. are the UCB$L_AMB (associated mailbox UCB address, which is currently not
  105. used by DEC for disk devices), and UCB$L_XTRA (which is documented as SMP
  106. alternate STARTIO wait, whatever that means).
  107.  
  108. I talked with Paul Sorenson on August 13, 1992 about CDDRIVER.  He hasn't
  109. made any changes to the CDDRIVER since it was submitted to the VAX89B1
  110. tape.  We discussed the possibility of cloning the DDT and then modifying
  111. the UCB$L_DDT field to point to this copy.  We couldn't think of any
  112. obvious problems.  I then asked about using a field in the disk UCB.
  113. Paul thought about it a second and then came up with a much safer idea.
  114. If we are going to clone the DDT, why not put it in an extension of the
  115. CDDRIVER UCB.  We will use up more non-paged pool, since we will need the
  116. info in each CDA unit's UCB, instead of one copy per disk device driver
  117. type.  However, when we change the DDT$L_UCB field of the disk UCB to
  118. point to the cloned DDT, we will have a pointer to a structure within the
  119. associated CDA UCB.  Now, a negative offset from the DDT structure will
  120. return the address of the associated CDA UCB.
  121.  
  122.       Questionable practice
  123.  
  124. UCB$L_CD_ACDUCB = UCB$L_AMB  ; define our symbol to overload an "unused"
  125.                              ; UCB field.  Another possibility UCB$L_XTRA
  126.  
  127.         MOVL    UCB$L_CD_ACDUCB(R5), R0    ;; Get address of associated
  128.                                            ;; CDA unit UCB
  129.  
  130. ++++++++++++++++
  131.  
  132.       Safer practice
  133.  
  134.         MOVL    UCB$L_DDT(R5), Rx          ;; Get address of cloned DDT
  135.                                            ;; within the associated CDA
  136.                                            ;; units UCB extension.
  137.         MOVAL   -UCB$L_CD_CLONEDDT(Rx), R0 ;; Now get the address of the
  138.                                            ;; associated CDA unit UCB.
  139.  
  140.         Where Rx is a scratch register.  It could be R0, but under most
  141.         VAX implementations, using a different register will be faster.
  142.  
  143.       Another alternative:
  144.  
  145.         SUBL3   #UCB$L_CD_CLONEDDT, -      ;; Get address of associated
  146.                 UCB$L_DDT(R5), R0          ;; CDA unit UCB
  147.  
  148.       Ok, which of the previous two is faster?  They both require 10
  149.       bytes.
  150.  
  151. ++++++++++++++++
  152.  
  153. This all leads to the following options.
  154.  
  155. 1.  Be "safe".  Don't clone the DDT or change UCB$L_DDT in
  156.     cached disk UCBs.  This precludes the use of hash queues.
  157.     All CDAx UCBs will have to be explicitly searched for the UCB
  158.     of the disk drive.
  159.  
  160. 2.  First level optimization.  Clone the DDT and change UCB$L_DDT
  161.     in cached disk UCBs.  This isolates non-cached units from the
  162.     changes.
  163.  
  164. 3.  Second level optimization.  Requires first level
  165.     optimization.  Hash the disk UCB address and chose a queue of
  166.     CDAx based on the result.  This should substantially reduce
  167.     the average number of CDAx UCBs that must be searched to find
  168.     the associated Disk UCB.
  169.  
  170. 4.  Third level optimization.  Requires first level optimization,
  171.     and the DDT must be cloned into the associated CDAx UCB.  The
  172.     address of the associated CDAx UCB is computed from the
  173.     address of the cloned DDT.  This is what I am planning to do.
  174.  
  175. 5.  Fourth level optimization.  Requires first level
  176.     optimization.  Overload an unused field in the disk UCB to
  177.     contain the address of the associated UCB.  Not recommended.
  178.  
  179. Note that options 1 through 3 can be further optimized by having a
  180. repeating system TQE routine sort the queue(s) based on number of I/O
  181. operations.  The frequency of this routine would need to be determined, I
  182. would start out at something like once every 5 minutes (300 seconds).
  183.  
  184. Now on to the question:  What reasons are there for not changing the
  185. UCB$L_DDT field to point to a cloned DDT with a different startio vector?
  186. I realize that the I/O database won't be consistent, in that DDB$L_DDT
  187. won't be that same as UCB$L_DDT for devices that are being cached.  What
  188. possible problems could that cause?  It would be possible to clone a
  189. dangling DDB (i.e. there would be no path to it via IOC$GL_DEVLIST and
  190. DDB$L_LINK fields, and its own DDB$L_LINK field would be 0) and have
  191. UCB$L_DDB point to that, but I can't think of a good reason to do so.  I
  192. definitely want any new device that is created to get the real disk
  193. driver DDT, so I couldn't change the original DDB's DDB$L_DDT address to
  194. point the the cloned DDT.
  195.  
  196. Can anyone think of problems this would cause?  Are there other options
  197. that would be better?
  198.  
  199. Jon Pinkley  jon@clevax.wec.com  ...uunet!tron!clevax!jon (216)486-8300 x1335
  200.