[Devel,RHEL7,COMMIT] ms/procfs: fdinfo: extend information about epoll target files

Submitted by Konstantin Khorenko on May 31, 2017, 1:25 p.m.

Details

Message ID 201705311325.v4VDPw8l018357@finist_cl7.x64_64.work.ct
State New
Series "ms/procfs: fdinfo: extend information about epoll target files"
Headers show

Commit Message

Konstantin Khorenko May 31, 2017, 1:25 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.32.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.16.1.vz7.32.5
------>
commit 751bcabae53c7c0e526f9fb65407259c3e195842
Author: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Date:   Wed May 31 17:25:58 2017 +0400

    ms/procfs: fdinfo: extend information about epoll target files
    
    Since it is possbile to have same number in tfd field (say file added,
    closed, then nother file dup'ed to same number and added back) it is
    imposible to distinguish such target files solely by their numbers.
    
    Strictly speaking regular applications don't need to recognize these
    targets at all but for checkpoint/restore sake we need to collect targets
    to be able to push them back on restore stage in a proper order.
    
    Thus lets add file position, inode and device number where this target
    lays.  This three fields can be used as a primary key for sorting, and
    together with kcmp help CRIU can find out an exact file target (from the
    whole set of processes being checkpointed).
    
    https://jira.sw.ru/browse/PSBM-60161
    
    Link: http://lkml.kernel.org/r/20170424154423.436491881@gmail.com
    Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
    
    Acked-by: Andrei Vagin <avagin@virtuozzo.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Pavel Emelyanov <xemul@virtuozzo.com>
    Cc: Michael Kerrisk <mtk.manpages@gmail.com>
    Cc: Jason Baron <jbaron@akamai.com>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
 Documentation/filesystems/proc.txt | 6 +++++-
 fs/eventpoll.c                     | 8 ++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 8c19bde..6d57bc0 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1745,12 +1745,16 @@  pair provide additional information particular to the objects they represent.
 	pos:	0
 	flags:	02
 	mnt_id:	9
-	tfd:        5 events:       1d data: ffffffffffffffff
+	tfd:        5 events:       1d data: ffffffffffffffff pos:0 ino:61af sdev:7
 
 	where 'tfd' is a target file descriptor number in decimal form,
 	'events' is events mask being watched and the 'data' is data
 	associated with a target [see epoll(7) for more details].
 
+	The 'pos' is current offset of the target file in decimal form
+	[see lseek(2)], 'ino' and 'sdev' are inode and device numbers
+	where target file resides, all in hex format.
+
 	Fsnotify files
 	~~~~~~~~~~~~~~
 	For inotify files the format is the following
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 1fbba90..b0aeaeb 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -883,10 +883,14 @@  static int ep_show_fdinfo(struct seq_file *m, struct file *f)
 	mutex_lock(&ep->mtx);
 	for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
 		struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
+		struct inode *inode = file_inode(epi->ffd.file);
 
-		seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
+		seq_printf(m, "tfd: %8d events: %8x data: %16llx "
+			   " pos:%lli ino:%lx sdev:%x\n",
 			   epi->ffd.fd, epi->event.events,
-			   (long long)epi->event.data);
+			   (long long)epi->event.data,
+			   (long long)epi->ffd.file->f_pos,
+			   inode->i_ino, inode->i_sb->s_dev);
 		if (m->count == m->size)
 			break;
 	}