From patchwork Fri Mar 10 08:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 9615193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74F1360415 for ; Fri, 10 Mar 2017 08:24:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65BC9286E3 for ; Fri, 10 Mar 2017 08:24:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A4BE28706; Fri, 10 Mar 2017 08:24:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0344F286E3 for ; Fri, 10 Mar 2017 08:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755234AbdCJIYR (ORCPT ); Fri, 10 Mar 2017 03:24:17 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35248 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754943AbdCJIYP (ORCPT ); Fri, 10 Mar 2017 03:24:15 -0500 Received: by mail-lf0-f65.google.com with SMTP id v2so6298934lfi.2; Fri, 10 Mar 2017 00:24:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:message-id:user-agent:date:from:to:cc:subject:mime-version :content-disposition; bh=0ltemdtP+JsdTqFxVUOQT7/Wd9zS3BVwujl/WvniBZc=; b=lEhHaHXHqfQ3CFux8gfmNQO2FS6aKCWx9xtF+SHXV9Mreo/0OJhpkDJFtg6bKHxWz0 l52E80DmSgfxfXmi84q34stWwFWli2EQHKZ5LU/xlFBmHkW5I4RnJ5nfezwHy4cGc+cV GFlsmMD/W0Skx6PaRoqWH7fbnEi45Cw8E0E6rht4aZz5Cal7J8n+lfX40suwlf0GOg7M r2kp9wgl+874PaVUFssIdm7vSfMsgoqfBSLLHnad+evulJRDgjdfkJtgITtoQ5rw9O73 CkUFOOBASUIhMH7HlWVb9E4up5BBXog4e/tk/rpzJ5Wm0yd1rDRNR+2VuCaIpgYim2RO Q2lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:message-id:user-agent:date:from:to:cc :subject:mime-version:content-disposition; bh=0ltemdtP+JsdTqFxVUOQT7/Wd9zS3BVwujl/WvniBZc=; b=h/I/oEoD0UySjbLTEiPaHm9tfEWDiMRFO+5Kmp8aXZFfDq8VWE5v4mZrbrRQXYtUC1 QM1cLTa7hjKy/TO+NZf+cORz3+V8jUYYxU5MNmWsPwR2jdotF4MLSFgVQij1+BvVXdVA /fgrbEpkR7UgKSRFNVxoc/LmrHirhQ5JkYd3w2+HqgKygnTrnxzZqCbZvB7D5mBNgwDq X1dswz3spUVyjV0wjfX6dqkGHgph7bCPCH6UU41ZfofT0hOopX4Kll8SAuhJhLUpRvd6 MTZiW1zzd2keknIBsTeBQWh9JLam5oS6ePhr2XfTWZ7bhOllcHVteZ3qDkuzJHkD2lEk BCvQ== X-Gm-Message-State: AMke39miPxYUiPUZJfC5h46uN6VFQMt64zs4msYkSyZzT99dbTo5FS5YiWlxiMkJ8p27Cg== X-Received: by 10.25.86.2 with SMTP id k2mr4327996lfb.51.1489134248046; Fri, 10 Mar 2017 00:24:08 -0800 (PST) Received: from uranus.localdomain ([5.18.238.201]) by smtp.gmail.com with ESMTPSA id r204sm1718069lff.57.2017.03.10.00.24.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 00:24:07 -0800 (PST) Received: by uranus.localdomain (Postfix, from userid 1000) id 944B52486D; Fri, 10 Mar 2017 11:21:46 +0300 (MSK) Message-Id: <20170310082146.041584651@openvz.org> User-Agent: quilt/0.64 Date: Fri, 10 Mar 2017 11:16:56 +0300 From: Cyrill Gorcunov To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: viro@zeniv.linux.org.uk, akpm@linuxfoundation.org, avagin@virtuozzo.com, xemul@virtuozzo.com, mtk.manpages@gmail.com, kir@openvz.org, gorcunov@openvz.org, Andrey Vagin , Jason Baron , Andy Lutomirski Subject: [patch 1/3] procfs: fdinfo -- Extend information about epoll target files MIME-Version: 1.0 Content-Disposition: inline; filename=epoll-fdinfo-2 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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). Signed-off-by: Cyrill Gorcunov CC: Al Viro CC: Andrew Morton CC: Andrey Vagin CC: Pavel Emelyanov CC: Michael Kerrisk CC: Kir Kolyshkin CC: Jason Baron CC: Andy Lutomirski --- Documentation/filesystems/proc.txt | 6 +++++- fs/eventpoll.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) Index: linux-ml.git/Documentation/filesystems/proc.txt =================================================================== --- linux-ml.git.orig/Documentation/filesystems/proc.txt +++ linux-ml.git/Documentation/filesystems/proc.txt @@ -1779,12 +1779,16 @@ pair provide additional information part 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 Index: linux-ml.git/fs/eventpoll.c =================================================================== --- linux-ml.git.orig/fs/eventpoll.c +++ linux-ml.git/fs/eventpoll.c @@ -883,10 +883,14 @@ static void ep_show_fdinfo(struct seq_fi 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 (seq_has_overflowed(m)) break; }