From: Dmitry Antipov <antipov@dev.rtsoft.ru>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] SIGIO-driven I/O with inotify queues
Date: Thu, 18 Oct 2007 14:10:51 +0400 [thread overview]
Message-ID: <4717312B.5050408@dev.rtsoft.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 164 bytes --]
This patch proposes SIGIO-driven I/O for descriptors returned by
inotify_init(). The thing may be enabled by convenient
fcntl (fd, F_SETFL, O_ASYNC) call.
Dmitry
[-- Attachment #2: 2.6.23-inotify-fasync.patch --]
[-- Type: text/x-patch, Size: 1979 bytes --]
Signed-off-by: Dmitry Antipov <antipov@dev.rtsoft.ru>
diff -ur -X /tmp/dontdiff .orig-2.6.23/fs/inotify_user.c 2.6.23/fs/inotify_user.c
--- .orig-2.6.23/fs/inotify_user.c 2007-10-10 00:31:38.000000000 +0400
+++ 2.6.23/fs/inotify_user.c 2007-10-18 14:06:38.000000000 +0400
@@ -78,6 +78,7 @@
atomic_t count; /* reference count */
struct user_struct *user; /* user who opened this dev */
struct inotify_handle *ih; /* inotify handle */
+ struct fasync_struct *fa; /* async notification */
unsigned int queue_size; /* size of the queue (bytes) */
unsigned int event_count; /* number of pending events */
unsigned int max_events; /* maximum number of events */
@@ -301,6 +302,7 @@
dev->queue_size += sizeof(struct inotify_event) + kevent->event.len;
list_add_tail(&kevent->list, &dev->events);
wake_up_interruptible(&dev->wq);
+ kill_fasync(&dev->fa, SIGIO, POLL_IN);
out:
mutex_unlock(&dev->ev_mutex);
@@ -489,6 +491,13 @@
return ret;
}
+static int inotify_fasync(int fd, struct file *file, int on)
+{
+ struct inotify_device *dev = file->private_data;
+
+ return fasync_helper(fd, file, on, &dev->fa) >= 0 ? 0 : -EIO;
+}
+
static int inotify_release(struct inode *ignored, struct file *file)
{
struct inotify_device *dev = file->private_data;
@@ -501,6 +510,9 @@
inotify_dev_event_dequeue(dev);
mutex_unlock(&dev->ev_mutex);
+ if (file->f_flags & FASYNC)
+ inotify_fasync(-1, file, 0);
+
/* free this device: the put matching the get in inotify_init() */
put_inotify_dev(dev);
@@ -529,6 +541,7 @@
static const struct file_operations inotify_fops = {
.poll = inotify_poll,
.read = inotify_read,
+ .fasync = inotify_fasync,
.release = inotify_release,
.unlocked_ioctl = inotify_ioctl,
.compat_ioctl = inotify_ioctl,
@@ -576,6 +589,7 @@
goto out_free_dev;
}
dev->ih = ih;
+ dev->fa = NULL;
filp->f_op = &inotify_fops;
filp->f_path.mnt = mntget(inotify_mnt);
reply other threads:[~2007-10-18 10:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4717312B.5050408@dev.rtsoft.ru \
--to=antipov@dev.rtsoft.ru \
--cc=linux-kernel@vger.kernel.org \
/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.