<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding file LUNS used for a process in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798669#M36121</link>
    <description>You are looking for a form of reference counting.&lt;BR /&gt;&lt;BR /&gt;Only Fortran and BASIC tend to have "LUNs", AFAIK.  &lt;BR /&gt;&lt;BR /&gt;OpenVMS processes do not generally have "LUNs", they have "I/O channels".   &lt;BR /&gt;&lt;BR /&gt;I would strongly suggest writing some (simple) diagnostic code here, and maintaining your own reference counters.   Jacket the lib$get_lun and lib$free_lun and related calls, and particularly centralize these and other tasks (such as memory management) that involve shared resources.&lt;BR /&gt;&lt;BR /&gt;This instrumentation and integrated debugging is usually the easiest approach, and the most easily tailored to your specific needs here.&lt;BR /&gt;&lt;BR /&gt;If you have (or can add) an exit handler for the application, you can also then look at the reference counter when the application exits, and (wait for it) log a diagnostic for failed releases.&lt;BR /&gt;&lt;BR /&gt;If you want to look at the open I/O channels for a process, then use the ANALYZE /SYSTEM tools.  &lt;BR /&gt;&lt;BR /&gt;GEIN $ set process/privil=cmkrnl   ! or =ALL)&lt;BR /&gt;GEIN $ analyze/system&lt;BR /&gt;&lt;BR /&gt;OpenVMS (TM) Alpha system analyzer&lt;BR /&gt;&lt;BR /&gt;SDA&amp;gt; show process/channel&lt;BR /&gt;&lt;BR /&gt;Process index: 0050   Name:...&lt;BR /&gt;&lt;BR /&gt;The gnarly approach is to intercept the calls in question, but that's usually less effective (and arguably more work) than adjusting and documenting and refactoring (spotty) application code.   John Gillings has posted some fake-RTL tools (search for /gillings fake rtl/ and you shall find...) and there are other examples around, if you do choose this approach.  (I much prefer instrumented application code, as you can log what you need that way.)</description>
    <pubDate>Tue, 14 Jun 2011 16:28:18 GMT</pubDate>
    <dc:creator>Hoff</dc:creator>
    <dc:date>2011-06-14T16:28:18Z</dc:date>
    <item>
      <title>Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798668#M36120</link>
      <description>is there a way to peek into another process and see how many LUNS have been allocated?  We have folks forgetting lib$free_lun and were looking for a way to double check them.&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2011 15:47:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798668#M36120</guid>
      <dc:creator>Shael Richmond</dc:creator>
      <dc:date>2011-06-14T15:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798669#M36121</link>
      <description>You are looking for a form of reference counting.&lt;BR /&gt;&lt;BR /&gt;Only Fortran and BASIC tend to have "LUNs", AFAIK.  &lt;BR /&gt;&lt;BR /&gt;OpenVMS processes do not generally have "LUNs", they have "I/O channels".   &lt;BR /&gt;&lt;BR /&gt;I would strongly suggest writing some (simple) diagnostic code here, and maintaining your own reference counters.   Jacket the lib$get_lun and lib$free_lun and related calls, and particularly centralize these and other tasks (such as memory management) that involve shared resources.&lt;BR /&gt;&lt;BR /&gt;This instrumentation and integrated debugging is usually the easiest approach, and the most easily tailored to your specific needs here.&lt;BR /&gt;&lt;BR /&gt;If you have (or can add) an exit handler for the application, you can also then look at the reference counter when the application exits, and (wait for it) log a diagnostic for failed releases.&lt;BR /&gt;&lt;BR /&gt;If you want to look at the open I/O channels for a process, then use the ANALYZE /SYSTEM tools.  &lt;BR /&gt;&lt;BR /&gt;GEIN $ set process/privil=cmkrnl   ! or =ALL)&lt;BR /&gt;GEIN $ analyze/system&lt;BR /&gt;&lt;BR /&gt;OpenVMS (TM) Alpha system analyzer&lt;BR /&gt;&lt;BR /&gt;SDA&amp;gt; show process/channel&lt;BR /&gt;&lt;BR /&gt;Process index: 0050   Name:...&lt;BR /&gt;&lt;BR /&gt;The gnarly approach is to intercept the calls in question, but that's usually less effective (and arguably more work) than adjusting and documenting and refactoring (spotty) application code.   John Gillings has posted some fake-RTL tools (search for /gillings fake rtl/ and you shall find...) and there are other examples around, if you do choose this approach.  (I much prefer instrumented application code, as you can log what you need that way.)</description>
      <pubDate>Tue, 14 Jun 2011 16:28:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798669#M36121</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2011-06-14T16:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798670#M36122</link>
      <description>Shael,&lt;BR /&gt;&lt;BR /&gt;  LIB$GET_LUN and LIB$FREE_LUN are very, very simple routines. They keep a bitmap of available LUNs in a static location. They're allocated sequentially using a FFS or FFC instruction (Find First Set/Clear).&lt;BR /&gt;&lt;BR /&gt;  A FAKE_LIBRTL could be used to trace calls, but if you work out the LIBRTL PSECT and offset of the bitmap, then use SDA to locate it in another process. &lt;BR /&gt;&lt;BR /&gt;Use SHOW PROCESS/IMAGE to determine the PSECTs then EXAMINE to peek at the contents.&lt;BR /&gt;&lt;BR /&gt;Source code would help, but single stepping by instruction through the LIBRTL routines should give enough clues to work out where it is.&lt;BR /&gt;&lt;BR /&gt;  Note that there's nothing magic about a "LUN". It's just a number. The LIB$ routines don't know or care if or when you open or close a channel on the LUN.&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2011 20:20:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798670#M36122</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2011-06-14T20:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798671#M36123</link>
      <description>If you are looking for a quick way to see how far along a proces is in using hte available LUNs, place the "current" LUN acquired from a call to GET_LUN in a known location that you can examine with SDA.  The LUNs are allocated in a particular order such that the actual LUN number can indicate the maximum that have been used.  This is an approximate number.  The code sequence would look like this:&lt;BR /&gt;&lt;BR /&gt;     Call to LIB$GET_LUN(NEW_LUN)&lt;BR /&gt;     LUN_LOCATION = max(LUN_LOCATION,NEW_LUN)&lt;BR /&gt;&lt;BR /&gt;Realize that the LUN_LOCATION variable should be in a common area and would be the highwater mark for LUN usage.  Freeing a LUN may make a hole that can get re-used, but at least this would give you a fairly accurate estimate of the usage.&lt;BR /&gt;&lt;BR /&gt;Dan</description>
      <pubDate>Wed, 15 Jun 2011 12:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798671#M36123</guid>
      <dc:creator>abrsvc</dc:creator>
      <dc:date>2011-06-15T12:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798672#M36124</link>
      <description>Not quite.&lt;BR /&gt;&lt;BR /&gt;On my V7.3-2 system, LIB$GET_LUN returns 119-100 in descending order followed by 299-120 also in descending order.</description>
      <pubDate>Wed, 15 Jun 2011 12:53:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798672#M36124</guid>
      <dc:creator>Mike Kier</dc:creator>
      <dc:date>2011-06-15T12:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798673#M36125</link>
      <description>Excuse my rented fingers.  The code we use uses MIN not MAX.  We verify the quantity this way.  We allocate the ones from 100-119 as "fixed" LUNs for specific files in the app.  Therefore, the only available LUNs are in the range of 120-299. In order for this to work in your case, verify that the LUN is greater than 120 and use the MIN function to gauge the LUN count.&lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;&lt;BR /&gt;Sorry about the confusion.</description>
      <pubDate>Wed, 15 Jun 2011 13:25:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798673#M36125</guid>
      <dc:creator>abrsvc</dc:creator>
      <dc:date>2011-06-15T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798674#M36126</link>
      <description>Dan is suggesting the start of writing integrated diagnostic code.  &lt;BR /&gt;&lt;BR /&gt;And if you're going to do that, then do yourself a huge favor and set up some central logging routines and then figure out how to start writing the diagnostics such that you can include other details in the diagnostic log file (eg: timestamps, other data) if and when needed.  &lt;BR /&gt;&lt;BR /&gt;Or with the diagnostics written to a diagnostic mailbox or out to a syslog server or somewhat other more complex approaches.  &lt;BR /&gt;&lt;BR /&gt;For basic diagnostic stuff, writing output to a log file (opened for shared-read!) usually works fine.  &lt;BR /&gt;&lt;BR /&gt;I'd stay away from writing diagnostics into shared memory, at least until you really need to do that.  Dealing with the memory interlocking can get a little gnarly, if you're not familiar with the topic.&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jun 2011 15:08:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798674#M36126</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2011-06-15T15:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding file LUNS used for a process</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798675#M36127</link>
      <description>&lt;!--!*#--&gt;Shael,&lt;BR /&gt;&lt;BR /&gt;  You can do this right now with no code changes. It just takes a bit of forensic work and CMKRNL privilege.&lt;BR /&gt;&lt;BR /&gt;  An actual experiment. On a V7.3-2 Alpha system I wrote a little program to allocate a bunch of LUNs, then free them:&lt;BR /&gt;&lt;BR /&gt;        .title getlun&lt;BR /&gt;        .psect data,rd,wrt,noexe&lt;BR /&gt;myluns: .BLKL 100&lt;BR /&gt;        .psect code,rd,nowrt,exe&lt;BR /&gt;        .entry start,^M&lt;R2&gt;&lt;BR /&gt;        MOVAB myluns,R2&lt;BR /&gt;        MOVL #30,R3&lt;BR /&gt;        GetLoop:&lt;BR /&gt;          PUSHAL (R2)+&lt;BR /&gt;          CALLS #1,G^LIB$GET_LUN&lt;BR /&gt;        SOBGTR R3,GetLoop&lt;BR /&gt;        MOVL #30,R3&lt;BR /&gt;        FreeLoop:&lt;BR /&gt;          PUSHAL -(R2)&lt;BR /&gt;          CALLS #1,G^LIB$FREE_LUN&lt;BR /&gt;        SOBGTR R3,FreeLoop&lt;BR /&gt;        RET&lt;BR /&gt;        .END start&lt;BR /&gt;&lt;BR /&gt;Compile, link and run with DEBUG. Stepping into LIB$GET_LUN and looking at the addresses I found the bit map at address 122480&lt;BR /&gt;&lt;BR /&gt;$ run getlun&lt;BR /&gt;&lt;BR /&gt;         OpenVMS Alpha Debug64 Version V8.3-008&lt;BR /&gt;&lt;BR /&gt;%DEBUG-I-INITIAL, Language: AMACRO, Module: GETLUN&lt;BR /&gt;&lt;BR /&gt;DBG&amp;gt; Step&lt;BR /&gt;stepped to GETLUN\START\%LINE 6&lt;BR /&gt;     6:         MOVAB myluns,R2&lt;BR /&gt;DBG&amp;gt; Step&lt;BR /&gt;stepped to GETLUN\START\%LINE 7&lt;BR /&gt;     7:         MOVL #30,R3&lt;BR /&gt;DBG&amp;gt; Step&lt;BR /&gt;stepped to GETLUN\START\%LINE 9&lt;BR /&gt;     9:           PUSHAL (R2)+&lt;BR /&gt;DBG&amp;gt; Step&lt;BR /&gt;stepped to GETLUN\START\%LINE 10&lt;BR /&gt;    10:           CALLS #1,G^LIB$GET_LUN&lt;BR /&gt;DBG&amp;gt; Step/Into&lt;BR /&gt;stepped to SHARE$LIBRTL_CODE0+89700&lt;BR /&gt;%DEBUG-I-SOURCESCOPE, source lines not available for %PC in scope number 0&lt;BR /&gt;        Displaying source for 1\%PC&lt;BR /&gt;    10:           CALLS #1,G^LIB$GET_LUN&lt;BR /&gt;DBG&amp;gt; set image librtl&lt;BR /&gt;%DEBUG-I-NODSTS, no Debugger Symbol Table: no DSF file found and&lt;BR /&gt;-DEBUG-I-NODSTIMG, no symbols in DISK$SFETA_SYS:[VMS$COMMON.SYSLIB]LIBRTL.EXE;1&lt;BR /&gt;DBG&amp;gt; set step instruction&lt;BR /&gt;DBG&amp;gt; Step&lt;BR /&gt;stepped to LIB$GET_LUN+4:       STQ             R27,(SP)&lt;BR /&gt;DBG&amp;gt; Step ! prologue&lt;BR /&gt;stepped to LIB$GET_LUN+8:       STQ             R26,#X0010(SP)&lt;BR /&gt;DBG&amp;gt; Step ! prologue&lt;BR /&gt;stepped to LIB$GET_LUN+0C:      STQ             FP,#X0018(SP)&lt;BR /&gt;DBG&amp;gt; Step ! prologue&lt;BR /&gt;stepped to LIB$GET_LUN+10:      BIS             R31,SP,FP&lt;BR /&gt;DBG&amp;gt; Step ! prologue&lt;BR /&gt;stepped to LIB$GET_LUN+14:      LDQ             R18,#X0028(R27)&lt;BR /&gt;DBG&amp;gt; Step ! Get address of bitmap into R18&lt;BR /&gt;stepped to LIB$GET_LUN+18:      BIS             R31,R31,R0&lt;BR /&gt;DBG&amp;gt; ex r18&lt;BR /&gt;0\%R18: 0000000000122480&lt;BR /&gt;DBG&amp;gt;&lt;BR /&gt;&lt;BR /&gt;From another process, using SDA and looking at the image layout, the LIBRTL data PSECT is at 112000, so the magic offset is 122480-112000=10480:&lt;BR /&gt;&lt;BR /&gt;SDA&amp;gt; show proc/images=all&lt;BR /&gt;Process index: 003A   Name: JG1               Extended PID: 000EFA3A&lt;BR /&gt;--------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;                            Process activated images&lt;BR /&gt;                            ------------------------&lt;BR /&gt;&lt;BR /&gt;   Image Name/Link Time/Section Type     Start     End        Type       IMCB   Sym Vect Maj,Minor ID   Base     End    ImageOff&lt;BR /&gt;--------------------------------------- -------- -------- ------------ -------- -------- ------------ -------- -------- --------&lt;BR /&gt;GETLUN                                  00010000 000401FF MAIN         7FF500D0           15,8784656&lt;BR /&gt; 16-JUN-2011 08:15:40.31&lt;BR /&gt;&lt;BR /&gt;LIBRTL                                  00112000 001639FF GLBL     SHR 7FF505D0 0011E5C0   1,1&lt;BR /&gt; 17-JUL-2007 10:18:51.27&lt;BR /&gt;                   System Resident Code                                                               80C2A000 80CF69FF 00000000&lt;BR /&gt;&lt;BR /&gt;SYS$SSISHR                              00164000 001943FF GLBL PRT SHR 7FF548B0 00184220   1,1000&lt;BR /&gt; 20-AUG-2004 17:00:44.42&lt;BR /&gt;&lt;BR /&gt;DEBUG                                   00196000 002E6FFF MRGD     SHR 7FF51150 001AA6D0   5,1&lt;BR /&gt; 14-JUN-2006 13:19:07.83&lt;BR /&gt;&lt;BR /&gt;SHRIMGMSG                               0030A000 003109FF MRGD     SHR 7FF51030 0030A000 107,15341581&lt;BR /&gt;  1-OCT-2003 21:18:59.71&lt;BR /&gt;&lt;BR /&gt;DBGTBKMSG                               00312000 0031F9FF MRGD         7FF53760 00312000 109,13609879&lt;BR /&gt;  9-OCT-2007 07:37:12.68&lt;BR /&gt;&lt;BR /&gt;SYS$PUBLIC_VECTORS                      8F304998 8F307037 GLBL         7FF4E740 00184270 106,6270694&lt;BR /&gt;&lt;BR /&gt;SYS$BASE_IMAGE                          8F323330 8F337E9F GLBL         7FF51AA0 8F323330 106,6271228&lt;BR /&gt;&lt;BR /&gt;Total images = 8                        Pages allocated = 271&lt;BR /&gt;&lt;BR /&gt;Watching the bit map whilst stepping through the loop looks like this:&lt;BR /&gt;&lt;BR /&gt;SDA&amp;gt; ex 122480 ! Before entering loop, empty&lt;BR /&gt;LIBRTL+10480:  00000000.00000000   "........"&lt;BR /&gt;SDA&amp;gt; ex 122480 ! allocated one&lt;BR /&gt;LIBRTL+10480:  00000000.00000001   "........"&lt;BR /&gt;SDA&amp;gt; ex 122480 ! allocated two&lt;BR /&gt;LIBRTL+10480:  00000000.00000003   "........"&lt;BR /&gt;SDA&amp;gt; ex 122480 ! allocated three&lt;BR /&gt;LIBRTL+10480:  00000000.00000007   "........"&lt;BR /&gt;SDA&amp;gt; ex 122480 ! at end of getloop&lt;BR /&gt;LIBRTL+10480:  00000000.3FFFFFFF   "...?...."&lt;BR /&gt;SDA&amp;gt; ex 122480 ! first iteration of free loop&lt;BR /&gt;LIBRTL+10480:  00000000.1FFFFFFF   "........"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So, first run the above program on your version, architecture and patch level to determine the offset for your system. This a one-off exercise. The offset won't change unless LIBRTL is updated.&lt;BR /&gt;&lt;BR /&gt;Any process you want to check, go into SDA, SET PROCESS and SHOW PROCESS/IMAGE=ALL to locate the LIBRTL PSECT. You can then examine the bitmap using the offset you found. Unfortunately although SDA displays LIBRTL as if it were a symbol, it doesn't actually define it.&lt;/R2&gt;</description>
      <pubDate>Wed, 15 Jun 2011 21:59:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/finding-file-luns-used-for-a-process/m-p/4798675#M36127</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2011-06-15T21:59:43Z</dc:date>
    </item>
  </channel>
</rss>

