Cc: Tonnerre <tonnerre@...>, Alexander G. M. Smith <agmsmith@...>, <spam@...>, <akpm@...>, <wichert@...>, <jra@...>, <torvalds@...>, <reiser@...>, <hch@...>, <linux-fsdevel@...>, Linux Kernel Mailing List <linux-kernel@...>, <flx@...>, <reiserfs-list@...>, <vonbrand@...>
Indeed it does, but it fails for the example I was commenting on to
which you replied..
1. The file /var/www/site/index.html's written in vi.
2. "The daemon" (that's what I objected to) receives inotify.
blocks waiting for scheduler, however...
3. Seeing that vi is now finished, I phone person on other side
of world and say the updated file is now available.
4. Person fetches http://site/index.html
...oh! They receive the wrong content-type (bollocks!)
5. Eventually after paging & scheduling deems it appropriate,
"The daemon" gets to run, looks at file, updates content-type.
In other words I was criticising Tonnerre's idea of a daemon which
updates the xattrs by looking at file contents... by definition, a
daemon runs in the background, and the whole point of it updating a
content-type xattr was obviously so that programs like httpd could
just _use_ that xattr.
That doesn't work, even if that daemon uses inotify.
Basically, anytime where you want an ordering guarantee that something
will be recalculated in the interval after a file is modified and
before the calculated result is used, you have to be very careful
about exactly which code is using dnotify or inotify to achieve that.
Single threaded programs can use it easily, but a multi-threaded file
server has to be very careful about ordering if it's to avoid glitches.
It is exactly a real problem I have faced in a multi-threaded HTTP
server which uses dnotify to detect changes to prerequisite files and
also changes to the path walked and permissions on it, and thus
invalidate cached generated pages, thus giving strong cache
guarantees. Performance is great, if you ignore the race conditions...
(One of the more popular small web servers, lighttpd (PHP people seem
to like it), also uses dnotify. Apparently it provides a big
performance boost, just by avoiding stat() calls. So I'm not alone in
using dnotify for such things.)
-- Jamie