<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Chris Ball: Filesystem notifications revisited</title>
    <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Filesystem notifications revisited</title>
      <description>&lt;p&gt;After writing my previous &lt;a href="http://blog.printf.net/articles/2006/03/25/lightweight-filesystem-notifications"&gt;post about notifications&lt;/a&gt; (which is required reading for the rest of this one, I'm afraid), I was able to talk to &lt;a href="http://rlove.org/log/"&gt;Robert Love&lt;/a&gt; about &lt;a href="http://thread.gmane.org/gmane.linux.kernel/391851"&gt;the Yi Yang patch&lt;/a&gt;, and why he thinks it didn't get a good response.  He gave a few reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's lossy; you lose events from boot time, from before the userspace daemon starts, and if the daemon crashes.&lt;/li&gt;
&lt;li&gt;Requires root to listen on netlink, as opposed to the  &lt;code&gt;inotify_add_watch(2)&lt;/code&gt; syscall interface of inotify.&lt;/li&gt;
&lt;li&gt;For this purpose &lt;code&gt;poll(2)&lt;/code&gt; is good, netlink is bad.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of which are reasonable complaints.  If that's the wrong solution, though, what would the right one look like?  Thankfully, Robert has ideas on that too (and I hope I explain them correctly):&lt;/p&gt;

&lt;hr/&gt;

&lt;p&gt;To avoid the causes of lossiness above, the log should be an on-disk log maintained by the filesystem.  Having it done by each filesystem separately isn't necessarily awful for maintainability; the ext3 journalling layer is supposedly generic.  There should be sequence points, so the (single) userspace daemon reading the log knows that it's up to date as of sequence &lt;em&gt;n&lt;/em&gt;, and can tell the kernel to clean the parts of the log up to &lt;em&gt;n&lt;/em&gt;.
The on-disk log would be fixed in size and circular &amp;#8212; so still lossy so far &amp;#8212; but Robert has an idea (which Tridge and Rusty Russell are apparently also partly responsible for) to make sure the lossiness doesn't hurt so bad.  Here it is.&lt;/p&gt;

&lt;p&gt;You do event "compression"; the log is stored in a tree of path names and events.  If you have change events for a couple of hundred files in &lt;code&gt;/home/foo/{bar,baz,etc}&lt;/code&gt;, you mark all of &lt;code&gt;/home/foo&lt;/code&gt; as dirty and throw away the events inside it.  Userspace has to go off and &lt;code&gt;stat(2)&lt;/code&gt;-dance inside &lt;code&gt;/home/foo&lt;/code&gt; to find which files have changed, but at least you've traded precision for accuracy and come out with a log that enables every change to be noticed.  You'd keep reparenting as you run out of room in the log, so if you exhausted log space recording changes in &lt;code&gt;/home/foo&lt;/code&gt; and &lt;code&gt;/home/bar&lt;/code&gt;, all of &lt;code&gt;/home&lt;/code&gt; gets marked dirty.
This is still root-only so far, but you can build security on it. &lt;/p&gt;

&lt;hr/&gt;

&lt;p&gt;&lt;p&gt;So!  This is a lot more work than Yang's elegant netlink patch, but I've decided that ridding the world of updatedb is a worthy goal, and so I'll be starting work on Robert's design next week.  I've booked days off work to go to LinuxWorld Boston, and an interested friend is visiting from the UK as well.  A further idea is to get the userspace daemon to export inotify-compatible events, so that programs like &lt;a href="http://beaglewiki.org/"&gt;Beagle&lt;/a&gt; can use this new mechanism without requiring a rewrite.  I'm assured that apps like &lt;a href="http://f-spot.org"&gt;F-spot&lt;/a&gt; and &lt;a href="http://www.chipx86.com/wiki/Leaftag"&gt;Leaftag&lt;/a&gt; are waiting for this kind of event notification too.
&lt;br&gt;&lt;br&gt;
(&lt;em&gt;Note&lt;/em&gt;: Firefox hung as I was writing this post, taking the unfinished blog entry with it, with strace hanging on a futex.  I blame the flash on the &lt;a href="http://www.linuxworldexpo.com"&gt;LinuxWorld&lt;/a&gt; site.  But!  Getting a core file with gdb's &lt;code&gt;gcore&lt;/code&gt; and running strings on it gave me a perfectly-formatted blog post back.  Yay!)&lt;/p&gt;</description>
      <pubDate>Fri, 31 Mar 2006 01:56:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:bf603537-166e-413c-96f6-06aa00e8c408</guid>
      <author>Chris Ball</author>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited</link>
      <category>kernel</category>
      <category>linux</category>
      <trackback:ping>http://blog.printf.net/articles/trackback/22</trackback:ping>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by computer backgammon</title>
      <description>&lt;p&gt;Looking to play free online backgammon? We have the best downloads and fastest software, the highest payouts, plus incredible guides and tips.&lt;/p&gt;</description>
      <pubDate>Sun, 30 Dec 2007 01:21:23 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3125d425-cda7-4c26-923b-917fffa4976e</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-37254</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by casino in rete</title>
      <description>&lt;p&gt;Questo casino in rete vi procurer&#224; le pi&#249; grandi emozioni ai giochi di carte e della roulette.&lt;/p&gt;</description>
      <pubDate>Tue, 25 Dec 2007 00:52:10 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:9778201e-717b-4bfc-bf13-1a9813dc6e1c</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-37247</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by Amateur facial</title>
      <description>&lt;p&gt;gratz&lt;/p&gt;</description>
      <pubDate>Fri, 22 Dec 2006 09:39:35 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ca896fab-edab-4f89-b0ef-bf31f5eb25d5</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-197</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by &lt;a href='http://blog.welover.org/entry.php?u=nikeanich2&amp;e_id=1613' rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow"&gt;Amateur facial&lt;/a&gt;</title>
      <description>&lt;p&gt;happy xmas&lt;/p&gt;</description>
      <pubDate>Fri, 22 Dec 2006 09:38:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:43a1a531-c555-401d-94ce-169d8cf58505</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-196</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by froda</title>
      <description>&lt;p&gt;nice webpage&lt;/p&gt;</description>
      <pubDate>Wed, 11 Oct 2006 23:44:34 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:9f2af565-65c3-4b1d-9fe4-6cef7d5b5d18</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-134</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by froda</title>
      <description>&lt;p&gt;Very good work, nice webpage.&lt;/p&gt;</description>
      <pubDate>Wed, 11 Oct 2006 23:29:08 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:745f4358-c453-4983-8e53-8e95d4f8a8eb</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-133</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by protective life insurance</title>
      <description>&lt;p&gt;protective life insurance&lt;/p&gt;</description>
      <pubDate>Mon, 09 Oct 2006 19:36:14 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:44350e79-a014-467b-be3f-732187bc7750</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-131</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by protective life insurance</title>
      <description>&lt;p&gt;protective life insurance&lt;/p&gt;</description>
      <pubDate>Mon, 09 Oct 2006 19:35:59 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:c3b8b227-6364-42e1-908d-10b4806c61e2</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-130</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by protective life insurance</title>
      <description>&lt;p&gt;protective life insurance&lt;/p&gt;</description>
      <pubDate>Mon, 09 Oct 2006 19:35:28 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:cf8fe372-9bb6-43a2-a9d4-0e80d2901ac0</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-129</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by protective life insurance</title>
      <description>&lt;p&gt;hello&lt;/p&gt;</description>
      <pubDate>Mon, 09 Oct 2006 19:34:41 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:dc121bf8-094e-41b2-ac83-5ce853c4b3c9</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-128</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by Nexium</title>
      <description>&lt;p&gt;Nexium &lt;a &gt;nexium online&lt;/a rel="nofollow"&gt; or  &lt;a &gt;nexium generic&lt;/a rel="nofollow"&gt; pills &lt;a &gt;nexium dosage&lt;/a rel="nofollow"&gt; tablet &lt;a &gt;nexium tablet&lt;/a rel="nofollow"&gt; &lt;/p&gt;</description>
      <pubDate>Fri, 09 Jun 2006 10:02:20 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:60854117-97cd-47a5-a77f-f4b7a9dc5c75</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-59</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by Nexium</title>
      <description>&lt;p&gt;Nexium &lt;a &gt;nexium online&lt;/a rel="nofollow"&gt; or  &lt;a &gt;nexium generic&lt;/a rel="nofollow"&gt; pills &lt;a &gt;nexium dosage&lt;/a rel="nofollow"&gt; tablet &lt;a &gt;nexium tablet&lt;/a rel="nofollow"&gt; &lt;/p&gt;</description>
      <pubDate>Fri, 09 Jun 2006 10:01:32 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:81de097c-f8a9-4e93-aac5-99d569cc08f6</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-58</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by Chris</title>
      <description>Thanks for the Bugzilla link!  That looks about right.  I was running esd, although I didn't have any esd functions in my backtrace.
&lt;br&gt;&lt;br&gt;
I think the reason rlove wants to use the disk is that the sort of log size we're considering is ~20M, and we're unlikely to get this enabled by default by adding an extra 20M of RAM usage to the kernel.
&lt;br&gt;&lt;br&gt;
&gt; dramatically slow down large disk updates
&lt;br&gt;&lt;br&gt;
Well, ext3 already gives you the choice of journal/ordered/writeback modes -- perhaps we want to make the update mode of this log depend on the chosen journal update mode.  I think for now it'll be best to get it working and see what comes up.</description>
      <pubDate>Fri, 31 Mar 2006 17:21:14 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:98658903-8426-41a5-83a6-8f53394508bf</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-20</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by LH</title>
      <description>If the log is fixed in size, why can't it just be kept in memory?  It seems like storing it on disk would cause a lot of thrashing, that could dramatically slow down large disk updates (perhaps by a factor of 2 or even an order of magnitude for some situations I can envision).
</description>
      <pubDate>Fri, 31 Mar 2006 17:05:46 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:718acb4a-12a3-4ac4-beae-d8ef6a66a253</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-19</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by LH</title>
      <description>I think you hit this bug in esound, which caused the lockup:

&lt;a href="http://bugzilla.gnome.org/show_bug.cgi?id=317857" rel="nofollow"&gt;http://bugzilla.gnome.org/show_bug.cgi?id=317857&lt;/a&gt;
</description>
      <pubDate>Fri, 31 Mar 2006 17:03:28 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:3585cfda-1e3d-46f7-b0e8-c1f5a563fa7c</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-18</link>
    </item>
    <item>
      <title>"Filesystem notifications revisited" by Christian Kellner</title>
      <description>We 'gnome-vfs &amp; nautilus' people would be even more interested. I wonder why f-spot and even leaftag get mention but not nautilus ;)</description>
      <pubDate>Fri, 31 Mar 2006 05:31:59 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:18034e8f-88cd-45d9-9b32-40d6dd1a388e</guid>
      <link>http://blog.printf.net/articles/2006/03/31/filesystem-notifications-revisited#comment-17</link>
    </item>
  </channel>
</rss>
