Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Cyrill Gorcunov and committed by
Linus Torvalds
77493f04 9263969a

+11 -3
+5 -1
Documentation/filesystems/proc.txt
··· 1786 1786 pos: 0 1787 1787 flags: 02 1788 1788 mnt_id: 9 1789 - tfd: 5 events: 1d data: ffffffffffffffff 1789 + tfd: 5 events: 1d data: ffffffffffffffff pos:0 ino:61af sdev:7 1790 1790 1791 1791 where 'tfd' is a target file descriptor number in decimal form, 1792 1792 'events' is events mask being watched and the 'data' is data 1793 1793 associated with a target [see epoll(7) for more details]. 1794 + 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. 1794 1798 1795 1799 Fsnotify files 1796 1800 ~~~~~~~~~~~~~~
+6 -2
fs/eventpoll.c
··· 960 960 mutex_lock(&ep->mtx); 961 961 for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { 962 962 struct epitem *epi = rb_entry(rbp, struct epitem, rbn); 963 + struct inode *inode = file_inode(epi->ffd.file); 963 964 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", 965 967 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); 967 971 if (seq_has_overflowed(m)) 968 972 break; 969 973 }