linux/Documentation/filesystems
Andrey Vagin 6c8c90319c proc: show locks in /proc/pid/fdinfo/X
Let's show locks which are associated with a file descriptor in
its fdinfo file.

Currently we don't have a reliable way to determine who holds a lock.  We
can find some information in /proc/locks, but PID which is reported there
can be wrong.  For example, a process takes a lock, then forks a child and
dies.  In this case /proc/locks contains the parent pid, which can be
reused by another process.

$ cat /proc/locks
...
6: FLOCK  ADVISORY  WRITE 324 00:13:13431 0 EOF
...

$ ps -C rpcbind
  PID TTY          TIME CMD
  332 ?        00:00:00 rpcbind

$ cat /proc/332/fdinfo/4
pos:	0
flags:	0100000
mnt_id:	22
lock:	1: FLOCK  ADVISORY  WRITE 324 00:13:13431 0 EOF

$ ls -l /proc/332/fd/4
lr-x------ 1 root root 64 Mar  5 14:43 /proc/332/fd/4 -> /run/rpcbind.lock

$ ls -l /proc/324/fd/
total 0
lrwx------ 1 root root 64 Feb 27 14:50 0 -> /dev/pts/0
lrwx------ 1 root root 64 Feb 27 14:50 1 -> /dev/pts/0
lrwx------ 1 root root 64 Feb 27 14:49 2 -> /dev/pts/0

You can see that the process with the 324 pid doesn't hold the lock.

This information is required for proper dumping and restoring file
locks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Acked-by: Jeff Layton <jlayton@poochiereds.net>
Acked-by: "J. Bruce Fields" <bfields@fieldses.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-17 09:04:12 -04:00
..
caching sched: Remove proliferation of wait_on_bit() action functions 2014-07-16 15:10:39 +02:00
cifs update CIFS TODO list 2014-08-02 01:26:07 -05:00
configfs
nfs Merge branch 'for-3.20' of git://linux-nfs.org/~bfields/linux 2015-02-12 10:39:41 -08:00
pohmelfs
.gitignore Documentation: update .gitignore files 2014-09-26 11:02:59 +02:00
9p.txt
00-INDEX dax: replace XIP documentation with DAX documentation 2015-02-16 17:56:03 -08:00
adfs.txt
affs.txt
afs.txt
autofs4-mount-control.txt
autofs4.txt autofs: the documentation I wanted to read 2014-10-14 02:18:17 +02:00
automount-support.txt
befs.txt
bfs.txt
btrfs.txt
ceph.txt
coda.txt
cramfs.txt
dax.txt dax: does not work correctly with virtual aliasing caches 2015-02-16 17:56:04 -08:00
debugfs.txt debugfs: Have debugfs_print_regs32() return void 2014-11-05 14:13:38 -05:00
devpts.txt
directory-locking
dlmfs.txt ocfs2: update web page + git tree in documentation 2015-02-28 09:57:50 -08:00
dnotify_test.c
dnotify.txt
ecryptfs.txt
efivarfs.txt
exofs.txt
ext2.txt ext2: get rid of most mentions of XIP in ext2 2015-02-16 17:56:04 -08:00
ext3.txt
ext4.txt ext4: add DAX functionality 2015-02-16 17:56:04 -08:00
f2fs.txt f2fs: introduce a batched trim 2015-02-11 17:04:44 -08:00
fiemap.txt fsioctl.c: make generic_block_fiemap() signal-tolerant 2015-02-10 14:30:30 -08:00
files.txt
fuse.txt
gfs2-glocks.txt
gfs2-uevents.txt
gfs2.txt
hfs.txt
hfsplus.txt
hpfs.txt
inotify.txt inotify: update documentation to reflect code changes 2015-02-10 14:30:28 -08:00
isofs.txt
jfs.txt
Locking Merge branch 'akpm' (patches from Andrew) 2015-04-15 16:39:15 -07:00
locks.txt
logfs.txt
Makefile Documentation: add makefiles for more targets 2014-09-26 11:02:56 +02:00
mandatory-locking.txt
ncpfs.txt
nilfs2.txt
ntfs.txt NTFS: Remove changelog from Documentation/filesystems/ntfs.txt. 2014-10-16 12:43:57 +01:00
ocfs2.txt ocfs2: update web page + git tree in documentation 2015-02-28 09:57:50 -08:00
omfs.txt
overlayfs.txt ovl: document lower layer ordering 2015-01-08 15:09:15 +01:00
path-lookup.txt
porting ->aio_read and ->aio_write removed 2015-04-11 22:29:43 -04:00
proc.txt proc: show locks in /proc/pid/fdinfo/X 2015-04-17 09:04:12 -04:00
qnx6.txt
quota.txt
ramfs-rootfs-initramfs.txt
relay.txt
romfs.txt
seq_file.txt Documentation: update seq_file 2014-12-29 15:40:18 -07:00
sharedsubtree.txt
spufs.txt
squashfs.txt Squashfs: Add LZ4 compression configuration option 2014-11-27 18:48:44 +00:00
sysfs-pci.txt
sysfs-tagging.txt
sysfs.txt
sysv-fs.txt
tmpfs.txt
ubifs.txt
udf.txt
ufs.txt
vfat.txt
vfs.txt ->aio_read and ->aio_write removed 2015-04-11 22:29:43 -04:00
xfs-delayed-logging-design.txt
xfs-self-describing-metadata.txt
xfs.txt Merge branch 'xfs-misc-fixes-for-3.20-4' into for-next 2015-02-10 09:24:25 +11:00