From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754713Ab2ILVf1 (ORCPT ); Wed, 12 Sep 2012 17:35:27 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:40105 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754385Ab2ILVfP (ORCPT ); Wed, 12 Sep 2012 17:35:15 -0400 Message-Id: <20120912213507.717230135@openvz.org> User-Agent: quilt/0.48-1 Date: Thu, 13 Sep 2012 01:29:12 +0400 From: Cyrill Gorcunov To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Al Viro Cc: Alexey Dobriyan , Andrew Morton , Pavel Emelyanov , James Bottomley , Matthew Helsley , aneesh.kumar@linux.vnet.ibm.com, bfields@fieldses.org, Cyrill Gorcunov , Al Viro , Andrey Vagin Subject: [patch 6/7] fs, epoll: Add procfs fdinfo helper v2 References: <20120912212906.407242774@openvz.org> Content-Disposition: inline; filename=seq-fdinfo-eventpoll-7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allow us to print out eventpoll target file descriptor, events and data, the /proc/pid/fdinfo/fd consists of | pos: 0 | flags: 02 | tfd: 5 events: 1d data: ffffffffffffffff This feature is CONFIG_CHECKPOINT_RESTORE only. [avagin@: fix for unitialized ret variable] Signed-off-by: Cyrill Gorcunov CC: Pavel Emelyanov CC: Al Viro CC: Alexey Dobriyan CC: Andrew Morton CC: James Bottomley CC: "Aneesh Kumar K.V" CC: Alexey Dobriyan CC: Matthew Helsley CC: "J. Bruce Fields" CC: "Aneesh Kumar K.V" CC: Andrey Vagin --- fs/eventpoll.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) Index: linux-2.6.git/fs/eventpoll.c =================================================================== --- linux-2.6.git.orig/fs/eventpoll.c +++ linux-2.6.git/fs/eventpoll.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include /* * LOCKING: @@ -783,8 +785,34 @@ static unsigned int ep_eventpoll_poll(st return pollflags != -1 ? pollflags : 0; } +#ifdef CONFIG_PROC_FS +static int ep_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct eventpoll *ep = f->private_data; + struct rb_node *rbp; + int ret = 0; + + mutex_lock(&ep->mtx); + for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) { + struct epitem *epi = rb_entry(rbp, struct epitem, rbn); + + ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n", + epi->ffd.fd, epi->event.events, + (long long)epi->event.data); + if (ret) + break; + } + mutex_unlock(&ep->mtx); + + return ret; +} +#endif + /* File callbacks that implement the eventpoll file behaviour */ static const struct file_operations eventpoll_fops = { +#ifdef CONFIG_PROC_FS + .show_fdinfo = ep_show_fdinfo, +#endif .release = ep_eventpoll_release, .poll = ep_eventpoll_poll, .llseek = noop_llseek,