From patchwork Mon Apr 24 15:39:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 9696621 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 185AF603F3 for ; Mon, 24 Apr 2017 15:44:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 097A827813 for ; Mon, 24 Apr 2017 15:44:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0964283FE; Mon, 24 Apr 2017 15:44:58 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 9967E27813 for ; Mon, 24 Apr 2017 15:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S972070AbdDXPoo (ORCPT ); Mon, 24 Apr 2017 11:44:44 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33224 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S972065AbdDXPon (ORCPT ); Mon, 24 Apr 2017 11:44:43 -0400 Received: by mail-lf0-f68.google.com with SMTP id 88so17106867lfr.0; Mon, 24 Apr 2017 08:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:user-agent:date:from:to:cc:subject:mime-version :content-disposition; bh=PwQ1k3bYmf/KXHoKiB8g6KQSDLUgmdlMhEyuJANBmtM=; b=BKhWxWInx0Ly0egXmSfOEwdpViaP0XPTZcjEVF1dIRUkDjz2IXFcG4LQgAAgJa19Kn UfZLaXmWu8uCc1ygnzGysxeWI8Mfv8EkoOiWp7cKXgdgGW8XycdK9YtfT7GUOqMxFSX2 sWUgjAty/T+H/9WEDKbp3WBmWs9g0amoQNk4/+Ewdj0fFcZcElM33UVO14tada9xJScX QjqzxUrkrEhvxdrarCSc2o3LPPhLGDoOfwtb3jLGr6Nr+fJBhO5j4mtfR/D2dVO350wp 5hEL6XapZ14wWVe5qXohvRDlIR74TJqpQcg15zhE1BxD1I9O3gWODtpYrrnYNvImHrjw osbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :mime-version:content-disposition; bh=PwQ1k3bYmf/KXHoKiB8g6KQSDLUgmdlMhEyuJANBmtM=; b=MgadCipuhBZUKZYroUmAibBeqiC/bhN36XkEZNMtuVEOQMVA1/IEKei4sBG+FNRrJS sgnnAziwF0n2dFiic7mA0mHNj0gTh3Tk65rbrrXeKFob+UilaiHzMf5Tt2OhORZpVOJ1 fD6Lfcsr2VjulXy57e8Tj13w68lOWJs4ZUuMuLFPGQP5JGalcFjxcnN7wsoELQs6/cPq 3wKv1+rdY+Fvhl6E3ZgZ869W8yv+gB7yAutacPwhPOfOu3azjHKN8lbM7NUEmzFRyOzv 73p4sdvs+VIIclkzOagODOsnddHd59BYlDKZoPith1VtmmQTY7Um7EbagWnLP4IOQhaR 34Lw== X-Gm-Message-State: AN3rC/6810HgEd2CKD58XIdXKJ5KnAaHSYBQvmXG9mgmsN3dmy5K+7n/ Ee0FyTAg0tctEg== X-Received: by 10.25.43.1 with SMTP id r1mr9665884lfr.89.1493048676133; Mon, 24 Apr 2017 08:44:36 -0700 (PDT) Received: from uranus.localdomain ([5.18.237.75]) by smtp.gmail.com with ESMTPSA id o81sm3345485lfi.33.2017.04.24.08.44.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2017 08:44:35 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 7A89C243EE; Mon, 24 Apr 2017 18:44:23 +0300 (MSK) Message-Id: <20170424154423.436491881@gmail.com> User-Agent: quilt/0.64 Date: Mon, 24 Apr 2017 18:39:27 +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, gorcunov@openvz.org, avagin@openvz.org, jbaron@akamai.com, luto@amacapital.net Subject: [patch v4 resend 1/2] 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: Jason Baron CC: Andy Lutomirski Acked-by: Andrei Vagin --- 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; }