Bug 962755 - lsof command hangs on a system with unavailable NFS share.
lsof command hangs on a system with unavailable NFS share.
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lsof (Show other bugs)
6.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Peter Schiffer
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-14 07:45 EDT by Lukas Pramuk
Modified: 2014-10-16 08:22 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-10-15 10:29:18 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Lukas Pramuk 2013-05-14 07:45:45 EDT
Description of problem:
lsof command hangs on a system with unavailable NFS share.

Version-Release number of selected component (if applicable):
lsof-4.82-4.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. mount nfs share to a machine (any mountpoint, any exported path)
2. make nfs share unavailable (poweroff exporting machine, suspend exporting guest, ...)
3. run any of lsof, lsof /path, lsof -p PID 
( lsof -i PORT is not affected )


Actual results:
lsof hangs

Expected results:
lsof ends up in reasonable time
Comment 3 Jan Pazdziora 2013-05-14 07:59:38 EDT
I'd add that this bug report is a spin-off from bug 961463 and that our use of lsof in the Satellite code base is

   lsof -t -i TCP:8005 -p 31789

And the strange thing is that the above command blocks while merely doing

   lsof -t -i TCP:8005 | grep '^31789$'

does not block. It's a bit counterintuitive that a less specific lsof command would run fine while the more specific (which should be able to touch less /proc files or whatever lsof is using) blocks.
Comment 4 RHEL Product and Program Management 2013-10-13 19:37:19 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.
Comment 5 Peter Schiffer 2014-10-15 10:29:18 EDT
Hi guys,

really sorry for such a late response, but here it is:

Jan:

those two commands are not equivalent. By default, lsof is doing an OR on options. Equivalent lsof version of grep command would be:

$ lsof -t -a -i TCP:8005 -p 31789

(but that would also block because lsof is scanning mount points for the -p option)


Anyway, blocking issue is well known for lsof and it tries to handle it with multiple ways. There are 3 sections in lsof(8) man page discussing this issue (BLOCKS AND TIMEOUTS, AVOIDING KERNEL BLOCKS and ALTERNATE DEVICE NUMBERS).

Long story short, the blocking is done on the kernel side, in one of the lstat(2), readlink(2) and stat(2) syscalls. lsof tries to avoid block by using timers and child processes, where you can control the length of the timer via -S option (default 15 seconds), however, this does not work for me. Another possibility is to use -b option, which tells to lsof to avoid mentioned syscalls and which for me, works great.
Comment 6 Jan Pazdziora 2014-10-16 08:22:49 EDT
(In reply to Peter Schiffer from comment #5)
> 
> Long story short, the blocking is done on the kernel side, in one of the
> lstat(2), readlink(2) and stat(2) syscalls. lsof tries to avoid block by
> using timers and child processes, where you can control the length of the
> timer via -S option (default 15 seconds), however, this does not work for
> me. Another possibility is to use -b option, which tells to lsof to avoid
> mentioned syscalls and which for me, works great.

Thank you for the explanation.

Note You need to log in before you can comment on or make changes to this bug.