Errno Libretto

By Hal Stern, Unix Insider |  Operating Systems

bigboy# fhfind 1540002 2 a0000 4f77 48df4455 a0000 2 25d1121d
/export/home/stern/summary

Running fhfind can take quite a while, particularly for
large filesystems, because it does a find on every file
to locate the inode number. On the client reporting the error, use the
fuser
utility to find the process holding this file open:

huey# fuser /home/stern/summary
/home/stern/summary:  10543o  

We can get more detail via the
lsof
tool:

huey# lsof /home/stern/summary
COMMAND     PID     USER   FD   TYPE     DEVICE   SIZE/OFF  INODE/NAME
reptool   12582    stern    3r  VREG 0x022000a9        158  68376 /home/stern (sugar:/export/home/stern)

lsof shows us the file descriptor number used to hold the
file open, as well as some information normally included with
ps. Look for open files of type VREG in
lsof's output, noting that these are regular open
files. Entries marked with a type of VDIR are current directories, and
are probably not the source of your problem.

There is a drawback to this approach: stale file handles can't be
found using the fhfind script. Inodes associated with
stale file handles either aren't valid, and therefore can't be found
by searching the filesystem, or have been re-used by a new file,
possibly with a different name. In this case the best tactic is to
narrow down the process candidates using lsof to find
those with NFS files open:

huey# lsof -N | fgrep VREG

Look for file descriptors (in the FD column) with a w in
them, indicating the file has been opened for writing. You don't
really need the filename for the stale file handle; it may not even
exist at this point. Just take the inode numbers reported by
lsof and match them against the inode numbers pulled from
the stale file handle error messages on the console. Use this script
to convert a file handle into a server inode number:

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Operating SystemsWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question
randomness