Skip to content

Commit 77493f0

Browse files
cyrillostorvalds
authored andcommitted
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). 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9263969 commit 77493f0

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎Documentation/filesystems/proc.txt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,12 +1786,16 @@ pair provide additional information particular to the objects they represent.
17861786
pos: 0
17871787
flags: 02
17881788
mnt_id: 9
1789-
tfd: 5 events: 1d data: ffffffffffffffff
1789+
tfd: 5 events: 1d data: ffffffffffffffff pos:0 ino:61af sdev:7
17901790

17911791
where 'tfd' is a target file descriptor number in decimal form,
17921792
'events' is events mask being watched and the 'data' is data
17931793
associated with a target [see epoll(7) for more details].
17941794

1795+
The 'pos' is current offset of the target file in decimal form
1796+
[see lseek(2)], 'ino' and 'sdev' are inode and device numbers
1797+
where target file resides, all in hex format.
1798+
17951799
Fsnotify files
17961800
~~~~~~~~~~~~~~
17971801
For inotify files the format is the following

‎fs/eventpoll.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,14 @@ static void ep_show_fdinfo(struct seq_file *m, struct file *f)
960960
mutex_lock(&ep->mtx);
961961
for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
962962
struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
963+
struct inode *inode = file_inode(epi->ffd.file);
963964

964-
seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
965+
seq_printf(m, "tfd: %8d events: %8x data: %16llx "
966+
" pos:%lli ino:%lx sdev:%x\n",
965967
epi->ffd.fd, epi->event.events,
966-
(long long)epi->event.data);
968+
(long long)epi->event.data,
969+
(long long)epi->ffd.file->f_pos,
970+
inode->i_ino, inode->i_sb->s_dev);
967971
if (seq_has_overflowed(m))
968972
break;
969973
}

0 commit comments

Comments
 (0)