linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zach Brown <zab@zabbo.net>
To: Robert Love <rml@novell.com>
Cc: linux-kernel@vger.kernel.org,
	Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
	John McCutchan <ttb@tentacle.dhs.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [patch] inotify.
Date: Thu, 16 Jun 2005 10:52:11 -0700	[thread overview]
Message-ID: <42B1BC4B.3010804@zabbo.net> (raw)
In-Reply-To: <1118855899.3949.21.camel@betsy>

Robert Love wrote:
> Below find an updated inotify, with a doubt the world's great inotify
> release, against 2.6.12-rc6.

some quick comments, nothing earth shattering..

> @@ -0,0 +1,123 @@

diff -p, please.

> + * struct inotify_kernel_event - An intofiy event, originating from a watch and

intofiy!

> +/*
> + * inotify_dev_is_watching_inode - is this device watching this inode?
> + *
> + * Callers must hold dev->sem.
> + */
> +static inline int inotify_dev_is_watching_inode(struct inotify_device *dev,
> +						struct inode *inode)
> +{
> +	struct inotify_watch *watch;
> +
> +	list_for_each_entry(watch, &dev->watches, d_list) {
> +		if (watch->inode == inode)
> +			return 1;
> +	}
> +
> +	return 0;
> +}

Am I missing where this is used?

> +       if (likely(!atomic_read(&inode->inotify_watch_count)))
> +               return;

Are there still platforms that implement atomic_read() with locks?  I
wonder if there isn't a cheaper way for inodes to find out that they're
not involved in inotify.. maybe an inode function pointer that is only
set to queue_event when watchers are around?

> +	down(&inode->inotify_sem);
> +	list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
> +		u32 watch_mask = watch->mask;
> +		if (watch_mask & mask) {
> +			struct inotify_device *dev = watch->dev;
> +			get_inotify_watch(watch);
> +			down(&dev->sem);
> +			inotify_dev_queue_event(dev, watch, mask, cookie, name);

I wonder if its worth walking the watches as they're added and removed
to calculate a total mask of what is being watched so that uninteresting
events can be immediately ignored without walking the watches.

I also wonder about adding references to an event from each device that
is watching the inode rather than queueing events on all the devices.
If it only ever copies the full event to user space anyway, you'd just
need a series of pointers on the dev that hold references to a
refcounted event.  It looks like events are only ever dequeued from the
device as they're walked from the head of the list so it doesn't seem
like the ability to remove an event from the middle would be missed.

Too aggressive for a situation that rarely happens anyway?

> +	while (1) {
> +		int events;
> +
> +		prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE);
> +
> +		down(&dev->sem);
> +		events = !list_empty(&dev->events);
> +		up(&dev->sem);
> +		if (events) {
> +			ret = 0;
> +			break;
> +		}
> +
> +		if (file->f_flags & O_NONBLOCK) {
> +			ret = -EAGAIN;
> +			break;
> +		}
> +
> +		if (signal_pending(current)) {
> +			ret = -EINTR;
> +			break;
> +		}
> +
> +		schedule();
> +	}
> +
> +	finish_wait(&dev->wq, &wait);

It'd be nice to get some wait_event_interruptible() love to replace the
hand-rolled _wait()s and schedule().  It could probably be folded into
the second loop, I imagine.  I suspect that the signal_pending() case
wants to return ERESTARTSYS like w_e_i() does.

> +	nonseekable_open(inode, file);

While it doesn't return errors today, it might be nice to test anyway.

> +/*
> + * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
> + */
> +static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
> +				 const char *old_name, const char *new_name,
> +				 int isdir)
> +{
> +	u32 cookie = inotify_get_cookie();

How about deferring this atomic_inc() until it's known if the event is
going to be queued or not so that renames that have nothing to do with
inotify don't bounce the cache line around?  If it's *only* used to
assciate two different events with a single rename maybe it'd be better
to roll some compound rename event.

I hope this helps.  I, for one, would be thrilled to see dnotify deprecated.

- z

  reply	other threads:[~2005-06-16 17:52 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15 17:18 [patch] inotify Robert Love
2005-06-16 17:52 ` Zach Brown [this message]
2005-06-16 18:25   ` Robert Love
2005-06-17  1:30     ` Nick Piggin
2005-06-17  1:35       ` Robert Love
2005-06-17 15:15         ` [patch] inotify, improved Robert Love
2005-06-17 15:37           ` Chris Friesen
2005-06-17 15:44             ` Robert Love
2005-06-17 16:11               ` Valdis.Kletnieks
2005-06-17 16:29                 ` Robert Love
2005-06-17 16:36                 ` Chris Friesen
2005-06-17 16:43                   ` Chris Wright
2005-06-17 16:46                   ` Muli Ben-Yehuda
2005-06-17 16:40               ` Chris Friesen
2005-06-17 17:57                 ` John McCutchan
2005-06-17 17:20           ` Zach Brown
2005-06-17 17:54             ` John McCutchan
2005-06-17 17:56               ` Zach Brown
2005-06-17 18:15                 ` John McCutchan
2005-06-17 18:17                   ` Zach Brown
2005-06-17 17:07     ` [patch] inotify Arnd Bergmann
2005-06-17 17:54       ` Christoph Hellwig
2005-06-17 18:12         ` John McCutchan
2005-06-17 18:16         ` Robert Love
2005-06-17 18:28           ` Christoph Hellwig
2005-06-17 18:38             ` Robert Love
2005-06-17 18:45               ` Christoph Hellwig
2005-06-17 18:54                 ` Robert Love
2005-06-17 17:56       ` John McCutchan
2005-06-17 21:33         ` Andrew Morton
2005-06-17 21:40           ` Robert Love
2005-06-17 23:52             ` Robert Love
2005-06-21  0:51               ` Neil Brown
2005-06-21  2:15                 ` John McCutchan
2005-06-21  2:29                   ` Neil Brown
2005-06-21  2:43                     ` John McCutchan
2005-06-21 15:55                     ` Robert Love
2005-07-14  0:25                       ` Neil Brown
2005-07-14  4:11                         ` John McCutchan
2005-06-18  0:05             ` Arnd Bergmann
2005-06-18  0:57               ` Robert Love
2005-06-18  1:51       ` Chris Wedgwood
  -- strict thread matches above, loose matches on Subject: below --
2005-05-09 16:05 Robert Love
2005-05-09 17:43 ` Coywolf Qi Hunt
2005-01-06 20:00 Robert Love

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=42B1BC4B.3010804@zabbo.net \
    --to=zab@zabbo.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    --cc=ttb@tentacle.dhs.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).