2013-10-30 20:22:33

by Cyrill Gorcunov

[permalink] [raw]
Subject: [patch 3/6] eventfd: Use sequential fdinfo engine

Signed-off-by: Cyrill Gorcunov <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Andrey Vagin <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Matthew Helsley <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: Andrew Morton <[email protected]>
---
fs/eventfd.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)

Index: linux-2.6.git/fs/eventfd.c
===================================================================
--- linux-2.6.git.orig/fs/eventfd.c
+++ linux-2.6.git/fs/eventfd.c
@@ -287,9 +287,26 @@ static ssize_t eventfd_write(struct file
}

#ifdef CONFIG_PROC_FS
-static int eventfd_show_fdinfo(struct seq_file *m, struct file *f)
+static void *seq_start(struct seq_file *m, loff_t *pos)
{
- struct eventfd_ctx *ctx = f->private_data;
+ if (*pos == 0)
+ return m->private;
+ return NULL;
+}
+
+static void seq_stop(struct seq_file *m, void *v)
+{
+}
+
+static void *seq_next(struct seq_file *m, void *p, loff_t *pos)
+{
+ ++*pos;
+ return NULL;
+}
+
+static int seq_show(struct seq_file *m, void *v)
+{
+ struct eventfd_ctx *ctx = ((struct file *)v)->private_data;
int ret;

spin_lock_irq(&ctx->wqh.lock);
@@ -299,11 +316,18 @@ static int eventfd_show_fdinfo(struct se

return ret;
}
+
+static struct seq_operations eventfd_fdinfo_ops = {
+ .start = seq_start,
+ .next = seq_next,
+ .stop = seq_stop,
+ .show = seq_show,
+};
#endif

static const struct file_operations eventfd_fops = {
#ifdef CONFIG_PROC_FS
- .show_fdinfo = eventfd_show_fdinfo,
+ .fdinfo_ops = &eventfd_fdinfo_ops,
#endif
.release = eventfd_release,
.poll = eventfd_poll,