[patch] inotify: remove timer

From: Robert Love
Date: Tue Sep 28 2004 - 12:52:03 EST


On Sun, 2004-09-26 at 22:02 -0400, John McCutchan wrote:

John,

> Announcing the release of inotify 0.10.0.
> Attached is a patch to 2.6.8.1.

Attached patch removes dev->timer and instead wakes up waiting tasks in
inotify_dev_queue_event().

I'd like you to go over it, make sure this works the same and makes
sense. It needs a good testing before merged.

Robert Love

Remove dev->timer

Signed-Off-By: Robert Love <rml@xxxxxxxxxx>

drivers/char/inotify.c | 32 +++++++-------------------------
1 files changed, 7 insertions(+), 25 deletions(-)

diff -urN linux-inotify/drivers/char/inotify.c linux/drivers/char/inotify.c
--- linux-inotify/drivers/char/inotify.c 2004-09-27 16:40:37.000000000 -0400
+++ linux/drivers/char/inotify.c 2004-09-28 13:43:07.924958624 -0400
@@ -63,10 +63,14 @@
*
* 'bitmask' holds one bit for each possible watcher descriptor: a set bit
* implies that the given WD is valid, unset implies it is not.
+ *
+ * This structure is protected by 'lock'. Lock ordering:
+ * dev->lock
+ * dev->wait->lock
+ * FIXME: Define lock ordering wrt inode and dentry locking!
*/
struct inotify_device {
DECLARE_BITMAP(bitmask, MAX_INOTIFY_DEV_WATCHERS);
- struct timer_list timer;
wait_queue_head_t wait;
struct list_head events;
struct list_head watchers;
@@ -248,9 +252,11 @@
return;
}

+ /* queue the event and wake up anyone waiting */
list_add_tail(&kevent->list, &dev->events);
iprintk(INOTIFY_DEBUG_EVENTS,
"queued event %x for %p\n", kevent->event.mask, dev);
+ wake_up_interruptible(&dev->wait);
}

/*
@@ -747,22 +753,6 @@
return out;
}

-static void inotify_dev_timer(unsigned long data)
-{
- struct inotify_device *dev;
-
- if (!data)
- return;
- dev = (struct inotify_device *) data;
-
- /* reset the timer */
- mod_timer(&dev->timer, jiffies + (HZ/4));
-
- /* wake up anyone blocked on the device */
- if (inotify_dev_has_events(dev))
- wake_up_interruptible(&dev->wait);
-}
-
static int inotify_open(struct inode *inode, struct file *file)
{
struct inotify_device *dev;
@@ -780,7 +770,6 @@

INIT_LIST_HEAD(&dev->events);
INIT_LIST_HEAD(&dev->watchers);
- init_timer(&dev->timer);
init_waitqueue_head(&dev->wait);

dev->event_count = 0;
@@ -789,12 +778,6 @@

file->private_data = dev;

- dev->timer.data = (unsigned long) dev;
- dev->timer.function = inotify_dev_timer;
- dev->timer.expires = jiffies + (HZ/4);
-
- add_timer(&dev->timer);
-
printk(KERN_ALERT "inotify device opened\n");

return 0;
@@ -825,7 +808,6 @@
struct inotify_device *dev;

dev = file->private_data;
- del_timer_sync(&dev->timer);
inotify_release_all_watchers(dev);
inotify_release_all_events(dev);
kfree(dev);