1748072 Members
5713 Online
108758 Solutions
New Discussion юеВ

Open files on a disk

 
SOLVED
Go to solution
Zahid Ghani
Frequent Advisor

Open files on a disk

Is there anyway other than sho dev/file to find out if any files are open on a disk?
What I am trying to do is to check for opened files before dismounting disks.
The reason for this is that we have a 'spare' set of disks that are mounted cluster wide for testing/training purposes. At night these disks are dismounted and added to live mirror sets. once the 'cloning' is completed they are taken out of mirrsets and mounted locally to take tape backsups. these disks are then mounted cluster wide as separate data disks.
9 REPLIES 9
Ian Miller.
Honored Contributor

Re: Open files on a disk

You could just dismount the disk and deal with the status return indicating that the disk was not dismounted as there are files open. Then parhaps do SHOW DEVICE/FILES to see which files. In a program I suspect there would a volume lock you could look at but why not let DISMOUNT do the check for you.
____________________
Purely Personal Opinion
Zahid Ghani
Frequent Advisor

Re: Open files on a disk

Ian- I am dismounting the disks but unfortunately one user ignored the instructions. As I am dismounting cluster wide the dismount command did not dismount. The user process went into RWAST state and left dismount command in very messy state mountveri etc.
Lokesh_2
Esteemed Contributor

Re: Open files on a disk

Also check SHO DEV/FILE on each node of cluster. You can use the following command and then work with this output file a.out to kill the process which are opening the files.

$DEFIN/USER SYS$OUTPUT A.OUT
$MC SYSMAN SET E/C
DO SHO DEV/FILE
EXIT
$

HTH,
Thanks & regards,
Lokesh Jain
What would you do with your life if you knew you could not fail?
Volker Halle
Honored Contributor
Solution

Re: Open files on a disk

$ WRITE SYS$OUTPUT F$GETDVI("disk-name","TRANSCNT") will show you the transaction count, same as in $ SHOW DEV d Trans Count column. A TRANSCNT greater than 1 means open files (including devices spooled to that disk).

In a cluster, you would need to issue this command on ALL nodes, which have the disk mounted.
Lokesh_2
Esteemed Contributor

Re: Open files on a disk

You can kill the user processes with STOP/ID before dismounting the disk. This will free up your disk for dismount.

Best regards,
Lokesh
What would you do with your life if you knew you could not fail?
Zahid Ghani
Frequent Advisor

Re: Open files on a disk

Volker - thats exactly what I was after.thanks ill try it.
Lokesh - I don't its a good idea going around killing users even though they are a pain.
Uwe Zessin
Honored Contributor

Re: Open files on a disk

Ahem...
Lokesh suggested to stop the user's process(es), not the human beings ;-)

Watch out for any 00000000 PIDs if you are going over the list of:
$ SHOW DEVICE/FILES

Remember that '$ STOP/IDENTIFICATION=0' is a different spelling for LOGOUT.
.
Martin P.J. Zinser
Honored Contributor

Re: Open files on a disk

Hi,

one way to skip over the 00000000 PID files is to either test for this particular PID or take advantage of the fact that they are not associated with a process name. Also
dismount/override=checks and parsing the output of that command might be worth a thought. This should prevent race conditions, that are possible if you do a

show dev/files
kill proc with open files
dismount

since between the show dev/files and the dismount new files can potentially be opened.

Greetings, Martin
Wim Van den Wyngaert
Honored Contributor

Re: Open files on a disk

Hi,

The 00000000 can be skipped by adding /NOSYS.

I also noticed that after stopping a process with stop/id you need to to wait until the process is gone. Otherwise some files might still be open at the moment of the dismount.

To make the shutdown lighter, I stop all interactive and batch jobs at the beginning of the shutdown. All application servers that are running detached are stopped later by application shutdown procedures.

Wim
Wim