From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: David Miller <davem@davemloft.net>,
Ulrich Drepper <drepper@redhat.com>,
Andrew Morton <akpm@osdl.org>,
Evgeniy Polyakov <johnpol@2ka.mipt.ru>,
netdev <netdev@vger.kernel.org>,
Zach Brown <zach.brown@oracle.com>,
Christoph Hellwig <hch@infradead.org>,
Chase Venters <chase.venters@clientec.com>,
Johann Borck <johann.borck@densedata.com>,
linux-kernel@vger.kernel.org, Jeff Garzik <jeff@garzik.org>
Subject: [take28-resend_1->0 6/8] kevent: Pipe notifications.
Date: Thu, 21 Dec 2006 12:14:17 +0300 [thread overview]
Message-ID: <1166692457991@2ka.mipt.ru> (raw)
In-Reply-To: <1166692457438@2ka.mipt.ru>
Pipe notifications.
diff --git a/fs/pipe.c b/fs/pipe.c
index f3b6f71..aeaee9c 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -16,6 +16,7 @@
#include <linux/uio.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
+#include <linux/kevent.h>
#include <asm/uaccess.h>
#include <asm/ioctls.h>
@@ -312,6 +313,7 @@ redo:
break;
}
if (do_wakeup) {
+ kevent_pipe_notify(inode, KEVENT_SOCKET_SEND);
wake_up_interruptible_sync(&pipe->wait);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
@@ -321,6 +323,7 @@ redo:
/* Signal writers asynchronously that there is more room. */
if (do_wakeup) {
+ kevent_pipe_notify(inode, KEVENT_SOCKET_SEND);
wake_up_interruptible(&pipe->wait);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
@@ -490,6 +493,7 @@ redo2:
break;
}
if (do_wakeup) {
+ kevent_pipe_notify(inode, KEVENT_SOCKET_RECV);
wake_up_interruptible_sync(&pipe->wait);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
do_wakeup = 0;
@@ -501,6 +505,7 @@ redo2:
out:
mutex_unlock(&inode->i_mutex);
if (do_wakeup) {
+ kevent_pipe_notify(inode, KEVENT_SOCKET_RECV);
wake_up_interruptible(&pipe->wait);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
}
@@ -605,6 +610,7 @@ pipe_release(struct inode *inode, int decr, int decw)
free_pipe_info(inode);
} else {
wake_up_interruptible(&pipe->wait);
+ kevent_pipe_notify(inode, KEVENT_SOCKET_SEND|KEVENT_SOCKET_RECV);
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}
diff --git a/kernel/kevent/kevent_pipe.c b/kernel/kevent/kevent_pipe.c
new file mode 100644
index 0000000..91dc1eb
--- /dev/null
+++ b/kernel/kevent/kevent_pipe.c
@@ -0,0 +1,123 @@
+/*
+ * kevent_pipe.c
+ *
+ * 2006 Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/file.h>
+#include <linux/fs.h>
+#include <linux/kevent.h>
+#include <linux/pipe_fs_i.h>
+
+static int kevent_pipe_callback(struct kevent *k)
+{
+ struct inode *inode = k->st->origin;
+ struct pipe_inode_info *pipe = inode->i_pipe;
+ int nrbufs = pipe->nrbufs;
+
+ if (k->event.event & KEVENT_SOCKET_RECV && nrbufs > 0) {
+ if (!pipe->writers)
+ return -1;
+ return 1;
+ }
+
+ if (k->event.event & KEVENT_SOCKET_SEND && nrbufs < PIPE_BUFFERS) {
+ if (!pipe->readers)
+ return -1;
+ return 1;
+ }
+
+ return 0;
+}
+
+int kevent_pipe_enqueue(struct kevent *k)
+{
+ struct file *pipe;
+ int err = -EBADF;
+ struct inode *inode;
+
+ pipe = fget(k->event.id.raw[0]);
+ if (!pipe)
+ goto err_out_exit;
+
+ inode = igrab(pipe->f_dentry->d_inode);
+ if (!inode)
+ goto err_out_fput;
+
+ err = -EINVAL;
+ if (!S_ISFIFO(inode->i_mode))
+ goto err_out_iput;
+
+ err = kevent_storage_enqueue(&inode->st, k);
+ if (err)
+ goto err_out_iput;
+
+ if (k->event.req_flags & KEVENT_REQ_ALWAYS_QUEUE) {
+ kevent_requeue(k);
+ err = 0;
+ } else {
+ err = k->callbacks.callback(k);
+ if (err)
+ goto err_out_dequeue;
+ }
+
+ fput(pipe);
+
+ return err;
+
+err_out_dequeue:
+ kevent_storage_dequeue(k->st, k);
+err_out_iput:
+ iput(inode);
+err_out_fput:
+ fput(pipe);
+err_out_exit:
+ return err;
+}
+
+int kevent_pipe_dequeue(struct kevent *k)
+{
+ struct inode *inode = k->st->origin;
+
+ kevent_storage_dequeue(k->st, k);
+ iput(inode);
+
+ return 0;
+}
+
+void kevent_pipe_notify(struct inode *inode, u32 event)
+{
+ kevent_storage_ready(&inode->st, NULL, event);
+}
+
+static int __init kevent_init_pipe(void)
+{
+ struct kevent_callbacks sc = {
+ .callback = &kevent_pipe_callback,
+ .enqueue = &kevent_pipe_enqueue,
+ .dequeue = &kevent_pipe_dequeue,
+ .flags = 0,
+ };
+
+ return kevent_add_callbacks(&sc, KEVENT_PIPE);
+}
+module_init(kevent_init_pipe);
next prev parent reply other threads:[~2006-12-21 9:19 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3154985aa0591036@2ka.mipt.ru>
2006-12-17 13:53 ` [take28-resend_2->0 0/8] kevent: Generic event handling mechanism Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 1/8] kevent: Description Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 2/8] kevent: Core files Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 3/8] kevent: poll/select() notifications Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 4/8] kevent: Socket notifications Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 5/8] kevent: Timer notifications Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 6/8] kevent: Pipe notifications Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 7/8] kevent: Signal notifications Evgeniy Polyakov
2006-12-17 13:53 ` [take28-resend_2->0 8/8] kevent: Kevent posix timer notifications Evgeniy Polyakov
2006-12-19 3:47 ` [take28-resend_2->0 0/8] kevent: Generic event handling mechanism Ulrich Drepper
2006-12-19 4:01 ` Randy Dunlap
2006-12-19 4:51 ` Evgeniy Polyakov
2006-12-19 6:21 ` Ulrich Drepper
2006-12-19 6:38 ` Evgeniy Polyakov
2006-12-19 8:01 ` Ulrich Drepper
2006-12-19 8:56 ` Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 " Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 1/8] kevent: Description Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 2/8] kevent: Core files Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 3/8] kevent: poll/select() notifications Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 4/8] kevent: Socket notifications Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 5/8] kevent: Timer notifications Evgeniy Polyakov
2006-12-21 9:14 ` Evgeniy Polyakov [this message]
2006-12-21 9:14 ` [take28-resend_1->0 7/8] kevent: Signal notifications Evgeniy Polyakov
2006-12-21 9:14 ` [take28-resend_1->0 8/8] kevent: Kevent posix timer notifications Evgeniy Polyakov
2006-12-21 10:35 ` [take28-resend_1->0 0/8] kevent: Generic event handling mechanism Evgeniy Polyakov
2006-12-21 10:41 ` Jeff Garzik
2006-12-21 10:49 ` Evgeniy Polyakov
2006-12-21 10:57 ` Evgeniy Polyakov
2006-12-21 13:48 ` jamal
2006-12-21 14:04 ` Evgeniy Polyakov
2006-12-21 14:21 ` jamal
2006-12-21 14:23 ` Evgeniy Polyakov
2006-12-21 14:36 ` Evgeniy Polyakov
2006-12-21 14:40 ` jamal
2006-12-21 14:46 ` Evgeniy Polyakov
2006-12-21 16:42 ` jamal
2006-12-21 16:51 ` Evgeniy Polyakov
2006-12-23 16:51 ` [take29 " Evgeniy Polyakov
2006-12-23 16:51 ` [take29 1/8] kevent: Description Evgeniy Polyakov
2006-12-23 16:51 ` [take29 2/8] kevent: Core files Evgeniy Polyakov
2006-12-23 16:51 ` [take29 3/8] kevent: poll/select() notifications Evgeniy Polyakov
2006-12-23 16:51 ` [take29 4/8] kevent: Socket notifications Evgeniy Polyakov
2006-12-23 16:51 ` [take29 5/8] kevent: Timer notifications Evgeniy Polyakov
2006-12-23 16:51 ` [take29 6/8] kevent: Pipe notifications Evgeniy Polyakov
2006-12-23 16:51 ` [take29 7/8] kevent: Signal notifications Evgeniy Polyakov
2006-12-23 16:51 ` [take29 8/8] kevent: Kevent posix timer notifications Evgeniy Polyakov
2006-12-23 17:10 ` [take29 0/8] kevent: Generic event handling mechanism Evgeniy Polyakov
2006-12-28 15:56 ` Ingo Molnar
2006-12-29 8:48 ` Evgeniy Polyakov
2006-12-28 16:01 ` Ingo Molnar
2006-12-29 8:55 ` Evgeniy Polyakov
2006-12-29 12:54 ` Ingo Molnar
2006-12-29 13:14 ` Evgeniy Polyakov
2006-12-29 13:24 ` Ingo Molnar
2006-12-29 12:25 ` [take30 0/9] " Evgeniy Polyakov
2006-12-29 12:25 ` [take30 1/9] kevent: Description Evgeniy Polyakov
2006-12-29 12:25 ` [take30 2/9] kevent: Core files Evgeniy Polyakov
2006-12-29 12:25 ` [take30 3/9] kevent: poll/select() notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 4/9] kevent: Socket notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 5/9] kevent: Timer notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 6/9] kevent: Pipe notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 7/9] kevent: Signal notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 8/9] kevent: Kevent posix timer notifications Evgeniy Polyakov
2006-12-29 12:25 ` [take30 9/9] kevent: Private userspace notifications Evgeniy Polyakov
2007-01-08 19:25 ` [take31 0/10] kevent: Generic event handling mechanism Evgeniy Polyakov
2007-01-08 19:25 ` [take31 1/10] kevent: Description Evgeniy Polyakov
2007-01-08 19:25 ` [take31 2/10] kevent: Core files Evgeniy Polyakov
2007-01-08 19:25 ` [take31 3/10] kevent: poll/select() notifications Evgeniy Polyakov
2007-01-08 19:25 ` [take31 4/10] kevent: Socket notifications Evgeniy Polyakov
2007-01-08 19:25 ` [take31 5/10] kevent: Timer notifications Evgeniy Polyakov
2007-01-08 19:25 ` [take31 6/10] kevent: Pipe notifications Evgeniy Polyakov
2007-01-08 19:25 ` [take31 7/10] kevent: Signal notifications Evgeniy Polyakov
2007-01-08 19:26 ` [take31 8/10] kevent: Kevent posix timer notifications Evgeniy Polyakov
2007-01-08 19:26 ` [take31 9/10] kevent: Private userspace notifications Evgeniy Polyakov
2007-01-08 19:26 ` [take31 10/10] kevent: Kevent based AIO (aio_sendfile()) Evgeniy Polyakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1166692457991@2ka.mipt.ru \
--to=johnpol@2ka.mipt.ru \
--cc=akpm@osdl.org \
--cc=chase.venters@clientec.com \
--cc=davem@davemloft.net \
--cc=drepper@redhat.com \
--cc=hch@infradead.org \
--cc=jeff@garzik.org \
--cc=johann.borck@densedata.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=zach.brown@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.