Re: on issues of recursive monitoring and races therein



On Mon, 2004-10-04 at 01:56 -0500, Jon Trowbridge wrote:

> Yes, the algorithm you describe ensures that a watch is placed on every
> directory.
> 
> I'm still not convinced, though, that this one-directory-at-a-time
> synthesized recursive monitoring is equivalent to true recursive
> monitoring.  It would be nice if we could guarantee something like this:
> 
> Given complete information about the initial state of a watched
> directory tree, and given a list of all of the inotify events generated
> by a set of file operations on that tree, it is possible to accurately
> compute the final state of the tree.
> 
> Obviously this property holds for a single directory.  I don't think it
> holds in general... I think we could leak an event if a file is created
> in a new directory before a watch can be set up in that directory.

Well, sure.  In the same sense that events that occur before beagled is
running are missed (leaked).  What can we expect to do about those?
Even if we had a truly atomic recursive setup, events before the
completion of the atomic setup are missed--same with the Love-Trowbridge
algorithm.

Now, with that said, the algorithm can be extended to ensure that files
are consistent, too.  You can still miss events that occur before the
completion of the algorithm but you can use the algorithm to get a
complete picture of the filesystem in the sense that you can load
consistent metadata for all files and guarantee the setup a watch.  So
knowing that a watch is loaded and that you have consistent metadata for
the files, you could figure out what changed before setup completed or
even began.

In Step 3, simply read the metadata (like the mtime or an MD5 hash or
whatever) to determine if the file was touched for the files in foo.
Now you are guaranteed to (a) receive a watch event for any change and
(b) at least have the consistent metadata in memory.

I guess I don't fully understand your concern, though, because to me it
is the same issue as events that occur before beagled starts.  Whether
or not we had some true-recursive atomic setup does not change this.
You can even look at Love-Trowbridge as atomic, as it fulfills the same
needs, in that events that occur during the algorithm can be modeled as
actually occurring after its completion.

	Robert Love





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]